コード例 #1
0
ファイル: BG Reader.cs プロジェクト: YowieDK/BgMonitor
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                bool colorAndSizeIsSet = false;
                //set this form global so I can use functions from this class from other classes
                Globals.form = this;

                if (!appSet.LicenseAgrRead)
                {
                    LicenseAgrement licenseWindow = new LicenseAgrement();
                    licenseWindow.ShowDialog();
                }

                //Set size and color if settings and license is done. This is done to make sure you don't see default color and size before it changes
                if (appSet.SettingsIsDone && appSet.LicenseAgrRead)
                {
                    //Setbackground color
                    SetBackgroundColor(appSet.BackgroundColor);
                    //Set app size
                    ScaleApp(appSet.ApplicationSize);
                    colorAndSizeIsSet = true;
                }

                //Make form moveable MinimizedBox
                this.MouseDown    += new MouseEventHandler(moveOnMouseDown);
                BgLabel.MouseDown += new MouseEventHandler(moveOnMouseDown);
                minutesSinceLastBgLabel.MouseDown += new MouseEventHandler(moveOnMouseDown);
                ArrowStraitBox.MouseDown          += new MouseEventHandler(moveOnMouseDown);
                ArrowOneUpBox.MouseDown           += new MouseEventHandler(moveOnMouseDown);
                ArrowOneDownBox.MouseDown         += new MouseEventHandler(moveOnMouseDown);
                ArrowDoubleUpBox.MouseDown        += new MouseEventHandler(moveOnMouseDown);
                ArrowDoubleDownBox.MouseDown      += new MouseEventHandler(moveOnMouseDown);
                Arrow45UpBox.MouseDown            += new MouseEventHandler(moveOnMouseDown);
                Arrow45DownBox.MouseDown          += new MouseEventHandler(moveOnMouseDown);
                //MinimizedBox.MouseDown += new MouseEventHandler(moveOnMouseDown);

                this.FormClosing    += new FormClosingEventHandler(bgMonitor_FormClosing);
                this.TopMost         = appSet.AppAlwaysOnTop;
                this.FormBorderStyle = FormBorderStyle.None;

                double windowScale  = 1.0;
                int    windowWidth  = this.Width;
                int    windowHeight = this.Height;

                this.Width           = System.Convert.ToInt32(Math.Round(windowWidth * windowScale));
                this.Height          = System.Convert.ToInt32(Math.Round(windowHeight * windowScale));
                closeWindow.Location = new Point(System.Convert.ToInt32(Math.Round(closeWindow.Location.X * windowScale)), System.Convert.ToInt32(Math.Round(closeWindow.Location.Y * windowScale)));

                //Hide alarm indicator
                this.AlarmpictureBox.Hide();
                appSet.getAllSettings();
                if (NewHelper.CheckConnectionToNs(appSet.NightscoutUrl) == "ok")
                {
                    newBgRip.getSourceFromUrl(appSet.NightscoutUrl);
                    minutesSinceLastBgLabel.Text = newBgRip.MinutesSinceLastBg + " Minutes since last sgv";
                    var BgLabelText = newBgRip.CalcBg;
                    BgLabel.Text      = BgLabelText;
                    BgLabel.ForeColor = NewHelper.CalculateColorFromBg(BgLabelText);
                }
                //Start timer
                GetBgTimer.Start();

                //Start timer that closes the app to avoid closing exception
                if (!appSet.LicenseAgrRead)
                {
                    CloseDownTimer.Start();
                }
                else
                {
                    this.Enabled = true;
                }

                //Open settings if not done and licensagreement read and accepted
                BgSettings settingsWindow = new BgSettings();
                if (!appSet.SettingsIsDone && appSet.LicenseAgrRead)
                {
                    settingsWindow.ShowDialog();
                    appSet.getAllSettings();
                }

                //Get first bg here
                GetBg_Tick(null, null);

                //make syre this don't run twice in load app
                if (!colorAndSizeIsSet)
                {
                    //Setbackground color
                    SetBackgroundColor(appSet.BackgroundColor);
                    //Set app size
                    ScaleApp(appSet.ApplicationSize);
                }

                //Set minimize tooltip
                SetButtonMinimizeToolTopText(appSet.MinutesToMinimize.ToString());

                //Call add to opened counter
                newBgRip.callAddToCounter();
            }
            catch (Exception)
            {
                //TODO
            }
        }
コード例 #2
0
ファイル: BG Reader.cs プロジェクト: YowieDK/BgMonitor
 public void StartCloseDownTimer()
 {
     CloseDownTimer.Start();
 }