Beispiel #1
0
        private void ButtonApply_Click(object sender, EventArgs e)
        {
            // Save profiles
            ProfileManager.SaveProfiles();

            // Update fallback profile
            fallbackProfile = new Profile("", MouseParams.GetSpeed(), MouseParams.GetAcceleration());

            // Refresh displayed settings
            RefreshCurrentSettings();
        }
Beispiel #2
0
        private void ContextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // Get current mouse parameters
            int  speed        = MouseParams.GetSpeed();
            bool acceleration = MouseParams.GetAcceleration();

            // Remove old items
            contextMenuStrip.Items.Clear();

            // Add top items
            contextMenuStrip.Items.AddRange(toolStripMenuItemsTop);

            // Check whether mouse profiles exist
            ProfileManager.LoadProfiles();
            if (ProfileManager.Profiles.Count > 0)
            {
                // Store number of items at top of menu for use as index shift correction
                int shift = toolStripMenuItemsTop.Count();

                // Add an item for each mouse profile
                for (int i = 0; i < ProfileManager.Profiles.Count; i++)
                {
                    Profile profile = ProfileManager.Profiles[i];

                    // Include the index as the name property of the item for identification
                    string text = (profile.Name == null || profile.Name.Trim() == "") ? "Untitled profile" : profile.Name.Trim();
                    contextMenuStrip.Items.Add(new ToolStripMenuItem(text, null, null, i.ToString()));

                    // Check item if associated profile is active
                    if (contextMenuStrip.Items[shift + i] is ToolStripMenuItem item)
                    {
                        item.Checked = profile.Speed == speed && profile.Acceleration == acceleration;
                    }
                }
            }
            else
            {
                // Add item with useful message
                contextMenuStrip.Items.Add(new ToolStripMenuItem("No saved profiles", null));
            }

            // Add bottom items
            contextMenuStrip.Items.AddRange(toolStripMenuItemsBottom);

            // Set cancel to false
            // By default this is set to true for optimisation if unspecified
            e.Cancel = false;
        }
Beispiel #3
0
        // Constructors

        public ProfileForm()
        {
            // Store current profile
            fallbackProfile = new Profile("", MouseParams.GetSpeed(), MouseParams.GetAcceleration());

            // Initialise form (designer code)
            InitializeComponent();
            Text = Application.ProductName;

            // Initialise data grid
            DataGridViewProfiles();

            // Initialise menu strip
            toolStripMenuItemAbout.Text = "&About " + Application.ProductName;

            // Display current mouse settings
            RefreshCurrentSettings();

            // Assign event handlers
            FormClosing                                       += ProfileForm_FormClosing;
            buttonApply.Click                                 += ButtonApply_Click;
            buttonCancel.Click                                += ButtonCancel_Click;
            buttonDonate.Click                                += ButtonDonate_Click;;
            buttonOK.Click                                    += ButtonOK_Click;
            buttonRefresh.Click                               += ButtonRefresh_Click;
            dataGridViewProfiles.CellClick                    += DataGridViewProfiles_CellClick;
            dataGridViewProfiles.CellPainting                 += DataGridViewProfiles_CellPainting;
            dataGridViewProfiles.CellValueChanged             += DataGridViewProfiles_CellValueChanged;
            dataGridViewProfiles.CurrentCellDirtyStateChanged += DataGridViewProfiles_CurrentCellDirtyStateChanged;
            dataGridViewProfiles.DataError                    += DataGridViewProfiles_DataError;
            dataGridViewProfiles.EditingControlShowing        += DataGridViewProfiles_EditingControlShowing;
            dataGridViewProfiles.RowPostPaint                 += DataGridViewProfiles_RowPostPaint;
            dataGridViewProfiles.RowsAdded                    += DataGridViewProfiles_RowsAdded;
            dataGridViewProfiles.RowsRemoved                  += DataGridViewProfiles_RowsRemoved;
            toolStripMenuItemAbout.Click                      += ToolStripMenuItemAbout_Click;
            toolStripMenuItemDonate.Click                     += ToolStripMenuItemDonate_Click;
            toolStripMenuItemOptions.Click                    += ToolStripMenuItemOptions_Click;

            // Load saved profiles and reset bindings for data grid
            ProfileManager.LoadProfiles();
            bindingSourceProfiles.ResetBindings(false);
        }
Beispiel #4
0
        public void ShowActiveProfiles()
        {
            // Get current mouse parameters
            int  speed        = MouseParams.GetSpeed();
            bool acceleration = MouseParams.GetAcceleration();

            // Unassign event handler to prevent StackOverFlowException on subsequent cell value changes
            dataGridViewProfiles.CellValueChanged -= DataGridViewProfiles_CellValueChanged;

            // Go through each row and show whether the corresponding profile is active
            foreach (DataGridViewRow row in dataGridViewProfiles.Rows)
            {
                if (!row.IsNewRow)
                {
                    row.Cells[columnActive.Index].Value = (int)row.Cells[columnSpeed.Index].Value == speed && (bool)row.Cells[columnAcceleration.Index].Value == acceleration;
                }
            }

            // Reassign event handler
            dataGridViewProfiles.CellValueChanged += DataGridViewProfiles_CellValueChanged;
        }
Beispiel #5
0
 public void RefreshCurrentSettings()
 {
     // Display the current mouse settings
     textBoxSpeed.Text        = MouseParams.GetSpeed().ToString();
     textBoxAcceleration.Text = MouseParams.GetAcceleration().ToString();
 }