示例#1
0
        private void imageButtonAlert_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show(ResourcesFiles.ProgramStrings.Cancelremindtext, ResourcesFiles.ProgramStrings.Cancelremind, MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                SaveWriter save = new SaveWriter(pthspc);
                save.Load();
                save.LoadedValuesToSaveValues();
                File.Delete(pthspc);
                save.RemoveItem("Warn");
                save.AddItem("Warn", false);
                save.Save();
                imageButtonAlert.Visible = false;
                HelpClass.NotesChange    = true;
            }
            else if (dialogResult == DialogResult.No)
            {
            }
        }
示例#2
0
        void SaveStatistics()
        {
            try
            {
                if (StatsEn)
                {
                    Directory.CreateDirectory(PathMS + "/Stats/");

                    if (File.Exists(PathMS + "/Stats/Today.sts"))
                    {
                        SaveWriter savew = new SaveWriter(PathMS + "/Stats/Today.sts");
                        savew.Load();

                        if (savew.GetItemInt("Day") != DateTime.Now.Day)
                        {
                            int hrs = savew.GetItemInt("Hours");

                            short mns = (short)savew.GetItemInt("Mins");

                            bool Graphskip = false;

                            if (DateTime.Now.Day < savew.GetItemInt("Day"))
                            {
                                Graphskip = true;

                                if (File.Exists(PathMS + "/Stats/MonthOld.sts"))
                                {
                                    File.Delete(PathMS + "/Stats/MonthOld.sts");
                                }
                                if (File.Exists(PathMS + "/Stats/MonthGraphOld.sts"))
                                {
                                    File.Delete(PathMS + "/Stats/MonthGraphOld.sts");
                                }


                                if (File.Exists(PathMS + "/Stats/Month.sts"))
                                {
                                    File.Move(PathMS + "/Stats/Month.sts", PathMS + "/Stats/MonthOld.sts");
                                }
                                if (File.Exists(PathMS + "/Stats/MonthGraph.sts"))
                                {
                                    File.Move(PathMS + "/Stats/MonthGraph.sts", PathMS + "/Stats/MonthGraphOld.sts");
                                }
                            }

                            savew.Destroy();

                            savew.PathToFile = PathMS + "/Stats/Month.sts";
                            if (File.Exists(PathMS + "/Stats/Month.sts"))
                            {
                                savew.Load();
                                int   hrsm = hrs + savew.GetItemInt("Hours");
                                short mnsm = (short)(mns + (savew.GetItemInt("Mins")));
                                if (mnsm > 59)
                                {
                                    mnsm -= 60;
                                    hrsm++;
                                }

                                int cnt = savew.GetItemInt("Divide");
                                File.Delete(PathMS + "/Stats/Month.sts");
                                savew.Destroy();
                                savew.AddItem("Month", DateTime.Now.Month);
                                savew.AddItem("Hours", hrsm);
                                savew.AddItem("Mins", mnsm);
                                savew.AddItem("Divide", (cnt + 1));
                                savew.Save();
                            }
                            else
                            {
                                if (!Graphskip)
                                {
                                    savew.AddItem("Month", DateTime.Now.Month);
                                    savew.AddItem("Hours", hrs);
                                    savew.AddItem("Mins", mns);
                                    savew.AddItem("Divide", 1);
                                    savew.Save();
                                }
                            }


                            savew.Destroy();
                            savew.PathToFile = PathMS + "/Stats/MonthGraph.sts";
                            if (File.Exists(PathMS + "/Stats/MonthGraph.sts"))
                            {
                                savew.Load();
                                savew.LoadedValuesToSaveValues();
                                int cnt = savew.GetItemInt("Count");
                                cnt++;
                                savew.AddItem("Value" + cnt, ((hrs * 60) + mns));
                                savew.AddItem("Day" + cnt, (DateTime.Now.Day - 1));
                                savew.RemoveItem("Count");
                                savew.AddItem("Count", cnt);
                                savew.Save();
                            }
                            else
                            {
                                if (!Graphskip)
                                {
                                    savew.AddItem("Value1", ((hrs * 60) + mns));
                                    savew.AddItem("Day1", (DateTime.Now.Day - 1));
                                    savew.AddItem("Count", 1);
                                    savew.Save();
                                }
                            }

                            savew.Destroy();
                            savew.PathToFile = PathMS + "/Stats/AllTime.sts";
                            if (File.Exists(PathMS + "/Stats/AllTime.sts"))
                            {
                                savew.Load();
                                int   hrsa = savew.GetItemInt("Hours");
                                short mnsa = (short)savew.GetItemInt("Mins");
                                int   cnt  = savew.GetItemInt("Divide");


                                hrsa += hrs;
                                mnsa += mns;
                                cnt++;

                                if (mnsa >= 60)
                                {
                                    hrsa++;
                                    mnsa -= 60;
                                }

                                if (cnt > 30)
                                {
                                    long  tms     = (hrsa * 60) + mnsa;
                                    long  time    = (tms / cnt) * 5;
                                    int   hour    = (int)Math.Floor((decimal)(time / 60));
                                    short minutes = (short)(time - (hour * 60));
                                    hrsa = hour;
                                    mnsa = minutes;
                                    cnt  = 5;
                                }

                                File.Delete(PathMS + "/Stats/AllTime.sts");
                                savew.Destroy();
                                savew.AddItem("Hours", hrsa);
                                savew.AddItem("Mins", mnsa);
                                savew.AddItem("Divide", cnt);
                                savew.Save();
                            }
                            else
                            {
                                savew.AddItem("Hours", hrs);
                                savew.AddItem("Mins", mns);
                                savew.AddItem("Divide", 1);
                                savew.Save();
                            }
                            allhour = 0;
                            allmin  = 0;
                        }
                    }//ak existuje today.sts



                    if (File.Exists(PathMS + "/Stats/Today.sts"))
                    {
                        File.Delete(PathMS + "/Stats/Today.sts");
                    }

                    SaveWriter save = new SaveWriter(PathMS + "/Stats/Today.sts");
                    save.AddItem("Date", "" + DateTime.Now);
                    save.AddItem("Hours", allhour);
                    save.AddItem("Mins", allmin);
                    save.AddItem("Day", DateTime.Now.Day);
                    save.Save();
                    save.Destroy();
                }//StatsEn == true
            }catch (Exception ex)
            {
                DebugService.WriteError("" + ex);
            }
        }//SaveStatistics()