public void TieEvents(PluginRepository plugins)
 {
     this.plugins = plugins;
     this.plugins.CherryEvents.Subscribe(new CherryEventListener(
         "Collect Menu Items",
         ea =>
         {
             var items = (ea as IconControllerEventArgs).MenuItems;
     #if DEBUG
             items.Add(new ToolStripSeparator());
             items.Add(new ToolStripMenuItem(
                     "[DEBUG] Fake evaluation window",
                     null,
                     (a, b) => this.RunFakeEvaluation()));
             items.Add(new ToolStripMenuItem(
                 "[DEBUG] Finish Pomodoro",
                 null,
                 (a, b) => this.plugins.CherryCommands["Stop Pomodoro"].Do(null)));
             items.Add(new ToolStripMenuItem(
                 "[DEBUG] Browse all events and commands",
                 null,
                 (a, b) => this.BrowseEventsAndCommands()));
     #endif
         }));
 }
        public SettingsForm(
            PluginRepository plugins,
            GuiConfigurablePluginInfo generalSettingsInfo,
            IEnumerable<GuiConfigurablePluginInfo> guiPluginInfos)
        {
            this.plugins = plugins;
            InitializeComponent();

            var generalSettingsPanel = generalSettingsInfo.PluginSettingsPanel;
            var generalSettingsNode = new TreeNode(generalSettingsInfo.PluginName) { Tag = generalSettingsPanel };
            settingsTreeView.Nodes.Add(generalSettingsNode);

            foreach (var plugin in guiPluginInfos)
            {
                var settingsNode = new TreeNode(plugin.PluginName) { Tag = plugin.PluginSettingsPanel };

                if(plugin.PluginIcon != null)
                {
                    treeviewImages.Images.Add(plugin.PluginIcon);
                    settingsNode.ImageIndex = treeviewImages.Images.Count - 1;
                    settingsNode.SelectedImageIndex = treeviewImages.Images.Count - 1;
                }

                generalSettingsNode.Nodes.Add(settingsNode);
            }

            settingsTreeView.SelectedNode = generalSettingsNode;
            generalSettingsNode.ExpandAll();
            panel.Controls.Add(generalSettingsPanel);

            CreateHandle();
        }
        public ReminderConfigurationForm(PluginRepository plugins, IReminder reminder, IReminderController guiController)
        {
            this.pluginsRepository = plugins;
            this.reminder = reminder;
            this.guiController = guiController;
            this.InitializeComponent();

            var reminderControl = this.guiController.GetSettingsPanel();
            reminderControl.Dock = DockStyle.Fill;
            this.pnlRemider.Controls.Add(reminderControl);

            var notificationsControl = plugins.CherryCommands["Get Notifications Configuration Control"].Do(null) as Control;
            notificationsControl.Dock = DockStyle.Fill;
            this.notificationsTabPage.Controls.Add(notificationsControl);

            var conditionssControl = plugins.CherryCommands["Get Conditions Configuration Control"].Do(null) as Control;
            conditionssControl.Dock = DockStyle.Fill;
            this.conditionsTabPage.Controls.Add(conditionssControl);

            this.nameTextBox.Text = this.reminder.Name;
            this.descriptionTextBox.Text = this.reminder.Description;
            this.guiController.LoadSettingsFromReminder(reminder);
            plugins.CherryCommands["Populate Notifications Configuration"].Do(
                new CompositeNotificationCommandArgs(this.reminder.CompositeNotification));
            plugins.CherryCommands["Populate Conditions Configuration"].Do(
                new CompositeConditionCommandArgs(this.reminder.CompositeCondition));
        }
        public void TieEvents(PluginRepository plugins)
        {
            plugins.CherryEvents.Subscribe(new CherryEventListener(
                "Load Configuration Event",
                cpea => this.LoadConfiguration(cpea as ConfigureEventArgs)));
            plugins.CherryEvents.Subscribe(new CherryEventListener(
                "Save Configuration Event",
                cpea => this.SaveConfiguration(cpea as ConfigureEventArgs)));

            this.showBaloonCommand = plugins.CherryCommands["Show Balloon Tip", false];

            plugins.CherryEvents.Subscribe(new CherryEventListener(
                "Application Started",
                ea =>
                {
                    if (!this.HasRun && this.showBaloonCommand != null)
                    {
                        this.showBaloonCommand.Do(new BaloonTipCommandArgs(new BaloonState
                        {
                            Caption = "I'm right here!",
                            Message = "This icon represents cherrytomato. Right-click to start a pomodoro.",
                        }));
                    }
                }),
                false);
        }
        public EventsAndCommandsBrowserForm(PluginRepository plugins)
            : this()
        {
            this.plugins = plugins;

            foreach (var e in this.plugins.CherryEvents.All)
            {
                this.dataEvents.Rows.Add(new object[]
                {
                    e.Name,
                    e.Listeners.Count(),
                    this.GetPrettyAssemblyName(e.ContainerAssembly),
                    e.Description,
                });
            }

            foreach (var c in this.plugins.CherryCommands.All)
            {
                this.dataCommands.Rows.Add(new object[]
                {
                    c.Name,
                    this.GetPrettyAssemblyName(c.ContainerAssembly),
                    c.Description,
                });
            }
        }
 public override IReminder CreateDefaultReminder(PluginRepository pluginRepository)
 {
     return new AfterPomodoroReminder(this.pluginRepository)
     {
         Timeout = new TimeSpan(0, 5, 0),
     };
 }
        public void TieEvents(PluginRepository plugins)
        {
            plugins.CherryEvents.Subscribe("Pomodoro Started", this.StartPomodoroInternal);

            plugins.CherryEvents.Subscribe(new CherryEventListener(
                "Pomodoro Finishing",
                ea => this.StopPomodoroInternal((ea as PomodoroEventArgs).PomodoroData.Successful)));
        }
 public void TieEvents(PluginRepository plugins)
 {
     plugins.CherryEvents.Subscribe(new CherryEventListener(
         "Load Configuration Event",
         cpea => this.LoadConfiguration(cpea as ConfigureEventArgs)));
     plugins.CherryEvents.Subscribe(new CherryEventListener(
         "Save Configuration Event",
         cpea => this.SaveConfiguration(cpea as ConfigureEventArgs)));
 }
 public void TieEvents(PluginRepository plugins)
 {
     this.pluginRepository = plugins;
     this.removeReminderCommand = plugins.CherryCommands["Remove Existing Reminder"];
     this.addNewReminderCommand = plugins.CherryCommands["Add New Reminder"];
     this.editReminderCommand = plugins.CherryCommands["Edit Reminder"];
     this.getAllRemindersCommand = plugins.CherryCommands["Get All Reminders"];
     this.getAllReminderPluginsCommand = plugins.CherryCommands["Get All Reminder Plugins"];
 }
        public override IReminder CreateDefaultReminder(PluginRepository pluginRepository)
        {
            var reminder = new IntervalReminder(pluginRepository)
            {
                FromInterval = new TimeSpan(0, 1, 50, 0),
                ToInterval = new TimeSpan(0, 2, 10, 0),
            };

            return reminder;
        }
 public void TieEvents(PluginRepository plugins)
 {
     this.pluginsRepository = plugins;
     this.showDialogCommand = plugins.CherryCommands["Show Window"];
     plugins.CherryEvents.Subscribe(
         "Application Started",
         () =>
             {
                 this.reminderPlugins =
                     plugins.CherryCommands["Get All Reminder Plugins"].Do(null) as ReminderPluginsRepository;
             });
 }
 public void TieEvents(PluginRepository plugins)
 {
     plugins.CherryEvents.Subscribe(new CherryEventListener(
         "Collect GUI Configurable Plugins",
         ea =>
         {
             var info = new GuiConfigurablePluginInfo(
                 this.PluginName,
                 new GeneralSettingsPanel(plugins),
                 null);
             (ea as GuiConfigurablePluginEventArgs).GeneralSettingsInfo = info;
         }));
 }
        public Reminder(PluginRepository plugins)
        {
            this.plugins = plugins;

            this.getCurrentTimeCommand = plugins.CherryCommands["Get Current Time"];
            this.scheduleActionCommand = plugins.CherryCommands["Schedule Single Action"];
            this.removeExistingTimeTriggerCommand = plugins.CherryCommands["Remove Existing Time Trigger"];

            this.CompositeNotification = new CompositeNotification(plugins);
            this.CompositeCondition = new CompositeCondition(plugins);

            this.LastNotificationTime = this.Now;
        }
        public void TieEvents(PluginRepository plugins)
        {
            plugins.CherryEvents.Subscribe("Pomodoro Started", this.StartPomodoroInternal);

            plugins.CherryEvents.Subscribe(new CherryEventListener(
                "Pomodoro Finishing",
                ea => this.StopPomodoroInternal((ea as PomodoroEventArgs).PomodoroData.Successful)));

            plugins.CherryEvents.Subscribe("Application Started", this.renderer.Initialize);

            this.addNewTriggerCommand = plugins.CherryCommands["Add New Time Trigger"];
            this.removeExistingTriggerCommand = plugins.CherryCommands["Remove Existing Time Trigger"];
        }
        public CompositeNotification(PluginRepository plugins, params INotification[] notifications)
        {
            this.notifiers = plugins.CherryCommands["Get All Notify Plugins"].Do(null) as NotifyPluginsRepository;

            foreach (var n in this.notifiers.All)
            {
                this.allNotifications[n.NotificationTypeName] = n.CreateNotification();
            }

            foreach (var notification in notifications)
            {
                this.allNotifications[notification.TypeName] = notification;
            }
        }
        public CompositeCondition(PluginRepository plugins, params ICondition[] conditions)
        {
            this.conditionPlugins = plugins.CherryCommands["Get All Condition Checker Plugins"].Do(null) as ConditionCheckerPluginsRepository;

            foreach (var n in this.conditionPlugins.All)
            {
                this.allConditions[n.ConditionTypeName] = n.CreateCondition();
            }

            foreach (var condition in conditions)
            {
                this.allConditions[condition.TypeName] = condition;
            }
        }
        public void TieEvents(PluginRepository plugins)
        {
            this.showNoActivateCommand = plugins.CherryCommands["Show Window No Activate"];
            plugins.CherryEvents.Subscribe(new CherryEventListener(
                "Pomodoro Finished",
                ea =>
                {
                    var pomodoro = (ea as PomodoroEventArgs).PomodoroData;
                    if (pomodoro.Successful)
                    {
                        this.pomodoroEvaluationForm.SetData(pomodoro);
                        this.showNoActivateCommand.Do(new WindowCommandArgs(this.pomodoroEvaluationForm));
                    }
                }));

            this.pomodoroEvaluationForm = new PomodoroEvaluationForm(plugins);
        }
        public GeneralSettingsPanel(PluginRepository plugins)
        {
            InitializeComponent();

            this.plugins = plugins;

            var v = new Version(Application.ProductVersion);
            versionLabel.Text = "Version " + v.Major + "." + v.Minor;

            // Currently, we can't check for updates..
            checkForUpdatesLinkLabel.Visible = false;

            var soundSettings =
                plugins.CherryCommands["Get Sound Settings"].Do(null) as
                SoundSettings;
            rewindCheckBox.Checked = soundSettings.PlayRewindSound;
            tickingSoundcheckBox.Checked = soundSettings.PlayTickingSound;
            ringSoundcheckBox.Checked = soundSettings.PlayRingSound;
        }
        public void TieEvents(PluginRepository plugins)
        {
            plugins.CherryEvents.Subscribe(new CherryEventListener(
                "Collect GUI Configurable Plugins",
                ea =>
                {
                    var info = new GuiConfigurablePluginInfo(
                        this.PluginName,
                        new ProcessCloserSettingsPanel(this),
                        Helpers.LoadIcon("res://process.ico"));
                    (ea as GuiConfigurablePluginEventArgs).PluginInfos.Add(info);
                }));

            plugins.CherryEvents.Subscribe(new CherryEventListener(
                "Load Plugin Configuration Event",
                cpea => this.LoadConfiguration(cpea as ConfigurePluginEventArgs)));
            plugins.CherryEvents.Subscribe(new CherryEventListener(
                "Save Plugin Configuration Event",
                cpea => this.SaveConfiguration(cpea as ConfigurePluginEventArgs)));

            plugins.CherryEvents.Subscribe("Pomodoro Started", this.StartPomodoroInternal);
        }
        public PomodoroEvaluationForm(PluginRepository pluginRepository)
        {
            this.pluginRepository = pluginRepository;

            this.InitializeComponent();

            this.tasksController = new TasksListController(this.tasksListControl);
            this.graphController = new ActivityGraphController(this.activityGraphControl, this.tasksController);
            this.ratingController = new RatingController(this.ratingControl, this.tasksController);
            this.taggingController = new TaggingController(this.taggingControl, this);
            this.reminderController = new OutOfPomodoroReminderController(
                this.outOfPomodoroReminderControl,
                this.pluginRepository);

            if (!(bool)this.pluginRepository.CherryCommands["Is User Activity Sensor Enabled"].Do(null))
            {
                this.OverlapGraphWithTasksList();
            }

            // Create a handle to allow invoke(show).
            this.CreateHandle();
        }
 public void TieEvents(PluginRepository plugins)
 {
     this.plugins = plugins;
     this.getAllConditionCheckerPluginsCommand = plugins.CherryCommands["Get All Condition Checker Plugins"];
 }
 public void TieEvents(PluginRepository plugins)
 {
 }
        public void TieEvents(PluginRepository plugins)
        {
            plugins.CherryEvents.Subscribe(new CherryEventListener(
                "Number of Pomodoro Changed",
                ea => this.SetPomodorosToday((ea as PomodoroEventArgs).ProductivityData)));

            plugins.CherryEvents.Subscribe("Icon Left Button Clicked", () => this.Enabled = !this.Enabled);
            plugins.CherryEvents.Subscribe(new CherryEventListener(
                "Connect To Database Event",
                ea => this.ConnectToDatabase((ea as ConnectToDbEventArgs).DbConnection)));

            plugins.CherryEvents.Subscribe(new CherryEventListener(
                "Collect GUI Configurable Plugins",
                ea =>
                {
                    var info = new GuiConfigurablePluginInfo(
                        this.PluginName,
                        new SimpleDashSettingsPanel(this),
                        Helpers.LoadIcon("res://dashboard.ico"));
                    (ea as GuiConfigurablePluginEventArgs).PluginInfos.Add(info);
                }));

            plugins.CherryEvents.Subscribe(new CherryEventListener(
                "Load Plugin Configuration Event",
                cpea => this.LoadConfiguration(cpea as ConfigurePluginEventArgs)));
            plugins.CherryEvents.Subscribe(new CherryEventListener(
                "Save Plugin Configuration Event",
                cpea => this.SaveConfiguration(cpea as ConfigurePluginEventArgs)));

            this.getCurrentPomodoroStatus = plugins.CherryCommands["Get Current Pomodoro Status Data"];
            this.addNewTriggerCommand = plugins.CherryCommands["Add New Time Trigger"];
            this.removeExistingTriggerCommand = plugins.CherryCommands["Remove Existing Time Trigger"];
            this.getCurrentTime = plugins.CherryCommands["Get Current Time"];
        }
 public void TieEvents(PluginRepository plugins)
 {
     this.plugins = plugins;
     this.getAllNotifyPluginsCommand = plugins.CherryCommands["Get All Notify Plugins"];
 }
 public FakeReminder(PluginRepository pluginRepository)
 {
     this.pluginRepository = pluginRepository;
 }
 public override void TieEvents(PluginRepository plugins)
 {
     this.now = plugins.CherryCommands["Get Current Time"];
 }
 public override void TieEvents(PluginRepository plugins)
 {
     this.showBaloonTip = plugins.CherryCommands["Show Balloon Tip"];
 }
 public override void TieEvents(PluginRepository plugins)
 {
     this.getPomodoroStatus = plugins.CherryCommands["Get Current Pomodoro Status Data"];
 }
 public void TieEvents(PluginRepository plugins)
 {
     this.allConditionCheckerPlugins = plugins.All.OfType<IConditionChecker>().ToDictionary(p => p.PluginName);
 }
 public override void TieEvents(PluginRepository plugins)
 {
     this.playSound = plugins.CherryCommands["Play Sound"];
 }