/// <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.SwitchList.Add(new ClearColorSwitch()); // 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.SwitchList.Add(new ClearColorSwitch(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.SwitchList.Add(new ClearColorSwitch(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.SwitchList.Add(new ClearColorSwitch(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.SwitchList.Add(new ClearColorSwitch(Color.Green)); label.Text = ((float)i).ToShortString(); label.BeforeLayout += label_beforeLayout; this.Children.Add(label); this.labelList.Add(label); } this.currentMarkersCount = 2; } }
/// <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; } }