/// <summary> /// Initializes a new instance of the <see cref="NotifyIconController" /> class. /// </summary> /// <param name="application">The application.</param> public NotifyIconController(GacApplication application) { _application = application; _notifyIcon = new NotifyIcon(); var contextMenu = new ContextMenuStrip(); contextMenu.Items.AddRange( new ToolStripItem[] { new ToolStripMenuItem(Resources.NotifyIconController_NotifyIconController_About, null, (s, e) => ShowAbout()), new ToolStripSeparator(), new ToolStripMenuItem(Resources.NotifyIconController_NotifyIconController_Configuration, null, (s, e) => ShowMainForm()), new ToolStripMenuItem(Resources.NotifyIconController_NotifyIconController_Exit, null, (s, e) => Close()) } ); _notifyIcon.ContextMenuStrip = contextMenu; _notifyIcon.Icon = Resources.icon_16; _notifyIcon.Text = Resources.AppName; _notifyIcon.DoubleClick += delegate { ShowMainForm(); }; if (!application.IsCommandLineDriven && application.Tasks.Count == 0) { ShowMainForm(); } }
/// <summary> /// Initializes a new instance of the <see cref="MainForm" /> class. /// </summary> /// <param name="application">The application.</param> /// <exception cref="Exception">A delegate callback throws an exception.</exception> public MainForm(GacApplication application) { _application = application; InitializeComponent(); LoadLanguage(); tasksLabel.Font = FontHelper.SubHeadingGuiFont; list.Bind(application.Tasks); list.ItemAdd += ListOnItemChange; list.ItemEdit += ListOnItemChange; list.ListChanged += ListOnChange; versionLabel.Text = Version; versionLabel.Left = pictureBox1.Left - 1 - versionLabel.Width; }
private static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); #if DEBUG _dw = new DebugWindow(); _dw.Show(); #endif GacApplication application; if (args.Length == 0) { application = new GacApplication(true); } else { int interval; string error = null; if (args.Length < 2 || !int.TryParse(args[0], out interval) || !AllDirectoriesExist(args.Skip(1), out error)) { if (string.IsNullOrEmpty(error)) error = Resources.Program_Main_Invalid_command_line_arguments; error = error + "\r\n\r\n" + Resources.Program_Main_usage; MessageBox.Show(error, Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(1); return; } var tasks = args.Skip(1).Select(x => new AutoCommitTask(interval, x)); application = new GacApplication(true, tasks); } var icon = new NotifyIconController(application); icon.Show(); Application.Run(); }