Exemplo n.º 1
0
        private void operationCheckedChanged(object sender, EventArgs e)
        {
            // Handle operation toggle and ensure that at least one toggle is always on
            // If one toggle is on and it is being turned off, turn all others on
            int checks = 0;

            foreach (Control ctrl in operationsGroupBox.Controls)
            {
                if (ctrl is MetroToggle)
                {
                    MetroToggle mt = (MetroToggle)ctrl;
                    if (mt.Checked)
                    {
                        checks++;
                    }
                }
            }

            MetroToggle mtsender = (MetroToggle)sender;

            if (!mtsender.Checked && checks < 1)
            {
                foreach (Control ctrl in operationsGroupBox.Controls)
                {
                    if (ctrl is MetroToggle)
                    {
                        MetroToggle mt = (MetroToggle)ctrl;
                        if (!mt.Equals(mtsender))
                        {
                            mt.Checked = true;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void chk_Click(object sender, EventArgs e)
        {
            MetroToggle chk = (MetroToggle)sender;

            setCheckBoxes(chk.Tag);
            refreshAvailableContacts();
        }
Exemplo n.º 3
0
        private List <Operation> GetOperations()
        {
            List <Operation> operations = new List <Operation>();

            // Iterate all controls
            foreach (Control ctrl in operationsGroupBox.Controls)
            {
                // Check if control is a toggle
                if (ctrl is MetroToggle)
                {
                    MetroToggle toggle = (MetroToggle)ctrl;

                    // A disabled toggle means a disabled operation - No further action req'd
                    if (!toggle.Checked)
                    {
                        continue;
                    }

                    // Iterate available operations
                    foreach (Operation operation in Operation.all)
                    {
                        // Check if that operation's toggle matches the current iteration toggle
                        if (operation.Toggle.Equals(toggle))
                        {
                            // Add operation to list for its toggle is assigned and enabled
                            operations.Add(operation);
                            break;
                        }
                    }
                }
            }

            return(operations);
        }
Exemplo n.º 4
0
        private void clientToggle_CheckedChanged(object sender, EventArgs e)
        {
            MetroToggle toggle = (MetroToggle)sender;

            lbl_ipServer.Visible   = !toggle.Checked;
            lblRunAsServer.Visible = !toggle.Checked;
            txtServer.Visible      = toggle.Checked;
            lblRunAsClient.Visible = toggle.Checked;
        }
Exemplo n.º 5
0
        private void InitializeComponent()
        {
            m_toggle = new MetroToggle();
            MetroSkinManager.ApplyMetroStyle(m_toggle);
            m_toggle.Top             = Height;
            m_toggle.CheckedChanged += new EventHandler(m_toggle_CheckedChanged);
            Controls.Add(m_toggle);

            Height += m_toggle.Height;
        }
Exemplo n.º 6
0
        private void operationsMouseUp(object sender, MouseEventArgs e)
        {
            // If a toggle is right-clicked, toggle it and set all other toggles in group to inverse state
            if (e.Button == MouseButtons.Right)
            {
                MetroToggle mtsender = (MetroToggle)sender;
                mtsender.Checked = !mtsender.Checked;

                foreach (Control ctrl in operationsGroupBox.Controls)
                {
                    if (ctrl is MetroToggle && !ctrl.Name.Equals(mtsender.Name))
                    {
                        MetroToggle mt = (MetroToggle)ctrl;
                        mt.Checked = !mtsender.Checked;
                    }
                }
            }
        }
Exemplo n.º 7
0
        protected Operation(string identifier, int factorMinimum, int factorMaximum, MetroToggle toggle)
        {
            // Store operation information
            Identifier         = identifier;
            this.factorMinimum = factorMinimum;
            this.factorMaximum = factorMaximum;
            Toggle             = toggle;

            // Add operation to "all" list if it one of subtype doesn't already exist
            foreach (Operation operation in all)
            {
                if (operation.GetType().Equals(GetType()))
                {
                    return;
                }
            }

            all.Add(this);
        }
Exemplo n.º 8
0
        public SettingsControl(string key, string value = null)
        {
            this.key = new MetroTextBox();
            this.key.UseStyleColors = true;
            this.equalsSign         = new MetroLabel();
            this.Size                = new System.Drawing.Size(450, 25);
            this.key.Width           = 200;
            this.equalsSign.AutoSize = true;
            this.equalsSign.Size     = new Size(10, 20);
            this.key.Width           = 200;
            this.key.Location        = new Point(0, 0);
            this.equalsSign.Location = new Point(210, 0);
            this.equalsSign.Text     = "=";
            this.key.ReadOnly        = true;

            Controls.Add(this.equalsSign);
            Controls.Add(this.key);

            if (value.ToLower() == "true" || value.ToLower() == "false")
            {
                this.boolValue = new MetroToggle();
                this.boolValue.UseStyleColors = true;
                this.boolValue.Width          = 100;
                this.boolValue.Height         = 20;
                this.boolValue.Location       = new Point(230, 0);
                this.boolValue.Checked        = value.ToLower() == "true";
                Controls.Add(this.boolValue);
            }
            else
            {
                this.textValue          = new MetroTextBox();
                this.textValue.Width    = 200;
                this.textValue.Location = new Point(230, 0);
                this.textValue.Text     = value;
                Controls.Add(this.textValue);
            }
            this.key.Text = key;
        }
Exemplo n.º 9
0
 void MoveToHome(MetroTrackBar metroTrackBar, MetroToggle metroToggle, TextBox textBox)
 {
     timer1.Interval = 1;
     if (z >= 0 && movimentoNeg == false && metroToggle.Checked == false) // movimento negativo rapido
     {
         metroTrackBar.Value = z;
         textBox.Text        = z.ToString();
         z--;
     }
     if (z >= 0 && movimentoNeg == false && metroToggle.Checked == true && velocidade != 0) // movimento negativo lento
     {
         timer1.Interval     = n;
         metroTrackBar.Value = z;
         textBox.Text        = z.ToString();
         z--;
         n++;
         velocidade--;
         if (velocidade == 0)
         {
             movimentoNeg = true;
         }
     }
     if (z >= 0 && movimentoNeg == true && metroToggle.Checked == true && velocidade == 0) //
     {
         timer1.Interval     = 100;
         metroTrackBar.Value = z;
         textBox.Text        = z.ToString();
         z++;
     }
     if (z >= 0 && movimentoNeg == true && metroToggle.Checked == false) //
     {
         timer1.Stop();
         velocidade = 100;
         n          = 10; // valor de intervalo
         caseSwitch++;
         Repeat();
     }
 }
Exemplo n.º 10
0
        private void metroButton7_Click(object sender, EventArgs e)
        {
            var        allFullPanels = trackPanel.Controls.OfType <MetroPanel>().OrderBy(c => c.TabIndex);
            MetroPanel lastFullPanel = allFullPanels.Last();
            MetroPanel newFullPanel  = new MetroPanel();

            newFullPanel.Location = new Point(lastFullPanel.Location.X + lastFullPanel.Size.Width + 40, lastFullPanel.Location.Y);
            newFullPanel.Size     = lastFullPanel.Size;
            newFullPanel.TabIndex = lastFullPanel.TabIndex + 1;
            newFullPanel.Visible  = true;

            for (int i = 0; i < 4; i++)
            {
                MetroPanel newQuarterPanel = new MetroPanel();
                newQuarterPanel.Location = new Point(i * 50, 5);
                newQuarterPanel.TabIndex = i;
                newQuarterPanel.Size     = new Size(40, 90);
                newQuarterPanel.Visible  = true;

                for (int ii = 0; ii < 4; ii++)
                {
                    MetroToggle newToggleButton = new MetroToggle();
                    newToggleButton.AutoSize      = false;
                    newToggleButton.Size          = new Size(30, 17);
                    newToggleButton.Location      = new Point(5, (ii * 20) + 5);
                    newToggleButton.TabIndex      = ii;
                    newToggleButton.Tag           = ii;
                    newToggleButton.Visible       = true;
                    newToggleButton.DisplayStatus = false;
                    newQuarterPanel.Controls.Add(newToggleButton);
                }

                newFullPanel.Controls.Add(newQuarterPanel);
            }

            trackPanel.Controls.Add(newFullPanel);
        }
Exemplo n.º 11
0
 /* SubtractOperation
  * Object for storage of data regarding the subtract operation
  */
 internal SubtractOperation(int factorMinimum, int factorMaximum, MetroToggle toggle) : base("-", factorMinimum, factorMaximum, toggle)
 {
 }
Exemplo n.º 12
0
 /* MultiplyOperation
  * Object for storage of data regarding the multiply operation
  */
 internal MultiplyOperation(int factorMinimum, int factorMaximum, MetroToggle toggle) : base("x", factorMinimum, factorMaximum, toggle)
 {
 }
Exemplo n.º 13
0
 /* DivideOperation
  * Object for storage of data regarding the divide operation
  */
 internal DivideOperation(int factorMinimum, int factorMaximum, MetroToggle toggle) : base("/", factorMinimum, factorMaximum, toggle)
 {
 }
Exemplo n.º 14
0
 internal AddOperation(int factorMinimum, int factorMaximum, MetroToggle toggle) : base("+", factorMinimum, factorMaximum, toggle)
 {
 }