Commit 07ba455d authored by Leander Schulten's avatar Leander Schulten
Browse files

Add a Installer written in c# forms. It replaces the batch script.

parent 673cacf0
Pipeline #144150 passed with stage
in 1 minute and 15 seconds
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true
**/wwwroot/lib/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
\ No newline at end of file
namespace WindowsInstaller
{
partial class Form1
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.button_close = new System.Windows.Forms.Button();
this.button_start = new System.Windows.Forms.Button();
this.label_info_delete = new System.Windows.Forms.Label();
this.label_info_copy = new System.Windows.Forms.Label();
this.label_delete = new System.Windows.Forms.Label();
this.label_copy = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label_wait = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Fortschritt:";
//
// button_close
//
this.button_close.Location = new System.Drawing.Point(41, 97);
this.button_close.Name = "button_close";
this.button_close.Size = new System.Drawing.Size(102, 23);
this.button_close.TabIndex = 1;
this.button_close.Text = "Beenden";
this.button_close.UseVisualStyleBackColor = true;
this.button_close.Click += new System.EventHandler(this.button_close_Click);
//
// button_start
//
this.button_start.Enabled = false;
this.button_start.Location = new System.Drawing.Point(149, 97);
this.button_start.Name = "button_start";
this.button_start.Size = new System.Drawing.Size(131, 23);
this.button_start.TabIndex = 2;
this.button_start.Text = "Lichtsteuerung starten";
this.button_start.UseVisualStyleBackColor = true;
this.button_start.Click += new System.EventHandler(this.button2_Click);
//
// label_info_delete
//
this.label_info_delete.AutoSize = true;
this.label_info_delete.ForeColor = System.Drawing.SystemColors.GrayText;
this.label_info_delete.Location = new System.Drawing.Point(25, 47);
this.label_info_delete.Name = "label_info_delete";
this.label_info_delete.Size = new System.Drawing.Size(97, 13);
this.label_info_delete.TabIndex = 3;
this.label_info_delete.Text = "Alte Daten löschen";
//
// label_info_copy
//
this.label_info_copy.AutoSize = true;
this.label_info_copy.ForeColor = System.Drawing.SystemColors.GrayText;
this.label_info_copy.Location = new System.Drawing.Point(25, 69);
this.label_info_copy.Name = "label_info_copy";
this.label_info_copy.Size = new System.Drawing.Size(109, 13);
this.label_info_copy.TabIndex = 4;
this.label_info_copy.Text = "Neue Daten kopieren";
//
// label_delete
//
this.label_delete.AutoSize = true;
this.label_delete.Location = new System.Drawing.Point(232, 47);
this.label_delete.Name = "label_delete";
this.label_delete.Size = new System.Drawing.Size(0, 13);
this.label_delete.TabIndex = 5;
//
// label_copy
//
this.label_copy.AutoSize = true;
this.label_copy.Location = new System.Drawing.Point(232, 69);
this.label_copy.Name = "label_copy";
this.label_copy.Size = new System.Drawing.Size(0, 13);
this.label_copy.TabIndex = 6;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(25, 25);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(177, 13);
this.label4.TabIndex = 7;
this.label4.Text = "Auf Ende der Lichtsteuerung warten";
//
// label_wait
//
this.label_wait.AutoSize = true;
this.label_wait.Location = new System.Drawing.Point(232, 25);
this.label_wait.Name = "label_wait";
this.label_wait.Size = new System.Drawing.Size(0, 13);
this.label_wait.TabIndex = 8;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(288, 129);
this.Controls.Add(this.label_wait);
this.Controls.Add(this.label4);
this.Controls.Add(this.label_copy);
this.Controls.Add(this.label_delete);
this.Controls.Add(this.label_info_copy);
this.Controls.Add(this.label_info_delete);
this.Controls.Add(this.button_start);
this.Controls.Add(this.button_close);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "Form1";
this.Text = "Lichtsteuerung Updater";
this.Shown += new System.EventHandler(this.Form1_Shown);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button_close;
private System.Windows.Forms.Button button_start;
private System.Windows.Forms.Label label_info_delete;
private System.Windows.Forms.Label label_info_copy;
private System.Windows.Forms.Label label_delete;
private System.Windows.Forms.Label label_copy;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label_wait;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using System.Threading;
namespace WindowsInstaller
{
public partial class Form1 : Form
{
string from;
string to;
public Form1(string[] args)
{
from = args[0].Replace('/','\\');
to = args[1].Replace('/', '\\');
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
if (!to.EndsWith("\\"))
to += "\\";
Process.Start(to + "Lichtsteuerung.exe");
this.Dispose();
}
private void button_close_Click(object sender, EventArgs e)
{
this.Dispose();
}
public static bool isProcessRunning(string s)
{
s = s.ToLower();
if (s == null || s.Length == 0)
{
return false;
}
foreach (Process p in Process.GetProcesses())
{
if (p.ProcessName.ToLower().Contains(s))
return true;
}
return false;
}
private void Form1_Shown(object sender, EventArgs e)
{
var thread = new Thread(() =>
{
while (isProcessRunning("lichtsteuerung"))
{
Thread.Sleep(100);
}
label_wait.Invoke((MethodInvoker)delegate {
label_wait.Text = "\u2713";
});
label_info_delete.Invoke((MethodInvoker)delegate {
label_info_delete.ForeColor = Color.Black;
});
try
{
Directory.Delete(to, true);
}
catch (Exception ex)
{
label_delete.Invoke((MethodInvoker)delegate {
label_delete.Text = "\u274C";
});
MessageBox.Show(ex.Message, "Fehler beim löschen.");
return;
}
label_delete.Invoke((MethodInvoker)delegate {
label_delete.Text = "\u2713";
});
label_info_copy.Invoke((MethodInvoker)delegate {
label_info_copy.ForeColor = Color.Black;
});
string rootDir = to.Substring(0, to.LastIndexOf('\\'));
string targetName = to.Substring(to.LastIndexOf('\\') + 1);
string fromName = from.Substring(from.LastIndexOf('\\') + 1);
try
{
Directory.Move(from, to);
}
catch (Exception ex)
{
label_copy.Invoke((MethodInvoker)delegate {
label_copy.Text = "\u274C";
});
MessageBox.Show(ex.Message, "Fehler beim kopieren.");
return;
}
label_copy.Invoke((MethodInvoker)delegate {
label_copy.Text = "\u2713";
});
button_start.Invoke((MethodInvoker)delegate {
button_start.Enabled = true;
});