public override void OnPaintBackground(IGUIContext ctx, RectangleF bounds) { //base.OnPaintBackground (ctx, bounds); int captionHeight = CaptionHeight; if (captionHeight > 0) { ctx.FillRectangle(ChartStyle.CaptionBrush, bounds.Left, bounds.Top, bounds.Width, captionHeight); bounds.Y += captionHeight; bounds.Height -= captionHeight; } // Draw the background Gradient rectangle ctx.FillRectangle(ChartStyle.GradientBrush, bounds); // Grid-lines should be optimizd by GL.CallList or a Vertex-Buffer // Draw all visible, vertical gridlines (if wanted) if (ChartStyle.ShowVerticalGridLines) { using (new PaintWrapper(RenderingFlags.HighQuality)) { GL.LineWidth(ChartStyle.VerticalGridPen.Pen.Width); GL.Color4(ChartStyle.VerticalGridPen.Pen.Color); GL.Begin(PrimitiveType.Lines); float i = bounds.Right + gridScrollOffset; while (i > bounds.Left) { GL.Vertex2(i, bounds.Bottom); GL.Vertex2(i, bounds.Top); i -= GridSpacing; } GL.End(); } } // Draw all visible, horizontal gridlines (if wanted) if (ChartStyle.ShowHorizontalGridLines) { using (new PaintWrapper(RenderingFlags.HighQuality)) { GL.Color4(ChartStyle.HorizontalGridPen.Pen.Color); GL.LineWidth(ChartStyle.HorizontalGridPen.Pen.Width); GL.Begin(PrimitiveType.Lines); for (int i = bounds.Bottom.Ceil(); i >= bounds.Top; i -= GridSpacing) { GL.Vertex2(bounds.Right, i + 0.5f); GL.Vertex2(bounds.Left, i + 0.5f); } GL.End(); } } }
public override void OnPaint(IGUIContext ctx, RectangleF bounds) { ComboBoxBase parent = Parent as ComboBoxBase; if (parent == null) { return; } float scrollOffsetY = 0; if (VScrollBar != null && VScrollBar.IsVisibleEnabled) { scrollOffsetY = VScrollBar.Value; } float itemHeight = parent.ItemHeight; for (int i = 0; i < parent.Items.Count; i++) { RectangleF itemBounds = new RectangleF(bounds.Left, (i * itemHeight) + bounds.Top - scrollOffsetY, bounds.Width, itemHeight); if (i == SelectedIndex) { IWidgetStyle style = Styles.GetStyle(WidgetStates.Selected); ctx.FillRectangle(style.BackColorBrush, itemBounds); parent.DrawItem(ctx, itemBounds, parent.Items[i], style); } else { parent.DrawItem(ctx, itemBounds, parent.Items[i], Style); } } }
public override void PaintBackground(IGUIContext ctx, Widget widget) { base.PaintBackground(ctx, widget); if (widget.Selected) { RectangleF bounds = widget.Bounds; //bounds.Inflate (-1, 0); bounds.Offset(0, bounds.Height - HighlightWidth - 1); bounds.Height = HighlightWidth; ctx.FillRectangle(HighlightBrush, bounds); } else { //Pen leftBorderPen = Theme.Pens.Base01; //Pen rightBorderPen = Theme.Pens.Base02; RectangleF b = widget.Bounds; float f = widget.ScaleFactor; float left = b.Left + f; using (Pen leftBorderPen = new Pen(Theme.Colors.Base01, f)) { ctx.DrawLine(leftBorderPen, left, b.Top + Border, left, b.Bottom - Border); } float right = b.Right; using (Pen rightBorderPen = new Pen(Theme.Colors.Base02, f)) { ctx.DrawLine(rightBorderPen, right, b.Top + Border, right, b.Bottom - Border); } } }
public virtual void FillRectangle(IGUIContext ctx, Widget widget) { if (BackColorBrush.Color != Color.Empty) { ctx.FillRectangle(BackColorBrush, widget.Bounds); } }
public override void PaintBackground(IGUIContext ctx, Widget widget) { if (widget.CanPaint) { switch (ButtonStyle) { case ButtonStyles.Gradient: base.PaintBackground(ctx, widget); break; case ButtonStyles.Glossy: ctx.DrawButton(widget.Bounds, BackColorBrush.Color, (BackColorBrush as LinearGradientBrush).GradientColor, BorderColorPen.Color); break; case ButtonStyles.Flat: if (BackColorBrush.Color != Color.Empty) { ctx.FillRectangle(new SolidBrush(BackColorBrush.Color), widget.Bounds); } DrawBorder(ctx, widget); break; } } }
public virtual void DrawDayGripper(IGUIContext gfx, RectangleF rect, int gripWidth) { using (var m_Brush = new SolidBrush(Color.White)) gfx.FillRectangle(m_Brush, rect.Left, rect.Top - 1, gripWidth, rect.Height); using (var m_Pen = new Pen(Color.Black)) gfx.DrawRectangle(m_Pen, rect.Left, rect.Top - 1, gripWidth, rect.Height); }
public override void FillRectangle(IGUIContext ctx, Widget widget) { base.FillRectangle(ctx, widget); if (IconColumnWidth > 0 && IconBackgroundBrush.Color != Color.Empty) { ctx.FillRectangle(IconBackgroundBrush, new RectangleF(widget.Bounds.Left, widget.Bounds.Top, IconColumnWidth, widget.Height)); } }
public override void DrawDayGripper(IGUIContext gfx, RectangleF rect, int gripWidth) { using (var m_Brush = new SolidBrush(BackColor)) { gfx.FillRectangle(m_Brush, rect.Left, rect.Top - 1, gripWidth, rect.Height + 1); } using (var m_Pen = new Pen(GripperBorderColor)) { gfx.DrawRectangle(m_Pen, rect.Left - 0.5f, rect.Top - 1, gripWidth, rect.Height + 1); } }
public override void OnPaintBackground(IGUIContext ctx, RectangleF bounds) { base.OnPaintBackground(ctx, bounds); if (HScrollBar != null && VScrollBar != null && HScrollBar.Right < Right && VScrollBar.Bottom < Bottom) { float sbWidth = ScrollBar.ScrollBarWidth; ctx.FillRectangle(VScrollBar.Style.BackColorBrush, new RectangleF(bounds.Right - sbWidth, bounds.Bottom - sbWidth, sbWidth, sbWidth)); } }
public virtual void DrawHourRange(IGUIContext gfx, System.Drawing.RectangleF rect, bool drawBorder, bool hilight, bool active) { using (var brush = new SolidBrush(hilight ? this.SelectionColor : this.WorkingHourColor)) { gfx.FillRectangle(brush, rect); } if (drawBorder) { using (var pen = new Pen(System.Drawing.Color.Gray)) gfx.DrawRectangle(pen, rect); } }
public override void DrawDayBackground(IGUIContext gfx, RectangleF rect, bool active) { /** * if (m_GanttControl != null) * m_GanttControl.GanttSettings.NonWorkingTimeFormatStyle.BackgroundStyle.FillRectangle(g, rect); **/ // *** NonWorkingTime //gfx.FillRectangle (SolarizedBrushes.SolarizedBase2, rect); if (active) { gfx.FillRectangle(NonWorkingTimeBrush, rect); } else { using (Brush b = new SolidBrush(NonWorkingTimeBrush.Color.ToGray())) { gfx.FillRectangle(b, rect); } } }
public static void DrawButton(this IGUIContext ctx, RectangleF rect, Color TopColor, Color BottomColor, Color LineColor) { RectangleF topPart = new RectangleF(rect.Left, rect.Top, rect.Width, (int)(rect.Height * 3f / 5f) - 2); RectangleF lowPart = new RectangleF(topPart.Left, topPart.Bottom, topPart.Width, rect.Height - topPart.Height); int gradientHeight = (int)(topPart.Height / 3f) + 1; RectangleF gradientPart = new RectangleF(topPart.Left, topPart.Bottom - gradientHeight, topPart.Width, gradientHeight); if (topPart.Width > 0 && topPart.Height > 0) { using (var brush = new SolidBrush(TopColor)) { ctx.FillRectangle(brush, topPart); } } if (lowPart.Width > 0 && lowPart.Height > 0) { using (var brush = new SolidBrush(BottomColor)) { ctx.FillRectangle(brush, lowPart); } } if (gradientPart.Width > 0 && gradientPart.Height > 0) { using (var aGB = new LinearGradientBrush(TopColor, BottomColor, GradientDirections.Vertical)) { ctx.FillRectangle(aGB, gradientPart); } } if (rect.Width > 0 && rect.Height > 0) { using (var aPen = new Pen(LineColor)) { ctx.DrawRectangle(aPen, rect.Left - 0.5f, rect.Top - 0.5f, rect.Width, rect.Height); } } }
public override void PaintBackground(IGUIContext ctx, Widget widget) { base.PaintBackground(ctx, widget); float deltaX = 12; float deltaY = (float)(widget.Bounds.Height); float x = widget.Bounds.Left + 1.0f; float y = widget.Bounds.Top + 1.0f; ctx.FillRectangle(BackColorBrush, x, y, deltaX - 1, deltaY - 1); x += deltaX; if (x + deltaX > widget.Bounds.Width) { x = 1; y += deltaY; } }
public override void DrawHourRange(IGUIContext gfx, System.Drawing.RectangleF rect, bool drawBorder, bool highlight, bool active) { System.Drawing.Color c = highlight ? this.SelectionColor : this.WorkingHourColor; if (!active) { c = c.ToGray(); } using (var brush = new SolidBrush(c)) { gfx.FillRectangle(brush, rect); } if (drawBorder) { using (var pen = new Pen(System.Drawing.Color.FromArgb(194, 200, 208))) { gfx.DrawRectangle(pen, rect); } } }
public override void OnPaint(IGUIContext ctx, RectangleF bounds) { base.OnPaint(ctx, bounds); // paint bar RectangleF rb = PaddingBounds; if (ProgressColorBrush != null && Value > 0.01f) { if (ProgressPadding > 0) { rb.Inflate(-ProgressPadding, -ProgressPadding); } RectangleF rbp = rb; float delta = 0; if (infiniteDirection != 0) { delta = rb.Width * 0.25f; rbp = rb; rbp.Width = (int)(rbp.Width * Value + 0.5f); float left = rbp.Right - delta; rbp = new RectangleF(left, rbp.Top, rbp.Right - left, rbp.Height); } else { rbp = rb; rbp.Width = (int)(rbp.Width * Value + 0.5f); } if (rbp.Width > 0 && rbp.Height > 0) { ctx.FillRectangle(ProgressColorBrush, rbp); } } // paint progress-text if (Font != null && infiniteDirection == 0) { ctx.DrawString(Text, Font, Style.ForeColorBrush, rb, FontFormat.DefaultSingleLineCentered); } }
public void DrawAllDayBackground(IGUIContext gfx, Rectangle rect) { using (var brush = new SolidBrush(InterpolateColors(this.BackColor, Color.Black, 0.5f))) gfx.FillRectangle(brush, rect); }
public override void OnPaint(IGUIContext ctx, RectangleF bounds) { bounds.Inflate(Padding); float icoWidth = LineHeight * 0.85f; bool buildTree = false; if (lastBounds != bounds || Tree == null || MenuDirtyFlag) { try { lastBounds = bounds; Tree = new QuadTree(bounds); buildTree = true; } catch (Exception ex) { ex.LogError(); } } RectangleF itemRect = bounds; try { foreach (var w in Queue) { if (w.IsSeparator) { } else { //float stringWidth = 0; bool toolTipFlag = false; itemRect.Height = LineHeight - 1; if (ctx.ClipBoundStack.IsOnScreen(itemRect)) { float indent = 0; Brush foreBrush = Theme.Brushes.Base2; Brush backBrush = Theme.Brushes.Base01; switch (w.Level) { case 0: backBrush = Theme.Brushes.Base1; if (w.Enabled) { foreBrush = Theme.Brushes.Base02; } else { foreBrush = Theme.Brushes.Base01; } break; case 1: indent = 8; if (!w.Enabled) { foreBrush = Theme.Brushes.Base02; } break; case 2: indent = 16; backBrush = Theme.Brushes.Base02; if (w.Enabled) { foreBrush = Theme.Brushes.Base1; } else { //foreColor = Theme.Colors.Base1.Lerp(Color.Black, 0.35); foreBrush = Theme.Brushes.Base01; } break; } if (w != null && w == LastExpandedItem && w.Enabled) { using (Brush sb = new SolidBrush(backBrush.Color.Lerp(Theme.Colors.Cyan, 0.85))) { ctx.FillRectangle(sb, itemRect); } foreBrush = Theme.Brushes.White; } else if (w != null && w == m_ActiveItem && w.Enabled) { using (Brush sb = new SolidBrush(backBrush.Color.Lerp(Theme.Colors.Orange, 0.85))) { ctx.FillRectangle(sb, itemRect); } foreBrush = Theme.Brushes.White; } else { ctx.FillRectangle(backBrush, itemRect); } indent *= ScaleFactor; RectangleF tb = itemRect; if (w.HasChildren) { char dropDownTriangle = w.Collapsed ? (char)FontAwesomeIcons.fa_caret_right : (char)FontAwesomeIcons.fa_caret_down; RectangleF ib = new RectangleF(itemRect.Right - icoWidth, itemRect.Top, icoWidth, itemRect.Height); ctx.DrawString(dropDownTriangle.ToString(), this.IconFont, foreBrush, ib, FontFormat.DefaultSingleBaseLineCentered); if (w.Level == 0) { tb.Width -= icoWidth * 2; tb.Offset(icoWidth, 0); } else { tb.Width -= icoWidth + 2; } } if (w.Level == 0) { tb.Offset(0, 2); toolTipFlag = ctx.DrawString(w.DisplayString.ToUpper(), this.Font, foreBrush, tb, FontFormat.DefaultSingleLineCentered) .Width > tb.Width; } else { if (w.ImageIndex > 0 || w.IsToggleButton) { RectangleF ib = itemRect; ib.Width = icoWidth; ib.Offset(indent, 0); string c; if (w.IsToggleButton) { if (w.Checked) { c = ((char)FontAwesomeIcons.fa_toggle_on).ToString(); } else { c = ((char)FontAwesomeIcons.fa_toggle_off).ToString(); } } else { c = ((char)w.ImageIndex).ToString(); } ctx.DrawString(c, this.IconFont, foreBrush, ib, FontFormat.DefaultSingleBaseLine); } tb.Offset(icoWidth + indent, 1); tb.Width -= icoWidth + indent; toolTipFlag = ctx.DrawString(w.DisplayString, this.Font, foreBrush, tb, FontFormat.DefaultSingleLine) .Width > tb.Width; } } if (buildTree) { try { Tree.Add(new MenuControlItem(itemRect, w, toolTipFlag)); } catch (Exception ex) { ex.LogError(); } } itemRect.Offset(0, LineHeight); } } } catch (Exception ex) { ex.LogError(); } }
public override void PaintBackground(IGUIContext ctx, Widget widget) { ctx.FillRectangle(BackColorBrush, widget.PaddingBounds); this.DrawBorder(ctx, widget); //ctx.DrawRectangle (BorderColorPen, widget.MarginBounds); }
//public override void DrawAppointment(OpenGlGdiContext gfx, Rectangle rect, Appointment appointment, bool isSelected, int gripWidth, ImageList imageList) public override void DrawAppointment(IGUIContext gfx, RectangleF rect, Appointment appointment, bool isSelected, int gripWidth) { if (rect.Width == 0 || rect.Height == 0) { //if (rect.Width < 6 || rect.Height < 3) return; } //Color start = InterpolateColors(appointment.Color, Color.White, 0.4f); //Color end = InterpolateColors(appointment.Color, Color.White, 0.7f); // better swap start and end color, text is more readable System.Drawing.Color end = InterpolateColors(appointment.Color, System.Drawing.Color.White, 0.4f); System.Drawing.Color start = InterpolateColors(appointment.Color, System.Drawing.Color.White, 0.7f); if ((appointment.Locked) || isSelected) { // Draw back using (var m_Brush = new HatchBrush("LargeConfetti", System.Drawing.Color.FromArgb(70, 90, 125), appointment.Color)) { gfx.FillRectangle(m_Brush, rect); } // little transparent start = System.Drawing.Color.FromArgb(230, start); end = System.Drawing.Color.FromArgb(180, end); using (var aGB = new LinearGradientBrush(start, end, GradientDirections.ForwardDiagonal)) { gfx.FillRectangle(aGB, rect); } } else { // Draw back using (var aGB = new LinearGradientBrush(start, end, GradientDirections.Vertical)) { gfx.FillRectangle(aGB, rect); } } if (isSelected) { RectangleF m_BorderRectangle = rect; m_BorderRectangle.Offset(-1, 0); using (var m_Pen = new Pen(appointment.BorderColor, 4)) { gfx.DrawRectangle(m_Pen, m_BorderRectangle); } } else { // Draw shadow lines float xLeft = rect.X + 6; float xRight = rect.Right + 1; float yTop = rect.Y + 1; float yButton = rect.Bottom + 1; for (int i = 0; i < 5; i++) { using (var shadow_Pen = new Pen(System.Drawing.Color.FromArgb(70 - 12 * i, System.Drawing.Color.Black))) using (var LineBuf = new LineDrawingBuffer(gfx)) { LineBuf.AddLine(shadow_Pen, xLeft + i, yButton + i, xRight + i - 1, yButton + i); LineBuf.AddLine(shadow_Pen, xRight + i, yTop + i, xRight + i, yButton + i); //gfx.DrawLine(shadow_Pen, xLeft + i, yButton + i, xRight + i - 1, yButton + i); //horisontal lines //gfx.DrawLine(shadow_Pen, xRight + i, yTop + i, xRight + i, yButton + i); //vertical } } rect.Width -= 1; using (var m_Pen = new Pen(System.Drawing.Color.FromArgb(70, 90, 125), 1)) { gfx.DrawRectangle(m_Pen, rect); } rect.Width += 1; } // Draw gripper ***** RectangleF m_GripRectangle = rect; m_GripRectangle.Width = gripWidth + 1; using (var aGB = new SolidBrush(appointment.BorderColor)) { gfx.FillRectangle(aGB, m_GripRectangle); } // Draw Icons ***** rect.X += gripWidth + 2; rect.Width -= gripWidth + 2; if (rect.Height > 56) { rect.Y += 6; rect.Height -= 10; } else if (rect.Height > 38) { rect.Y += 4; rect.Height -= 8; } else { rect.Y += 3; rect.Height -= 6; } float LeftX = rect.X; float IconWidth = 0; /** * if (appointment.ImageIndices != null && appointment.ImageIndices.Length > 0 && imageList != null && rect.Width >= 15 && rect.Height >= 10) * { * int imagecount = 0; * * int startX = rect.X; * foreach (int ImageIndex in appointment.ImageIndices) * { * //imageList.Draw(g, new Point(startX, rect.Y), ImageIndex); * imagecount++; * IconWidth += 18; * startX = rect.X + (imagecount * 18); * * if (startX + 18 > rect.Right - (gripWidth)) * { * startX = rect.X; * rect.Y += 18; * rect.Height -= 18; * IconWidth = 0; * * if (rect.Y + 18 > rect.Height) * break; * } * } * * if (IconWidth > 0) * IconWidth += 2; * } **/ rect.Width -= 2; //rect.Y -= 1; // Draw Text ***** System.Drawing.SizeF TextSize = gfx.MeasureString(appointment.Title, this.BaseFont, rect, m_AppointmentStringFormat); int TextLength = (int)TextSize.Width; int TextHeight = (int)TextSize.Height; if (TextLength + IconWidth + gripWidth + 2 > rect.Width && IconWidth > 20 && rect.Height > 36) { rect.Y += 20; rect.Height -= 20; } else { rect.X += IconWidth; rect.Width -= IconWidth; } gfx.DrawString(appointment.Title, this.BaseFont, SystemBrushes.WindowText, rect, m_AppointmentStringFormat); if (!String.IsNullOrEmpty(appointment.Description)) { rect.X = LeftX; rect.Y += TextHeight + 16; rect.Height -= TextHeight + 14; if (rect.Height > 12) { gfx.DrawString(appointment.Description, this.BaseFont, SystemBrushes.WindowText, rect, m_AppointmentStringFormat); } } }
public override void OnPaint(IGUIContext ctx, RectangleF bounds) { float x = bounds.Left; float y = Padding.Top; float line = 0; float lineHeight = LineHeight; //int lineHeight = Bounds.Height; bool buildTree = false; if (lastBounds != bounds || Tree == null) { try { lastBounds = bounds; Tree = new QuadTree(bounds); itemStartPositions = new float[Menu.Count]; buildTree = true; } catch (Exception ex) { ex.LogError(); } } for (int i = 0; i < Menu.Children.Count; i++) { IGuiMenuItem item = Menu.Children [i]; if (item == null || !item.Visible) { continue; } float iconWidth = 0; float textWidth = 0; if (IconFont != null && item.ImageIndex > 0) { iconWidth = IconFont.Measure(((char)item.ImageIndex).ToString()).Width; } if (Font != null) { textWidth = Font.MeasureMnemonicString(item.Text).Width; if (textWidth > 0) { iconWidth *= 1.35f; } } float itemWidth = iconWidth + textWidth + Padding.Width; if (x + itemWidth > bounds.Width) { line++; x = bounds.Left; y += lineHeight; } RectangleF itemBounds = new RectangleF(x, y, itemWidth, lineHeight - Padding.Height); if (buildTree) { try { Tree.Add(new LayoutItem(itemBounds, item)); itemStartPositions[i] = itemBounds.X; } catch (Exception ex) { ex.LogError(); } } WidgetStates state = WidgetStates.Default; if (!item.Enabled) { state = WidgetStates.Disabled; } else if (item == ActiveItem) { if (IsFocused || Selected) { state = WidgetStates.Active; } else { state = WidgetStates.Selected; } ctx.FillRectangle(Styles.GetStyle(state).BackColorBrush, // irgendjemand scheint den mit bereits abgezogenem Padding aufzurufen, was falsch wäre new RectangleF(itemBounds.X, itemBounds.Y - Padding.Top, itemBounds.Width, itemBounds.Height + Padding.Height)); } Brush brush = Styles.GetStyle(state).ForeColorBrush; itemBounds.Offset(Padding.Left, 1); itemBounds.Width -= Padding.Left; if (iconWidth > 0) { ctx.DrawString(((char)item.ImageIndex).ToString(), IconFont, brush, itemBounds, FontFormat.DefaultIconFontFormatLeft); itemBounds.Offset((int)iconWidth, 0); } if (textWidth > 0) { ctx.DrawString(item.Text, Font, brush, itemBounds, FontFormat.DefaultMnemonicLine); } x += itemWidth; if (x > bounds.Width) { line++; x = bounds.Left; y += lineHeight; } } }
public override void OnPaint(IGUIContext ctx, System.Drawing.RectangleF bounds) { base.OnPaint(ctx, bounds); if (m_Brain == null || m_Brain.Layers == null) { return; } if (m_IsPaintingFlag) { return; } //if (!System.Threading.Monitor.TryEnter (SyncObject)) // return; try { m_IsPaintingFlag = true; float rowHeight = Bounds.Height / Brain.Layers.Count; float rowWidth = Bounds.Width; float inputWidth = Bounds.Width / Brain.Layers.InputLayer.Classes.Count; float outputWidth = Bounds.Width / Brain.Layers.OutputLayer.Classes.Count; float hiddenHeight = Bounds.Height - (rowHeight * 2); //double squareSize = hiddenHeight * rowWidth; //double singleSize = squareSize / globals.CachedNeuronCount; //double singleSize = squareSize / (double)m_Brain.Layers.Configuration.NeuronsPerHiddenLayer; //float a = (float)Math.Floor(Math.Sqrt(singleSize)); //float a = (float)Math.Ceiling(Math.Sqrt(m_Brain.CachedNeuronCount)); //float a = (float)Math.Floor(Math.Sqrt(m_Brain.Layers.Configuration.NeuronsPerHiddenLayer)); /*** * double aspectRatio = rowWidth / rowHeight; * * float deltaX = (float)(rowWidth) / a; * float deltaY = (float)(rowHeight - 1) / a; * * deltaX = (float)(aspectRatio * a); * deltaY = (float)(aspectRatio / a); * * float deltaX = a - 1f; * float deltaY = a - 1f; ***/ float a = (float)Math.Ceiling(Math.Sqrt(m_Brain.CachedNeuronCount)); float deltaX = (float)(rowWidth - 1f) / a; float deltaY = (float)(hiddenHeight - 1f) / a; float x = 0; float y = 0; NeuronColors color = NeuronColors.Empty; int classIndex = 0; foreach (List <Neuron> nclass in m_Brain.Layers.InputLayer.Classes) { float lBound = Bounds.Left + 1 + (classIndex * inputWidth); float rBound = lBound + inputWidth; x = lBound + 1f; y = Bounds.Top + 2f; foreach (Neuron n in nclass) { color = GetNeuronColor(n); if (color != NeuronColors.Empty) { ctx.FillRectangle(Brushes[(int)color], x, y, deltaX - 1, deltaY - 1); } x += deltaX; if (x > rBound) { x = lBound + 1; y += deltaY; } } classIndex++; } a = (float)Math.Ceiling(Math.Sqrt(m_Brain.CachedNeuronCount)); deltaX = (float)(rowWidth - 1f) / a; deltaY = (float)(hiddenHeight - 1f) / a; x = Bounds.Left + 1f; y = Bounds.Top + (1 * rowHeight) + 1f; foreach (IBrainLayer layer in m_Brain.Layers.HiddenLayers) { foreach (Neuron n in layer.Neurons) { color = GetNeuronColor(n); if (color != NeuronColors.Empty) { ctx.FillRectangle(Brushes[(int)color], x, y, deltaX - 1, deltaY - 1); } x += deltaX; if (x > Bounds.Right) { x = Bounds.Left + 1; y += deltaY; } } } float yTop = Bounds.Top + (rowHeight * (Brain.Layers.Count)) - 12f; classIndex = 0; foreach (List <Neuron> nclass in m_Brain.Layers.OutputLayer.Classes) { float lBound = Bounds.Left + 1 + (classIndex * outputWidth); float rBound = lBound + outputWidth; x = lBound + 1f; y = yTop; foreach (Neuron n in nclass) { color = GetNeuronColor(n); if (color != NeuronColors.Empty) { ctx.FillRectangle(Brushes[(int)color], x, y, deltaX - 1, deltaY - 1); } x += deltaX; if (x > rBound) { x = lBound + 1; y += deltaY; } } classIndex++; } } catch (Exception ex) { ex.LogError(); } finally { //System.Threading.Monitor.Exit(SyncObject); m_IsPaintingFlag = false; } }
public override void OnPaint(IGUIContext ctx, RectangleF bounds) { base.OnPaint(ctx, bounds); float lineHeight = LineHeight; float separatorHeight = SeparatorHeight; RectangleF rLine = bounds; rLine.Height = lineHeight; rLine.Width -= Padding.Right; rLine.Offset(0, Padding.Top); float textOffset = lineHeight + Padding.Left; bool buildTree = false; if (lastBounds != bounds || Tree == null) { try { lastBounds = bounds; Tree = new QuadTree(bounds); itemStartPositions = new float[Menu.Count]; buildTree = true; } catch (Exception ex) { ex.LogError(); } } for (int i = 0; i < Menu.Children.Count; i++) { IGuiMenuItem item = Menu.Children [i]; float itemHeight = 0; if (item.IsSeparator) { itemHeight = separatorHeight; float y = rLine.Y + separatorHeight / 2; using (Pen pen = new Pen(Theme.Colors.Base02, ScaleFactor)) ctx.DrawLine(pen, rLine.X + textOffset, y, rLine.X + rLine.Width, y); y++; using (Pen pen = new Pen(Theme.Colors.Base0, ScaleFactor)) ctx.DrawLine(pen, rLine.X + textOffset, y, rLine.X + rLine.Width, y); } else { itemHeight = lineHeight; WidgetStates state = WidgetStates.Default; if (!item.Enabled) { state = WidgetStates.Disabled; } else if (item == m_ActiveItem) { if (IsFocused || Selected) { state = WidgetStates.Active; } else { state = WidgetStates.Selected; } ctx.FillRectangle(Styles.GetStyle(state).BackColorBrush, new RectangleF(rLine.X + 1, rLine.Y, rLine.Width + Padding.Right - 2, rLine.Height)); } IWidgetStyle style = Styles.GetStyle(state); if (IconFont != null) { char icon; if (item.IsToggleButton) { icon = item.Checked ? (char)FontAwesomeIcons.fa_toggle_on : (char)FontAwesomeIcons.fa_toggle_off; } else { icon = (char)item.ImageIndex; } if (icon > 0) { RectangleF rIcon = rLine; rIcon.Width = lineHeight; ctx.DrawString(icon.ToString(), IconFont, style.ForeColorBrush, rIcon, FontFormat.DefaultIconFontFormatCenter); } } if (Font != null) { RectangleF rText = new RectangleF(rLine.X + textOffset, rLine.Y + 1, rLine.Width - textOffset, rLine.Height - 1); ctx.DrawString(item.Text, Font, style.ForeColorBrush, rText, FontFormat.DefaultMnemonicLine); if (item.HasChildren) { if (IconFont != null) { ctx.DrawString(((char)FontAwesomeIcons.fa_caret_right).ToString(), IconFont, style.ForeColorBrush, rText, FontFormat.DefaultSingleLineFar); } } else { string modifier = ModifierString(item); if (modifier != null) { ctx.DrawString(modifier, Font, style.ForeColorBrush, rText, FontFormat.DefaultSingleLineFar); } } } } if (buildTree) { try { Tree.Add(new LayoutItem(rLine, item)); itemStartPositions[i] = rLine.Y; } catch (Exception ex) { ex.LogError(); } } rLine.Offset(0, itemHeight); } }
public override void OnPaint(IGUIContext ctx, RectangleF bounds) { base.OnPaint(ctx, bounds); if (DisplayMode == DisplayModes.None) { return; } MultiLineTextManager rowManager = Owner.RowManager; float paddingTop = Owner.Padding.Top; int selectedRowIndex = rowManager.CurrentParagraphIndex; Brush foreColorBrush = Style.ForeColorBrush; int lineHeight = rowManager.LineHeight; int offsetY = (int)Owner.ScrollOffsetY; int rowIndex = rowManager.FirstParagraphOnScreen; //float halfHeight = bounds.Height / 2f; while (rowIndex < rowManager.Paragraphs.Count) { Paragraph para = rowManager.Paragraphs [rowIndex]; Rectangle rowBounds; if (DisplayMode == DisplayModes.LineNumber) { rowBounds = new Rectangle((int)(bounds.Left + 0.5f), (int)(paddingTop + bounds.Top + para.Top + offsetY + 0.5f), (int)(bounds.Width + 0.5f), lineHeight); for (int i = 0; i < para.LineCount; i++) { if (rowBounds.Bottom > bounds.Top) { int line = para.Index + i; if (line == selectedRowIndex) { ctx.FillRectangle(Theme.Brushes.Base01, new RectangleF(bounds.Left, rowBounds.Top, bounds.Width, rowBounds.Height)); foreColorBrush = Theme.Brushes.Base2; } else { foreColorBrush = Style.ForeColorBrush; } ctx.DrawString((line + 1).ToString(), rowManager.Font, foreColorBrush, new RectangleF(bounds.Left, rowBounds.Top, bounds.Width - Padding.Right, lineHeight), Format); } rowBounds.Offset(0, lineHeight); if (rowBounds.Top > bounds.Bottom) { break; } } } else { rowBounds = new Rectangle((int)(bounds.Left + 0.5f), (int)(paddingTop + bounds.Top + para.Top + offsetY + 0.5f), (int)(bounds.Width + 0.5f), para.LineCount * lineHeight); if (rowBounds.Bottom > bounds.Top) { int line = para.Index; if (line == selectedRowIndex) { ctx.FillRectangle(Theme.Brushes.Base01, new RectangleF(bounds.Left, rowBounds.Top, bounds.Width, rowBounds.Height)); foreColorBrush = Theme.Brushes.Base2; } else { foreColorBrush = Style.ForeColorBrush; } float top = Math.Min(rowBounds.Bottom - lineHeight, Math.Max(rowBounds.Top, bounds.Top)); ctx.DrawString((line + 1).ToString(), rowManager.Font, foreColorBrush, new RectangleF(bounds.Left, top, bounds.Width - Padding.Right, lineHeight), Format); } } if (rowBounds.Top > bounds.Bottom) { break; } rowIndex++; } }