示例#1
0
        public MainForm(GACApplication application)
        {
            _application = application;
            InitializeComponent();

            tasksLabel.Font = FontHelper.SubHeadingGuiFont;

            list.Bind(application.Tasks);
            list.ItemAdd += ListOnItemChange;
            list.ItemEdit += ListOnItemChange;
            list.ListChanged += ListOnChange;

            versionLabel.Text = Version;
        }
        public NotifyIconController(GACApplication application)
        {
            _application = application;
            _notifyIcon = new NotifyIcon();
            _contextMenu = new ContextMenuStrip();
            _contextMenu.Items.AddRange(
                new[]
                    {
                        new ToolStripMenuItem("&Configuration", null, (s, e) => ShowMainForm()),
                        new ToolStripMenuItem("E&xit", null, (s, e) => Close())
                    }
                );

            _notifyIcon.ContextMenuStrip = _contextMenu;
            _notifyIcon.Icon = Resources.icon_16;
            _notifyIcon.Text = "Git auto commit";

            _notifyIcon.DoubleClick += delegate { ShowMainForm(); };

            if (!application.IsCommandLineDriven && application.Tasks.Count == 0)
            {
                ShowMainForm();
            }
        }
示例#3
0
        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 = "Invalid command line arguments";

                    error = error + "\r\n\r\n" +
                            "usage: git-auto-commit <commit-interval-seconds> <directory 1>, <directory 2>, ..., <directory n>";

                    MessageBox.Show(error, "git-auto-commit", 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();
        }