private void FloatingGlucose_Load(object sender, EventArgs e) { // We want all data values to be formatted with a dot, not comma, as some cultures do // as this messes up the gui a bit // we avoid this: double foo=7.0; foo.toString() => "7,0" in the nb-NO culture Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB"); if (Default.EnableInvertedTrayIcon == true) { this.notifyIcon1.Icon = Properties.Resources.noun_335372_cc_v2_inverted; } else { this.notifyIcon1.Icon = Properties.Resources.noun_335372_cc_v2; } SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; this.lblRawDelta.Visible = this.lblRawBG.Visible = Default.EnableRawGlucoseDisplay; // Manual scaling for now with values from config file // how to figure out the dpi: // this.CreateGraphics().DpiX > 96 setScaling(Default.GuiScalingRatio); setChildrenOnMouseDown(); notifyIcon1.BalloonTipClosed += (asender, ev) => { notifyIcon1.Visible = false; notifyIcon1.Dispose(); }; // Enable special color for debugging, // This is very handy when developing with a Release binary running alongside a dev version /*if (AppShared.isDebuggingBuild) * { * this.BackColor = Color.LightBlue; * }*/ this.BackColor = Default.BackgroundColorHex.FromHexStringToColor(); this.setBackgroundImage(); AppShared.RegisterSettingsChangedCallback(Settings_Changed_Event); this.setFormSize(); this.SetOpacity(); this.LoadGlucoseValue(); AppShared.refreshGlucoseTimer = new System.Windows.Forms.Timer(); //auto refresh data once every x seconds AppShared.refreshGlucoseTimer.Interval = this.refreshTime; //every 60s (default) reload the glucose numbers from the Nightscout pebble endpoint AppShared.refreshGlucoseTimer.Tick += new EventHandler((asender, ev) => LoadGlucoseValue()); AppShared.refreshGlucoseTimer.Start(); }
private void FloatingGlucose_Load(object sender, EventArgs e) { // We want all data values to be formatted with a dot, not comma, as some cultures do // as this messes up the gui a bit // we avoid this: double foo=7.0; foo.toString() => "7,0" in the nb-NO culture Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB"); this.notifyIcon1.Icon = Properties.Resources.noun_335372_cc; SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; this.lblRawDelta.Visible = this.lblRawBG.Visible = Default.EnableRawGlucoseDisplay; // Manual scaling for now with values from config file // how to figure out the dpi: // this.CreateGraphics().DpiX > 96 setScaling(Default.GuiScalingRatio); setChildrenOnMouseDown(); notifyIcon1.BalloonTipClosed += (asender, ev) => { notifyIcon1.Visible = false; notifyIcon1.Dispose(); }; // Enable special label only for debugging, // This is very handy when devloping with a Release binary running alongside a dev version if (this.isDebuggingBuild) { this.lblDebugModeOn.Visible = true; } AppShared.RegisterSettingsChangedCallback(Settings_Changed_Event); /*if (!Validators.IsUrl(this.datasourceLocation)) { * this.settingsForm.Visible = false; * this.settingsForm.ShowDialogIfNonVisible(); * * }*/ this.setFormSize(); this.Opacity = Default.GuiOpacity / 100D; this.LoadGlucoseValue(); var refreshGlucoseTimer = new System.Windows.Forms.Timer(); //auto refresh data once every x seconds refreshGlucoseTimer.Interval = this.refreshTime; //every 60s (default) reload the glucose numbers from the nightscout pebble endpoint refreshGlucoseTimer.Tick += new EventHandler((asender, ev) => LoadGlucoseValue()); refreshGlucoseTimer.Start(); }
private void btnVerifySubmit_Click(object sender, EventArgs e) { if (!Validators.IsUrl(this.txtNSURL.Text) || this.txtNSURL.Text == "https://mysite.azurewebsites.net") { MessageBox.Show("You have entered an invalid nightscout site URL", AppShared.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Default.NightscoutSite = this.txtNSURL.Text; Default.EnableAlarms = this.btnEnableAlarms.Checked; Default.AlarmUrgentHigh = this.numUrgentHigh.Value; Default.AlarmHigh = this.numHigh.Value; Default.AlarmLow = this.numLow.Value; Default.AlarmUrgentLow = this.numUrgentLow.Value; Default.GlucoseUnits = this.btnUnitsMMOL.Checked ? "mmol" : "mgdl"; Default.AlarmStaleDataUrgent = (int)this.numStaleUrgent.Value; Default.AlarmStaleDataWarning = (int)this.numStaleWarning.Value; Default.EnableSoundAlarms = this.chkEnableSoundAlarms.Checked; //advanced settings Default.GuiScalingRatio = (float)this.numScaling.Value; Default.GuiOpacity = (int)this.numOpacity.Value; Default.RefreshIntervalInSeconds = (int)this.numRefreshInterval.Value; Default.EnableExceptionLoggingToStderr = this.chkEnableExceptions.Checked; Default.DisableSoundAlarmsOnWorkstationLock = this.chkDisableSoundOnWorkstationLock.Checked; Default.EnableRawGlucoseDisplay = this.chkEnableRAWGlucose.Checked; Default.Save(); if (!this.chkEnableSoundAlarms.Checked) { var manager = SoundAlarm.Instance; manager.StopAlarm(); } AppShared.SettingsUpdatedSuccessfully = true; MessageBox.Show("Settings have been saved! Please note: some settings might require a restart to take effect!", AppShared.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information); AppShared.NotifyFormSettingsHaveChanged(); this.Close(); }
internal static bool InvestigationProcedureUpdate(Guid InvestigationProcedureGuid, Guid MainInvestigationGUID, Guid LabInvestigationGUID, string RadiologyInvestigation, string SpecialInvestigation, DateTime InvestigationProcedureDate, Guid modifiedByUser, out DateTime modifiedOn) { bool r = false; modifiedOn = DateTime.MinValue; using (SqlCommand cmd = AppDatabase.GetStoreProcCommand(InvestigationProcedure_Update)) { InvestigationProcedureParameter(cmd, InvestigationProcedureGuid, MainInvestigationGUID, LabInvestigationGUID, RadiologyInvestigation, SpecialInvestigation, InvestigationProcedureDate, modifiedByUser); SqlParameter prmDate = AppDatabase.AddOutParameter(cmd, InvestigationProcedure.Columns.InvestigationProcedureModifiedOn, SqlDbType.DateTime); AppDatabase db = OpenDatabase(); r = db != null && db.ExecuteCommand(cmd); if (r) { modifiedOn = AppShared.DbValueToDateTime(prmDate.Value); } } return(r); }
internal override bool Populate(SqlDataReader dr) { bool r = false; if (dr != null && AppShared.IsNotNull(dr[Columns.InvestigationProcedureGuid])) { this.mId = AppShared.DbValueToInteger(dr[Columns.InvestigationProcedureId]); this.mObjectGuid = AppShared.DbValueToGuid(dr[Columns.InvestigationProcedureGuid]); this.mMainInvestigationGUID = AppShared.DbValueToGuid(dr[Columns.MainInvestigationGUID]); this.mLabInvestigationGUID = AppShared.DbValueToGuid(dr[Columns.LabInvestigationGUID]); this.mRadiologyInvestigation = AppShared.DbValueToString(dr[Columns.InvestigationProcedureRadiologyInvestigation]); this.mSpecialInvestigation = AppShared.DbValueToString(dr[Columns.InvestigationProcedureSpecialInvestigation]); this.mCreatedByUser = AppShared.DbValueToGuid(dr[Columns.InvestigationProcedureCreatedBy]); this.mCreatedOn = AppShared.DbValueToDateTime(dr[Columns.InvestigationProcedureCreatedOn]); this.mModifiedByUser = AppShared.DbValueToGuid(dr[Columns.InvestigationProcedureModifiedBy]); this.mModifiedOn = AppShared.DbValueToDateTime(dr[Columns.InvestigationProcedureModifiedOn]); this.Status = ObjectStatus.Opened; r = true; } return(r); }
internal static bool OPDInvestigationInsert(Guid OPDInvestigationGuid, Guid MainInvestigationGUID, Guid LabInvestigationGUID, string OPDRadiologyInvestigation, string OPDSpecialInvestigation, DateTime OPDInvestigationDate, Guid createdByUser, out DateTime createdOn) { bool r = false; //id = 0; createdOn = DateTime.MinValue; using (SqlCommand cmd = AppDatabase.GetStoreProcCommand(OPDInvestigation_Insert)) { OPDInvestigationParameter(cmd, OPDInvestigationGuid, MainInvestigationGUID, LabInvestigationGUID, OPDRadiologyInvestigation, OPDSpecialInvestigation, OPDInvestigationDate, createdByUser); // SqlParameter prmId = AppDatabase.AddOutParameter(cmd, OPDInvestigation.Columns.OPDInvestigationId, SqlDbType.Int); SqlParameter prmDate = AppDatabase.AddOutParameter(cmd, OPDInvestigation.Columns.OPDInvestigationModifiedOn, SqlDbType.DateTime); AppDatabase db = OpenDatabase(); r = db != null && db.ExecuteCommand(cmd); if (r) { //id = AppShared.DbValueToInteger(prmId.Value); createdOn = AppShared.DbValueToDateTime(prmDate.Value); } } return(r); }
private void btnVerifySubmit_Click(object sender, EventArgs e) { /*if (!Validators.IsUrl(this.txtDataSourceLocation.Text) || this.txtDataSourceLocation.Text == "https://mysite.azurewebsites.net") { * MessageBox.Show("You have entered an invalid Nightscout site URL", AppShared.AppName, MessageBoxButtons.OK, * MessageBoxIcon.Error); * return; * }*/ Default.UserName = this.txtUserName.Text; Default.HashedPassword = new DataProtector(this.txtPassword.Text); Default.DataPathLocation = this.txtDataSourceLocation.Text; Default.EnableAlarms = this.btnEnableAlarms.Checked; Default.AlarmUrgentHigh = this.numUrgentHigh.Value; Default.AlarmHigh = this.numHigh.Value; Default.AlarmLow = this.numLow.Value; Default.AlarmUrgentLow = this.numUrgentLow.Value; Default.GlucoseUnits = this.btnUnitsMMOL.Checked ? "mmol" : "mgdl"; Default.AlarmStaleDataUrgent = (int)this.numStaleUrgent.Value; Default.AlarmStaleDataWarning = (int)this.numStaleWarning.Value; Default.EnableSoundAlarms = this.chkEnableSoundAlarms.Checked; //advanced settings Default.GuiScalingRatio = (float)this.numScaling.Value; Default.GuiOpacity = (int)this.numOpacity.Value; Default.RefreshIntervalInSeconds = (int)this.numRefreshInterval.Value; Default.EnableExceptionLoggingToStderr = this.chkEnableExceptions.Checked; Default.DisableSoundAlarmsOnWorkstationLock = this.chkDisableSoundOnWorkstationLock.Checked; Default.EnableRawGlucoseDisplay = this.chkEnableRAWGlucose.Checked; Default.BackgroundColorHex = this.txtBackColor.Text; Default.BackgroundImage = this.txtBackImage.Text; //Save plugin type based on the selected fullname Default.DataSourceFullName = (this.cbDataSource.SelectedItem as DataSourceInfo).FullName; Default.BackgroundImageLayout = (cbImageLayouts.SelectedItem as String) ?? "Stretch"; DataSourceInfo plugin; try { plugin = (DataSourceInfo)this.cbDataSource.SelectedItem; plugin.Instance.VerifyConfig(Default); } catch (ConfigValidationException ce) { MessageBox.Show(ce.Message, AppShared.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Default.DataSourceFullName = plugin.FullName; //this is here for a purpose var selectedPlugin = (this.cbDataSource.SelectedItem as DataSourceInfo); PluginLoader.Instance.SetActivePlugin(selectedPlugin.FullName); //only save if validation succeeded. Default.Save(); if (!this.chkEnableSoundAlarms.Checked) { var manager = SoundAlarm.Instance; manager.StopAlarm(); } AppShared.SettingsUpdatedSuccessfully = true; MessageBox.Show("Settings have been saved! Please note: some settings might require a restart to take effect!", AppShared.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information); AppShared.IsShowingSettings = false; AppShared.NotifyFormSettingsHaveChanged(); this.Close(); }
private void SettingsLoadedEventHandler(object sender, System.Configuration.SettingsLoadedEventArgs e) { // Add code to handle the SettingChangingEvent event here. AppShared.NotifyFormSettingsHaveChanged(); }
private static void InvestigationProcedureParameter(SqlCommand cmd, Guid InvestigationProcedureGuid, Guid MainInvestigationGUID, Guid LabInvestigationGUID, string RadiologyInvestigation, string SpecialInvestigation, DateTime InvestigationProcedureDate, Guid modifiedBy) { AppDatabase.AddInParameter(cmd, InvestigationProcedure.Columns.InvestigationProcedureGuid, SqlDbType.UniqueIdentifier, InvestigationProcedureGuid); AppDatabase.AddInParameter(cmd, InvestigationProcedure.Columns.MainInvestigationGUID, SqlDbType.UniqueIdentifier, MainInvestigationGUID); AppDatabase.AddInParameter(cmd, InvestigationProcedure.Columns.LabInvestigationGUID, SqlDbType.UniqueIdentifier, LabInvestigationGUID); AppDatabase.AddInParameter(cmd, InvestigationProcedure.Columns.InvestigationProcedureRadiologyInvestigation, SqlDbType.NVarChar, AppShared.SafeString(RadiologyInvestigation)); AppDatabase.AddInParameter(cmd, InvestigationProcedure.Columns.InvestigationProcedureSpecialInvestigation, SqlDbType.NVarChar, AppShared.SafeString(SpecialInvestigation)); AppDatabase.AddInParameter(cmd, InvestigationProcedure.Columns.InvestigationProcedureDate, SqlDbType.DateTime, InvestigationProcedureDate); AppDatabase.AddInParameter(cmd, InvestigationProcedure.Columns.InvestigationProcedureModifiedBy, SqlDbType.UniqueIdentifier, modifiedBy); }
internal static SqlDataReader InvestigationProcedureSearch(string SearchText) { return(GetReader(InvestigationProcedure_Search, "@SearchText", SqlDbType.NVarChar, AppShared.ToDbLikeText(SearchText))); }
private static void OPDInvestigationParameter(SqlCommand cmd, Guid OPDInvestigationGuid, Guid MainInvestigationGUID, Guid LabInvestigationGUID, string OPDRadiologyInvestigation, string OPDSpecialInvestigation, DateTime OPDInvestigationDate, Guid modifiedBy) { AppDatabase.AddInParameter(cmd, OPDInvestigation.Columns.OPDInvestigationGuid, SqlDbType.UniqueIdentifier, OPDInvestigationGuid); AppDatabase.AddInParameter(cmd, OPDInvestigation.Columns.MainInvestigationGUID, SqlDbType.UniqueIdentifier, MainInvestigationGUID); AppDatabase.AddInParameter(cmd, OPDInvestigation.Columns.LabInvestigationGUID, SqlDbType.UniqueIdentifier, LabInvestigationGUID); AppDatabase.AddInParameter(cmd, OPDInvestigation.Columns.OPDRadiologyInvestigation, SqlDbType.NVarChar, AppShared.ToDbValueNullable(OPDRadiologyInvestigation)); AppDatabase.AddInParameter(cmd, OPDInvestigation.Columns.OPDSpecialInvestigation, SqlDbType.NVarChar, AppShared.ToDbValueNullable(OPDSpecialInvestigation)); AppDatabase.AddInParameter(cmd, OPDInvestigation.Columns.OPDInvestigationDate, SqlDbType.DateTime, AppShared.ToDbValueNullable(OPDInvestigationDate)); AppDatabase.AddInParameter(cmd, OPDInvestigation.Columns.OPDInvestigationModifiedBy, SqlDbType.UniqueIdentifier, modifiedBy); }