Beispiel #1
0
        private void btnRemoveProfile_Click(object sender, EventArgs e)
        {
            if (lvUserProfiles.SelectedItems.Count > 0)
            {
                UserProfileListViewItem itemBeingEdited = (UserProfileListViewItem)lvUserProfiles.SelectedItems[0];
                UserProfile             userBeingEdited = itemBeingEdited.UserProfile;

                if (MessageBox.Show(this, $"Delete user ({userBeingEdited.Name}), are you sure?", "Deletion Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    try
                    {
                        ZAMsettings.BeginCachedConfiguration();

                        ZAMsettings.Settings.DeleteUserProfile(userBeingEdited);

                        ZAMsettings.CommitCachedConfiguration();

                        lvUserProfiles.BeginUpdate();
                        lvUserProfiles.Items.Remove(itemBeingEdited);

                        if (lvUserProfiles.Items.Count > 0)
                        {
                            lvUserProfiles.Items[0].Focused  = true;
                            lvUserProfiles.Items[0].Selected = true;
                        }
                        lvUserProfiles.EndUpdate();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Exception occurred: " + ex.ToString(), "Error deleting User Profile", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
        }
Beispiel #2
0
        private void btnStatsCancel_Click(object sender, EventArgs e)
        {
            ZAMsettings.RollbackCachedConfiguration();

            errorProvider.Clear();

            if (lvCollectors.SelectedItems.Count > 0)
            {
                CollectorListViewItem itemBeingEdited = (CollectorListViewItem)lvCollectors.SelectedItems[0];
                Collector             userBeingEdited = itemBeingEdited.Collector;

                // If a newly added row, remove it and select the first one in list
                if (1 == 0)
                {
                    //lvCollectors.Items.Remove(itemBeingEdited);
                    //if (lvCollectors.Items.Count > 0)
                    //{
                    //    lvCollectors.Items[0].Selected = true;
                    //}
                }
                else
                {
                    // Refresh user from rolled back configuration
                    Collector refreshCollector = ZAMsettings.Settings.Collectors[userBeingEdited.Name];
                    Collectors_LoadFields(refreshCollector);

                    // This will clone the Collector so that the listview doesn't have a direct link to the configuration
                    itemBeingEdited.Collector = refreshCollector;
                }
            }
            EditingCollectors = false;
        }
Beispiel #3
0
        private void btnSaveSettings_Click(object sender, EventArgs e)
        {
            bool errorOccurred = false;

            errorOccurred = (errorOccurred || ValidateSystemSettings(this.cbMeasurementSystem));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.rbManual));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.rbAutomatic));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.cbDistanceUom));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.cbPosition));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.tbDistance));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.tbHrs));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.tbMins));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.tbSecs));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.rbDistance));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.rbTime));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.rbPosition));

            // final validation
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.gbLaps));

            if (!errorOccurred)
            {
                ZAMsettings.CommitCachedConfiguration();
                EditingSystemSettings = false;
            }
        }
        private void btnAccept_Click(object sender, EventArgs e)
        {
            if (cbTheme.SelectedItem == null || cbTransparency.SelectedItem == null || cbFonts.SelectedItem == null)
            {
                MessageBox.Show(this.ParentForm, "Please make sure to select a valid theme, transparency, and font before saving.", "Unable to save", MessageBoxButtons.OK);
                return;
            }

            Logger.LogDebug($"Theme: {cbTheme.SelectedValue}, ManagedColor: {btnColor.SelectedColor}, Font: {cbFonts.SelectedItem} Transparency: {cbTransparency.SelectedValue}");

            ZAMsettings.BeginCachedConfiguration();

            ZAMsettings.Settings.Appearance.ThemeSetting        = ((KeyValuePair <ThemeType, string>)cbTheme.SelectedItem).Key;
            ZAMsettings.Settings.Appearance.TransparencySetting = ((KeyValuePair <TransparencyType, string>)cbTransparency.SelectedItem).Key;
            ZAMsettings.Settings.Appearance.ManagedColor        = btnColor.SelectedColor;
            ZAMsettings.Settings.Appearance.FontFamily          = cbFonts.SelectedItem.ToString();
            ZAMsettings.Settings.Appearance.FontSize            = (float)nudFontSize.Value;
            ZAMsettings.Settings.Appearance.IsFontBold          = cbBold.Checked;
            ZAMsettings.Settings.Appearance.IsFontItalic        = cbItalic.Checked;

            ZAMsettings.CommitCachedConfiguration();

            ZAMappearance cs = ZAMsettings.Settings.Appearance;

            ColorsAndFontChangedEventArgs args = new(cs.ThemeSetting, cs.TransparencySetting, cs.ManagedColor, cs.FontFamily, cs.FontSize, cs.IsFontBold, cs.IsFontItalic);

            // The MainForm listens for this event so it can refresh all colors
            this.OnColorsAndFontChanged(args);

            this.sfToolTip.Show("Configuration saved.", Cursor.Position, 2000);
        }
Beispiel #5
0
        private void btnCancelProfile_Click(object sender, EventArgs e)
        {
            ZAMsettings.RollbackCachedConfiguration();

            errorProvider.Clear();

            if (lvUserProfiles.SelectedItems.Count > 0)
            {
                UserProfileListViewItem itemBeingEdited = (UserProfileListViewItem)lvUserProfiles.SelectedItems[0];
                UserProfile             userBeingEdited = itemBeingEdited.UserProfile;

                // If a newly added row, remove it and select the first one in list
                if (userBeingEdited.UniqueId.Length == 0)
                {
                    lvUserProfiles.Items.Remove(itemBeingEdited);
                    if (lvUserProfiles.Items.Count > 0)
                    {
                        lvUserProfiles.Items[0].Selected = true;
                        lvUserProfiles.Items[0].Focused  = true;
                    }
                }
                else
                {
                    // Refresh user from rolled back configuration
                    UserProfile refreshUser = ZAMsettings.Settings.UserProfiles[userBeingEdited.UniqueId];
                    UserProfiles_LoadFields(refreshUser);

                    // This will clone the UserProfile so that the listview doesn't have a direct link to the configuration
                    itemBeingEdited.UserProfile = refreshUser;
                }
            }

            EditingUserProfiles = false;
        }
Beispiel #6
0
        private void btnAddProfile_Click(object sender, EventArgs e)
        {
            UserProfileListViewItem item = new UserProfileListViewItem();

            lvUserProfiles.Items.Add(item);
            item.Selected = true;
            item.Focused  = true;

            ZAMsettings.BeginCachedConfiguration();
            EditingUserProfiles = true;
        }
Beispiel #7
0
        private void btnCancelSettings_Click(object sender, EventArgs e)
        {
            ZAMsettings.RollbackCachedConfiguration();

            errorProvider.Clear();

            // Reload values from configuration into fields since cancel was pressed
            SystemSettings_LoadFields();

            EditingSystemSettings = false;
        }
Beispiel #8
0
        private bool m_mouseDown;                                   // for moving window

        public AboutForm()
        {
            InitializeComponent();

            string[] proSuperScript = { "\u1D3E", "\u1D3F", "\u1D3C" };
            this.lblName.Text += $" {proSuperScript[0]}{proSuperScript[1]}{proSuperScript[2]}";


            // This rounds the edges of the borderless window
            this.Region = System.Drawing.Region.FromHrgn(ZAMsettings.CreateRoundRectRgn(0, 0, Width, Height, 15, 15));
            btnClose.FlatAppearance.BorderColor = Color.FromArgb(0, 255, 255, 255); //transparent
        }
Beispiel #9
0
        private void btnEditSettings_Click(object sender, EventArgs e)
        {
            if (ckbCustomized.Checked)
            {
                DialogResult result = MessageBox.Show(this.ParentForm, "Editing settings will overwrite all custom split goals when saved.  Continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                if (result == DialogResult.No)
                {
                    return;
                }
            }

            ZAMsettings.BeginCachedConfiguration();
            EditingSystemSettings = true;
        }
        private void btnSaveSettings_Click(object sender, EventArgs e)
        {
            bool errorOccurred = false;

            errorOccurred = (errorOccurred || ValidateSystemSettings(tbWindowPosX));
            errorOccurred = (errorOccurred || ValidateSystemSettings(tbWindowPosY));
            errorOccurred = (errorOccurred || ValidateSystemSettings(cbNetwork));
            errorOccurred = (errorOccurred || ValidateSystemSettings(cbCurrentUser));
            errorOccurred = (errorOccurred || ValidateSystemSettings(ckbAutoStart));

            if (!errorOccurred)
            {
                ZAMsettings.CommitCachedConfiguration();
                EditingSystemSettings = false;

                ZAMsettings.OnSystemConfigChanged(this, new EventArgs());
            }
        }
Beispiel #11
0
        private void btnSaveSettings_Click(object sender, EventArgs e)
        {
            bool errorOccurred = false;

            if (this.EditingSystemSettings)
            {
                errorOccurred = (errorOccurred || ValidateSystemSettings(this.ckbShowSplits));
                errorOccurred = (errorOccurred || ValidateSystemSettings(this.tbSplitDistance));
                errorOccurred = (errorOccurred || ValidateSystemSettings(this.cbSplitUom));
                errorOccurred = (errorOccurred || ValidateSystemSettings(this.ckbCalculateGoal));
                errorOccurred = (errorOccurred || ValidateSystemSettings(this.dtpGoalTime));
                errorOccurred = (errorOccurred || ValidateSystemSettings(this.tbGoalDistance));

                if (!errorOccurred)
                {
                    // Wipe out splits and recalculate.  These will be saved in settings.
                    ZAMsettings.Settings.SplitsV2.CalculateDefaultSplits();

                    ZAMsettings.CommitCachedConfiguration();
                    EditingSystemSettings = false;

                    ZAMsettings.OnSplitsConfigChanged(this, new EventArgs());

                    // show recalculated splits
                    this.SystemSettings_LoadFields();
                }
            }
            else if (this.EditingSplitSettings)
            {
                errorOccurred = (errorOccurred || ValidateSystemSettings(this.dgvSplits));

                if (!errorOccurred)
                {
                    ZAMsettings.CommitCachedConfiguration();
                    EditingSplitSettings = false;

                    ZAMsettings.OnSplitsConfigChanged(this, new EventArgs());

                    this.SystemSettings_LoadFields();
                }
            }
        }
Beispiel #12
0
 private void btnEditProfile_Click(object sender, EventArgs e)
 {
     ZAMsettings.BeginCachedConfiguration();
     EditingUserProfiles = true;
 }
Beispiel #13
0
 private void btnEditSettings_Click(object sender, EventArgs e)
 {
     ZAMsettings.BeginCachedConfiguration();
     EditingSystemSettings = true;
 }
        /// <summary>
        /// Call this from the ListView's Resize event handler
        /// </summary>
        /// <param name="listView"></param>
        protected static void HideHorizontalScrollBar(ListView listView)
        {
            listView.Scrollable = true;

            ZAMsettings.ShowScrollBar(listView.Handle, 0, false);
        }
Beispiel #15
0
        private void btnSaveProfile_Click(object sender, EventArgs e)
        {
            bool errorOccurred = false;

            // this should not happen
            if (lvUserProfiles.SelectedItems.Count < 1)
            {
                ZAMsettings.RollbackCachedConfiguration();
                EditingUserProfiles = false;
                return;
            }

            UserProfileListViewItem itemBeingEdited = (UserProfileListViewItem)lvUserProfiles.SelectedItems[0];
            UserProfile             userBeingEdited = itemBeingEdited.UserProfile;

            errorOccurred = (errorOccurred || ValidateUserProfiles(tbName));
            errorOccurred = (errorOccurred || ValidateUserProfiles(ckbDefault));
            errorOccurred = (errorOccurred || ValidateUserProfiles(tbWeight));
            errorOccurred = (errorOccurred || ValidateUserProfiles(rbLbs));
            errorOccurred = (errorOccurred || ValidateUserProfiles(rbKgs));
            errorOccurred = (errorOccurred || ValidateUserProfiles(nPowerThreshold));
            errorOccurred = (errorOccurred || ValidateUserProfiles(tbEmailAddr));
            //errorOccurred = (errorOccurred || ValidateUserProfiles(clbCollectors));

            if (!errorOccurred)
            {
                try
                {
                    // Add or Update the UserProfile dictionary in the configuration.
                    ZAMsettings.Settings.UpsertUserProfile(userBeingEdited);

                    ZAMsettings.CommitCachedConfiguration();

                    lvUserProfiles.BeginUpdate();

                    // Refresh the fields and the list view
                    UserProfiles_LoadFields(userBeingEdited);
                    itemBeingEdited.Refresh();

                    //UserProfileListViewItem lvi = new UserProfileListViewItem(userBeingEdited);
                    //lvUserProfiles.Items.Add(lvi);
                    //lvi.Selected = true;

                    //lvUserProfiles.Items.Remove(itemBeingEdited);

                    foreach (UserProfileListViewItem item in lvUserProfiles.Items)
                    {
                        bool isDefault = (item.UserProfile.UniqueId == ZAMsettings.Settings.DefaultUserProfile);

                        if (item.UserProfile.Default != isDefault)
                        {
                            item.UserProfile.Default = isDefault;
                            item.Refresh();
                        }
                    }

                    lvUserProfiles.EndUpdate();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Exception occurred: " + ex.ToString(), "Error saving User Profile", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    errorOccurred = true;
                }
                finally
                {
                    EditingUserProfiles = false;
                }
            }
        }
Beispiel #16
0
        private void btnStatsSave_Click(object sender, EventArgs e)
        {
            bool errorOccurred = false;

            // this should not happen
            if (lvCollectors.SelectedItems.Count < 1)
            {
                ZAMsettings.RollbackCachedConfiguration();
                EditingCollectors = false;
                return;
            }

            CollectorListViewItem itemBeingEdited      = (CollectorListViewItem)lvCollectors.SelectedItems[0];
            Collector             collectorBeingEdited = itemBeingEdited.Collector;

            errorOccurred = (errorOccurred || ValidateStatistics(rbAvgHide));
            errorOccurred = (errorOccurred || ValidateStatistics(rbAvgWatts));
            errorOccurred = (errorOccurred || ValidateStatistics(rbAvgWkg));

            errorOccurred = (errorOccurred || ValidateStatistics(rbAvgMaxHide));
            errorOccurred = (errorOccurred || ValidateStatistics(rbAvgMaxWatts));
            errorOccurred = (errorOccurred || ValidateStatistics(rbAvgMaxWkg));

            errorOccurred = (errorOccurred || ValidateStatistics(rbFtpHide));
            errorOccurred = (errorOccurred || ValidateStatistics(rbFtpWatts));
            errorOccurred = (errorOccurred || ValidateStatistics(rbFtpWkg));

            if (!errorOccurred)
            {
                try
                {
                    // Add or Update the Collector dictionary in the configuration.
                    ZAMsettings.Settings.UpsertCollector(collectorBeingEdited);

                    ZAMsettings.CommitCachedConfiguration();

                    lvCollectors.BeginUpdate();

                    // Refresh the fields and the list view
                    Collectors_LoadFields(collectorBeingEdited);
                    itemBeingEdited.Refresh();

                    //CollectorListViewItem lvi = new CollectorListViewItem(collectorBeingEdited);
                    //lvCollectors.Items.Add(lvi);
                    //lvi.Selected = true;

                    //lvCollectors.Items.Remove(itemBeingEdited);

                    lvCollectors.EndUpdate();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Exception occurred: " + ex.ToString(), "Error saving Collector", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    errorOccurred = true;
                }
                finally
                {
                    EditingCollectors = false;
                }
            }
        }
Beispiel #17
0
 private void btnStatsEdit_Click(object sender, EventArgs e)
 {
     ZAMsettings.BeginCachedConfiguration();
     EditingCollectors = true;
 }
Beispiel #18
0
        public static Task Main(string[] args)
        {
            Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("NDUzNDQzQDMxMzkyZTMxMmUzMEF2Ymt3ckxSUkpCUU8yOHE4dldsYVVxRHBpVlNYNGhtcjdjVHI1MHd5WmM9");

            System.Windows.Forms.Application.EnableVisualStyles();

            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

            var executableLocation = Path.GetDirectoryName(typeof(Program).Assembly.Location);

            var host = new HostBuilder()
                       .ConfigureWinForms <SplashScreen>()
                       .ConfigureConfiguration(args)
                       .ConfigureLogging()
                       .ConfigureSingleInstance(builder =>
            {
                builder.MutexId = "{80B16FA8-ECAE-4DD8-9F8A-FE7E6780A825}";
                builder.WhenNotFirstInstance = (hostingEnvironment, logger) =>
                {
                    // This is called when an instance was already started, this is in the second instance
                    logger.LogWarning("Application {0} already running.", hostingEnvironment.ApplicationName);
                };
            })
                       .ConfigureServices(serviceCollection =>
            {
                // Add the ZwiftPacketMonitor extensions
                ZwiftPacketMonitor.RegistrationExtensions.AddZwiftPacketMonitoring(serviceCollection);

                // add our ZwiftPacketMonitor wrapper service
                serviceCollection.AddSingleton <ZPMonitorService>();

                //serviceCollection.AddTransient<AdvancedOptions>();
                //serviceCollection.AddTransient<ConfigurationOptions>();
                //serviceCollection.AddTransient<MonitorTimer>();
            })
                       .UseWinFormsLifetime()
                       .Build();


            ILoggerFactory   lf = host.Services.GetRequiredService <ILoggerFactory>();
            ZPMonitorService zp = host.Services.GetRequiredService <ZPMonitorService>();

            ZAMsettings.Initialize(lf, zp);

            // Uncomment to test logging setup in json configuration
            //ILogger logger = lf.CreateLogger("Testing Logger");

            //logger.LogTrace("This is a trace message. Should be discarded.");
            //logger.LogDebug("This is a debug message. Should be seen in development.");
            //logger.LogDebug("This is an info message. Should be seen in development.");
            //logger.LogWarning("This is a warning message. Should be seen everywhere.");
            //logger.LogError("This is an error message. Should be seen everywhere..");
            //logger.LogCritical("This is a critical message. Should be seen everywhere.");

            //try
            //{
            //    throw new ApplicationException("Some Exception");
            //}
            //catch (Exception ex)
            //{
            //    logger.LogError(ex, $"This is a test of exception logging logic.");
            //}


            return(host.RunAsync());
        }