Refactor is that shit

This commit is contained in:
BlubbFish 2017-04-11 17:56:55 +00:00
parent 01311c6adc
commit 19bd2da502
16 changed files with 645 additions and 576 deletions

View File

@ -1,160 +1,163 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BlubbFish.Utils; using BlubbFish.Utils;
using svnsync.Views; using svnsync.Views;
using svnsync.Helpers; using svnsync.Helpers;
namespace svnsync.Controllers 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;
/// <summary>
/// Controlls a Tray.
/// </summary>
public ControllersTray() { }
protected override void Init()
{ {
private static ViewsTray viewTray; viewTray = new ViewsTray();
private static ControllersWindow controllerWindow; controllerWindow = new ControllersWindow();
//private string args; controllerWindow.SetAction(Handles.FormType.Normal);
public delegate void _enableLoopRun(); if (viewTray.Model.Args.HasArgumentType("-cron")) {
public event _enableLoopRun StartLoop; if (this.CronJob(0, false)) {
viewTray.ShowSuccess();
/// <summary> System.Threading.Thread.Sleep(5000);
/// Controlls a Tray.
/// </summary>
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;
}
/// <summary>
/// If you Click on the Tray Icon
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public static void Click_Tray(object sender, EventArgs e)
{
controllerWindow.execute();
}
/// <summary>
/// If you Click on the Tray Ballon
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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(); 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;
}
/// <summary>
/// If you Click on the Tray Icon
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public static void Click_Tray(Object sender, EventArgs e)
{
controllerWindow.Execute();
}
/// <summary>
/// If you Click on the Tray Ballon
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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();
}
}
} }

View File

@ -1,41 +1,44 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using BlubbFish.Utils; using BlubbFish.Utils;
using svnsync.Views; using svnsync.Views;
using svnsync.Helpers; using svnsync.Helpers;
namespace svnsync.Controllers { namespace svnsync.Controllers
public class ControllersWindow : OwnController { {
public class ControllersWindow : OwnController
{
private static ViewsWindow viewWindow; private static ViewsWindow viewWindow;
private Handles.FormType initAction; private Handles.FormType initAction;
private string initMessage; private String initMessage;
/// <summary> /// <summary>
/// Tray Controller /// Tray Controller
/// </summary> /// </summary>
public ControllersWindow() { } public ControllersWindow() { }
override protected void init() { override protected void Init()
{
viewWindow = new ViewsWindow(); viewWindow = new ViewsWindow();
viewWindow.Model.Message = initMessage; viewWindow.Model.Message = this.initMessage;
viewWindow.Model.FormType = initAction; viewWindow.Model.FormType = this.initAction;
} }
public override void Dispose() { public override void Dispose()
if(viewWindow != null) {
if (viewWindow != null) {
viewWindow.Dispose(); viewWindow.Dispose();
}
} }
public static void FormClosed(object sender, FormClosedEventArgs e) { public static void FormClosed(Object sender, FormClosedEventArgs e)
{
viewWindow.Dispose(); viewWindow.Dispose();
} }
internal void setAction(Handles.FormType formType) { internal void SetAction(Handles.FormType formType)
if(viewWindow == null) { {
if (viewWindow == null) {
this.initAction = formType; this.initAction = formType;
} else { } else {
viewWindow.Model.FormType = formType; 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)); //this.CreateFileList("Löschen", "Diese Daten sind gelöscht worden:", s.getWasDeletedFiles(), new EventHandler(deleteButton_Click));
} }
internal void setMessage(string p) { internal void SetMessage(String p)
if(viewWindow == null) { {
if (viewWindow == null) {
this.initMessage = p; this.initMessage = p;
} else { } else {
viewWindow.Model.Message = p; viewWindow.Model.Message = p;

View File

@ -39,8 +39,8 @@ namespace svnsync
pargs.Add("-cron", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single)); pargs.Add("-cron", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single));
pargs.Add("-autoadd", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single)); pargs.Add("-autoadd", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single));
pargs.Add("-autodelete", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single)); pargs.Add("-autodelete", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single));
this.c = CmdArgs.getInstance(); this.c = CmdArgs.Instance;
this.c.setArguments(pargs, args); this.c.SetArguments(pargs, args);
this.StartSvn(); this.StartSvn();
if (this.s != null) if (this.s != null)
{ {
@ -68,8 +68,8 @@ namespace svnsync
return this.HandleSvn(HandleSvnType.NotInit, ""); return this.HandleSvn(HandleSvnType.NotInit, "");
if (run > 10) if (run > 10)
return this.HandleSvn(HandleSvnType.ToMutchChronRuns, ""); return this.HandleSvn(HandleSvnType.ToMutchChronRuns, "");
if (s.IsError()) if (s.IsError)
return this.HandleSvn(HandleSvnType.UnexpectedError, s.getError()); return this.HandleSvn(HandleSvnType.UnexpectedError, s.Error);
try try
{ {
s.CheckStatus(); s.CheckStatus();
@ -78,26 +78,26 @@ namespace svnsync
{ {
return this.HandleSvn(HandleSvnType.UnexpectedError, e.Message); return this.HandleSvn(HandleSvnType.UnexpectedError, e.Message);
} }
if (s.IsNotOnlyModified()) if (s.IsNotOnlyModified)
{ {
if (s.IsUncheckedFiles()) if (s.IsUncheckedFiles)
{ {
if (c.HasArgumentType("-autoadd")) if (c.HasArgumentType("-autoadd"))
s.AddFiles(s.getNoVersionFiles()); s.AddFiles(s.NoVersionFiles);
else else
return this.HandleSvn(HandleSvnType.HasVersionitedFiles, ""); return this.HandleSvn(HandleSvnType.HasVersionitedFiles, "");
} }
if (s.IsError()) if (s.IsError)
return this.HandleSvn(HandleSvnType.UnexpectedError, s.getError()); return this.HandleSvn(HandleSvnType.UnexpectedError, s.Error);
if (s.IsExternDeletedFiles()) if (s.IsExternDeletedFiles)
{ {
if (c.HasArgumentType("-autodelete")) if (c.HasArgumentType("-autodelete"))
s.DeleteFiles(s.getWasDeletedFiles()); s.DeleteFiles(s.WasDeletedFiles);
else else
return this.HandleSvn(HandleSvnType.ExternDeletedFiles, ""); return this.HandleSvn(HandleSvnType.ExternDeletedFiles, "");
} }
if (s.IsError()) if (s.IsError)
return this.HandleSvn(HandleSvnType.UnexpectedError, s.getError()); return this.HandleSvn(HandleSvnType.UnexpectedError, s.Error);
return this.cronJob(run + 1, true); return this.cronJob(run + 1, true);
} }
else else
@ -105,14 +105,14 @@ namespace svnsync
if (readyToCommit) if (readyToCommit)
{ {
s.SetArgCheckIn(this.GetTimeStamp(DateTime.Now)); s.SetArgCheckIn(this.GetTimeStamp(DateTime.Now));
if (s.IsError()) if (s.IsError)
return this.HandleSvn(HandleSvnType.UnexpectedError, s.getError()); return this.HandleSvn(HandleSvnType.UnexpectedError, s.Error);
} }
else else
{ {
s.Update(); s.Update();
if (s.IsError()) if (s.IsError)
return this.HandleSvn(HandleSvnType.UnexpectedError, s.getError()); return this.HandleSvn(HandleSvnType.UnexpectedError, s.Error);
return this.cronJob(run + 1, true); return this.cronJob(run + 1, true);
} }
} }
@ -132,7 +132,7 @@ namespace svnsync
return false; return false;
case HandleSvnType.HasVersionitedFiles: case HandleSvnType.HasVersionitedFiles:
this.ShowToolTip("Svn Sync", "Es sind unversionierte Dateien vorhanden (?)", ToolTipIcon.Info); 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; return false;
case HandleSvnType.UnexpectedError: case HandleSvnType.UnexpectedError:
this.ShowToolTip("Svn Sync Fehler", "Es ist ein Unvorhersebarer Fehler aufgetreten: " + p, ToolTipIcon.Error); this.ShowToolTip("Svn Sync Fehler", "Es ist ein Unvorhersebarer Fehler aufgetreten: " + p, ToolTipIcon.Error);
@ -140,7 +140,7 @@ namespace svnsync
return false; return false;
case HandleSvnType.ExternDeletedFiles: case HandleSvnType.ExternDeletedFiles:
this.ShowToolTip("Svn Sync", "Es sind extern gelöschte Dateien vorhanden (!)", ToolTipIcon.Info); 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;
} }
return false; return false;
@ -424,9 +424,9 @@ namespace svnsync
this.ShowInTaskbar = false; this.ShowInTaskbar = false;
this.WindowState = FormWindowState.Minimized; this.WindowState = FormWindowState.Minimized;
s.DeleteFiles(l); s.DeleteFiles(l);
if (s.IsError()) if (s.IsError)
{ {
this.HandleSvn(HandleSvnType.UnexpectedError, s.getError()); this.HandleSvn(HandleSvnType.UnexpectedError, s.Error);
return; return;
} }
this.runagainButton_Click(sender, null); this.runagainButton_Click(sender, null);
@ -462,9 +462,9 @@ namespace svnsync
this.ShowInTaskbar = false; this.ShowInTaskbar = false;
this.WindowState = FormWindowState.Minimized; this.WindowState = FormWindowState.Minimized;
s.AddFiles(l); s.AddFiles(l);
if (s.IsError()) if (s.IsError)
{ {
this.HandleSvn(HandleSvnType.UnexpectedError, s.getError()); this.HandleSvn(HandleSvnType.UnexpectedError, s.Error);
return; return;
} }
this.runagainButton_Click(sender, null); this.runagainButton_Click(sender, null);
@ -494,8 +494,8 @@ namespace svnsync
this.ShowToolTip("Svn Sync Fehler", "Kein Argument für \"-d\" angegeben", ToolTipIcon.Error); this.ShowToolTip("Svn Sync Fehler", "Kein Argument für \"-d\" angegeben", ToolTipIcon.Error);
return; return;
} }
this.s = Svn.getInstance(); this.s = Svn.Instance;
this.s.setDirectory(this.c.GetArgumentData("-d")); this.s.SetDirectory(this.c.GetArgumentData("-d"));
} }
private void EventHandler_Resize(object sender, System.EventArgs e) private void EventHandler_Resize(object sender, System.EventArgs e)

View File

@ -1,12 +1,11 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace svnsync.Helpers { namespace svnsync.Helpers
class Handles { {
public enum SvnType { class Handles
{
public enum SvnType
{
NotInit, NotInit,
ToMutchChronRuns, ToMutchChronRuns,
HasVersionitedFiles, HasVersionitedFiles,
@ -14,7 +13,8 @@ namespace svnsync.Helpers {
ExternDeletedFiles, ExternDeletedFiles,
LockedFile, LockedFile,
} }
public enum FormType { public enum FormType
{
MuchCronJobs, MuchCronJobs,
UnversionFiles, UnversionFiles,
Error, Error,
@ -24,11 +24,13 @@ namespace svnsync.Helpers {
} }
} }
[Serializable()] [Serializable()]
public class SvnLockedException : System.Exception { public class SvnLockedException : System.Exception
{
public SvnLockedException() : base() { } public SvnLockedException() : base() { }
public SvnLockedException(string message) : base(message) { } public SvnLockedException(String message) : base(message) { }
public SvnLockedException(string message, System.Exception inner) : base(message, inner) { } public SvnLockedException(String message, System.Exception inner) : base(message, inner) { }
protected SvnLockedException(System.Runtime.Serialization.SerializationInfo info, protected SvnLockedException(System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) { } System.Runtime.Serialization.StreamingContext context)
{ }
} }
} }

View File

@ -1,24 +1,20 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace svnsync.Helpers 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');
String ret = ""; ret += dateTime.Month.ToString().PadLeft(2, '0');
ret += dateTime.Year.ToString().PadLeft(4, '0'); ret += dateTime.Day.ToString().PadLeft(2, '0');
ret += dateTime.Month.ToString().PadLeft(2, '0'); ret += "-";
ret += dateTime.Day.ToString().PadLeft(2, '0'); ret += dateTime.Hour.ToString().PadLeft(2, '0');
ret += "-"; ret += dateTime.Minute.ToString().PadLeft(2, '0');
ret += dateTime.Hour.ToString().PadLeft(2, '0'); ret += dateTime.Second.ToString().PadLeft(2, '0');
ret += dateTime.Minute.ToString().PadLeft(2, '0'); return ret;
ret += dateTime.Second.ToString().PadLeft(2, '0');
return ret;
}
} }
}
} }

View File

@ -1,84 +1,84 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics; using System.Diagnostics;
namespace svnsync.Libraries { namespace svnsync.Libraries {
class Svn { class Svn {
private string dir; private String dir;
private Process p = new Process(); private Process p = new Process();
private List<String> modified; private List<String> modified;
private List<String> noversion; private List<String> noversion;
private List<String> wasdeleted; private List<String> wasdeleted;
private List<String> added; private List<String> added;
private string SvnError = ""; private String SvnError = "";
private string SvnOutput = ""; private String SvnOutput = "";
private List<string> isdeleted; private List<String> isdeleted;
private List<string> external; private List<String> external;
private static Svn instances; private static Svn instances;
private Svn() { } private Svn() { }
public void setDirectory(string dir) { public void SetDirectory(String dir) {
this.dir = dir; this.dir = dir;
this.Init(); this.Init();
} }
private void Init() { private void Init() {
p.StartInfo.FileName = "svn"; this.p.StartInfo.FileName = "svn";
p.StartInfo.WorkingDirectory = this.dir; this.p.StartInfo.WorkingDirectory = this.dir;
p.StartInfo.CreateNoWindow = true; this.p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true; this.p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true; this.p.StartInfo.RedirectStandardError = true;
p.StartInfo.UseShellExecute = false; this.p.StartInfo.UseShellExecute = false;
} }
internal void CheckStatus() { internal void CheckStatus() {
modified = new List<string>(); this.modified = new List<String>();
noversion = new List<string>(); this.noversion = new List<String>();
wasdeleted = new List<string>(); this.wasdeleted = new List<String>();
isdeleted = new List<string>(); this.isdeleted = new List<String>();
added = new List<string>(); this.added = new List<String>();
external = new List<string>(); this.external = new List<String>();
this.runner("st"); this.Runner("st");
string[] lines = this.SvnOutput.Split('\n'); String[] lines = this.SvnOutput.Split('\n');
foreach(String line in lines) { foreach (String line in lines) {
if(line.Length < 7) if (line.Length < 7) {
break; break;
}
Char[] handles = line.Substring(0, 7).ToCharArray(); Char[] handles = line.Substring(0, 7).ToCharArray();
String file = line.Substring(8).Trim(new Char[] { '\r', '\n', ' ', '\t' }); String file = line.Substring(8).Trim(new Char[] { '\r', '\n', ' ', '\t' });
if(handles[0] == ' ') { if (handles[0] == ' ') {
if(handles[2] == 'L') { if (handles[2] == 'L') {
throw new svnsync.Helpers.SvnLockedException("Datei: " + file + " ist gelockt!"); throw new Helpers.SvnLockedException("Datei: " + file + " ist gelockt!");
} }
//Modifizierte Eigenschaft //Modifizierte Eigenschaft
else if(handles[1] == 'M') { else if (handles[1] == 'M') {
modified.Add(file); this.modified.Add(file);
} else { } else {
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] ' '"); throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] ' '");
} }
} else if(handles[0] == 'A') { } else if (handles[0] == 'A') {
added.Add(file); this.added.Add(file);
} else if(handles[0] == 'D') { } else if (handles[0] == 'D') {
isdeleted.Add(file); this.isdeleted.Add(file);
} }
// Modifizierte Datei // Modifizierte Datei
else if(handles[0] == 'M') { else if (handles[0] == 'M') {
modified.Add(file); this.modified.Add(file);
} else if(handles[0] == 'R') { } else if (handles[0] == 'R') {
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[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'"); throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'C'");
} else if(handles[0] == 'X') { } else if (handles[0] == 'X') {
external.Add(file); this.external.Add(file);
} else if(handles[0] == 'I') { } else if (handles[0] == 'I') {
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'I'"); throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'I'");
} else if(handles[0] == '?') { } else if (handles[0] == '?') {
noversion.Add(file); this.noversion.Add(file);
} else if(handles[0] == '!') { } else if (handles[0] == '!') {
wasdeleted.Add(file); this.wasdeleted.Add(file);
} else if(handles[0] == '~') { } else if (handles[0] == '~') {
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] '~'"); throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] '~'");
} else { } else {
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: Unexpected Symbol! [0]: \"" + handles[0] + "\""); throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: Unexpected Symbol! [0]: \"" + handles[0] + "\"");
@ -86,100 +86,155 @@ namespace svnsync.Libraries {
} }
} }
internal bool IsNotOnlyModified() { internal void SetArgCheckIn(String message) {
if(this.noversion.Count != 0)
return true;
if(this.wasdeleted.Count != 0)
return true;
return false;
}
internal void SetArgCheckIn(string message) {
String arg = "ci -m \"" + message + "\""; String arg = "ci -m \"" + message + "\"";
this.runner(arg); this.Runner(arg);
} }
internal void AddFiles(List<String> files) { private void Runner(String arg) {
String arg = "add";
foreach(String item in files) {
arg += " \"" + item + "\"";
}
this.runner(arg);
}
private void runner(string arg) {
this.SvnOutput = ""; this.SvnOutput = "";
this.SvnError = ""; this.SvnError = "";
p.StartInfo.Arguments = arg; this.p.StartInfo.Arguments = arg;
p.Start(); this.p.Start();
this.SvnOutput = p.StandardOutput.ReadToEnd(); Int64 e_lenth = 0;
this.SvnError = p.StandardError.ReadToEnd(); while (!this.p.HasExited) {
p.WaitForExit(); 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() { private void P_ErrorDataReceived(Object sender, DataReceivedEventArgs e) {
if(this.noversion.Count != 0) if(e.Data != null) {
return true; this.SvnError += e.Data + "\n";
return false; }
} }
internal bool IsExternDeletedFiles() { private void P_OutputDataReceived(Object sender, DataReceivedEventArgs e) {
if(this.wasdeleted.Count != 0) this.SvnOutput += e.Data + "\n";
return true;
return false;
}
internal bool IsError() {
if(this.SvnError != "")
return true;
return false;
}
internal string getError() {
return this.SvnError;
} }
internal void DeleteFiles(List<String> files) { internal void DeleteFiles(List<String> files) {
String arg = "del"; String arg = "del";
foreach(String item in files) { foreach (String item in files) {
arg += " \"" + item + "\""; arg += " \"" + item + "\"";
} }
this.runner(arg); this.Runner(arg);
}
internal List<String> getWasDeletedFiles() {
return this.wasdeleted;
}
internal List<String> getNoVersionFiles() {
return this.noversion;
} }
internal void DeleteFiles(List<System.Windows.Forms.TreeNode> l) { internal void DeleteFiles(List<System.Windows.Forms.TreeNode> l) {
List<String> s = new List<string>(); List<String> s = new List<String>();
foreach(System.Windows.Forms.TreeNode item in l) { foreach (System.Windows.Forms.TreeNode item in l) {
s.Add(item.FullPath); s.Add(item.FullPath);
} }
this.DeleteFiles(s); this.DeleteFiles(s);
} }
internal void AddFiles(List<String> files) {
String arg = "add";
foreach (String item in files) {
arg += " \"" + item + "\"";
}
this.Runner(arg);
}
internal void AddFiles(List<System.Windows.Forms.TreeNode> l) { internal void AddFiles(List<System.Windows.Forms.TreeNode> l) {
List<String> s = new List<string>(); List<String> s = new List<String>();
foreach(System.Windows.Forms.TreeNode item in l) { foreach (System.Windows.Forms.TreeNode item in l) {
s.Add(item.FullPath); s.Add(item.FullPath);
} }
this.AddFiles(s); this.AddFiles(s);
} }
internal void Update() { internal void Update() {
this.runner("up"); this.Runner("up");
} }
public static Svn getInstance() { public static Svn Instance {
if(instances == null) { get {
instances = new Svn(); 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<String> WasDeletedFiles {
get {
return this.wasdeleted;
}
}
internal List<String> 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;
} }
} }
} }

View File

@ -1,36 +1,32 @@
using System; using BlubbFish.Utils;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BlubbFish.Utils;
using svnsync.Libraries; using svnsync.Libraries;
namespace svnsync.Models namespace svnsync.Models
{ {
class ModelsTray : OwnModel<ModelsTray> class ModelsTray : OwnModel<ModelsTray>
{
private ModelsTray()
{ {
private ModelsTray() this.Init();
{
this.init();
}
protected override void init()
{
this.Args = CmdArgs.getInstance();
this.Svn = Svn.getInstance();
}
/// <summary>
/// Saves the Argument of the Program
/// </summary>
public CmdArgs Args { get; private set; }
/// <summary>
/// Save a SVN
/// </summary>
public Svn Svn { get; private set; }
} }
protected override void Init()
{
this.Args = CmdArgs.Instance;
this.Svn = Svn.Instance;
}
/// <summary>
/// Saves the Argument of the Program
/// </summary>
public CmdArgs Args { get; private set; }
/// <summary>
/// Save a SVN
/// </summary>
public Svn Svn { get; private set; }
}
} }

View File

@ -1,33 +1,29 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BlubbFish.Utils; using BlubbFish.Utils;
using svnsync.Helpers; using svnsync.Helpers;
namespace svnsync.Models { namespace svnsync.Models
{
public class ModelsWindow : OwnModel<ModelsWindow> { public class ModelsWindow : OwnModel<ModelsWindow> {
private InIReader networkfile; //private InIReader networkfile;
private ModelsWindow() { private ModelsWindow() {
this.init(); this.Init();
} }
protected override void init() { protected override void Init() {
} }
private string MessageValue = ""; private String MessageValue = "";
public string Message { public String Message {
get { return MessageValue; } get { return this.MessageValue; }
set { MessageValue = value; this.update(); } set { this.MessageValue = value; this.Update(); }
} }
private Handles.FormType FormTypeValue; private Handles.FormType FormTypeValue;
internal Handles.FormType FormType { internal Handles.FormType FormType {
get { return FormTypeValue; } get { return this.FormTypeValue; }
set { FormTypeValue = value; this.update(); } set { this.FormTypeValue = value; this.Update(); }
} }
} }
} }

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using svnsync.Controllers; using svnsync.Controllers;
using BlubbFish.Utils; using BlubbFish.Utils;
@ -8,76 +7,82 @@ using svnsync.Libraries;
namespace svnsync namespace svnsync
{ {
static class Program static class Program
{
private static Boolean LoopStarted = false;
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main(String[] args)
{ {
private static bool LoopStarted = false; if (!Cmd(args)) {
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[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();
return; 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();
}*/
} }
FileMutex.Instance.SetName(CmdArgs.Instance.GetArgumentData("-d"));
static void t_StartLoop() { #if !DEBUG
if(!LoopStarted) { if (!FileMutex.Instance.Create()) {
LoopStarted = true; return;
Application.Run();
}
} }
#endif
private static bool cmd(string[] args) ControllersTray t = null;
{ try {
Dictionary<string, CmdArgs.VaildArguments> pargs = new Dictionary<string, CmdArgs.VaildArguments>(); Svn.Instance.SetDirectory(CmdArgs.Instance.GetArgumentData("-d"));
pargs.Add("-d", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Touple, true)); t = new ControllersTray();
pargs.Add("-cron", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single)); t.StartLoop += T_StartLoop;
pargs.Add("-autoadd", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single)); t.Execute();
pargs.Add("-autodelete", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single)); } catch (Exception e) {
CmdArgs.getInstance().setArguments(pargs, args); t.HideToolTip();
if (!CmdArgs.getInstance().HasAllRequiredArguments()) String text = e.Message + "\n\n" + e.StackTrace;
{ String title = "Exception in SVNSync: " + CmdArgs.Instance.GetArgumentData("-d");
System.Windows.Forms.MessageBox.Show(CmdArgs.getInstance().getUsageList("syncsvn.exe:"), "Fehlende Argumente auf der Komandozeile", MessageBoxButtons.OK, MessageBoxIcon.Stop); MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
return false; FileMutex.Instance.Delete();
} return;
return true; }
} 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<String, CmdArgs.VaildArguments> pargs = new Dictionary<String, CmdArgs.VaildArguments> {
{ "-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;
}
}
} }

View File

@ -11,7 +11,7 @@ using System.Resources;
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("BlubbFish")] [assembly: AssemblyCompany("BlubbFish")]
[assembly: AssemblyProduct("SvnSync")] [assembly: AssemblyProduct("SvnSync")]
[assembly: AssemblyCopyright("Copyright © 2012 - 03.03.2017")] [assembly: AssemblyCopyright("Copyright © 2012 - 10.03.2017")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@ -33,6 +33,6 @@ using System.Resources;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben: // übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.3.0")] [assembly: AssemblyVersion("1.0.3.1")]
[assembly: AssemblyFileVersion("1.0.3.0")] [assembly: AssemblyFileVersion("1.0.3.1")]
[assembly: NeutralResourcesLanguageAttribute("de-DE")] [assembly: NeutralResourcesLanguageAttribute("de-DE")]

View File

@ -1,126 +1,120 @@
using System; using BlubbFish.Utils;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BlubbFish.Utils;
using svnsync.Models; using svnsync.Models;
using svnsync.Controllers; using svnsync.Controllers;
using System.Windows.Forms; using System.Windows.Forms;
using System.Drawing; using System.Drawing;
using svnsync.Properties; using svnsync.Properties;
using svnsync.Helpers; using svnsync.Helpers;
using System;
namespace svnsync.Views namespace svnsync.Views
{ {
class ViewsTray : OwnView class ViewsTray : OwnView
{ {
/// <summary> /// <summary>
/// Model of the View /// Model of the View
/// </summary> /// </summary>
public ModelsTray Model { get; private set; } public ModelsTray Model { get; private set; }
private NotifyIcon trayicon; private NotifyIcon trayicon;
/// <summary> /// <summary>
/// View of a Tray /// View of a Tray
/// </summary> /// </summary>
public ViewsTray() public ViewsTray() {
{ this.Init();
this.init(); this.Model = ModelsTray.Instance;
this.Model = ModelsTray.Instance; this.Model.SetObserver(this);
this.Model.setObserver(this);
}
/// <summary>
/// Updates the Tray
/// </summary>
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;
}
/// <summary>
/// Delete the Tray
/// </summary>
public override void Dispose()
{
this.trayicon.Visible = false;
Application.ExitThread();
}
/// <summary>
/// Show a Success Message
/// </summary>
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);
}
/// <summary>
/// Show a Error Message.
/// </summary>
/// <param name="svnType"></param>
/// <param name="p"></param>
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;
}
} }
/// <summary>
/// Updates the Tray
/// </summary>
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;
}
/// <summary>
/// Delete the Tray
/// </summary>
public override void Dispose() {
this.trayicon.Visible = false;
Application.ExitThread();
}
/// <summary>
/// Show a Success Message
/// </summary>
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);
}
/// <summary>
/// Show a Error Message.
/// </summary>
/// <param name="svnType"></param>
/// <param name="message"></param>
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;
}
}
} }

View File

@ -1,33 +1,33 @@
using System; 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 BlubbFish.Utils;
using svnsync.Models; using svnsync.Models;
namespace svnsync.Views { namespace svnsync.Views
public class ViewsWindow : OwnView { {
public class ViewsWindow : OwnView
{
private ViewsWindowForm form; private ViewsWindowForm form;
public ViewsWindow() { public ViewsWindow()
{
this.form = new ViewsWindowForm(); this.form = new ViewsWindowForm();
this.init(); this.Init();
this.Model.setObserver(this); this.Model.SetObserver(this);
} }
public override void update() { public override void Update()
{
this.form.UpdateForm(); this.form.UpdateForm();
} }
protected override void init() { protected override void Init()
{
this.Model = ModelsWindow.Instance; this.Model = ModelsWindow.Instance;
this.form.SetModel(this.Model); this.form.SetModel(this.Model);
this.form.Show(); this.form.Show();
} }
public override void Dispose() { public override void Dispose()
{
this.form.BeginInvoke((Action)(() => { this.form.BeginInvoke((Action)(() => {
this.form.Dispose(); this.form.Dispose();
})); }));

View File

@ -30,6 +30,7 @@
{ {
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.messageBox = new System.Windows.Forms.RichTextBox(); this.messageBox = new System.Windows.Forms.RichTextBox();
this.opencmd = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// label1 // label1
@ -50,11 +51,22 @@
this.messageBox.TabIndex = 2; this.messageBox.TabIndex = 2;
this.messageBox.Text = ""; 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 // ViewsWindowForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(464, 262); this.ClientSize = new System.Drawing.Size(464, 262);
this.Controls.Add(this.opencmd);
this.Controls.Add(this.messageBox); this.Controls.Add(this.messageBox);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Name = "ViewsWindowForm"; this.Name = "ViewsWindowForm";
@ -68,5 +80,6 @@
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.RichTextBox messageBox; private System.Windows.Forms.RichTextBox messageBox;
} private System.Windows.Forms.Button opencmd;
}
} }

View File

@ -10,21 +10,26 @@ using System.Windows.Forms;
using svnsync.Models; using svnsync.Models;
using svnsync.Controllers; using svnsync.Controllers;
namespace svnsync.Views { namespace svnsync.Views
public partial class ViewsWindowForm : Form { {
public partial class ViewsWindowForm : Form
{
private ModelsWindow model; private ModelsWindow model;
public ViewsWindowForm() { public ViewsWindowForm()
{
InitializeComponent(); InitializeComponent();
this.FormClosed += ControllersWindow.FormClosed; this.FormClosed += ControllersWindow.FormClosed;
} }
public void UpdateForm() { public void UpdateForm()
{
this.BeginInvoke((Action)(() => { this.BeginInvoke((Action)(() => {
this.messageBox.Text = this.model.Message; this.messageBox.Text = this.model.Message;
})); }));
} }
public void SetModel(ModelsWindow window) { public void SetModel(ModelsWindow window)
{
this.model = window; this.model = window;
} }
} }

View File

@ -31,7 +31,7 @@
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
@ -42,7 +42,7 @@
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<StartArguments>-d "E:\Eigene Dateien\Doc%27s\Basteleien" -cron -autoadd -autodelete</StartArguments> <StartArguments>-d "E:\\Eigene Dateien\\Dokumente\\Visual Studio 2017\\Projects" -cron -autoadd -autodelete -externals-own</StartArguments>
<RemoteDebugEnabled>false</RemoteDebugEnabled> <RemoteDebugEnabled>false</RemoteDebugEnabled>
<StartAction>Project</StartAction> <StartAction>Project</StartAction>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<StartArguments>-d "D:\\Doc%27s\\Studium\\" -cron -autoadd -autodelete</StartArguments> <StartArguments>-d "E:\\Eigene Dateien\\Dokumente\\Visual Studio 2017\\Projects" -cron -autoadd -autodelete -externals-own</StartArguments>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<PublishUrlHistory>veröffentlichen\</PublishUrlHistory> <PublishUrlHistory>veröffentlichen\</PublishUrlHistory>