/// <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();
public void SetText() { txtVal1.Text = ValueMin.ToString("0.###"); txtVal2.Text = ValueMax.ToString("0.###"); numGain.Value = (decimal)Gain; Refresh(); }
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)); } }
protected override void OnPaint(PaintEventArgs e) { var G = e.Graphics; float max = ValueMax ?? (Values.Count() > 0 ? Values.Max() : 0); float min = ValueMin ?? (Values.Count() > 0 ? Values.Min() : 0); float averagegeCount = (max - min) / ValueStripes; float currentCount = max; G.SmoothingMode = SmoothingMode.HighQuality; float startWidthPosition = ValueMax == null ? GraphicsHelper.GetTextWidthInPixels(Values.Select(a => a.ToString()).OrderByDescending(a => a.Length).FirstOrDefault(), FontText) : GraphicsHelper.GetTextWidthInPixels(ValueMax.ToString(), FontText); float chartHeight = Height - 17; float itemHeight = 10; G.FillPath(fillheaderColor, RoundedRectangle.Create(0, 0, Width - 1, Height - 1, 4)); for (int i = 0; i <= ValueStripes; i++) { G.DrawLine(new Pen(ColorStripes, SizeStripes), startWidthPosition, itemHeight, Width, itemHeight); G.DrawString((Math.Floor(currentCount)).ToString(), FontText, new SolidBrush(ColorText), 0, itemHeight - 7); itemHeight += chartHeight / ValueStripes; currentCount -= averagegeCount; } float lastItemHeight = (chartHeight - (chartHeight / (max - min) * (Values.FirstOrDefault() - min))) + 10; float lastItemWidth = startWidthPosition; float itemWidth = startWidthPosition; foreach (var value in Values) { var valueMin = value - min; var item = chartHeight - (chartHeight / (max - min) * valueMin); item = item == chartHeight ? chartHeight + 10 : item + 10; var currentBrush = FoxSettings.UpColor; G.DrawLine(new Pen(currentBrush.Color, SizeValues), lastItemWidth, lastItemHeight, itemWidth, item); G.FillEllipse(currentBrush, itemWidth - (SizeValues / 2), item - (SizeValues / 2), SizeValues, SizeValues); lastItemHeight = item; lastItemWidth = itemWidth; itemWidth += Width / Values.Count(); } }
private void txtVal2_Leave(object sender, EventArgs e) { txtVal2.Text = ValueMax.ToString("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; } } } }
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; }