From 19bd2da50231240e1d0eb5222967230d12b93a8d Mon Sep 17 00:00:00 2001 From: BlubbFish Date: Tue, 11 Apr 2017 17:56:55 +0000 Subject: [PATCH] Refactor is that shit --- svnsync/Controllers/ControllersTray.cs | 299 +++++++++++----------- svnsync/Controllers/ControllersWindow.cs | 38 +-- svnsync/Form1.cs | 50 ++-- svnsync/Helpers/Handles.cs | 26 +- svnsync/Helpers/StringHelper.cs | 30 +-- svnsync/Libraries/Svn.cs | 269 +++++++++++-------- svnsync/Models/ModelsTray.cs | 48 ++-- svnsync/Models/ModelsWindow.cs | 26 +- svnsync/Program.cs | 141 +++++----- svnsync/Properties/AssemblyInfo.cs | 6 +- svnsync/Views/ViewsTray.cs | 222 ++++++++-------- svnsync/Views/ViewsWindow.cs | 28 +- svnsync/Views/ViewsWindowForm.Designer.cs | 15 +- svnsync/Views/ViewsWindowForm.cs | 15 +- svnsync/svnsync.csproj | 4 +- svnsync/svnsync.csproj.user | 4 +- 16 files changed, 645 insertions(+), 576 deletions(-) diff --git a/svnsync/Controllers/ControllersTray.cs b/svnsync/Controllers/ControllersTray.cs index 57326d0..7dfd0b6 100644 --- a/svnsync/Controllers/ControllersTray.cs +++ b/svnsync/Controllers/ControllersTray.cs @@ -1,160 +1,163 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using BlubbFish.Utils; using svnsync.Views; using svnsync.Helpers; namespace svnsync.Controllers { - class ControllersTray : OwnController + class ControllersTray : OwnController + { + private static ViewsTray viewTray; + private static ControllersWindow controllerWindow; + //private string args; + public delegate void _enableLoopRun(); + public event _enableLoopRun StartLoop; + + /// + /// Controlls a Tray. + /// + public ControllersTray() { } + + protected override void Init() { - private static ViewsTray viewTray; - private static ControllersWindow controllerWindow; - //private string args; - public delegate void _enableLoopRun(); - public event _enableLoopRun StartLoop; - - /// - /// Controlls a Tray. - /// - public ControllersTray() {} - - protected override void init() { - viewTray = new ViewsTray(); - controllerWindow = new ControllersWindow(); - controllerWindow.setAction(Handles.FormType.Normal); - if(viewTray.Model.Args.HasArgumentType("-cron")) { - if(this.cronJob(0, false)) { - viewTray.ShowSuccess(); - System.Threading.Thread.Sleep(5000); - viewTray.Dispose(); - } else { - this.StartLoop(); - } - return; - } else { - controllerWindow.execute(); - } - } - - public override void Dispose() { - if(viewTray != null) { - viewTray.Dispose(); - } - if(controllerWindow != null) { - controllerWindow.Dispose(); - } - } - - private bool cronJob(int run, bool readyToCommit) { - if(viewTray.Model.Svn == null) { - return HandleError(Handles.SvnType.NotInit, ""); - } - if(run > 10) { - return HandleError(Handles.SvnType.ToMutchChronRuns, ""); - } - if(viewTray.Model.Svn.IsError()) { - return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.getError()); - } - try { - viewTray.Model.Svn.CheckStatus(); - } catch(NotImplementedException e) { - return HandleError(Handles.SvnType.UnexpectedError, e.Message, e.StackTrace); - } catch(Helpers.SvnLockedException e) { - return HandleError(Handles.SvnType.LockedFile, e.Message); - } - if(viewTray.Model.Svn.IsNotOnlyModified()) { - if(viewTray.Model.Svn.IsUncheckedFiles()) { - if(viewTray.Model.Args.HasArgumentType("-autoadd")) { - viewTray.Model.Svn.AddFiles(viewTray.Model.Svn.getNoVersionFiles()); - if(viewTray.Model.Svn.IsError()) { - return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.getError()); - } - } else { - return HandleError(Handles.SvnType.HasVersionitedFiles, ""); - } - } - if(viewTray.Model.Svn.IsExternDeletedFiles()) { - if(viewTray.Model.Args.HasArgumentType("-autodelete")) { - viewTray.Model.Svn.DeleteFiles(viewTray.Model.Svn.getWasDeletedFiles()); - if(viewTray.Model.Svn.IsError()) { - return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.getError()); - } - } else { - return HandleError(Handles.SvnType.ExternDeletedFiles, ""); - } - } - return this.cronJob(run + 1, true); - } else { - if(readyToCommit) { - viewTray.Model.Svn.SetArgCheckIn("Automatic Cronjob Checkin: " + StringHelper.GetTimeStamp(DateTime.Now)); - if(viewTray.Model.Svn.IsError()) { - return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.getError()); - } - } else { - viewTray.Model.Svn.Update(); - if(viewTray.Model.Svn.IsError()) { - return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.getError()); - } - return this.cronJob(run + 1, true); - } - } - return true; - } - - private bool HandleError(Handles.SvnType svnType, string p, string p1 = "") { - viewTray.ShowError(svnType, p); - switch(svnType) { - case Handles.SvnType.ToMutchChronRuns: - controllerWindow.setAction(Handles.FormType.MuchCronJobs); - break; - case Handles.SvnType.HasVersionitedFiles: - controllerWindow.setAction(Handles.FormType.UnversionFiles); - break; - case Handles.SvnType.UnexpectedError: - controllerWindow.setAction(Handles.FormType.Error); - controllerWindow.setMessage(p+" "+p1); - break; - case Handles.SvnType.ExternDeletedFiles: - controllerWindow.setAction(Handles.FormType.DeletedFiles); - break; - case Handles.SvnType.LockedFile: - controllerWindow.setAction(Handles.FormType.ManualResolve); - controllerWindow.setMessage(p); - break; - } - return false; - } - - /// - /// If you Click on the Tray Icon - /// - /// - /// - public static void Click_Tray(object sender, EventArgs e) - { - controllerWindow.execute(); - } - - /// - /// If you Click on the Tray Ballon - /// - /// - /// - public static void Click_Ballon(object sender, EventArgs e) - { - controllerWindow.execute(); - } - - internal void hideToolTip() { - viewTray.HideToolTip(); - } - - internal static void Click_Quit(object sender, EventArgs e) { + viewTray = new ViewsTray(); + controllerWindow = new ControllersWindow(); + controllerWindow.SetAction(Handles.FormType.Normal); + if (viewTray.Model.Args.HasArgumentType("-cron")) { + if (this.CronJob(0, false)) { + viewTray.ShowSuccess(); + System.Threading.Thread.Sleep(5000); viewTray.Dispose(); - System.Windows.Forms.Application.Exit(); + } else { + this.StartLoop(); } + return; + } else { + controllerWindow.Execute(); + } } + + public override void Dispose() + { + if (viewTray != null) { + viewTray.Dispose(); + } + if (controllerWindow != null) { + controllerWindow.Dispose(); + } + } + + private Boolean CronJob(Int32 run, Boolean readyToCommit) + { + if (viewTray.Model.Svn == null) { + return HandleError(Handles.SvnType.NotInit, ""); + } + if (run > 10) { + return HandleError(Handles.SvnType.ToMutchChronRuns, ""); + } + if (viewTray.Model.Svn.IsError) { + return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.Error); + } + try { + viewTray.Model.Svn.CheckStatus(); + } catch (NotImplementedException e) { + return HandleError(Handles.SvnType.UnexpectedError, e.Message, e.StackTrace); + } catch (Helpers.SvnLockedException e) { + return HandleError(Handles.SvnType.LockedFile, e.Message); + } + if (viewTray.Model.Svn.IsNotOnlyModified) { + if (viewTray.Model.Svn.IsUncheckedFiles) { + if (viewTray.Model.Args.HasArgumentType("-autoadd")) { + viewTray.Model.Svn.AddFiles(viewTray.Model.Svn.NoVersionFiles); + if (viewTray.Model.Svn.IsError) { + return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.Error); + } + } else { + return HandleError(Handles.SvnType.HasVersionitedFiles, ""); + } + } + if (viewTray.Model.Svn.IsExternDeletedFiles) { + if (viewTray.Model.Args.HasArgumentType("-autodelete")) { + viewTray.Model.Svn.DeleteFiles(viewTray.Model.Svn.WasDeletedFiles); + if (viewTray.Model.Svn.IsError) { + return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.Error); + } + } else { + return HandleError(Handles.SvnType.ExternDeletedFiles, ""); + } + } + return this.CronJob(run + 1, true); + } else { + if (readyToCommit) { + viewTray.Model.Svn.SetArgCheckIn("Automatic Cronjob Checkin: " + StringHelper.GetTimeStamp(DateTime.Now)); + if (viewTray.Model.Svn.IsError) { + return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.Error); + } + } else { + viewTray.Model.Svn.Update(); + if (viewTray.Model.Svn.IsError) { + return HandleError(Handles.SvnType.UnexpectedError, viewTray.Model.Svn.Error); + } + return this.CronJob(run + 1, true); + } + } + return true; + } + + private Boolean HandleError(Handles.SvnType svnType, String message, String stacktrace = "") + { + viewTray.ShowError(svnType, message); + switch (svnType) { + case Handles.SvnType.ToMutchChronRuns: + controllerWindow.SetAction(Handles.FormType.MuchCronJobs); + break; + case Handles.SvnType.HasVersionitedFiles: + controllerWindow.SetAction(Handles.FormType.UnversionFiles); + break; + case Handles.SvnType.UnexpectedError: + controllerWindow.SetAction(Handles.FormType.Error); + controllerWindow.SetMessage(message + " " + stacktrace); + break; + case Handles.SvnType.ExternDeletedFiles: + controllerWindow.SetAction(Handles.FormType.DeletedFiles); + break; + case Handles.SvnType.LockedFile: + controllerWindow.SetAction(Handles.FormType.ManualResolve); + controllerWindow.SetMessage(message); + break; + } + return false; + } + + /// + /// If you Click on the Tray Icon + /// + /// + /// + public static void Click_Tray(Object sender, EventArgs e) + { + controllerWindow.Execute(); + } + + /// + /// If you Click on the Tray Ballon + /// + /// + /// + public static void Click_Ballon(Object sender, EventArgs e) + { + controllerWindow.Execute(); + } + + internal void HideToolTip() + { + viewTray.HideToolTip(); + } + + internal static void Click_Quit(Object sender, EventArgs e) + { + viewTray.Dispose(); + System.Windows.Forms.Application.Exit(); + } + } } diff --git a/svnsync/Controllers/ControllersWindow.cs b/svnsync/Controllers/ControllersWindow.cs index 1475ce3..ff4e09c 100644 --- a/svnsync/Controllers/ControllersWindow.cs +++ b/svnsync/Controllers/ControllersWindow.cs @@ -1,41 +1,44 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; using BlubbFish.Utils; using svnsync.Views; using svnsync.Helpers; -namespace svnsync.Controllers { - public class ControllersWindow : OwnController { +namespace svnsync.Controllers +{ + public class ControllersWindow : OwnController + { private static ViewsWindow viewWindow; private Handles.FormType initAction; - private string initMessage; + private String initMessage; /// /// Tray Controller /// public ControllersWindow() { } - override protected void init() { + override protected void Init() + { viewWindow = new ViewsWindow(); - viewWindow.Model.Message = initMessage; - viewWindow.Model.FormType = initAction; + viewWindow.Model.Message = this.initMessage; + viewWindow.Model.FormType = this.initAction; } - public override void Dispose() { - if(viewWindow != null) + public override void Dispose() + { + if (viewWindow != null) { viewWindow.Dispose(); + } } - public static void FormClosed(object sender, FormClosedEventArgs e) { + public static void FormClosed(Object sender, FormClosedEventArgs e) + { viewWindow.Dispose(); } - internal void setAction(Handles.FormType formType) { - if(viewWindow == null) { + internal void SetAction(Handles.FormType formType) + { + if (viewWindow == null) { this.initAction = formType; } else { viewWindow.Model.FormType = formType; @@ -47,8 +50,9 @@ namespace svnsync.Controllers { //this.CreateFileList("Löschen", "Diese Daten sind gelöscht worden:", s.getWasDeletedFiles(), new EventHandler(deleteButton_Click)); } - internal void setMessage(string p) { - if(viewWindow == null) { + internal void SetMessage(String p) + { + if (viewWindow == null) { this.initMessage = p; } else { viewWindow.Model.Message = p; diff --git a/svnsync/Form1.cs b/svnsync/Form1.cs index b93f304..102acd8 100644 --- a/svnsync/Form1.cs +++ b/svnsync/Form1.cs @@ -39,8 +39,8 @@ namespace svnsync pargs.Add("-cron", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single)); pargs.Add("-autoadd", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single)); pargs.Add("-autodelete", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single)); - this.c = CmdArgs.getInstance(); - this.c.setArguments(pargs, args); + this.c = CmdArgs.Instance; + this.c.SetArguments(pargs, args); this.StartSvn(); if (this.s != null) { @@ -68,8 +68,8 @@ namespace svnsync return this.HandleSvn(HandleSvnType.NotInit, ""); if (run > 10) return this.HandleSvn(HandleSvnType.ToMutchChronRuns, ""); - if (s.IsError()) - return this.HandleSvn(HandleSvnType.UnexpectedError, s.getError()); + if (s.IsError) + return this.HandleSvn(HandleSvnType.UnexpectedError, s.Error); try { s.CheckStatus(); @@ -78,26 +78,26 @@ namespace svnsync { return this.HandleSvn(HandleSvnType.UnexpectedError, e.Message); } - if (s.IsNotOnlyModified()) + if (s.IsNotOnlyModified) { - if (s.IsUncheckedFiles()) + if (s.IsUncheckedFiles) { if (c.HasArgumentType("-autoadd")) - s.AddFiles(s.getNoVersionFiles()); + s.AddFiles(s.NoVersionFiles); else return this.HandleSvn(HandleSvnType.HasVersionitedFiles, ""); } - if (s.IsError()) - return this.HandleSvn(HandleSvnType.UnexpectedError, s.getError()); - if (s.IsExternDeletedFiles()) + if (s.IsError) + return this.HandleSvn(HandleSvnType.UnexpectedError, s.Error); + if (s.IsExternDeletedFiles) { if (c.HasArgumentType("-autodelete")) - s.DeleteFiles(s.getWasDeletedFiles()); + s.DeleteFiles(s.WasDeletedFiles); else return this.HandleSvn(HandleSvnType.ExternDeletedFiles, ""); } - if (s.IsError()) - return this.HandleSvn(HandleSvnType.UnexpectedError, s.getError()); + if (s.IsError) + return this.HandleSvn(HandleSvnType.UnexpectedError, s.Error); return this.cronJob(run + 1, true); } else @@ -105,14 +105,14 @@ namespace svnsync if (readyToCommit) { s.SetArgCheckIn(this.GetTimeStamp(DateTime.Now)); - if (s.IsError()) - return this.HandleSvn(HandleSvnType.UnexpectedError, s.getError()); + if (s.IsError) + return this.HandleSvn(HandleSvnType.UnexpectedError, s.Error); } else { s.Update(); - if (s.IsError()) - return this.HandleSvn(HandleSvnType.UnexpectedError, s.getError()); + if (s.IsError) + return this.HandleSvn(HandleSvnType.UnexpectedError, s.Error); return this.cronJob(run + 1, true); } } @@ -132,7 +132,7 @@ namespace svnsync return false; case HandleSvnType.HasVersionitedFiles: this.ShowToolTip("Svn Sync", "Es sind unversionierte Dateien vorhanden (?)", ToolTipIcon.Info); - this.CreateFileList("Hinzufügen", "Diese Daten sind unversioniert:", s.getNoVersionFiles(), new EventHandler(addButton_Click)); + this.CreateFileList("Hinzufügen", "Diese Daten sind unversioniert:", s.NoVersionFiles, new EventHandler(addButton_Click)); return false; case HandleSvnType.UnexpectedError: this.ShowToolTip("Svn Sync Fehler", "Es ist ein Unvorhersebarer Fehler aufgetreten: " + p, ToolTipIcon.Error); @@ -140,7 +140,7 @@ namespace svnsync return false; case HandleSvnType.ExternDeletedFiles: this.ShowToolTip("Svn Sync", "Es sind extern gelöschte Dateien vorhanden (!)", ToolTipIcon.Info); - this.CreateFileList("Löschen", "Diese Daten sind gelöscht worden:", s.getWasDeletedFiles(), new EventHandler(deleteButton_Click)); + this.CreateFileList("Löschen", "Diese Daten sind gelöscht worden:", s.WasDeletedFiles, new EventHandler(deleteButton_Click)); return false; } return false; @@ -424,9 +424,9 @@ namespace svnsync this.ShowInTaskbar = false; this.WindowState = FormWindowState.Minimized; s.DeleteFiles(l); - if (s.IsError()) + if (s.IsError) { - this.HandleSvn(HandleSvnType.UnexpectedError, s.getError()); + this.HandleSvn(HandleSvnType.UnexpectedError, s.Error); return; } this.runagainButton_Click(sender, null); @@ -462,9 +462,9 @@ namespace svnsync this.ShowInTaskbar = false; this.WindowState = FormWindowState.Minimized; s.AddFiles(l); - if (s.IsError()) + if (s.IsError) { - this.HandleSvn(HandleSvnType.UnexpectedError, s.getError()); + this.HandleSvn(HandleSvnType.UnexpectedError, s.Error); return; } this.runagainButton_Click(sender, null); @@ -494,8 +494,8 @@ namespace svnsync this.ShowToolTip("Svn Sync Fehler", "Kein Argument für \"-d\" angegeben", ToolTipIcon.Error); return; } - this.s = Svn.getInstance(); - this.s.setDirectory(this.c.GetArgumentData("-d")); + this.s = Svn.Instance; + this.s.SetDirectory(this.c.GetArgumentData("-d")); } private void EventHandler_Resize(object sender, System.EventArgs e) diff --git a/svnsync/Helpers/Handles.cs b/svnsync/Helpers/Handles.cs index c600722..b6ed83b 100644 --- a/svnsync/Helpers/Handles.cs +++ b/svnsync/Helpers/Handles.cs @@ -1,12 +1,11 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace svnsync.Helpers { - class Handles { - public enum SvnType { +namespace svnsync.Helpers +{ + class Handles + { + public enum SvnType + { NotInit, ToMutchChronRuns, HasVersionitedFiles, @@ -14,7 +13,8 @@ namespace svnsync.Helpers { ExternDeletedFiles, LockedFile, } - public enum FormType { + public enum FormType + { MuchCronJobs, UnversionFiles, Error, @@ -24,11 +24,13 @@ namespace svnsync.Helpers { } } [Serializable()] - public class SvnLockedException : System.Exception { + public class SvnLockedException : System.Exception + { public SvnLockedException() : base() { } - public SvnLockedException(string message) : base(message) { } - public SvnLockedException(string message, System.Exception inner) : base(message, inner) { } + public SvnLockedException(String message) : base(message) { } + public SvnLockedException(String message, System.Exception inner) : base(message, inner) { } protected SvnLockedException(System.Runtime.Serialization.SerializationInfo info, - System.Runtime.Serialization.StreamingContext context) { } + System.Runtime.Serialization.StreamingContext context) + { } } } diff --git a/svnsync/Helpers/StringHelper.cs b/svnsync/Helpers/StringHelper.cs index fdcb98a..ead64f5 100644 --- a/svnsync/Helpers/StringHelper.cs +++ b/svnsync/Helpers/StringHelper.cs @@ -1,24 +1,20 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace svnsync.Helpers { - class StringHelper + class StringHelper + { + public static String GetTimeStamp(DateTime dateTime) { - public static string GetTimeStamp(DateTime dateTime) - { - String ret = ""; - ret += dateTime.Year.ToString().PadLeft(4, '0'); - ret += dateTime.Month.ToString().PadLeft(2, '0'); - ret += dateTime.Day.ToString().PadLeft(2, '0'); - ret += "-"; - ret += dateTime.Hour.ToString().PadLeft(2, '0'); - ret += dateTime.Minute.ToString().PadLeft(2, '0'); - ret += dateTime.Second.ToString().PadLeft(2, '0'); - return ret; - } + String ret = ""; + ret += dateTime.Year.ToString().PadLeft(4, '0'); + ret += dateTime.Month.ToString().PadLeft(2, '0'); + ret += dateTime.Day.ToString().PadLeft(2, '0'); + ret += "-"; + ret += dateTime.Hour.ToString().PadLeft(2, '0'); + ret += dateTime.Minute.ToString().PadLeft(2, '0'); + ret += dateTime.Second.ToString().PadLeft(2, '0'); + return ret; } + } } diff --git a/svnsync/Libraries/Svn.cs b/svnsync/Libraries/Svn.cs index d15d040..78413e6 100644 --- a/svnsync/Libraries/Svn.cs +++ b/svnsync/Libraries/Svn.cs @@ -1,84 +1,84 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Diagnostics; namespace svnsync.Libraries { class Svn { - private string dir; + private String dir; private Process p = new Process(); private List modified; private List noversion; private List wasdeleted; private List added; - private string SvnError = ""; - private string SvnOutput = ""; - private List isdeleted; - private List external; + private String SvnError = ""; + private String SvnOutput = ""; + private List isdeleted; + private List external; private static Svn instances; private Svn() { } - public void setDirectory(string dir) { + public void SetDirectory(String dir) { this.dir = dir; this.Init(); } private void Init() { - p.StartInfo.FileName = "svn"; - p.StartInfo.WorkingDirectory = this.dir; - p.StartInfo.CreateNoWindow = true; - p.StartInfo.RedirectStandardOutput = true; - p.StartInfo.RedirectStandardError = true; - p.StartInfo.UseShellExecute = false; + this.p.StartInfo.FileName = "svn"; + this.p.StartInfo.WorkingDirectory = this.dir; + this.p.StartInfo.CreateNoWindow = true; + this.p.StartInfo.RedirectStandardOutput = true; + this.p.StartInfo.RedirectStandardError = true; + this.p.StartInfo.UseShellExecute = false; } internal void CheckStatus() { - modified = new List(); - noversion = new List(); - wasdeleted = new List(); - isdeleted = new List(); - added = new List(); - external = new List(); - this.runner("st"); - string[] lines = this.SvnOutput.Split('\n'); - foreach(String line in lines) { - if(line.Length < 7) + this.modified = new List(); + this.noversion = new List(); + this.wasdeleted = new List(); + this.isdeleted = new List(); + this.added = new List(); + this.external = new List(); + this.Runner("st"); + String[] lines = this.SvnOutput.Split('\n'); + foreach (String line in lines) { + if (line.Length < 7) { break; + } + Char[] handles = line.Substring(0, 7).ToCharArray(); String file = line.Substring(8).Trim(new Char[] { '\r', '\n', ' ', '\t' }); - if(handles[0] == ' ') { - if(handles[2] == 'L') { - throw new svnsync.Helpers.SvnLockedException("Datei: " + file + " ist gelockt!"); - } + if (handles[0] == ' ') { + if (handles[2] == 'L') { + throw new Helpers.SvnLockedException("Datei: " + file + " ist gelockt!"); + } //Modifizierte Eigenschaft - else if(handles[1] == 'M') { - modified.Add(file); + else if (handles[1] == 'M') { + this.modified.Add(file); } else { throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] ' '"); } - } else if(handles[0] == 'A') { - added.Add(file); - } else if(handles[0] == 'D') { - isdeleted.Add(file); + } else if (handles[0] == 'A') { + this.added.Add(file); + } else if (handles[0] == 'D') { + this.isdeleted.Add(file); } // Modifizierte Datei - else if(handles[0] == 'M') { - modified.Add(file); - } else if(handles[0] == 'R') { + else if (handles[0] == 'M') { + this.modified.Add(file); + } else if (handles[0] == 'R') { throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'R'"); - } else if(handles[0] == 'C') { + } else if (handles[0] == 'C') { throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'C'"); - } else if(handles[0] == 'X') { - external.Add(file); - } else if(handles[0] == 'I') { + } else if (handles[0] == 'X') { + this.external.Add(file); + } else if (handles[0] == 'I') { throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'I'"); - } else if(handles[0] == '?') { - noversion.Add(file); - } else if(handles[0] == '!') { - wasdeleted.Add(file); - } else if(handles[0] == '~') { + } else if (handles[0] == '?') { + this.noversion.Add(file); + } else if (handles[0] == '!') { + this.wasdeleted.Add(file); + } else if (handles[0] == '~') { throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] '~'"); } else { throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: Unexpected Symbol! [0]: \"" + handles[0] + "\""); @@ -86,100 +86,155 @@ namespace svnsync.Libraries { } } - internal bool IsNotOnlyModified() { - if(this.noversion.Count != 0) - return true; - if(this.wasdeleted.Count != 0) - return true; - return false; - } - - internal void SetArgCheckIn(string message) { + internal void SetArgCheckIn(String message) { String arg = "ci -m \"" + message + "\""; - this.runner(arg); + this.Runner(arg); } - internal void AddFiles(List files) { - String arg = "add"; - foreach(String item in files) { - arg += " \"" + item + "\""; - } - this.runner(arg); - } - - private void runner(string arg) { + private void Runner(String arg) { this.SvnOutput = ""; this.SvnError = ""; - p.StartInfo.Arguments = arg; - p.Start(); - this.SvnOutput = p.StandardOutput.ReadToEnd(); - this.SvnError = p.StandardError.ReadToEnd(); - p.WaitForExit(); + this.p.StartInfo.Arguments = arg; + this.p.Start(); + Int64 e_lenth = 0; + while (!this.p.HasExited) { + if(this.p.StandardOutput.Peek() != -1) { + this.SvnOutput += this.p.StandardOutput.ReadLine(); + } + this.p.StandardError.BaseStream.Flush(); + + if (this.p.StandardError.BaseStream.Length > e_lenth) { + this.SvnError += this.p.StandardError.BaseStream.ReadByte(); + e_lenth++; + } + System.Threading.Thread.Sleep(10); + } + this.SvnOutput += p.StandardOutput.ReadToEnd(); + this.SvnError += p.StandardError.ReadToEnd(); + /*this.p.OutputDataReceived += this.P_OutputDataReceived; + this.p.ErrorDataReceived += this.P_ErrorDataReceived; + this.p.BeginOutputReadLine(); + this.p.BeginErrorReadLine(); + while(!this.p.HasExited) { + this.p.StandardError.BaseStream.FlushAsync(); + this.p.StandardOutput.BaseStream.FlushAsync(); + System.Threading.Thread.Sleep(10); + } + this.p.WaitForExit(); + this.p.CancelOutputRead(); + this.p.CancelErrorRead();*/ } - internal bool IsUncheckedFiles() { - if(this.noversion.Count != 0) - return true; - return false; + private void P_ErrorDataReceived(Object sender, DataReceivedEventArgs e) { + if(e.Data != null) { + this.SvnError += e.Data + "\n"; + } } - internal bool IsExternDeletedFiles() { - if(this.wasdeleted.Count != 0) - return true; - return false; - } - - internal bool IsError() { - if(this.SvnError != "") - return true; - return false; - } - - internal string getError() { - return this.SvnError; + private void P_OutputDataReceived(Object sender, DataReceivedEventArgs e) { + this.SvnOutput += e.Data + "\n"; } internal void DeleteFiles(List files) { String arg = "del"; - foreach(String item in files) { + foreach (String item in files) { arg += " \"" + item + "\""; } - this.runner(arg); - } - - internal List getWasDeletedFiles() { - return this.wasdeleted; - } - - internal List getNoVersionFiles() { - return this.noversion; + this.Runner(arg); } internal void DeleteFiles(List l) { - List s = new List(); - foreach(System.Windows.Forms.TreeNode item in l) { + List s = new List(); + foreach (System.Windows.Forms.TreeNode item in l) { s.Add(item.FullPath); } this.DeleteFiles(s); } + internal void AddFiles(List files) { + String arg = "add"; + foreach (String item in files) { + arg += " \"" + item + "\""; + } + this.Runner(arg); + } + internal void AddFiles(List l) { - List s = new List(); - foreach(System.Windows.Forms.TreeNode item in l) { + List s = new List(); + foreach (System.Windows.Forms.TreeNode item in l) { s.Add(item.FullPath); } this.AddFiles(s); } internal void Update() { - this.runner("up"); + this.Runner("up"); } - public static Svn getInstance() { - if(instances == null) { - instances = new Svn(); + public static Svn Instance { + get { + if (instances == null) { + instances = new Svn(); + } + return instances; + } + } + + internal Boolean IsNotOnlyModified { + get { + if (this.noversion.Count != 0) { + return true; + } + if (this.wasdeleted.Count != 0) { + return true; + } + return false; + } + } + + internal Boolean IsUncheckedFiles { + get { + if (this.noversion.Count != 0) { + return true; + } + return false; + } + } + + internal Boolean IsExternDeletedFiles { + get { + if (this.wasdeleted.Count != 0) { + return true; + } + return false; + } + } + + internal List WasDeletedFiles { + get { + return this.wasdeleted; + } + } + + internal List NoVersionFiles { + get { + return this.noversion; + } + } + + internal Boolean IsError { + get { + if (this.SvnError != "") { + return true; + } + return false; + } + } + + internal String Error { + get { + return this.SvnError; } - return instances; } } } diff --git a/svnsync/Models/ModelsTray.cs b/svnsync/Models/ModelsTray.cs index 09076b8..9efd7a2 100644 --- a/svnsync/Models/ModelsTray.cs +++ b/svnsync/Models/ModelsTray.cs @@ -1,36 +1,32 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using BlubbFish.Utils; +using BlubbFish.Utils; using svnsync.Libraries; namespace svnsync.Models { - class ModelsTray : OwnModel + class ModelsTray : OwnModel + { + private ModelsTray() { - private ModelsTray() - { - this.init(); - } - - protected override void init() - { - this.Args = CmdArgs.getInstance(); - this.Svn = Svn.getInstance(); - } - - /// - /// Saves the Argument of the Program - /// - public CmdArgs Args { get; private set; } - - /// - /// Save a SVN - /// - public Svn Svn { get; private set; } + this.Init(); } + protected override void Init() + { + this.Args = CmdArgs.Instance; + this.Svn = Svn.Instance; + } + + /// + /// Saves the Argument of the Program + /// + public CmdArgs Args { get; private set; } + + /// + /// Save a SVN + /// + public Svn Svn { get; private set; } + } + } diff --git a/svnsync/Models/ModelsWindow.cs b/svnsync/Models/ModelsWindow.cs index b731b1b..e6eb755 100644 --- a/svnsync/Models/ModelsWindow.cs +++ b/svnsync/Models/ModelsWindow.cs @@ -1,33 +1,29 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; using BlubbFish.Utils; using svnsync.Helpers; -namespace svnsync.Models { +namespace svnsync.Models +{ public class ModelsWindow : OwnModel { - private InIReader networkfile; + //private InIReader networkfile; private ModelsWindow() { - this.init(); + this.Init(); } - protected override void init() { + protected override void Init() { } - private string MessageValue = ""; - public string Message { - get { return MessageValue; } - set { MessageValue = value; this.update(); } + private String MessageValue = ""; + public String Message { + get { return this.MessageValue; } + set { this.MessageValue = value; this.Update(); } } private Handles.FormType FormTypeValue; internal Handles.FormType FormType { - get { return FormTypeValue; } - set { FormTypeValue = value; this.update(); } + get { return this.FormTypeValue; } + set { this.FormTypeValue = value; this.Update(); } } } } diff --git a/svnsync/Program.cs b/svnsync/Program.cs index 3894bf0..b600b2e 100644 --- a/svnsync/Program.cs +++ b/svnsync/Program.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Windows.Forms; using svnsync.Controllers; using BlubbFish.Utils; @@ -8,76 +7,82 @@ using svnsync.Libraries; namespace svnsync { - static class Program + static class Program + { + private static Boolean LoopStarted = false; + + /// + /// Der Haupteinstiegspunkt für die Anwendung. + /// + [STAThread] + static void Main(String[] args) { - private static bool LoopStarted = false; - - /// - /// Der Haupteinstiegspunkt für die Anwendung. - /// - [STAThread] - static void Main(string[] args) { - if(!cmd(args)) { - return; - } - FileMutex.Instance.setName(CmdArgs.getInstance().GetArgumentData("-d")); - if(!FileMutex.Instance.create()) { - return; - } - ControllersTray t = null; - try { - Svn.getInstance().setDirectory(CmdArgs.getInstance().GetArgumentData("-d")); - t = new ControllersTray(); - t.StartLoop += t_StartLoop; - t.execute(); - } catch(Exception e) { - t.hideToolTip(); - string text = e.Message + "\n\n" + e.StackTrace; - string title = "Exception in SVNSync: " + CmdArgs.getInstance().GetArgumentData("-d"); - System.Windows.Forms.MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Error); - FileMutex.Instance.delete(); - return; - } - if(!CmdArgs.getInstance().HasArgumentType("-cron")) { - t_StartLoop(); - } - FileMutex.Instance.delete(); + if (!Cmd(args)) { return; - /*Application.Run();*/ - /*Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - try { - Application.Run(new Form1(args)); - } catch(NotImplementedException e) { - System.Windows.Forms.MessageBox.Show("In: " + e.Source + "\n\n" + e.Message, "Fehler!", MessageBoxButtons.OK, MessageBoxIcon.Error); - } catch(Exception e) { - //System.Windows.Forms.MessageBox.Show("In: " + e.Source + "\n\n" + e.Message, "Fehler!", MessageBoxButtons.OK, MessageBoxIcon.Error); - Application.Exit(); - }*/ } - - static void t_StartLoop() { - if(!LoopStarted) { - LoopStarted = true; - Application.Run(); - } - + FileMutex.Instance.SetName(CmdArgs.Instance.GetArgumentData("-d")); + #if !DEBUG + if (!FileMutex.Instance.Create()) { + return; } - - private static bool cmd(string[] args) - { - Dictionary pargs = new Dictionary(); - pargs.Add("-d", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Touple, true)); - pargs.Add("-cron", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single)); - pargs.Add("-autoadd", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single)); - pargs.Add("-autodelete", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single)); - CmdArgs.getInstance().setArguments(pargs, args); - if (!CmdArgs.getInstance().HasAllRequiredArguments()) - { - System.Windows.Forms.MessageBox.Show(CmdArgs.getInstance().getUsageList("syncsvn.exe:"), "Fehlende Argumente auf der Komandozeile", MessageBoxButtons.OK, MessageBoxIcon.Stop); - return false; - } - return true; - } + #endif + ControllersTray t = null; + try { + Svn.Instance.SetDirectory(CmdArgs.Instance.GetArgumentData("-d")); + t = new ControllersTray(); + t.StartLoop += T_StartLoop; + t.Execute(); + } catch (Exception e) { + t.HideToolTip(); + String text = e.Message + "\n\n" + e.StackTrace; + String title = "Exception in SVNSync: " + CmdArgs.Instance.GetArgumentData("-d"); + MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Error); + FileMutex.Instance.Delete(); + return; + } + if (!CmdArgs.Instance.HasArgumentType("-cron")) { + T_StartLoop(); + } + FileMutex.Instance.Delete(); + return; + /*Application.Run();*/ + /*Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + try { + Application.Run(new Form1(args)); + } catch(NotImplementedException e) { + System.Windows.Forms.MessageBox.Show("In: " + e.Source + "\n\n" + e.Message, "Fehler!", MessageBoxButtons.OK, MessageBoxIcon.Error); + } catch(Exception e) { + //System.Windows.Forms.MessageBox.Show("In: " + e.Source + "\n\n" + e.Message, "Fehler!", MessageBoxButtons.OK, MessageBoxIcon.Error); + Application.Exit(); + }*/ } + + static void T_StartLoop() + { + if (!LoopStarted) { + LoopStarted = true; + Application.Run(); + } + + } + + private static Boolean Cmd(String[] args) + { + Dictionary pargs = new Dictionary { + { "-d", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Touple, true) }, + { "-cron", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single) }, + { "-autoadd", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single) }, + { "-autodelete", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single) }, + { "-externals-own", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single) }, + { "-externals", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single) } + }; + CmdArgs.Instance.SetArguments(pargs, args); + if (!CmdArgs.Instance.HasAllRequiredArguments()) { + MessageBox.Show(CmdArgs.Instance.GetUsageList("syncsvn.exe:"), "Fehlende Argumente auf der Komandozeile", MessageBoxButtons.OK, MessageBoxIcon.Stop); + return false; + } + return true; + } + } } diff --git a/svnsync/Properties/AssemblyInfo.cs b/svnsync/Properties/AssemblyInfo.cs index 285ff1b..809062f 100644 --- a/svnsync/Properties/AssemblyInfo.cs +++ b/svnsync/Properties/AssemblyInfo.cs @@ -11,7 +11,7 @@ using System.Resources; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("BlubbFish")] [assembly: AssemblyProduct("SvnSync")] -[assembly: AssemblyCopyright("Copyright © 2012 - 03.03.2017")] +[assembly: AssemblyCopyright("Copyright © 2012 - 10.03.2017")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -33,6 +33,6 @@ using System.Resources; // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.3.0")] -[assembly: AssemblyFileVersion("1.0.3.0")] +[assembly: AssemblyVersion("1.0.3.1")] +[assembly: AssemblyFileVersion("1.0.3.1")] [assembly: NeutralResourcesLanguageAttribute("de-DE")] diff --git a/svnsync/Views/ViewsTray.cs b/svnsync/Views/ViewsTray.cs index db71b98..f2a3675 100644 --- a/svnsync/Views/ViewsTray.cs +++ b/svnsync/Views/ViewsTray.cs @@ -1,126 +1,120 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using BlubbFish.Utils; +using BlubbFish.Utils; using svnsync.Models; using svnsync.Controllers; using System.Windows.Forms; using System.Drawing; using svnsync.Properties; using svnsync.Helpers; +using System; namespace svnsync.Views { - class ViewsTray : OwnView - { - /// - /// Model of the View - /// - public ModelsTray Model { get; private set; } - private NotifyIcon trayicon; + class ViewsTray : OwnView + { + /// + /// Model of the View + /// + public ModelsTray Model { get; private set; } + private NotifyIcon trayicon; - /// - /// View of a Tray - /// - public ViewsTray() - { - this.init(); - this.Model = ModelsTray.Instance; - this.Model.setObserver(this); - } - - /// - /// Updates the Tray - /// - public override void update() - { - this.trayicon.Text = "SvnSync: " + this.Model.Args.GetArgumentData("-d"); - } - - protected override void init() - { - this.trayicon = new NotifyIcon(); - this.trayicon.Visible = true; - this.trayicon.Icon = new Icon(Resources.Icon, 40, 40); - this.trayicon.Text = "SVN Sync Tool"; - this.trayicon.DoubleClick += ControllersTray.Click_Tray; - this.trayicon.BalloonTipClicked += ControllersTray.Click_Ballon; - this.trayicon.ContextMenuStrip = this.genMenu(); - } - - private ContextMenuStrip genMenu() { - ContextMenuStrip menu = new ContextMenuStrip(); - ToolStripMenuItem m1 = new ToolStripMenuItem("Öffnen"); - m1.Image = Resources.door_open; - m1.Click += ControllersTray.Click_Tray; - m1.Name = "Open"; - menu.Items.Add(m1); - - ToolStripMenuItem m2 = new ToolStripMenuItem("Beenden"); - m2.Image = Resources.door_open; - m2.Click += ControllersTray.Click_Quit; - m2.Name = "Quit"; - menu.Items.Add(m2); - - return menu; - } - - /// - /// Delete the Tray - /// - public override void Dispose() - { - this.trayicon.Visible = false; - Application.ExitThread(); - } - - /// - /// Show a Success Message - /// - public void ShowSuccess() - { - this.showBallonTooltip("Datensicherung Erfolgreich\n" + this.Model.Args.GetArgumentData("-d").Replace("\\\\", "\\"), ToolTipIcon.Info); - } - - private void showBallonTooltip(string text, ToolTipIcon toolTipIcon, string title = "SvnSync") - { - this.trayicon.BalloonTipIcon = toolTipIcon; - this.trayicon.BalloonTipText = text; - this.trayicon.BalloonTipTitle = title; - this.trayicon.ShowBalloonTip(100); - } - - /// - /// Show a Error Message. - /// - /// - /// - public void ShowError(Handles.SvnType svnType, string p) { - switch(svnType) { - case Handles.SvnType.NotInit: - this.showBallonTooltip("Svn wurde noch nicht inizialisiert", ToolTipIcon.Error, "Svn Sync Fehler"); - break; - case Handles.SvnType.ToMutchChronRuns: - this.showBallonTooltip("Fehler im Cronjob, mehr als 10 Aufrufe!", ToolTipIcon.Error, "Svn Sync Fehler"); - break; - case Handles.SvnType.HasVersionitedFiles: - this.showBallonTooltip("Es sind unversionierte Dateien vorhanden (?)", ToolTipIcon.Info, "Svn Sync Fehler"); - break; - case Handles.SvnType.UnexpectedError: - this.showBallonTooltip("Es ist ein Unvorhersebarer Fehler aufgetreten: " + p, ToolTipIcon.Error, "Svn Sync Fehler"); - break; - case Handles.SvnType.ExternDeletedFiles: - this.showBallonTooltip("Es sind extern gelöschte Dateien vorhanden (!)", ToolTipIcon.Info, "Svn Sync Fehler"); - break; - case Handles.SvnType.LockedFile: - this.showBallonTooltip("Es sind blokierte Dateien vorhanden (L)", ToolTipIcon.Info, "Svn Sync Fehler"); - break; - } - } - - internal void HideToolTip() { - this.trayicon.Visible = false; - } + /// + /// View of a Tray + /// + public ViewsTray() { + this.Init(); + this.Model = ModelsTray.Instance; + this.Model.SetObserver(this); } + + /// + /// Updates the Tray + /// + public override void Update() { + this.trayicon.Text = "SvnSync: " + ((this.Model.Args.GetArgumentData("-d").Length <= 54) ? this.Model.Args.GetArgumentData("-d") : "..."+this.Model.Args.GetArgumentData("-d").Substring(this.Model.Args.GetArgumentData("-d").Length - 51)); + } + + protected override void Init() { + this.trayicon = new NotifyIcon() { + Visible = true, + Icon = new Icon(Resources.Icon, 40, 40), + Text = "SVN Sync Tool" + }; + this.trayicon.DoubleClick += ControllersTray.Click_Tray; + this.trayicon.BalloonTipClicked += ControllersTray.Click_Ballon; + this.trayicon.ContextMenuStrip = this.GenMenu(); + } + + private ContextMenuStrip GenMenu() { + ContextMenuStrip menu = new ContextMenuStrip(); + ToolStripMenuItem m1 = new ToolStripMenuItem("Öffnen") { + Image = Resources.door_open, + Name = "Open" + }; + m1.Click += ControllersTray.Click_Tray; + menu.Items.Add(m1); + + ToolStripMenuItem m2 = new ToolStripMenuItem("Beenden") { + Image = Resources.door_open, + Name = "Quit" + }; + m2.Click += ControllersTray.Click_Quit; + menu.Items.Add(m2); + + return menu; + } + + /// + /// Delete the Tray + /// + public override void Dispose() { + this.trayicon.Visible = false; + Application.ExitThread(); + } + + /// + /// Show a Success Message + /// + public void ShowSuccess() { + this.ShowBallonTooltip("Datensicherung Erfolgreich\n" + this.Model.Args.GetArgumentData("-d").Replace("\\\\", "\\"), ToolTipIcon.Info); + } + + private void ShowBallonTooltip(System.String text, ToolTipIcon toolTipIcon, System.String title = "SvnSync") { + this.trayicon.BalloonTipIcon = toolTipIcon; + this.trayicon.BalloonTipText = text; + this.trayicon.BalloonTipTitle = title; + this.trayicon.ShowBalloonTip(100); + } + + /// + /// Show a Error Message. + /// + /// + /// + public void ShowError(Handles.SvnType svnType, System.String message) { + switch (svnType) { + case Handles.SvnType.NotInit: + this.ShowBallonTooltip("Svn wurde noch nicht inizialisiert", ToolTipIcon.Error, "Svn Sync Fehler"); + break; + case Handles.SvnType.ToMutchChronRuns: + this.ShowBallonTooltip("Fehler im Cronjob, mehr als 10 Aufrufe!", ToolTipIcon.Error, "Svn Sync Fehler"); + break; + case Handles.SvnType.HasVersionitedFiles: + this.ShowBallonTooltip("Es sind unversionierte Dateien vorhanden (?)", ToolTipIcon.Info, "Svn Sync Fehler"); + break; + case Handles.SvnType.UnexpectedError: + this.ShowBallonTooltip("Es ist ein Unvorhersebarer Fehler aufgetreten: " + message, ToolTipIcon.Error, "Svn Sync Fehler"); + break; + case Handles.SvnType.ExternDeletedFiles: + this.ShowBallonTooltip("Es sind extern gelöschte Dateien vorhanden (!)", ToolTipIcon.Info, "Svn Sync Fehler"); + break; + case Handles.SvnType.LockedFile: + this.ShowBallonTooltip("Es sind blokierte Dateien vorhanden (L)", ToolTipIcon.Info, "Svn Sync Fehler"); + break; + } + } + + internal void HideToolTip() { + this.trayicon.Visible = false; + } + } } diff --git a/svnsync/Views/ViewsWindow.cs b/svnsync/Views/ViewsWindow.cs index bbb3ee7..6105793 100644 --- a/svnsync/Views/ViewsWindow.cs +++ b/svnsync/Views/ViewsWindow.cs @@ -1,33 +1,33 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using System.Drawing; using BlubbFish.Utils; using svnsync.Models; -namespace svnsync.Views { - public class ViewsWindow : OwnView { +namespace svnsync.Views +{ + public class ViewsWindow : OwnView + { private ViewsWindowForm form; - public ViewsWindow() { + public ViewsWindow() + { this.form = new ViewsWindowForm(); - this.init(); - this.Model.setObserver(this); + this.Init(); + this.Model.SetObserver(this); } - public override void update() { + public override void Update() + { this.form.UpdateForm(); } - protected override void init() { + protected override void Init() + { this.Model = ModelsWindow.Instance; this.form.SetModel(this.Model); this.form.Show(); } - public override void Dispose() { + public override void Dispose() + { this.form.BeginInvoke((Action)(() => { this.form.Dispose(); })); diff --git a/svnsync/Views/ViewsWindowForm.Designer.cs b/svnsync/Views/ViewsWindowForm.Designer.cs index 06ec089..d862d51 100644 --- a/svnsync/Views/ViewsWindowForm.Designer.cs +++ b/svnsync/Views/ViewsWindowForm.Designer.cs @@ -30,6 +30,7 @@ { this.label1 = new System.Windows.Forms.Label(); this.messageBox = new System.Windows.Forms.RichTextBox(); + this.opencmd = new System.Windows.Forms.Button(); this.SuspendLayout(); // // label1 @@ -50,11 +51,22 @@ this.messageBox.TabIndex = 2; this.messageBox.Text = ""; // + // opencmd + // + this.opencmd.Location = new System.Drawing.Point(15, 227); + this.opencmd.Name = "opencmd"; + this.opencmd.Size = new System.Drawing.Size(75, 23); + this.opencmd.TabIndex = 3; + this.opencmd.Text = "Open CMD"; + this.opencmd.UseVisualStyleBackColor = true; + this.opencmd.Visible = false; + // // ViewsWindowForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(464, 262); + this.Controls.Add(this.opencmd); this.Controls.Add(this.messageBox); this.Controls.Add(this.label1); this.Name = "ViewsWindowForm"; @@ -68,5 +80,6 @@ private System.Windows.Forms.Label label1; private System.Windows.Forms.RichTextBox messageBox; - } + private System.Windows.Forms.Button opencmd; + } } \ No newline at end of file diff --git a/svnsync/Views/ViewsWindowForm.cs b/svnsync/Views/ViewsWindowForm.cs index 3afe3b8..034a135 100644 --- a/svnsync/Views/ViewsWindowForm.cs +++ b/svnsync/Views/ViewsWindowForm.cs @@ -10,21 +10,26 @@ using System.Windows.Forms; using svnsync.Models; using svnsync.Controllers; -namespace svnsync.Views { - public partial class ViewsWindowForm : Form { +namespace svnsync.Views +{ + public partial class ViewsWindowForm : Form + { private ModelsWindow model; - public ViewsWindowForm() { + public ViewsWindowForm() + { InitializeComponent(); this.FormClosed += ControllersWindow.FormClosed; } - public void UpdateForm() { + public void UpdateForm() + { this.BeginInvoke((Action)(() => { this.messageBox.Text = this.model.Message; })); } - public void SetModel(ModelsWindow window) { + public void SetModel(ModelsWindow window) + { this.model = window; } } diff --git a/svnsync/svnsync.csproj b/svnsync/svnsync.csproj index 9b729bf..7e2bbb4 100644 --- a/svnsync/svnsync.csproj +++ b/svnsync/svnsync.csproj @@ -31,7 +31,7 @@ true - x86 + x64 true full false @@ -42,7 +42,7 @@ false - AnyCPU + x64 pdbonly true bin\Release\ diff --git a/svnsync/svnsync.csproj.user b/svnsync/svnsync.csproj.user index 83eb743..458d539 100644 --- a/svnsync/svnsync.csproj.user +++ b/svnsync/svnsync.csproj.user @@ -1,12 +1,12 @@  - -d "E:\Eigene Dateien\Doc%27s\Basteleien" -cron -autoadd -autodelete + -d "E:\\Eigene Dateien\\Dokumente\\Visual Studio 2017\\Projects" -cron -autoadd -autodelete -externals-own false Project - -d "D:\\Doc%27s\\Studium\\" -cron -autoadd -autodelete + -d "E:\\Eigene Dateien\\Dokumente\\Visual Studio 2017\\Projects" -cron -autoadd -autodelete -externals-own veröffentlichen\