Пример #1
0
 public ProjectChangeProcessorNewDay(ProjectChangeHandler handler,
                                     WorktimeAnalyzer worktimeAnalyzer,
                                     WorktrackerUpdater worktrackerUpdater) : base(handler)
 {
     WorktimeAnalyzer   = worktimeAnalyzer;
     WorktrackerUpdater = worktrackerUpdater;
 }
Пример #2
0
 public ProjectChangeHandler(ProjectChangeHandler handler = null) : base(handler)
 {
     currentProject        = "";
     currentProjectComment = "";
     Handler = this;
     this.RaiseProjectChangeEvent += handleProjectChangeEvent;
     projectChangeNotifiers.Add(this);
 }
Пример #3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Form1   form      = new Form1();
            Overlay overlay   = new Overlay();
            var     presenter = new Presenter(form, overlay);

            form.Presenter = presenter;

            ProjectChangeHandler mainHandler = new ProjectChangeHandler();
            var worktimebreakHandler         = new ProjectChangeProcessorWorktimebreaks(mainHandler);
            var projectCorrectionHandler     = new ProjectChangeNotifierCorrection(mainHandler);
            var projectAnalysisHandler       = new ProjectChangeNotifierAnalysis(mainHandler);
            var storageEngine      = new WorktimeRecordStorageNoSQL();
            var worktimeAnalyzer   = new WorktimeAnalyzer(storageEngine, mainHandler);
            var worktrackerUpdater = new WorktrackerUpdater();

            //Change notifiers
            mainHandler.addProjectChangeNotifier(new ProjectChangeNotifierDexpot(mainHandler, presenter));
            mainHandler.addProjectChangeNotifier(new ProjectChangeNotifierTimeular(mainHandler, presenter));
            mainHandler.addProjectChangeNotifier(new ProjectChangeNotifierLockscreen(mainHandler));
            mainHandler.addProjectChangeNotifier(new ProjectChangeNotifierAppExit(mainHandler));
            mainHandler.addProjectChangeNotifier(new ProjectChangeNotifierUpcomingAppointment(mainHandler, presenter));
            mainHandler.addProjectChangeNotifier(projectAnalysisHandler);
            mainHandler.addProjectChangeNotifier(projectCorrectionHandler);

            //Change processors
            mainHandler.addProjectChangeProcessor(new ProjectChangeProcessorAppStart(mainHandler));
            mainHandler.addProjectChangeProcessor(new ProjectChangeProcessorNewDay(mainHandler, worktimeAnalyzer, worktrackerUpdater));
            mainHandler.addProjectChangeProcessor(new ProjectChangeProcessorLockscreen(mainHandler));
            mainHandler.addProjectChangeProcessor(worktimebreakHandler);
            //mainHandler.addProjectChangeProcessor(new ProjectChangeProcessorLongerThan10secs(mainHandler));

            //Change subscribers
            mainHandler.addProjectChangeSubscriber(new ProjectChangeSubscriberFormUpdater(presenter));
            mainHandler.addProjectChangeSubscriber(new ProjectChangeSubscriberBalloonInformant(presenter.showNotification));
            mainHandler.addProjectChangeSubscriber(new ProjectChangeSubscriberOverlayUpdater(overlay.setOverlayText));
            mainHandler.addProjectChangeSubscriber(new ProjectChangeSubscriberLogger());

            //Storages
            mainHandler.addWorktimeRecordStorage(new WorktimeRecordStorageCSV());
            mainHandler.addWorktimeRecordStorage(storageEngine);
            mainHandler.RaiseStorageExceptionEvent += new StorageExceptionBalloonInformant(presenter.showNotification).handleStorageException;

            //Presenter
            presenter.WorktimeAnalyzer         = worktimeAnalyzer;
            presenter.WorktimebreakHandler     = worktimebreakHandler;
            presenter.ProjectCorrectionHandler = projectCorrectionHandler;
            presenter.ProjectHandler           = mainHandler;
            presenter.storage   = storageEngine;
            presenter.wtUpdater = worktrackerUpdater;

            presenter.onInitCompleted();

            Application.Run(form);
        }
Пример #4
0
        private void processSuggestions()
        {
            var fullList = calculateFullSuggestionList();

            foreach (var wtr in fullList)
            {
                createRow();
                minutes.Last().Text  = ((int)Math.Floor((wtr.End - wtr.Start).TotalMinutes)).ToString();
                comments.Last().Text = wtr.Comment;
                if (wtr.ProjectName == GAP_PROJECTNAME)
                {
                    projects.Last().SelectedIndex = Handler.getAvailableProjectIndex(ProjectChangeHandler.PROJECT_WORKTIMEBREAK);
                }
                else
                {
                    projects.Last().SelectedIndex = ProjectChangeHandler.getFirstCustomProjectIndex();
                }
            }

            //Hacky the hack, adjust last value if we floored too much
            var breakLeft = getMinutesLeft();

            minutes.Last().Text = (Convert.ToInt32(minutes.Last().Text) + breakLeft).ToString();
        }
 public ProjectChangeNotifierTimeular(ProjectChangeHandler handler, Presenter presenter) : base(handler)
 {
     Presenter = presenter;
 }
Пример #6
0
 public ProjectChangeNotifierCorrection(ProjectChangeHandler handler) : base(handler)
 {
 }
Пример #7
0
 public ProjectChangeProcessorAppStart(ProjectChangeHandler handler) : base(handler)
 {
 }
 protected AProjectChangeNotifier(ProjectChangeHandler handler)
 {
     Handler = handler;
 }
Пример #9
0
 public ProjectChangeProcessorLongerThan10secs(ProjectChangeHandler handler) : base(handler)
 {
 }
Пример #10
0
 public ProjectChangeProcessorLockscreen(ProjectChangeHandler handler) : base(handler)
 {
 }
 public ProjectChangeNotifierAnalysis(ProjectChangeHandler handler) : base(handler)
 {
 }
Пример #12
0
 public ProjectChangeNotifierAppExit(ProjectChangeHandler handler) : base(handler)
 {
 }
 public ProjectChangeNotifierUpcomingAppointment(ProjectChangeHandler handler, Presenter presenter) : base(handler)
 {
     Presenter = presenter;
 }
Пример #14
0
 public ProjectChangeNotifierLockscreen(ProjectChangeHandler handler) : base(handler)
 {
 }
 public ProjectChangeNotifierDexpot(ProjectChangeHandler handler, Presenter presenter) : base(handler)
 {
     Presenter = presenter;
 }
Пример #16
0
 public ProjectChangeProcessorWorktimebreaks(ProjectChangeHandler handler)  : base(handler)
 {
 }
 public AProjectChangeProcessor(ProjectChangeHandler handler) : base(handler)
 {
 }
Пример #18
0
        public List <WorktimeRecord> ShowDialogMeantime(DateTime from, DateTime to, ProjectChangeHandler handler, List <WorktimeRecord> suggestions = null)
        {
            MinutesTotal = (int)(Math.Floor((to - from).TotalMinutes));
            From         = from;
            To           = to;
            Suggestions  = suggestions;
            Handler      = handler;

            generateForm("What did you do in the mean time?");

            AddRowButton = new System.Windows.Forms.Button()
            {
                Left = 461, Top = 68 - lineHeightAdd, Width = 23, Text = "+"
            };
            OkButton = new System.Windows.Forms.Button()
            {
                Left = 410, Top = 112 - lineHeightAdd, Width = 75, Text = "OK"
            };

            AddRowButton.Click   += AddRowButton_ClickMeantime;
            OkButton.Click       += (sender, e) => { prompt.Close(); };
            OkButton.DialogResult = DialogResult.OK;
            OkButton.Click       += OkButton_Click;
            prompt.AcceptButton   = OkButton;

            prompt.Controls.Add(new System.Windows.Forms.Label()
            {
                Left = 47, Top = 24, Text = "Break: ", Width = 40
            });
            prompt.Controls.Add(new System.Windows.Forms.Label()
            {
                Left = 91, Top = 24, Text = $"{MinutesTotal} mins"
            });
            prompt.Controls.Add(new System.Windows.Forms.Label()
            {
                Left = 41, Top = 53, Text = "Minutes", Width = 50, Height = 13
            });
            prompt.Controls.Add(new System.Windows.Forms.Label()
            {
                Left = 221, Top = 53, Text = "Comment", Width = 60, Height = 13
            });
            prompt.Controls.Add(new System.Windows.Forms.Label()
            {
                Left = 91, Top = 53, Text = "Project", Width = 50, Height = 13
            });
            prompt.Controls.Add(OkButton);
            prompt.Controls.Add(CancelButton);
            prompt.Controls.Add(AddRowButton);

            if (suggestions != null)
            {
                processSuggestions();
            }
            else
            {
                createRow();
            }

            createRowNewProject(false, Handler.currentProjectComment);

            continuallyFocusDialog();
            centerDialogOnMainscreen();
            var result = prompt.ShowDialog();

            var ret = new List <WorktimeRecord>();

            if (result == DialogResult.OK)
            {
                DateTime start = from;
                for (int index = 0; index < minutes.Count; index++)
                {
                    var end = start.AddMinutes(Convert.ToInt32(minutes[index].Text));
                    ret.Add(new WorktimeRecord(start, end, projects[index].Text, comments[index].Text));
                    start = end;
                }
                ret.Last().End = to; //to compensate for additional seconds

                //Also pass information regarding the current project
                ret.Add(new WorktimeRecord(DateTime.MinValue, DateTime.MinValue, currentProject.Text, currentComment.Text)); //what a hack
            }
            return(ret);
        }