public MainWindow() { InitializeComponent(); (this.Content as FrameworkElement).DataContext = this; this.MaxWidth = 10000; this.MaxHeight = 10000; this.Loaded += window1Loaded; CollectorArgs options = CollectorArgs.ParseArgs(Environment.GetCommandLineArgs()); try { //SetWindowPositionAndDimensions(options); string[] files = options.DataFile.Split(','); string[] senderIds = options.SenderId.Split(','); int taskId = int.Parse(senderIds[0]); taskFile = new FileInfo(files[0]); int projectId = int.Parse(senderIds[1]); projectFile = new FileInfo(files[1]); this.Title = string.Format("[{0},{1}] - {2}", taskId, projectId, this.Title); taskNetList = new TodoNetList(); taskNetList.LogEvent += taskNetList_LogEvent; taskNetList.CurrentItemChangedEvent += taskNetList_CurrentItemChangedEvent; projectNetList = new ProjectNetList(); projectNetList.LogEvent += projectNetList_LogEvent; projectNetList.CurrentItemChangedEvent += projectNetList_CurrentItemChangedEvent; taskNetList.Start <Todo>(options.ConnectionString, taskId, options.LogFile, taskFile); projectNetList.Start <Project>(options.ConnectionString, projectId, options.LogFile, projectFile); System.Timers.Timer autoSaveTimer = new System.Timers.Timer(); autoSaveTimer.Elapsed += autoSaveTimer_Elapsed; autoSaveTimer.Interval = 5000; autoSaveTimer.Enabled = true; System.Timers.Timer halfHourSaveTimer = new System.Timers.Timer(); halfHourSaveTimer.Elapsed += halfHourSaveTimer_Elapsed; halfHourSaveTimer.Interval = 1800000; halfHourSaveTimer.Enabled = true; if (options.Left > 0 || options.Top > 0) { this.Left = options.Left; this.Top = options.Top; } if (options.Width > 0 || options.Height > 0) { this.Width = options.Width; this.Height = options.Height; } } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(string.Format("Start Exception: {0}", ex.Message)); Console.ForegroundColor = ConsoleColor.Green; } }
public static CollectorArgs ParseArgs(string[] args) { CollectorArgs options = new CollectorArgs(); if (!CommandLine.Parser.Default.ParseArguments(args, options)) { Console.WriteLine("Wrong params. Press any key to close."); foreach (string arg in args) { Console.WriteLine(arg); } Console.ReadKey(); Environment.Exit(100); } // Show results Console.ForegroundColor = ConsoleColor.DarkMagenta; Console.WriteLine(string.Format("Connection string: '{0}'", options.ConnectionString)); Console.WriteLine("Filters:"); Console.WriteLine(string.Format("LogFile: '{0}'", options.LogFile)); Console.WriteLine(string.Format("[Position] Top: '{0}' Left: '{1}'", options.Top, options.Left)); Console.WriteLine(string.Format("[Dimensions] Width: '{0}' Height:'{1}'", options.Width, options.Height)); Console.ResetColor(); return(options); }