/// <summary> /// 彩色的色标带。 /// </summary> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> /// <param name="zNear"></param> /// <param name="zFar"></param> public UIColorPaletteBarRenderer( CodedColor[] codedColors, System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int zNear, int zFar) : base(anchor, margin, size, zNear, zFar) { this.codedColors = codedColors; var model = new QuadStripModel(1); this.Renderer = QuadStripRenderer.Create(model); }
/// <summary> /// 彩色的色标带。 /// </summary> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> /// <param name="zNear"></param> /// <param name="zFar"></param> public UIColorPaletteColoredBarRenderer( int maxMarkerCount, CodedColor[] codedColors, System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int zNear, int zFar) : base(anchor, margin, size, zNear, zFar) { this.codedColors = codedColors; var model = new QuadStripColoredModel(maxMarkerCount, codedColors.GetBitmap(1024)); this.Renderer = QuadStripColoredRenderer.Create(model); }
public static CodedColor[] GetDefault() { var result = new CodedColor[5]; result[0] = new CodedColor( Color.FromArgb(255, 0, 22, 76).ToVec3(), 0.0f, 0.0f); result[1] = new CodedColor( Color.FromArgb(255, 0, 193, 136).ToVec3(), 0.25f, 0.25f); result[2] = new CodedColor( Color.FromArgb(255, 166, 255, 27).ToVec3(), 0.5f, 0.5f); result[3] = new CodedColor( Color.FromArgb(255, 255, 173, 0).ToVec3(), 0.75f, 0.75f); result[4] = new CodedColor( Color.FromArgb(255, 255, 8, 1).ToVec3(), 1.0f, 1.0f); return result; }
public ColorCodedBarLine(CodedColor[] codedColors) { if (codedColors == null || codedColors.Length < 1) { throw new ArgumentException(); } this.codedColors = codedColors; }
/// <summary> /// </summary> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> /// <param name="zNear"></param> /// <param name="zFar"></param> public UIColorPaletteRenderer(int maxMarkerCount, CodedColor[] codedColors, System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int zNear, int zFar) : base(anchor, margin, size, zNear, zFar) { this.maxMarkerCount = maxMarkerCount; this.currentMarkersCount = maxMarkerCount; //// display this UI control's area. //this.StateList.Add(new ClearColorState()); // color bar using texture. { var bar = new UIColorPaletteBarRenderer( codedColors, System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right, new System.Windows.Forms.Padding(marginLeft, 1, marginRight, 0), new System.Drawing.Size(size.Width - marginLeft - marginRight, size.Height / 3), zNear, zFar); //this.StateList.Add(new ClearColorState(Color.Blue)); this.Children.Add(bar); this.colorPaletteBar = bar; } // color bar using vec3 color(hidden as default state) // just to compare with color bar using texture. { var bar = new UIColorPaletteColoredBarRenderer( maxMarkerCount, codedColors, System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right, new System.Windows.Forms.Padding(marginLeft, 1 + size.Height / 3, marginRight, 0), new System.Drawing.Size(size.Width - marginLeft - marginRight, size.Height / 3), zNear, zFar); //this.StateList.Add(new ClearColorState(Color.Blue)); this.Children.Add(bar); this.colorPaletteBar2 = bar; bar.Enabled = false; } // white vertical lines. { var markers = new UIColorPaletteMarkersRenderer(maxMarkerCount, System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right, new System.Windows.Forms.Padding(marginLeft, 1, marginRight, 0), new System.Drawing.Size(size.Width - marginLeft - marginRight, size.Height / 2), zNear, zFar); //markers.StateList.Add(new ClearColorState(Color.Red)); this.Children.Add(markers); this.markers = markers; } // labels that display values(float values) { int length = maxMarkerCount; var font = new Font("Arial", 32); for (int i = 0; i < length; i++) { const int width = 100; float distance = marginLeft; distance += 2.0f * (float)i / (float)length * (float)(this.Size.Width - marginLeft - marginRight); distance -= width / 2; var label = new UIText( System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Bottom, new System.Windows.Forms.Padding((int)distance, 0, 0, 0), new System.Drawing.Size(width, size.Height / 2), zNear, zFar, font.GetFontBitmap("0123456789.eE+-").GetFontTexture(), 100); label.Initialize(); //label.StateList.Add(new ClearColorState(Color.Green)); label.Text = ((float)i).ToShortString(); label.BeforeLayout += label_beforeLayout; this.Children.Add(label); this.labelList.Add(label); } this.currentMarkersCount = 2; } }