diff --git a/svnsync.sln b/svnsync.sln index d74c976..9b8729d 100644 --- a/svnsync.sln +++ b/svnsync.sln @@ -1,18 +1,40 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "svnsync", "svnsync\svnsync.csproj", "{447D3E59-FD95-47EA-AB2F-AA241EFD6E0C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils", "..\Utils\Utils\Utils.csproj", "{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {447D3E59-FD95-47EA-AB2F-AA241EFD6E0C}.Debug|Any CPU.ActiveCfg = Debug|x86 + {447D3E59-FD95-47EA-AB2F-AA241EFD6E0C}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {447D3E59-FD95-47EA-AB2F-AA241EFD6E0C}.Debug|Mixed Platforms.Build.0 = Debug|x86 {447D3E59-FD95-47EA-AB2F-AA241EFD6E0C}.Debug|x86.ActiveCfg = Debug|x86 {447D3E59-FD95-47EA-AB2F-AA241EFD6E0C}.Debug|x86.Build.0 = Debug|x86 + {447D3E59-FD95-47EA-AB2F-AA241EFD6E0C}.Release|Any CPU.ActiveCfg = Release|x86 + {447D3E59-FD95-47EA-AB2F-AA241EFD6E0C}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {447D3E59-FD95-47EA-AB2F-AA241EFD6E0C}.Release|Mixed Platforms.Build.0 = Release|x86 {447D3E59-FD95-47EA-AB2F-AA241EFD6E0C}.Release|x86.ActiveCfg = Release|x86 {447D3E59-FD95-47EA-AB2F-AA241EFD6E0C}.Release|x86.Build.0 = Release|x86 + {FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|x86.ActiveCfg = Debug|Any CPU + {FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.Build.0 = Release|Any CPU + {FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/svnsync/Controllers/ControllersTray.cs b/svnsync/Controllers/ControllersTray.cs new file mode 100644 index 0000000..508f85c --- /dev/null +++ b/svnsync/Controllers/ControllersTray.cs @@ -0,0 +1,147 @@ +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 + { + private static ViewsTray viewTray; + private static ControllersWindow controllerWindow; + private string args; + + /// + /// 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(); + return; + } + } else { + controllerWindow.execute(); + } + } + + 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); + } 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) { + 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); + 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.Dispose(); + System.Windows.Forms.Application.Exit(); + } + } +} diff --git a/svnsync/Controllers/ControllersWindow.cs b/svnsync/Controllers/ControllersWindow.cs new file mode 100644 index 0000000..78d8d4c --- /dev/null +++ b/svnsync/Controllers/ControllersWindow.cs @@ -0,0 +1,53 @@ +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 { + private static ViewsWindow viewWindow; + private Handles.FormType initAction; + private string initMessage; + /// + /// Tray Controller + /// + public ControllersWindow() { } + + override protected void init() { + viewWindow = new ViewsWindow(); + viewWindow.Model.Message = initMessage; + viewWindow.Model.FormType = initAction; + } + + public static void FormClosed(object sender, FormClosedEventArgs e) { + viewWindow.Dispose(); + } + + + internal void setAction(Handles.FormType formType) { + if(viewWindow == null) { + this.initAction = formType; + } else { + viewWindow.Model.FormType = formType; + } + //throw new NotImplementedException(); + //this.CreateSVNOpen("Fehler im Cronjob, mehr als 10 Aufrufe!", ""); + //this.CreateFileList("Hinzufügen", "Diese Daten sind unversioniert:", s.getNoVersionFiles(), new EventHandler(addButton_Click)); + //this.CreateSVNOpen("Es ist ein Unvorhersebarer Fehler aufgetreten", p); + //this.CreateFileList("Löschen", "Diese Daten sind gelöscht worden:", s.getWasDeletedFiles(), new EventHandler(deleteButton_Click)); + } + + 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 c4d669a..b93f304 100644 --- a/svnsync/Form1.cs +++ b/svnsync/Form1.cs @@ -6,6 +6,8 @@ using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; +using BlubbFish.Utils; +using svnsync.Libraries; namespace svnsync { @@ -31,7 +33,14 @@ namespace svnsync l.Add("/Blubb/Bla/Foo"); l.Add("/Blubb/Bla/Blubb"); this.CreateFileList("Löschen", "Diese Daten sind gelöscht worden:", l, new EventHandler(deleteButton_Click)); - */this.c = new CmdArgs(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)); + this.c = CmdArgs.getInstance(); + this.c.setArguments(pargs, args); this.StartSvn(); if (this.s != null) { @@ -485,7 +494,8 @@ namespace svnsync this.ShowToolTip("Svn Sync Fehler", "Kein Argument für \"-d\" angegeben", ToolTipIcon.Error); return; } - this.s = new Svn(this.c.GetArgumentData("-d")); + this.s = Svn.getInstance(); + 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 new file mode 100644 index 0000000..c600722 --- /dev/null +++ b/svnsync/Helpers/Handles.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace svnsync.Helpers { + class Handles { + public enum SvnType { + NotInit, + ToMutchChronRuns, + HasVersionitedFiles, + UnexpectedError, + ExternDeletedFiles, + LockedFile, + } + public enum FormType { + MuchCronJobs, + UnversionFiles, + Error, + DeletedFiles, + Normal, + ManualResolve, + } + } + [Serializable()] + public class SvnLockedException : System.Exception { + public SvnLockedException() : base() { } + 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) { } + } +} diff --git a/svnsync/Helpers/StringHelper.cs b/svnsync/Helpers/StringHelper.cs new file mode 100644 index 0000000..fdcb98a --- /dev/null +++ b/svnsync/Helpers/StringHelper.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace svnsync.Helpers +{ + class StringHelper + { + 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; + } + } +} diff --git a/svnsync/Svn.cs b/svnsync/Libraries/Svn.cs similarity index 78% rename from svnsync/Svn.cs rename to svnsync/Libraries/Svn.cs index 6683440..c2f3a0e 100644 --- a/svnsync/Svn.cs +++ b/svnsync/Libraries/Svn.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Diagnostics; -namespace svnsync +namespace svnsync.Libraries { class Svn { @@ -17,8 +17,12 @@ namespace svnsync private string SvnError = ""; private string SvnOutput = ""; private List isdeleted; + private List external; + private static Svn instances; - public Svn(string dir) + private Svn() { } + + public void setDirectory(string dir) { this.dir = dir; this.Init(); @@ -41,6 +45,7 @@ namespace svnsync 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) @@ -51,7 +56,11 @@ namespace svnsync String file = line.Substring(8).Trim(new Char[] {'\r','\n',' ','\t'}); if (handles[0] == ' ') { - throw new NotImplementedException("SVN Line ' '"); + if(handles[2] == 'L') { + throw new svnsync.Helpers.SvnLockedException("Datei: " + file + " ist gelockt!"); + } else { + throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] ' '"); + } } else if (handles[0] == 'A') { @@ -67,19 +76,19 @@ namespace svnsync } else if (handles[0] == 'R') { - throw new NotImplementedException("SVN Line 'R'"); + throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'R'"); } else if (handles[0] == 'C') { - throw new NotImplementedException("SVN Line 'C'"); + throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'C'"); } else if (handles[0] == 'X') { - throw new NotImplementedException("SVN Line 'X'"); + external.Add(file); } else if (handles[0] == 'I') { - throw new NotImplementedException("SVN Line 'I'"); + throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'I'"); } else if (handles[0] == '?') { @@ -91,11 +100,11 @@ namespace svnsync } else if (handles[0] == '~') { - throw new NotImplementedException("SVN Line '~'"); + throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] '~'"); } else { - throw new NotImplementedException("Unexpected Symbol!"); + throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: Unexpected Symbol! [0]: \"" + handles[0] + "\""); } } } @@ -206,5 +215,14 @@ namespace svnsync { this.runner("up"); } + + public static Svn getInstance() + { + if (instances == null) + { + instances = new Svn(); + } + return instances; + } } } diff --git a/svnsync/Models/ModelsTray.cs b/svnsync/Models/ModelsTray.cs new file mode 100644 index 0000000..09076b8 --- /dev/null +++ b/svnsync/Models/ModelsTray.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using BlubbFish.Utils; +using svnsync.Libraries; + +namespace svnsync.Models +{ + class ModelsTray : OwnModel + { + 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; } + } + +} + + + diff --git a/svnsync/Models/ModelsWindow.cs b/svnsync/Models/ModelsWindow.cs new file mode 100644 index 0000000..b731b1b --- /dev/null +++ b/svnsync/Models/ModelsWindow.cs @@ -0,0 +1,33 @@ +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 { + public class ModelsWindow : OwnModel { + private InIReader networkfile; + private ModelsWindow() { + this.init(); + } + + protected override void init() { + + } + + private string MessageValue = ""; + public string Message { + get { return MessageValue; } + set { MessageValue = value; this.update(); } + } + + private Handles.FormType FormTypeValue; + internal Handles.FormType FormType { + get { return FormTypeValue; } + set { FormTypeValue = value; this.update(); } + } + } +} diff --git a/svnsync/Program.cs b/svnsync/Program.cs index 95854a3..27faaf5 100644 --- a/svnsync/Program.cs +++ b/svnsync/Program.cs @@ -2,6 +2,9 @@ using System.Collections.Generic; using System.Linq; using System.Windows.Forms; +using svnsync.Controllers; +using BlubbFish.Utils; +using svnsync.Libraries; namespace svnsync { @@ -13,6 +16,29 @@ namespace svnsync [STAThread] static void Main(string[] args) { + if (!cmd(args)) + { + return; + } + ControllersTray t = null; + try + { + Svn.getInstance().setDirectory(CmdArgs.getInstance().GetArgumentData("-d")); + t = new ControllersTray(); + 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); + + return; + } + Application.Run(); + return; + /*Application.Run();*/ Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try @@ -29,5 +55,21 @@ namespace svnsync Application.Exit(); } } + + 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; + } } } diff --git a/svnsync/Properties/Resources.Designer.cs b/svnsync/Properties/Resources.Designer.cs index 61230eb..b6d601e 100644 --- a/svnsync/Properties/Resources.Designer.cs +++ b/svnsync/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // Dieser Code wurde von einem Tool generiert. -// Laufzeitversion:4.0.30319.17929 +// Laufzeitversion:4.0.30319.34209 // // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn // der Code erneut generiert wird. @@ -60,6 +60,16 @@ namespace svnsync.Properties { } } + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap door_open { + get { + object obj = ResourceManager.GetObject("door_open", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol). /// diff --git a/svnsync/Properties/Resources.resx b/svnsync/Properties/Resources.resx index b8c408a..467e449 100644 --- a/svnsync/Properties/Resources.resx +++ b/svnsync/Properties/Resources.resx @@ -118,6 +118,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\door_open.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\file\Icon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/svnsync/Properties/Settings.Designer.cs b/svnsync/Properties/Settings.Designer.cs index cb8ebc5..22ace91 100644 --- a/svnsync/Properties/Settings.Designer.cs +++ b/svnsync/Properties/Settings.Designer.cs @@ -1,28 +1,24 @@ //------------------------------------------------------------------------------ // -// This code was generated by a tool. -// Runtime Version:4.0.30319.269 +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion:4.0.30319.18444 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. // //------------------------------------------------------------------------------ -namespace svnsync.Properties -{ - - +namespace svnsync.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } diff --git a/svnsync/Resources/door_open.png b/svnsync/Resources/door_open.png new file mode 100644 index 0000000..64bab57 Binary files /dev/null and b/svnsync/Resources/door_open.png differ diff --git a/svnsync/Views/ViewsTray.cs b/svnsync/Views/ViewsTray.cs new file mode 100644 index 0000000..db71b98 --- /dev/null +++ b/svnsync/Views/ViewsTray.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using BlubbFish.Utils; +using svnsync.Models; +using svnsync.Controllers; +using System.Windows.Forms; +using System.Drawing; +using svnsync.Properties; +using svnsync.Helpers; + +namespace svnsync.Views +{ + 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; + } + } +} diff --git a/svnsync/Views/ViewsWindow.cs b/svnsync/Views/ViewsWindow.cs new file mode 100644 index 0000000..bbb3ee7 --- /dev/null +++ b/svnsync/Views/ViewsWindow.cs @@ -0,0 +1,38 @@ +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 { + private ViewsWindowForm form; + public ViewsWindow() { + this.form = new ViewsWindowForm(); + this.init(); + this.Model.setObserver(this); + } + + public override void update() { + this.form.UpdateForm(); + } + + protected override void init() { + this.Model = ModelsWindow.Instance; + this.form.SetModel(this.Model); + this.form.Show(); + } + + public override void Dispose() { + this.form.BeginInvoke((Action)(() => { + this.form.Dispose(); + })); + } + + public ModelsWindow Model { get; private set; } + } +} diff --git a/svnsync/Views/ViewsWindowForm.Designer.cs b/svnsync/Views/ViewsWindowForm.Designer.cs new file mode 100644 index 0000000..06ec089 --- /dev/null +++ b/svnsync/Views/ViewsWindowForm.Designer.cs @@ -0,0 +1,72 @@ +namespace svnsync.Views +{ + partial class ViewsWindowForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.messageBox = new System.Windows.Forms.RichTextBox(); + 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(51, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Meldung:"; + // + // messageBox + // + this.messageBox.Location = new System.Drawing.Point(15, 26); + this.messageBox.Name = "messageBox"; + this.messageBox.ReadOnly = true; + this.messageBox.Size = new System.Drawing.Size(437, 96); + this.messageBox.TabIndex = 2; + this.messageBox.Text = ""; + // + // 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.messageBox); + this.Controls.Add(this.label1); + this.Name = "ViewsWindowForm"; + this.Text = "ViewsWindowsForm"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.RichTextBox messageBox; + } +} \ No newline at end of file diff --git a/svnsync/Views/ViewsWindowForm.cs b/svnsync/Views/ViewsWindowForm.cs new file mode 100644 index 0000000..3afe3b8 --- /dev/null +++ b/svnsync/Views/ViewsWindowForm.cs @@ -0,0 +1,31 @@ +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 svnsync.Models; +using svnsync.Controllers; + +namespace svnsync.Views { + public partial class ViewsWindowForm : Form { + private ModelsWindow model; + public ViewsWindowForm() { + InitializeComponent(); + this.FormClosed += ControllersWindow.FormClosed; + } + + public void UpdateForm() { + this.BeginInvoke((Action)(() => { + this.messageBox.Text = this.model.Message; + })); + } + + public void SetModel(ModelsWindow window) { + this.model = window; + } + } +} diff --git a/svnsync/Views/ViewsWindowForm.resx b/svnsync/Views/ViewsWindowForm.resx new file mode 100644 index 0000000..29dcb1b --- /dev/null +++ b/svnsync/Views/ViewsWindowForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/svnsync/bin/Release/SvnSync.exe b/svnsync/bin/Release/SvnSync.exe index 2957e8b..19e27b5 100644 Binary files a/svnsync/bin/Release/SvnSync.exe and b/svnsync/bin/Release/SvnSync.exe differ diff --git a/svnsync/svnsync.csproj b/svnsync/svnsync.csproj index 3715631..9b729bf 100644 --- a/svnsync/svnsync.csproj +++ b/svnsync/svnsync.csproj @@ -10,9 +10,25 @@ Properties svnsync SvnSync - v4.0 - Client + v4.5 + + 512 + veröffentlichen\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true x86 @@ -23,6 +39,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU @@ -32,6 +49,7 @@ TRACE prompt 4 + false file\Icon.ico @@ -50,16 +68,29 @@ - + + Form Form1.cs + + + + - + + + + + Form + + + ViewsWindowForm.cs + Form1.cs @@ -73,6 +104,9 @@ Resources.resx True + + ViewsWindowForm.cs + SettingsSingleFileGenerator Settings.Designer.cs @@ -92,6 +126,37 @@ + + + {fac8ce64-bf13-4ece-8097-aeb5dd060098} + Utils + + + + + + + + False + Microsoft .NET Framework 4 Client Profile %28x86 und x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + False + Windows Installer 4.5 + true + +