Exemplo n.º 1
0
        private void Ranger_Load(object sender, EventArgs e)
        {
            txtVal1.Text = ValueMin.ToString("0.###");
            txtVal2.Text = ValueMax.ToString("0.###");

            Refresh();
        }
Exemplo n.º 2
0
        private void NumberUpDownControl_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (_ignoreTextUpdate)
            {
                return;
            }

            short number = 0;

            if (!string.IsNullOrWhiteSpace(NumberUpDownControlTextBox.Text))
            {
                if (!short.TryParse(NumberUpDownControlTextBox.Text, out number))
                {
                    NumberUpDownControlTextBox.Text = ValueStart.ToString();
                }
            }
            if (number > ValueMax)
            {
                NumberUpDownControlTextBox.Text = ValueMax.ToString();
            }
            if (number < ValueMin)
            {
                NumberUpDownControlTextBox.Text = ValueMin.ToString();
            }
            NumberUpDownControlTextBox.SelectionStart = NumberUpDownControlTextBox.Text.Length;
            CurrentValue = number;
        }
Exemplo n.º 3
0
 public void SetText()
 {
     txtVal1.Text  = ValueMin.ToString("0.###");
     txtVal2.Text  = ValueMax.ToString("0.###");
     numGain.Value = (decimal)Gain;
     Refresh();
 }
 /// <inheritdoc/>
 public override int GetHashCode()
 => Role.GetHashCode() ^
 Name.GetHashCode() ^
 Value.GetHashCode() ^
 Description.GetHashCode() ^
 KeyShortcuts.GetHashCode() ^
 RoleDescription.GetHashCode() ^
 ValueText.GetHashCode() ^
 AutoComplete.GetHashCode() ^
 HasPopup.GetHashCode() ^
 Orientation.GetHashCode() ^
 Disabled.GetHashCode() ^
 Expanded.GetHashCode() ^
 Focused.GetHashCode() ^
 Modal.GetHashCode() ^
 Multiline.GetHashCode() ^
 Multiselectable.GetHashCode() ^
 Readonly.GetHashCode() ^
 Required.GetHashCode() ^
 Selected.GetHashCode() ^
 Pressed.GetHashCode() ^
 Checked.GetHashCode() ^
 Level.GetHashCode() ^
 ValueMin.GetHashCode() ^
 ValueMax.GetHashCode() ^
 Children.GetHashCode();
Exemplo n.º 5
0
        //public string Text { get; set; }

        public override string ToString()
        {
            var str = new StringBuilder(Currency, 4);

            str.Append(ValueMin.ToString());
            if (ValueMax > 0)
            {
                str.Append(" - ");
                str.Append(ValueMax.ToString());
            }
            return(str.ToString());
        }
Exemplo n.º 6
0
        private void CGauge_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                rightClickMinimumTextbox.Text = ValueMin.ToString();
                rightClickMaximumTextbox.Text = ValueMax.ToString();
                rightClickWarningTextbox.Text = (ThresholdWarning / 100).ToString("0%");
                rightClickAlarmTextbox.Text   = (ThresholdAlarm / 100).ToString("0%");

                rightClickMenu.Show(this, new Point(e.X, e.Y));
            }
        }
Exemplo n.º 7
0
 private void txtVal1_Leave(object sender, EventArgs e)
 {
     txtVal1.Text = ValueMin.ToString("0.###");
 }
Exemplo n.º 8
0
        private void RangerMouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right)
            {
                int barWidth = Width - 16;
                switch (_currentGrab)
                {
                case GrabSelected.MinGrab:
                    ValueMin = (e.X - 8) / ((Convert.ToDouble(barWidth) / (Maximum - Minimum)));
                    if (ValueMin < Minimum)
                    {
                        ValueMin = Minimum;
                    }
                    if (ValueMin > Maximum)
                    {
                        ValueMin = Maximum;
                    }

                    if (ValueMin > ValueMax)
                    {
                        ValueMax = ValueMin;
                    }
                    break;

                case GrabSelected.MaxGrab:
                    ValueMax = (e.X - 8) / ((Convert.ToDouble(barWidth) / (Maximum - Minimum)));
                    if (ValueMax < Minimum)
                    {
                        ValueMax = Minimum;
                    }
                    if (ValueMax > Maximum)
                    {
                        ValueMax = Maximum;
                    }

                    if (ValueMax < ValueMin)
                    {
                        ValueMin = ValueMax;
                    }
                    break;
                }

                txtVal1.Text = ValueMin.ToString("0.###");
                txtVal2.Text = ValueMax.ToString("0.###");
                Refresh();
            }
            else
            {
                Cursor = Cursors.Default;
                int barWidth = Width - 16;
                int x1       = 8 + Convert.ToInt32((Convert.ToDouble(barWidth) / (Maximum - Minimum)) * ValueMin);
                int x2       = 8 + Convert.ToInt32((Convert.ToDouble(barWidth) / (Maximum - Minimum)) * ValueMax);
                if (e.X > x1 - 5 && e.X < x1 + 5 && e.Y > 3 && e.Y < 19)
                {
                    Cursor = Cursors.Hand;
                }
                else
                {
                    if (e.X > x2 - 5 && e.X < x2 + 5 && e.Y > 3 && e.Y < 19)
                    {
                        Cursor = Cursors.Hand;
                    }
                }
            }
        }
Exemplo n.º 9
0
        public void drawSlider()
        {
            int top = aff.Height / 3, height = aff.Height * 1 / 3;

            g.Clear(backColor);               //.FillRectangle( new SolidBrush( Color.White ), 0, 0, aff.Width, aff.Height );

            #region color bars
            if (red > ValueMin)
            {
                Rectangle rRed = new Rectangle(
                    8,
                    top,
                    ((red - ValueMin) * (aff.Width - 16)) / ((ValueMax - ValueMin) != 0 ? (ValueMax - ValueMin) : 1),
                    height
                    );

                g.FillRectangle(
                    new SolidBrush(Color.Red),
                    rRed
                    );
            }
            if (yellow > ValueMin)
            {
                int left;
                if (red <= ValueMin)
                {
                    left = 0;
                }
                else
                {
                    left = ((red - ValueMin) * (aff.Width - 16)) / ((ValueMax - ValueMin) != 0 ? (ValueMax - ValueMin) : 1) + 8;
                }

                Rectangle rYellow = new Rectangle(
                    left,                     // ( ( red - ValueMin ) * ( aff.Width - 16 ) ) / ( ValueMax - ValueMin ) + 8,
                    top,
                    ((yellow - ValueMin) * (aff.Width - 16)) / ((ValueMax - ValueMin) != 0 ? (ValueMax - ValueMin) : 1) - ((red - ValueMin) * (aff.Width - 16)) / ((ValueMax - ValueMin) != 0 ? (ValueMax - ValueMin) : 1),
                    height
                    );

                g.FillRectangle(
                    new SolidBrush(Color.Yellow),
                    rYellow
                    );
            }
            if (green > ValueMin)
            {
                if (yellow > 0)
                {
                    Rectangle rGreen = new Rectangle(
                        ((yellow - ValueMin) * (aff.Width - 16)) / ((ValueMax - ValueMin) != 0 ? (ValueMax - ValueMin) : 1) + 8,
                        top,
                        ((green - ValueMin) * (aff.Width - 16)) / ((ValueMax - ValueMin) != 0 ? (ValueMax - ValueMin) : 1) - ((yellow - ValueMin) * (aff.Width - 16)) / ((ValueMax - ValueMin) != 0 ? (ValueMax - ValueMin) : 1),
                        height
                        );

                    g.FillRectangle(
                        new SolidBrush(Color.Green),
                        rGreen
                        );
                }
                else
                {
                    Rectangle rGreen = new Rectangle(
                        ((red - ValueMin) * (aff.Width - 16)) / ((ValueMax - ValueMin) != 0 ? (ValueMax - ValueMin) : 1) + 8,
                        top,
                        ((green - ValueMin) * (aff.Width - 16)) / ((ValueMax - ValueMin) != 0 ? (ValueMax - ValueMin) : 1) - ((red - ValueMin) * (aff.Width - 16)) / ((ValueMax - ValueMin) != 0 ? (ValueMax - ValueMin) : 1),
                        height
                        );

                    g.FillRectangle(
                        new SolidBrush(Color.Green),
                        rGreen
                        );
                }
            }
            #endregion

            #region main lines
            g.DrawLine(
                grayPen,
                8,
                1,
                8,
                aff.Height - 1
                );
            g.DrawLine(
                grayPen,
                8,
                aff.Height / 2,
                aff.Width - 8,
                aff.Height / 2
                );
            g.DrawLine(
                grayPen,
                aff.Width - 7,
                1,
                aff.Width - 7,
                aff.Height - 1
                );

            Pen tempBlackPen;
            /*if ( enabled )*/
            tempBlackPen = blackPen;

            /*	else
             *              tempBlackPen = new Pen( Color.DarkGray );*/

            g.DrawLine(
                tempBlackPen,
                7,
                0,
                7,
                aff.Height - 2
                );
            g.DrawLine(
                tempBlackPen,
                8 - 1,
                aff.Height / 2 - 1,
                aff.Width - 8 - 1,
                aff.Height / 2 - 1
                );
            g.DrawLine(
                tempBlackPen,
                aff.Width - 8,
                0,
                aff.Width - 8,
                aff.Height - 2
                );
            #endregion

            #region line at 0
            if (ValueMin != 0)
            {
                // 0 - 2
                g.DrawLine(
                    blackPen,
                    ((0 - ValueMin) * (aff.Width - 16)) / (ValueMax - ValueMin) + 8,
                    0,
                    ((0 - ValueMin) * (aff.Width - 16)) / (ValueMax - ValueMin) + 8,
                    aff.Height - 2
                    );
                g.DrawLine(
                    grayPen,
                    ((0 - ValueMin) * (aff.Width - 16)) / (ValueMax - ValueMin) + 9,
                    1,
                    ((0 - ValueMin) * (aff.Width - 16)) / (ValueMax - ValueMin) + 9,
                    aff.Height / 2 - 2
                    );
                g.DrawLine(
                    grayPen,
                    ((0 - ValueMin) * (aff.Width - 16)) / (ValueMax - ValueMin) + 9,
                    aff.Height / 2,
                    ((0 - ValueMin) * (aff.Width - 16)) / (ValueMax - ValueMin) + 9,
                    aff.Height - 1
                    );
            }
            #endregion

            #region default value
            if (defaultValue != 0)
            {
                g.DrawLine(
                    blackPen,
                    ((defaultValue - ValueMin) * (aff.Width - 16)) / (ValueMax - ValueMin) + 8,
                    aff.Height / 4 - 1,
                    ((defaultValue - ValueMin) * (aff.Width - 16)) / (ValueMax - ValueMin) + 8,
                    aff.Height * 3 / 4 - 1
                    );
                g.DrawLine(
                    grayPen,
                    ((defaultValue - ValueMin) * (aff.Width - 16)) / (ValueMax - ValueMin) + 9,
                    aff.Height / 4 + 1 - 1,
                    ((defaultValue - ValueMin) * (aff.Width - 16)) / (ValueMax - ValueMin) + 9,
                    aff.Height / 2 - 2
                    );
                g.DrawLine(
                    grayPen,
                    ((defaultValue - ValueMin) * (aff.Width - 16)) / (ValueMax - ValueMin) + 9,
                    aff.Height / 2,
                    ((defaultValue - ValueMin) * (aff.Width - 16)) / (ValueMax - ValueMin) + 9,
                    aff.Height * 3 / 4 + 1 - 1
                    );
            }
            #endregion

            #region text
            if (Text != "")
            {
                Font fntText = new Font("Tahoma", 10, FontStyle.Regular);
                g.DrawString(
                    Text,
                    fntText,
                    new SolidBrush(Color.White),
                    11,
                    -3
                    );
                g.DrawString(
                    Text,
                    fntText,
                    new SolidBrush(Color.DarkGray),
                    13,
                    -3
                    );
                g.DrawString(
                    Text,
                    fntText,
                    new SolidBrush(Color.Black),
                    12,
                    -4
                    );
            }
            #endregion

            #region text2
            if (Text2 != "")
            {
                Font  fntText  = new Font("Tahoma", 8, FontStyle.Regular);
                SizeF sizeText = g.MeasureString(Text2, fntText);

                g.DrawString(
                    Text2,
                    fntText,
                    new SolidBrush(Color.White),
                    aff.Width - sizeText.Width - 10,
                    aff.Height - sizeText.Height + 1
                    );
                g.DrawString(
                    Text2,
                    fntText,
                    new SolidBrush(Color.DarkGray),
                    aff.Width - sizeText.Width - 8,
                    aff.Height - sizeText.Height + 1
                    );
                g.DrawString(
                    Text2,
                    fntText,
                    new SolidBrush(Color.Black),
                    aff.Width - sizeText.Width - 9,
                    aff.Height - sizeText.Height
                    );
            }
            #endregion

            #region showMax
            if (showMax)
            {
                Font  fntText  = new Font("Tahoma", 7, FontStyle.Regular);
                SizeF sizeText = g.MeasureString(ValueMax.ToString() + maxInfo, fntText);

                g.DrawString(
                    ValueMax.ToString() + maxInfo,
                    fntText,
                    new SolidBrush(Color.White),
                    aff.Width - sizeText.Width - 10,
                    -3 + 2
                    );
                g.DrawString(
                    ValueMax.ToString() + maxInfo,
                    fntText,
                    new SolidBrush(Color.DarkGray),
                    aff.Width - sizeText.Width - 8,
                    -3 + 2
                    );
                g.DrawString(
                    ValueMax.ToString() + maxInfo,
                    fntText,
                    new SolidBrush(Color.Black),
                    aff.Width - sizeText.Width - 9,
                    -4 + 2
                    );

                //	fntText = new Font( "Tahoma", 10, FontStyle.Regular );
                sizeText = g.MeasureString(ValueMin.ToString() + maxInfo, fntText);

                g.DrawString(
                    ValueMin.ToString() + maxInfo,
                    fntText,
                    new SolidBrush(Color.White),
                    11,
                    aff.Height - sizeText.Height + 1
                    );
                g.DrawString(
                    ValueMin.ToString() + maxInfo,
                    fntText,
                    new SolidBrush(Color.DarkGray),
                    13,
                    aff.Height - sizeText.Height + 1
                    );
                g.DrawString(
                    ValueMin.ToString() + maxInfo,
                    fntText,
                    new SolidBrush(Color.Black),
                    12,
                    aff.Height - sizeText.Height
                    );
            }
            #endregion

            #region ellipse

            int sliderWidth = 6 * platformSpec.resolution.mod;

            Rectangle r = new Rectangle(
                ((Value - ValueMin) * (aff.Width - 16)) / (ValueMax - ValueMin) + 8 - sliderWidth / 2,
                0,
                sliderWidth,
                aff.Height - 1
                );

            if (enabled)
            {
                if (Value <= red && red > ValueMin)
                {
                    g.FillEllipse(
                        new SolidBrush(Color.Red),
                        r
                        );
                }
                else if (Value <= yellow && yellow > ValueMin)
                {
                    g.FillEllipse(
                        new SolidBrush(Color.Yellow),
                        r
                        );
                }
                else if (Value <= green && green > ValueMin)
                {
                    g.FillEllipse(
                        new SolidBrush(Color.Green),
                        r
                        );
                }
                else
                {
                    g.FillEllipse(
                        new SolidBrush(Color.White),
                        r
                        );
                }
            }
            else
            {
                g.FillEllipse(
                    new SolidBrush(Color.DimGray),
                    r
                    );
            }

            g.DrawEllipse(
                new Pen(Color.Black),
                r
                );

            #endregion

            picBox.Image = aff;
        }