//-------------------------------------------------------------------- public unsafe override void BlendSolidVerticalSpan(int x, int y, uint len, RGBA_Bytes c, byte* covers) { PixelFormat.BlendSolidHorizontalSpan(y, x, len, c, covers); }
internal OpenMenuContents(ObservableCollection<MenuItem> MenuItems, GuiWidget widgetRelativeTo, Vector2 openOffset, Direction direction, RGBA_Bytes backgroundColor, RGBA_Bytes borderColor, int borderWidth, double maxHeight, bool alignToRightEdge) { this.MenuItems = new List<MenuItem>(); this.MenuItems.AddRange(MenuItems); this.alignToRightEdge = alignToRightEdge; this.openOffset = openOffset; this.borderWidth = borderWidth; this.borderColor = borderColor; this.BackgroundColor = backgroundColor; this.direction = direction; this.widgetRelativeTo = widgetRelativeTo; scrollingWindow = new ScrollableWidget(true); { FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); foreach (MenuItem menu in MenuItems) { menu.ClearRemovedFlag(); topToBottom.AddChild(menu); menu.DoClickFunction = AllowClickingItems; } topToBottom.HAnchor = UI.HAnchor.ParentLeft | UI.HAnchor.FitToChildren; topToBottom.VAnchor = UI.VAnchor.ParentBottom; Width = topToBottom.Width; Height = topToBottom.Height; scrollingWindow.AddChild(topToBottom); } scrollingWindow.HAnchor = HAnchor.ParentLeftRight; scrollingWindow.VAnchor = VAnchor.ParentBottomTop; if (maxHeight > 0 && Height > maxHeight) { MakeMenuHaveScroll(maxHeight); } AddChild(scrollingWindow); LostFocus += new EventHandler(DropListItems_LostFocus); GuiWidget topParent = widgetRelativeTo.Parent; while (topParent.Parent != null) { // Regretably we don't know who it is that is the window that will actually think it is moving relative to its parent // but we need to know anytime our widgetRelativeTo has been moved by any change, so we hook them all. if (!widgetRefList.Contains(topParent)) { widgetRefList.Add(topParent); topParent.PositionChanged += new EventHandler(widgetRelativeTo_PositionChanged); topParent.BoundsChanged += new EventHandler(widgetRelativeTo_PositionChanged); } topParent = topParent.Parent; } topParent.AddChild(this); widgetRelativeTo_PositionChanged(widgetRelativeTo, null); widgetRelativeTo.Closed += widgetRelativeTo_Closed; }
public void TestGetHashCode() { { RGBA_Bytes a = new RGBA_Bytes(10, 11, 12); RGBA_Bytes b = new RGBA_Bytes(10, 11, 12); Assert.IsTrue(a.GetHashCode() == b.GetHashCode()); } { RGBA_Floats a = new RGBA_Floats(10, 11, 12); RGBA_Floats b = new RGBA_Floats(10, 11, 12); Assert.IsTrue(a.GetHashCode() == b.GetHashCode()); } { BorderDouble a = new BorderDouble(10, 11, 12, 13); BorderDouble b = new BorderDouble(10, 11, 12, 13); Assert.IsTrue(a.GetHashCode() == b.GetHashCode()); } { Point2D a = new Point2D(10, 11); Point2D b = new Point2D(10, 11); Assert.IsTrue(a.GetHashCode() == b.GetHashCode()); } { RectangleDouble a = new RectangleDouble(10, 11, 12, 13); RectangleDouble b = new RectangleDouble(10, 11, 12, 13); Assert.IsTrue(a.GetHashCode() == b.GetHashCode()); } { RectangleInt a = new RectangleInt(10, 11, 12, 13); RectangleInt b = new RectangleInt(10, 11, 12, 13); Assert.IsTrue(a.GetHashCode() == b.GetHashCode()); } }
public TextWidget(string text, double x = 0, double y = 0, double pointSize = 12, Justification justification = Justification.Left, RGBA_Bytes textColor = new RGBA_Bytes(), bool ellipsisIfClipped = true, bool underline = false, RGBA_Bytes backgroundColor = new RGBA_Bytes()) { pointSize *= GlobalPointSizeScaleRatio; Selectable = false; DoubleBuffer = DoubleBufferDefault; AutoExpandBoundsToText = false; EllipsisIfClipped = ellipsisIfClipped; OriginRelativeParent = new Vector2(x, y); this.textColor = textColor; if (this.textColor.Alpha0To255 == 0) { // we assume it is the default if alpha 0. Also there is no reason to make a text color of this as it will draw nothing. this.textColor = RGBA_Bytes.Black; } if (backgroundColor.Alpha0To255 != 0) { BackgroundColor = backgroundColor; } base.Text = text; StyledTypeFace typeFaceStyle = new StyledTypeFace(LiberationSansFont.Instance, pointSize, underline); printer = new TypeFacePrinter(text, typeFaceStyle, justification: justification); LocalBounds = printer.LocalBounds; MinimumSize = new Vector2(LocalBounds.Width, LocalBounds.Height); }
public void CopyPixels(byte[] buffer, int bufferOffset, RGBA_Bytes sourceColor, int count) { do { buffer[bufferOffset++] = sourceColor.red; } while (--count != 0); }
public span_gouraud_rgba(RGBA_Bytes c1, RGBA_Bytes c2, RGBA_Bytes c3, double x1, double y1, double x2, double y2, double x3, double y3) : this(c1, c2, c3, x1, y1, x2, y2, x3, y3, 0) { }
private void AddText(string tabText, GuiWidget widgetState, RGBA_Bytes textColor, RGBA_Bytes backgroundColor, double pointSize) { tabTitle = new TextWidget(tabText, pointSize: pointSize, textColor: textColor); tabTitle.AutoExpandBoundsToText = true; widgetState.AddChild(tabTitle); widgetState.Selectable = false; widgetState.SetBoundsToEncloseChildren(); widgetState.BackgroundColor = backgroundColor; }
public span_gouraud_rgba(RGBA_Bytes c1, RGBA_Bytes c2, RGBA_Bytes c3, double x1, double y1, double x2, double y2, double x3, double y3, double d) : base(c1, c2, c3, x1, y1, x2, y2, x3, y3, d) { }
public RadioButtonViewText(string label) { labelTextWidget = new TextWidget(label, 12); AddChild(labelTextWidget); LocalBounds = GetLocalBounds(); inactiveColor = new RGBA_Bytes(0.0, 0.0, 0.0); activeColor = new RGBA_Bytes(0.4, 0.0, 0.0); }
private GuiWidget createState(string word, double width, double height, ref RGBA_Bytes backgroundColor, ref RGBA_Bytes interiorColor, ref RGBA_Bytes thumbColor, ref RGBA_Bytes textColor) { TextWidget text = new TextWidget(word, pointSize: 10, textColor: textColor); text.VAnchor = VAnchor.ParentCenter; SwitchView switchGraphics = new SwitchView(width, height, word == onText, backgroundColor, interiorColor, thumbColor, textColor); switchGraphics.VAnchor = VAnchor.ParentCenter; switchGraphics.Margin = new BorderDouble(5, 0, 0, 0); GuiWidget switchNormalToPressed = new FlowLayoutWidget(FlowDirection.LeftToRight, text, switchGraphics); return switchNormalToPressed; }
public void CopyPixels(byte[] pDestBuffer, int bufferOffset, RGBA_Bytes sourceColor, int count) { do { int y = (sourceColor.red * 77) + (sourceColor.green * 151) + (sourceColor.blue * 28); int gray = (y >> 8); pDestBuffer[bufferOffset] = (byte)gray; bufferOffset += bytesBetweenPixelsInclusive; } while (--count != 0); }
public void BlendPixel(byte[] pDestBuffer, int bufferOffset, RGBA_Bytes sourceColor) { int OneOverAlpha = base_mask - sourceColor.alpha; unchecked { int y = (sourceColor.red * 77) + (sourceColor.green * 151) + (sourceColor.blue * 28); int gray = (y >> 8); gray = (byte)((((gray - (int)(pDestBuffer[bufferOffset])) * sourceColor.alpha) + ((int)(pDestBuffer[bufferOffset]) << base_shift)) >> base_shift); pDestBuffer[bufferOffset] = (byte)gray; } }
//-------------------------------------------------------------------- public span_gouraud(RGBA_Bytes c1, RGBA_Bytes c2, RGBA_Bytes c3, double x1, double y1, double x2, double y2, double x3, double y3, double d) { m_vertex = (0); colors(c1, c2, c3); triangle(x1, y1, x2, y2, x3, y3, d); }
internal SwitchView(double width, double height, bool startValue, RGBA_Bytes backgroundColor, RGBA_Bytes interiorColor, RGBA_Bytes thumbColor, RGBA_Bytes exteriorColor) { this.startValue = startValue; switchWidth = width; switchHeight = height; thumbHeight = height; thumbWidth = width / 4; InteriorColor = interiorColor; ExteriorColor = exteriorColor; ThumbColor = thumbColor; LocalBounds = new RectangleDouble(0, 0, width, height); }
public DynamicDropDownMenu(GuiWidget buttonView, Direction direction = Direction.Down, double pointSize = 12) : base(buttonView, direction, pointSize) { menuItems = new TupleList<string, Func<bool>>(); TextColor = RGBA_Bytes.Black; NormalArrowColor = RGBA_Bytes.Black; HoverArrowColor = RGBA_Bytes.Black; BorderWidth = 1; BorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200); this.SelectionChanged += new EventHandler(AltChoices_SelectionChanged); }
public SimpleTextTabWidget(TabPage tabPageControledByTab, string internalTabName, double pointSize, RGBA_Bytes selectedTextColor, RGBA_Bytes selectedBackgroundColor, RGBA_Bytes normalTextColor, RGBA_Bytes normalBackgroundColor) : base(internalTabName, new GuiWidget(), new GuiWidget(), new GuiWidget(), tabPageControledByTab) { AddText(tabPageControledByTab.Text, selectedWidget, selectedTextColor, selectedBackgroundColor, pointSize); AddText(tabPageControledByTab.Text, normalWidget, normalTextColor, normalBackgroundColor, pointSize); //hoverWidget; tabPageControledByTab.TextChanged += new EventHandler(tabPageControledByTab_TextChanged); SetBoundsToEncloseChildren(); }
public MessageBox(String message, string windowTitle, MessageType messageType, double width, double height) : base(width, height) { BackgroundColor = new RGBA_Bytes(50, 50, 50, 240); FlowLayoutWidget topToBottomFlow = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottomFlow.HAnchor = Agg.UI.HAnchor.ParentCenter; topToBottomFlow.VAnchor = Agg.UI.VAnchor.ParentCenter; topToBottomFlow.AddChild(new TextWidget(message, textColor: RGBA_Bytes.White)); Title = windowTitle; // add a spacer topToBottomFlow.AddChild(new GuiWidget(10, 10)); switch (messageType) { case MessageType.YES_NO: { FlowLayoutWidget yesNoButtonsFlow = new FlowLayoutWidget(); Button yesButton = new Button("Yes"); yesButton.Click += new ButtonBase.ButtonEventHandler(okButton_Click); yesNoButtonsFlow.AddChild(yesButton); Button noButton = new Button("No"); noButton.Click += new ButtonBase.ButtonEventHandler(noButton_Click); yesNoButtonsFlow.AddChild(noButton); topToBottomFlow.AddChild(yesNoButtonsFlow); } break; case MessageType.OK: { Button okButton = new Button("Ok"); okButton.Click += new ButtonBase.ButtonEventHandler(okButton_Click); topToBottomFlow.AddChild(okButton); } break; default: throw new NotImplementedException(); } topToBottomFlow.SetBoundsToEncloseChildren(); AddChild(topToBottomFlow); IsModal = true; }
public ToggleSwitchView(string onText, string offText, double width, double height, RGBA_Bytes backgroundColor, RGBA_Bytes interiorColor, RGBA_Bytes thumbColor, RGBA_Bytes textColor) { this.onText = onText; GuiWidget normal = createState(offText, width, height, ref backgroundColor, ref interiorColor, ref thumbColor, ref textColor); GuiWidget normalHover = createState(offText, width, height, ref backgroundColor, ref interiorColor, ref thumbColor, ref textColor); GuiWidget switchNormalToPressed = createState(onText, width, height, ref backgroundColor, ref interiorColor, ref thumbColor, ref textColor); GuiWidget pressed = createState(onText, width, height, ref backgroundColor, ref interiorColor, ref thumbColor, ref textColor); GuiWidget pressedHover = createState(onText, width, height, ref backgroundColor, ref interiorColor, ref thumbColor, ref textColor); GuiWidget switchPressedToNormal = createState(offText, width, height, ref backgroundColor, ref interiorColor, ref thumbColor, ref textColor); GuiWidget disabled = new TextWidget("disabled"); SetViewStates(normal, normalHover, switchNormalToPressed, pressed, pressedHover, switchPressedToNormal, disabled); this.VAnchor = VAnchor.FitToChildren; }
public void BlendPixels(byte[] destBuffer, int bufferOffset, RGBA_Bytes[] sourceColors, int sourceColorsOffset, byte[] covers, int coversIndex, bool firstCoverForAll, int count) { if (firstCoverForAll) { int cover = covers[coversIndex]; if (cover == 255) { do { BlendPixel(destBuffer, bufferOffset, sourceColors[sourceColorsOffset++]); bufferOffset += bytesBetweenPixelsInclusive; } while (--count != 0); } else { do { sourceColors[sourceColorsOffset].alpha = (byte)((sourceColors[sourceColorsOffset].alpha * cover + 255) >> 8); BlendPixel(destBuffer, bufferOffset, sourceColors[sourceColorsOffset]); bufferOffset += bytesBetweenPixelsInclusive; ++sourceColorsOffset; } while (--count != 0); } } else { do { int cover = covers[coversIndex++]; if (cover == 255) { BlendPixel(destBuffer, bufferOffset, sourceColors[sourceColorsOffset]); } else { RGBA_Bytes color = sourceColors[sourceColorsOffset]; color.alpha = (byte)((color.alpha * (cover) + 255) >> 8); BlendPixel(destBuffer, bufferOffset, color); } bufferOffset += bytesBetweenPixelsInclusive; ++sourceColorsOffset; } while (--count != 0); } }
public unsafe void PixelHighResolution(RasterBuffer buf, RGBA_Bytes* p, int x, int y) { int r, g, b, a; r = g = b = a = LineAABasics.line_subpixel_scale * LineAABasics.line_subpixel_scale / 2; int weight; int x_lr = x >> LineAABasics.line_subpixel_shift; int y_lr = y >> LineAABasics.line_subpixel_shift; x &= LineAABasics.line_subpixel_mask; y &= LineAABasics.line_subpixel_mask; RGBA_Bytes* ptr = (RGBA_Bytes*)buf.GetPixelPointer(x_lr, y_lr); weight = (LineAABasics.line_subpixel_scale - x) * (LineAABasics.line_subpixel_scale - y); r += weight * ptr->m_R; g += weight * ptr->m_G; b += weight * ptr->m_B; a += weight * ptr->m_A; ++ptr; weight = x * (LineAABasics.line_subpixel_scale - y); r += weight * ptr->m_R; g += weight * ptr->m_G; b += weight * ptr->m_B; a += weight * ptr->m_A; ptr = (RGBA_Bytes*)buf.GetPixelPointer(x_lr, y_lr + 1); weight = (LineAABasics.line_subpixel_scale - x) * y; r += weight * ptr->m_R; g += weight * ptr->m_G; b += weight * ptr->m_B; a += weight * ptr->m_A; ++ptr; weight = x * y; r += weight * ptr->m_R; g += weight * ptr->m_G; b += weight * ptr->m_B; a += weight * ptr->m_A; p->m_R = (byte)(r >> LineAABasics.line_subpixel_shift * 2); p->m_G = (byte)(g >> LineAABasics.line_subpixel_shift * 2); p->m_B = (byte)(b >> LineAABasics.line_subpixel_shift * 2); p->m_A = (byte)(a >> LineAABasics.line_subpixel_shift * 2); }
public override void copy_hline(int x, int y, int len, RGBA_Bytes c) { throw new NotImplementedException(); /* realloc_span((int)len); unsafe { fixed (byte* pBuffer = m_span.Array) { m_mask.fill_hspan(x, y, pBuffer, (int)len); m_LinkedImage.blend_solid_hspan(x, y, len, c, pBuffer); } } */ }
public void BlendPixel(byte[] buffer, int bufferOffset, RGBA_Bytes sourceColor) { unchecked { if (sourceColor.alpha == 255) { buffer[bufferOffset] = (byte)(sourceColor.red); } else { int r = buffer[bufferOffset]; buffer[bufferOffset] = (byte)(((sourceColor.red - r) * sourceColor.alpha + (r << (int)RGBA_Bytes.base_shift)) >> (int)RGBA_Bytes.base_shift); } } }
public SlideView(Slider sliderWidget) { sliderAttachedTo = sliderWidget; TrackHeight = 3; TextColor = RGBA_Bytes.Black; TrackColor = new RGBA_Bytes(220, 220, 220); ThumbColor = DefaultViewFactory.DefaultBlue; sliderWidget.ValueChanged += new EventHandler(sliderWidget_ValueChanged); sliderWidget.TextChanged += new EventHandler(sliderWidget_TextChanged); SetFormatStringForText(); }
public WrappedTextWidget(string text, double startingWidth, double pointSize = 12, Justification justification = Justification.Left, RGBA_Bytes textColor = new RGBA_Bytes(), bool ellipsisIfClipped = true, bool underline = false, RGBA_Bytes backgroundColor = new RGBA_Bytes()) { this.pointSize = pointSize; textWidget = new TextWidget(text, 0, 0, pointSize, justification, textColor, ellipsisIfClipped, underline, backgroundColor); textWidget.AutoExpandBoundsToText = true; textWidget.HAnchor = HAnchor.ParentLeft; textWidget.VAnchor = VAnchor.ParentCenter; unwrappedText = text; HAnchor = HAnchor.ParentLeftRight; VAnchor = VAnchor.FitToChildren; AddChild(textWidget); Width = startingWidth; }
public static RGBA_Bytes InvertColor(RGBA_Bytes color) { RGBA_Floats colorFloat = new RGBA_Floats(color); double hue0To1; double saturation0To1; double lightness0To1; colorFloat.GetHSL(out hue0To1, out saturation0To1, out lightness0To1); RGBA_Floats colorInvertedFloat = RGBA_Floats.FromHSL(hue0To1, saturation0To1, 1 - lightness0To1); RGBA_Bytes invertedColor = new RGBA_Bytes( colorInvertedFloat.Red0To255, colorInvertedFloat.Green0To255, colorInvertedFloat.Blue0To255, // and don't change the alpha value color.alpha); return invertedColor; }
public spline_ctrl(Vector2 location, Vector2 size, int num_pnt) : base(location, false) { LocalBounds = new RectangleDouble(0, 0, size.x, size.y); m_curve_pnt = new PathStorage(); m_curve_poly = new Stroke(m_curve_pnt); m_ellipse = new Ellipse(); m_background_color = new RGBA_Bytes(1.0, 1.0, 0.9); m_border_color = new RGBA_Bytes(0.0, 0.0, 0.0); m_curve_color = new RGBA_Bytes(0.0, 0.0, 0.0); m_inactive_pnt_color = new RGBA_Bytes(0.0, 0.0, 0.0); m_active_pnt_color = new RGBA_Bytes(1.0, 0.0, 0.0); m_num_pnt = (num_pnt); m_border_width = (1.0); m_border_extra = (0.0); m_curve_width = (1.0); m_point_size = (3.0); m_curve_poly = new Stroke(m_curve_pnt); m_idx = (0); m_vertex = (0); m_active_pnt = (-1); m_move_pnt = (-1); m_pdx = (0.0); m_pdy = (0.0); if (m_num_pnt < 4) m_num_pnt = 4; if (m_num_pnt > 32) m_num_pnt = 32; for (int i = 0; i < m_num_pnt; i++) { m_xp[i] = (double)(i) / (double)(m_num_pnt - 1); m_yp[i] = 0.5; } calc_spline_box(); update_spline(); { m_spline.init((int)m_num_pnt, m_xp, m_yp); for (int i = 0; i < 256; i++) { m_spline_values[i] = m_spline.get((double)(i) / 255.0); if (m_spline_values[i] < 0.0) m_spline_values[i] = 0.0; if (m_spline_values[i] > 1.0) m_spline_values[i] = 1.0; m_spline_values8[i] = (byte)(m_spline_values[i] * 255.0); } } }
///<summary> ///</summary> ///<param name="x"></param> ///<param name="y"></param> ///<param name="len"></param> ///<param name="colors"></param> ///<param name="covers"></param> ///<param name="cover"></param> public unsafe override void BlendHorizontalColorSpan(int x, int y, uint len, RGBA_Bytes* colors, byte* covers, byte cover) { fixed (byte* pBuffer = _span.Array) { if (covers != null) { InitSpan((int)len, covers); _alphaMask.CombineHorizontalSpan(x, y, pBuffer, (int)len); } else { ReallocateSpan((int)len); _alphaMask.FillHorizontalSpan(x, y, pBuffer, (int)len); } PixelFormat.BlendHorizontalColorSpan(x, y, len, colors, pBuffer, cover); } }
public WindowWidget(RectangleDouble InBounds) { int sizeOfDragBar = 20; BackgroundColor = RGBA_Bytes.White; OriginRelativeParent = new Vector2(InBounds.Left, InBounds.Bottom); LocalBounds = new RectangleDouble(0, 0, InBounds.Width, InBounds.Height); DragBarColor = RGBA_Bytes.LightGray; dragBar = new TitleBarWidget(new RectangleDouble(0, InBounds.Height - sizeOfDragBar, InBounds.Width, InBounds.Height)); //dragBar.DebugShowBounds = true; base.AddChild(dragBar); //clientArea.DebugShowBounds = true; base.AddChild(clientArea); }
public PopOutTextTabWidget(TabPage tabPageControledByTab, string internalTabName, Vector2 minSize, double pointSize) : base(internalTabName, new GuiWidget(), new GuiWidget(), new GuiWidget(), tabPageControledByTab) { RGBA_Bytes selectedTextColor = ActiveTheme.Instance.PrimaryTextColor; RGBA_Bytes selectedBackgroundColor = new RGBA_Bytes(); RGBA_Bytes normalTextColor = ActiveTheme.Instance.TabLabelUnselected; RGBA_Bytes normalBackgroundColor = new RGBA_Bytes(); AddText(tabPageControledByTab.Text, selectedWidget, selectedTextColor, selectedBackgroundColor, pointSize); AddText(tabPageControledByTab.Text, normalWidget, normalTextColor, normalBackgroundColor, pointSize); tabPageControledByTab.TextChanged += new EventHandler(tabPageControledByTab_TextChanged); SetBoundsToEncloseChildren(); popOutManager = new PopOutManager(TabPageControlledByTab, minSize, tabPageControledByTab.Text, internalTabName); }
private bool ClearAndCheckImage(ImageBuffer image, RGBA_Bytes color) { image.NewGraphics2D().Clear(color); for (int y = 0; y < image.Height; y++) { for (int x = 0; x < image.Width; x++) { if (image.GetPixel(x, y) != color) { return false; } } } return true; }
public void ConstructPrintQueueItem() { linkButtonFactory.fontSize = 10; linkButtonFactory.textColor = RGBA_Bytes.Black; WidgetTextColor = RGBA_Bytes.Black; WidgetBackgroundColor = RGBA_Bytes.White; TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; SetDisplayAttributes(); FlowLayoutWidget topToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottomLayout.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; FlowLayoutWidget topContentsFlowLayout = new FlowLayoutWidget(FlowDirection.LeftToRight); topContentsFlowLayout.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; { FlowLayoutWidget leftColumn = new FlowLayoutWidget(FlowDirection.LeftToRight); leftColumn.VAnchor = VAnchor.ParentTop | Agg.UI.VAnchor.FitToChildren; { selectionCheckBoxContainer = new GuiWidget(); selectionCheckBoxContainer.VAnchor = VAnchor.ParentBottomTop; selectionCheckBoxContainer.Width = 40; selectionCheckBoxContainer.Visible = false; selectionCheckBoxContainer.Margin = new BorderDouble(left: 6); selectionCheckBox = new CheckBox(""); selectionCheckBox.VAnchor = VAnchor.ParentCenter; selectionCheckBox.HAnchor = HAnchor.ParentCenter; selectionCheckBoxContainer.AddChild(selectionCheckBox); PartThumbnailWidget thumbnailWidget = new PartThumbnailWidget(PrintItemWrapper, "part_icon_transparent_40x40.png", "building_thumbnail_40x40.png", PartThumbnailWidget.ImageSizes.Size50x50); leftColumn.AddChild(selectionCheckBoxContainer); leftColumn.AddChild(thumbnailWidget); } FlowLayoutWidget middleColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); middleColumn.VAnchor = VAnchor.ParentTop | Agg.UI.VAnchor.FitToChildren; middleColumn.HAnchor = HAnchor.ParentLeftRight;// | Agg.UI.HAnchor.FitToChildren; middleColumn.Padding = new BorderDouble(8); middleColumn.Margin = new BorderDouble(10, 0); { string labelName = textInfo.ToTitleCase(PrintItemWrapper.Name); labelName = labelName.Replace('_', ' '); partLabel = new TextWidget(labelName, pointSize: 14); partLabel.TextColor = WidgetTextColor; partLabel.MinimumSize = new Vector2(1, 16); string partStatusLabelTxt = LocalizedString.Get("Status").ToUpper(); string partStatusLabelTxtTest = LocalizedString.Get("Queued to Print"); string partStatusLabelTxtFull = "{0}: {1}".FormatWith(partStatusLabelTxt, partStatusLabelTxtTest); partStatus = new TextWidget(partStatusLabelTxtFull, pointSize: 10); partStatus.AutoExpandBoundsToText = true; partStatus.TextColor = WidgetTextColor; partStatus.MinimumSize = new Vector2(50, 12); middleColumn.AddChild(partLabel); middleColumn.AddChild(partStatus); } CreateEditControls(); topContentsFlowLayout.AddChild(leftColumn); topContentsFlowLayout.AddChild(middleColumn); //topContentsFlowLayout.AddChild(editControls); editControls.Visible = false; } // The ConditionalClickWidget supplies a user driven Enabled property based on a delegate of your choosing conditionalClickContainer = new ConditionalClickWidget(() => queueDataView.EditMode); conditionalClickContainer.HAnchor = HAnchor.ParentLeftRight; conditionalClickContainer.VAnchor = VAnchor.ParentBottomTop; conditionalClickContainer.Click += onLibraryItemClick; topToBottomLayout.AddChild(topContentsFlowLayout); this.AddChild(topToBottomLayout); actionButtonContainer = getItemActionButtons(); actionButtonContainer.Visible = false; this.AddChild(conditionalClickContainer); this.AddChild(actionButtonContainer); AddHandlers(); }
public abstract void from_pix(RGBA_Bytes c);
public override void from_pix(RGBA_Bytes c) { r = c.red; g = c.green; b = c.blue; }
public override void from_pix(RGBA_Bytes c) { r = c.red; }
public override void OnDraw(Graphics2D graphics2D) { { ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect()); Graphics2D subGraphics2D = widgetsSubImage.NewGraphics2D(); subGraphics2D.Clear(new RGBA_Bytes(255, 255, 255)); for (int y = 0; y < MomsGame.GetHeight(); y++) { for (int x = 0; x < MomsGame.GetWidth(); x++) { DrawCard(subGraphics2D, x, y); } } String whatToDo = "Select any open space marked with an 'O'"; RGBA_Bytes backFillCollor = new RGBA_Bytes(0xe1, 0xe0, 0xf6); if (MomsGame.GetWaitingForKing()) { backFillCollor = new RGBA_Bytes(0xf8, 0x89, 0x78); whatToDo = "Select a King for the hole"; } else if (MomsGame.IsSolved()) { backFillCollor = new RGBA_Bytes(0xf8, 0x89, 0x78); whatToDo = "You win!"; } else if (!MomsGame.MoveAvailable()) { backFillCollor = new RGBA_Bytes(0xf8, 0x89, 0x78); whatToDo = "No more moves! Shuffle to continue."; } if (whatToDo != null) { TextWidget stringToDraw = new TextWidget(whatToDo, 12); RectangleDouble Size = stringToDraw.Printer.LocalBounds; double TextX = m_BoardX + CARD_WIDTH * 4; double TextY = m_BoardY - 34; RoundedRect BackFill = new RoundedRect(Size.Left - 6, Size.Bottom - 3, Size.Right + 6, Size.Top + 6, 3); Stroke BackBorder = new Stroke(BackFill); BackBorder.width(2); subGraphics2D.SetTransform(Affine.NewTranslation(TextX, TextY)); subGraphics2D.Render(BackFill, backFillCollor); subGraphics2D.Render(BackBorder, new RGBA_Bytes(0, 0, 0)); subGraphics2D.Render(stringToDraw.Printer, new RGBA_Bytes(0, 0, 0)); } String ShufflesString; ShufflesString = "Number of shuffles so far = "; ShufflesString += MomsGame.GetNumShuffles().ToString(); TextWidget shuffelStringToDraw = new TextWidget(ShufflesString, 12); subGraphics2D.SetTransform(Affine.NewTranslation(m_BoardX, 350)); subGraphics2D.Render(shuffelStringToDraw.Printer, new RGBA_Bytes(0, 0, 0)); subGraphics2D.SetTransform(Affine.NewIdentity()); } base.OnDraw(graphics2D); }
public static void DoSetToColor(ImageBuffer sourceImageAndDest, RGBA_Bytes color) { DoSetToColor(sourceImageAndDest, sourceImageAndDest, color); }
//-------------------------------------------------------------------- ///<summary> ///</summary> ///<param name="x"></param> ///<param name="y"></param> ///<param name="c"></param> ///<param name="cover"></param> public override void BlendPixel(int x, int y, RGBA_Bytes c, byte cover) { PixelFormat.BlendPixel(x, y, c, _alphaMask.CombinePixel(x, y, cover)); }
private void AddText(string tabText, GuiWidget widgetState, RGBA_Bytes textColor, RGBA_Bytes backgroundColor, double pointSize) { leftToRight = new FlowLayoutWidget(); tabTitle = new TextWidget(tabText, pointSize: pointSize, textColor: textColor); tabTitle.AutoExpandBoundsToText = true; leftToRight.AddChild(tabTitle); ImageBuffer popOutImageClick = StaticData.Instance.LoadIcon(Path.Combine("icon_pop_out_32x32.png")); if (ActiveTheme.Instance.IsDarkTheme) { InvertLightness.DoInvertLightness(popOutImageClick); } ImageBuffer popOutImage = new ImageBuffer(popOutImageClick); byte[] buffer = popOutImage.GetBuffer(); for (int i = 0; i < buffer.Length; i++) { if ((i & 3) != 3) { buffer[i] = textColor.red; } } Button popOut = new Button(0, 0, new ButtonViewStates(new ImageWidget(popOutImage), new ImageWidget(popOutImage), new ImageWidget(popOutImageClick), new ImageWidget(popOutImageClick))); popOut.Click += (sender, e) => { popOutManager.ShowContentInWindow(); }; popOut.Margin = new BorderDouble(3, 0); popOut.VAnchor = VAnchor.ParentTop; leftToRight.AddChild(popOut); widgetState.AddChild(leftToRight); widgetState.SetBoundsToEncloseChildren(); widgetState.BackgroundColor = backgroundColor; }
public TextImageWidget(string label, RGBA_Bytes fillColor, RGBA_Bytes borderColor, RGBA_Bytes textColor, double borderWidth, BorderDouble margin, ImageBuffer image = null, int fontSize = 12, FlowDirection flowDirection = FlowDirection.LeftToRight, double height = 40, double width = 0, bool centerText = false) : base() { this.image = image; this.fillColor = fillColor; this.borderColor = borderColor; this.borderWidth = borderWidth; this.Margin = new BorderDouble(0); this.Padding = new BorderDouble(0); TextWidget textWidget = new TextWidget(label, pointSize: fontSize); ImageWidget imageWidget; FlowLayoutWidget container = new FlowLayoutWidget(flowDirection); if (centerText) { // make sure the contents are centered GuiWidget leftSpace = new GuiWidget(0, 1); leftSpace.HAnchor = Agg.UI.HAnchor.ParentLeftRight; container.AddChild(leftSpace); } if (image != null && image.Width > 0) { imageWidget = new ImageWidget(image); imageWidget.VAnchor = VAnchor.ParentCenter; container.AddChild(imageWidget); } if (label != "") { textWidget.VAnchor = VAnchor.ParentCenter; textWidget.TextColor = textColor; textWidget.Padding = new BorderDouble(3, 0); container.AddChild(textWidget); } if (centerText) { GuiWidget rightSpace = new GuiWidget(0, 1); rightSpace.HAnchor = Agg.UI.HAnchor.ParentLeftRight; container.AddChild(rightSpace); container.HAnchor = Agg.UI.HAnchor.ParentLeftRight | Agg.UI.HAnchor.FitToChildren; } container.VAnchor = Agg.UI.VAnchor.ParentCenter; container.MinimumSize = new Vector2(width, height); container.Margin = margin; this.AddChild(container); HAnchor = HAnchor.ParentLeftRight | HAnchor.FitToChildren; VAnchor = VAnchor.ParentCenter | Agg.UI.VAnchor.FitToChildren; }
public ViewControls3D(MeshViewerWidget meshViewerWidget) { if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen) { buttonHeight = 40; } else { buttonHeight = 20; } this.meshViewerWidget = meshViewerWidget; TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); textImageButtonFactory.FixedHeight = buttonHeight; textImageButtonFactory.FixedWidth = buttonHeight; textImageButtonFactory.AllowThemeToAdjustImage = false; textImageButtonFactory.checkedBorderColor = RGBA_Bytes.White; string rotateIconPath = Path.Combine("ViewTransformControls", "rotate.png"); rotateButton = textImageButtonFactory.GenerateRadioButton("", rotateIconPath); rotateButton.ToolTipText = "Rotate (Alt + L. Mouse)".Localize(); rotateButton.Margin = new BorderDouble(3); AddChild(rotateButton); rotateButton.Click += (sender, e) => { this.ActiveButton = ViewControls3DButtons.Rotate; }; string translateIconPath = Path.Combine("ViewTransformControls", "translate.png"); translateButton = textImageButtonFactory.GenerateRadioButton("", translateIconPath); translateButton.ToolTipText = "Move (Shift + L. Mouse)".Localize(); translateButton.Margin = new BorderDouble(3); AddChild(translateButton); translateButton.Click += (sender, e) => { this.ActiveButton = ViewControls3DButtons.Translate; }; string scaleIconPath = Path.Combine("ViewTransformControls", "scale.png"); scaleButton = textImageButtonFactory.GenerateRadioButton("", scaleIconPath); scaleButton.ToolTipText = "Zoom (Ctrl + L. Mouse)".Localize(); scaleButton.Margin = new BorderDouble(3); AddChild(scaleButton); scaleButton.Click += (sender, e) => { this.ActiveButton = ViewControls3DButtons.Scale; }; partSelectSeparator = new GuiWidget(2, 32); partSelectSeparator.BackgroundColor = RGBA_Bytes.White; partSelectSeparator.Margin = new BorderDouble(3); AddChild(partSelectSeparator); string partSelectIconPath = Path.Combine("ViewTransformControls", "partSelect.png"); partSelectButton = textImageButtonFactory.GenerateRadioButton("", partSelectIconPath); partSelectButton.ToolTipText = "Select Part".Localize(); partSelectButton.Margin = new BorderDouble(3); AddChild(partSelectButton); partSelectButton.Click += (sender, e) => { this.ActiveButton = ViewControls3DButtons.PartSelect; }; Margin = new BorderDouble(5); HAnchor |= Agg.UI.HAnchor.ParentLeft; VAnchor = Agg.UI.VAnchor.ParentTop; rotateButton.Checked = true; SetMeshViewerDisplayTheme(); partSelectButton.CheckedStateChanged += SetMeshViewerDisplayTheme; ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents); }
public PrintLibraryListItem(PrintItemWrapper printItem) { this.printItem = printItem; linkButtonFactory.fontSize = 10; linkButtonFactory.textColor = RGBA_Bytes.White; WidgetTextColor = RGBA_Bytes.Black; WidgetBackgroundColor = RGBA_Bytes.White; TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; SetDisplayAttributes(); FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.LeftToRight); mainContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; { GuiWidget selectionCheckBoxContainer = new GuiWidget(); selectionCheckBoxContainer.VAnchor = VAnchor.Max_FitToChildren_ParentHeight; selectionCheckBoxContainer.HAnchor = Agg.UI.HAnchor.FitToChildren; selectionCheckBoxContainer.Margin = new BorderDouble(left: 6); selectionCheckBox = new CheckBox(""); selectionCheckBox.VAnchor = VAnchor.ParentCenter; selectionCheckBox.HAnchor = HAnchor.ParentCenter; selectionCheckBoxContainer.AddChild(selectionCheckBox); FlowLayoutWidget leftColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); leftColumn.VAnchor |= VAnchor.ParentTop; FlowLayoutWidget middleColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); middleColumn.HAnchor = Agg.UI.HAnchor.ParentLeftRight; middleColumn.VAnchor = Agg.UI.VAnchor.ParentBottomTop; middleColumn.Padding = new BorderDouble(0, 6); middleColumn.Margin = new BorderDouble(10, 0); { string labelName = textInfo.ToTitleCase(printItem.Name); labelName = labelName.Replace('_', ' '); partLabel = new TextWidget(labelName, pointSize: 12); partLabel.TextColor = WidgetTextColor; partLabel.MinimumSize = new Vector2(1, 16); middleColumn.AddChild(partLabel); } FlowLayoutWidget rightColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); rightColumn.VAnchor = Agg.UI.VAnchor.ParentBottomTop; buttonContainer = new FlowLayoutWidget(); buttonContainer.Margin = new BorderDouble(0, 6); buttonContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; { addToQueueLink = linkButtonFactory.Generate(new LocalizedString("Add to Queue").Translated); addToQueueLink.Margin = new BorderDouble(left: 0, right: 10); addToQueueLink.VAnchor = VAnchor.ParentCenter; addToQueueLink.Click += (sender, e) => { PrintQueueItem queueItem = new PrintQueueItem(this.printItem.Name, this.printItem.FileLocation); PrintQueueControl.Instance.AddChild(queueItem); }; viewLink = linkButtonFactory.Generate(new LocalizedString("View").Translated); viewLink.Margin = new BorderDouble(left: 0, right: 10); viewLink.VAnchor = VAnchor.ParentCenter; exportLink = linkButtonFactory.Generate(new LocalizedString("Export").Translated); exportLink.Margin = new BorderDouble(left: 0, right: 10); exportLink.VAnchor = VAnchor.ParentCenter; exportLink.Click += (sender, e) => { OpenExportWindow(); }; removeLink = linkButtonFactory.Generate(new LocalizedString("Remove").Translated); removeLink.Margin = new BorderDouble(left: 10, right: 10); removeLink.VAnchor = VAnchor.ParentCenter; buttonContainer.AddChild(addToQueueLink); buttonContainer.AddChild(viewLink); buttonContainer.AddChild(exportLink); buttonContainer.AddChild(removeLink); } middleColumn.AddChild(buttonContainer); //rightColumn.AddChild(buttonContainer); mainContainer.AddChild(selectionCheckBoxContainer); { PartThumbnailWidget thumbnailWidget = new PartThumbnailWidget(printItem, "part_icon_transparent_40x40.png", "building_thumbnail_40x40.png", new Vector2(50, 50)); mainContainer.AddChild(thumbnailWidget); } mainContainer.AddChild(leftColumn); mainContainer.AddChild(middleColumn); mainContainer.AddChild(rightColumn); } this.AddChild(mainContainer); AddHandlers(); }
public RadioButton(string label, RGBA_Bytes textColor, int fontSize = 12) : this(0, 0, label, fontSize) { this.TextColor = textColor; }
private void onExit(object sender, EventArgs e) { HoverBorderColor = new RGBA_Bytes(); this.Invalidate(); }
public HorizontalLine(RGBA_Bytes backgroundColor) : base(1, 1) { BackgroundColor = backgroundColor; HAnchor = HAnchor.ParentLeftRight; }
public void DrawCard(Graphics2D DestGraphics, int CardX, int CardY) { double StartX = CardX * CARD_WIDTH + m_BoardX; double StartY = CardY * CARD_HEIGHT + m_BoardY; RectangleDouble CardBounds = new RectangleDouble(StartX + 1.5, StartY + 1.5, StartX + CARD_WIDTH - 1.5, StartY + CARD_HEIGHT - 1.5); RoundedRect CardFiledRoundedRect = new RoundedRect(CardBounds.Left, CardBounds.Bottom, CardBounds.Right, CardBounds.Top, 5); Stroke CardRectBounds = new Stroke(CardFiledRoundedRect); CardRectBounds.width(1); CCard Card = MomsGame.GetCard(CardX, CardY); int CardValue = Card.GetValue(); int CardSuit = Card.GetSuit(); String ValueString = "Uninitialized "; if (CardValue > (int)CCard.CARD_VALUE.VALUE_ACE) { DestGraphics.SetTransform(Affine.NewIdentity()); DestGraphics.Render(CardRectBounds, new RGBA_Bytes(0, 0, 0)); if (CardValue > 10) { switch (CardValue) { case 11: ValueString = "J"; break; case 12: ValueString = "Q"; break; case 13: ValueString = "K"; break; default: throw new Exception(); } } else { ValueString = CardValue.ToString(); } TextWidget stringToDraw = new TextWidget(ValueString, 10); RectangleDouble textBounds = stringToDraw.Printer.LocalBounds; DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Left + 2, CardBounds.Top - 8 - textBounds.Height / 2)); DestGraphics.Render(stringToDraw.Printer, new RGBA_Bytes(0, 0, 0)); DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Right - 4 - textBounds.Width, CardBounds.Bottom + 9 - textBounds.Height / 2)); DestGraphics.Render(stringToDraw.Printer, new RGBA_Bytes(0, 0, 0)); RGBA_Bytes SuitColor = new RGBA_Bytes(0, 0, 0); IVertexSource suitPath = new PathStorage(); switch (CardSuit) { case (int)CCard.CARD_SUIT.SUIT_DIAMOND: { SuitColor = new RGBA_Bytes(0xFF, 0x11, 0x11); suitPath = m_DiamondShape; } break; case (int)CCard.CARD_SUIT.SUIT_CLUB: { SuitColor = new RGBA_Bytes(0x22, 0x22, 0x66); suitPath = new FlattenCurves(m_ClubShape); } break; case (int)CCard.CARD_SUIT.SUIT_HEART: { SuitColor = new RGBA_Bytes(0xBB, 0x00, 0x00); suitPath = new FlattenCurves(m_HeartShape); } break; case (int)CCard.CARD_SUIT.SUIT_SPADE: { SuitColor = new RGBA_Bytes(0x00, 0x00, 0x00); suitPath = new FlattenCurves(m_SpadeShape); } break; default: break; } textBounds = stringToDraw.Printer.LocalBounds; if (CardValue < 11) { for (int CurDot = 0; CurDot < CardValue; CurDot++) { double OffsetX = 0, OffsetY = 0; GetSuitOffset(ref OffsetX, ref OffsetY, CurDot, (int)CardValue); DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Left + OffsetX, CardBounds.Bottom + OffsetY)); DestGraphics.Render(suitPath, SuitColor); } } else { DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Left + 9, CardBounds.Bottom + 17)); DestGraphics.Render(suitPath, SuitColor); DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Right - 9, CardBounds.Top - 17)); DestGraphics.Render(suitPath, SuitColor); stringToDraw = new TextWidget(ValueString, 22); textBounds = stringToDraw.Printer.LocalBounds; DestGraphics.SetTransform(Affine.NewTranslation(-1 + CardBounds.Left + CardBounds.Width / 2 - textBounds.Width / 2, CardBounds.Bottom + CardBounds.Height / 2 - textBounds.Height / 2)); DestGraphics.Render(stringToDraw.Printer, new RGBA_Bytes(0, 0, 0)); } } else { RGBA_Bytes HoleColor = new RGBA_Bytes(0, 0, 0); String OpenSpaceString; if (!MomsGame.SpaceIsClickable(CardX, CardY)) { HoleColor = new RGBA_Bytes(0xf8, 0xe2, 0xe8); OpenSpaceString = "X"; } else { HoleColor = new RGBA_Bytes(0xe1, 0xe0, 0xf6); OpenSpaceString = "O"; } TextWidget stringToDraw = new TextWidget(OpenSpaceString, 35); RectangleDouble Size = stringToDraw.Printer.LocalBounds; DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Left + CardBounds.Width / 2 - Size.Width / 2, CardBounds.Bottom + CardBounds.Height / 2 - Size.Height / 2)); DestGraphics.Render(stringToDraw.Printer, HoleColor); } }
public void active_pnt_color(RGBA_Bytes c) { m_active_pnt_color = c; }
public override void to_pix(ref RGBA_Bytes c) { c.red = (byte)agg_basics.uround(r); }
public void curve_color(RGBA_Bytes c) { m_curve_color = c; }
public override void to_pix(ref RGBA_Bytes c) { c.red = (byte)agg_basics.uround(r); c.green = (byte)agg_basics.uround(g); c.blue = (byte)agg_basics.uround(b); }
public void border_color(RGBA_Bytes c) { m_border_color = c; }
public abstract void to_pix(ref RGBA_Bytes c);
// Set colors public void background_color(RGBA_Bytes c) { m_background_color = c; }
public TextWidget(string text, double x = 0, double y = 0, double pointSize = 12, Justification justification = Justification.Left, RGBA_Bytes textColor = new RGBA_Bytes(), bool ellipsisIfClipped = true, bool underline = false, RGBA_Bytes backgroundColor = new RGBA_Bytes(), TypeFace typeFace = null) { Selectable = false; DoubleBuffer = DoubleBufferDefault; AutoExpandBoundsToText = false; EllipsisIfClipped = ellipsisIfClipped; OriginRelativeParent = new Vector2(x, y); this.textColor = textColor; if (this.textColor.Alpha0To255 == 0) { // we assume it is the default if alpha 0. Also there is no reason to make a text color of this as it will draw nothing. this.textColor = RGBA_Bytes.Black; } if (backgroundColor.Alpha0To255 != 0) { BackgroundColor = backgroundColor; } base.Text = text; if (typeFace == null) { typeFace = LiberationSansFont.Instance; } StyledTypeFace typeFaceStyle = new StyledTypeFace(typeFace, pointSize * GuiWidget.DeviceScale, underline); printer = new TypeFacePrinter(text, typeFaceStyle, justification: justification); LocalBounds = printer.LocalBounds; MinimumSize = new Vector2(LocalBounds.Width, LocalBounds.Height); }
public static void DrawTo(Graphics2D graphics2D, Mesh meshToDraw, Vector2 offset, double scale, RGBA_Bytes silhouetteColor) { graphics2D.Rasterizer.gamma(new gamma_power(.3)); PathStorage polygonProjected = new PathStorage(); foreach (Face face in meshToDraw.Faces) { if (face.normal.z > 0) { polygonProjected.remove_all(); bool first = true; foreach (FaceEdge faceEdge in face.FaceEdges()) { Vector2 position = new Vector2(faceEdge.firstVertex.Position.x, faceEdge.firstVertex.Position.y); position += offset; position *= scale; if (first) { polygonProjected.MoveTo(position.x, position.y); first = false; } else { polygonProjected.LineTo(position.x, position.y); } } graphics2D.Render(polygonProjected, silhouetteColor); } } graphics2D.Rasterizer.gamma(new gamma_none()); }
static public void CreateCylinder(VectorPOD <ColorVertexData> colorVertexData, VectorPOD <int> indexData, Vector3 startPos, Vector3 endPos, double radius, int steps, RGBA_Bytes color, double layerHeight) { Vector3 direction = endPos - startPos; Vector3 directionNormal = direction.GetNormal(); Vector3 startSweepDirection = Vector3.GetPerpendicular(startPos, endPos).GetNormal(); int[] tubeStartIndices = new int[steps]; int[] tubeEndIndices = new int[steps]; int[] capStartIndices = new int[steps]; int[] capEndIndices = new int[steps]; double halfHeight = layerHeight / 2 + (layerHeight * .1); double halfWidth = (radius * radius) / halfHeight; double zScale = halfHeight / radius; double xScale = halfWidth / radius; Vector3 scale = new Vector3(xScale, xScale, zScale); for (int i = 0; i < steps; i++) { // create tube ends verts Vector3 tubeNormal = Vector3.Transform(startSweepDirection, Matrix4X4.CreateRotation(direction, MathHelper.Tau / (steps * 2) + MathHelper.Tau / (steps) * i)); Vector3 offset = Vector3.Transform(startSweepDirection * radius, Matrix4X4.CreateRotation(direction, MathHelper.Tau / (steps * 2) + MathHelper.Tau / (steps) * i)); offset *= scale; Vector3 tubeStart = startPos + offset; tubeStartIndices[i] = colorVertexData.Count; colorVertexData.Add(new ColorVertexData(tubeStart, tubeNormal, color)); Vector3 tubeEnd = endPos + offset; tubeEndIndices[i] = colorVertexData.Count; colorVertexData.Add(new ColorVertexData(tubeEnd, tubeNormal, color)); // create cap verts Vector3 rotateAngle = Vector3.Cross(direction, startSweepDirection); Vector3 capStartNormal = Vector3.Transform(startSweepDirection, Matrix4X4.CreateRotation(rotateAngle, MathHelper.Tau / 8)); capStartNormal = Vector3.Transform(capStartNormal, Matrix4X4.CreateRotation(direction, MathHelper.Tau / (steps * 2) + MathHelper.Tau / (steps) * i)); capStartNormal = (capStartNormal * scale).GetNormal(); Vector3 capStartOffset = capStartNormal * radius; capStartOffset *= scale; Vector3 capStart = startPos + capStartOffset; capStartIndices[i] = colorVertexData.Count; colorVertexData.Add(new ColorVertexData(capStart, capStartNormal, color)); Vector3 capEndNormal = Vector3.Transform(startSweepDirection, Matrix4X4.CreateRotation(-rotateAngle, MathHelper.Tau / 8)); capEndNormal = Vector3.Transform(capEndNormal, Matrix4X4.CreateRotation(direction, MathHelper.Tau / (steps * 2) + MathHelper.Tau / (steps) * i)); capEndNormal = (capEndNormal * scale).GetNormal(); Vector3 capEndOffset = capEndNormal * radius; capEndOffset *= scale; Vector3 capEnd = endPos + capEndOffset; capEndIndices[i] = colorVertexData.Count; colorVertexData.Add(new ColorVertexData(capEnd, capEndNormal, color)); } int tipStartIndex = colorVertexData.Count; Vector3 tipOffset = directionNormal * radius; tipOffset *= scale; colorVertexData.Add(new ColorVertexData(startPos - tipOffset, -directionNormal, color)); int tipEndIndex = colorVertexData.Count; colorVertexData.Add(new ColorVertexData(endPos + tipOffset, directionNormal, color)); for (int i = 0; i < steps; i++) { // create tube polys indexData.Add(tubeStartIndices[i]); indexData.Add(tubeEndIndices[i]); indexData.Add(tubeEndIndices[(i + 1) % steps]); indexData.Add(tubeStartIndices[i]); indexData.Add(tubeEndIndices[(i + 1) % steps]); indexData.Add(tubeStartIndices[(i + 1) % steps]); // create start cap polys indexData.Add(tubeStartIndices[i]); indexData.Add(capStartIndices[i]); indexData.Add(capStartIndices[(i + 1) % steps]); indexData.Add(tubeStartIndices[i]); indexData.Add(capStartIndices[(i + 1) % steps]); indexData.Add(tubeStartIndices[(i + 1) % steps]); // create end cap polys indexData.Add(tubeEndIndices[i]); indexData.Add(capEndIndices[i]); indexData.Add(capEndIndices[(i + 1) % steps]); indexData.Add(tubeEndIndices[i]); indexData.Add(capEndIndices[(i + 1) % steps]); indexData.Add(tubeEndIndices[(i + 1) % steps]); // create start tip polys indexData.Add(tipStartIndex); indexData.Add(capStartIndices[i]); indexData.Add(capStartIndices[(i + 1) % steps]); // create end tip polys indexData.Add(tipEndIndex); indexData.Add(capEndIndices[i]); indexData.Add(capEndIndices[(i + 1) % steps]); } }
private FlowLayoutWidget GetHomeButtonBar() { FlowLayoutWidget homeButtonBar = new FlowLayoutWidget(); homeButtonBar.HAnchor = HAnchor.ParentLeftRight; homeButtonBar.Margin = new BorderDouble(3, 0, 3, 6) * TextWidget.GlobalPointSizeScaleRatio; homeButtonBar.Padding = new BorderDouble(0); textImageButtonFactory.borderWidth = 1; textImageButtonFactory.normalBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200); textImageButtonFactory.hoverBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200); ImageBuffer helpIconImage = StaticData.Instance.LoadIcon("icon_home_white_24x24.png"); ImageWidget homeIconImageWidget = new ImageWidget(helpIconImage); homeIconImageWidget.Margin = new BorderDouble(0, 0, 6, 0) * TextWidget.GlobalPointSizeScaleRatio; homeIconImageWidget.OriginRelativeParent += new Vector2(0, 2) * TextWidget.GlobalPointSizeScaleRatio; RGBA_Bytes oldColor = this.textImageButtonFactory.normalFillColor; textImageButtonFactory.normalFillColor = new RGBA_Bytes(180, 180, 180); homeAllButton = textImageButtonFactory.Generate(LocalizedString.Get("ALL")); this.textImageButtonFactory.normalFillColor = oldColor; homeAllButton.Margin = new BorderDouble(0, 0, 6, 0) * TextWidget.GlobalPointSizeScaleRatio; homeAllButton.Click += new EventHandler(homeAll_Click); textImageButtonFactory.FixedWidth = (int)homeAllButton.Width * TextWidget.GlobalPointSizeScaleRatio; homeXButton = textImageButtonFactory.Generate("X", centerText: true); homeXButton.Margin = new BorderDouble(0, 0, 6, 0) * TextWidget.GlobalPointSizeScaleRatio; homeXButton.Click += new EventHandler(homeXButton_Click); homeYButton = textImageButtonFactory.Generate("Y", centerText: true); homeYButton.Margin = new BorderDouble(0, 0, 6, 0) * TextWidget.GlobalPointSizeScaleRatio; homeYButton.Click += new EventHandler(homeYButton_Click); homeZButton = textImageButtonFactory.Generate("Z", centerText: true); homeZButton.Margin = new BorderDouble(0, 0, 6, 0) * TextWidget.GlobalPointSizeScaleRatio; homeZButton.Click += new EventHandler(homeZButton_Click); textImageButtonFactory.normalFillColor = RGBA_Bytes.White; textImageButtonFactory.FixedWidth = 0; GuiWidget spacer = new GuiWidget(); spacer.HAnchor = HAnchor.ParentLeftRight; disableMotors = textImageButtonFactory.Generate("Release".Localize().ToUpper()); disableMotors.Margin = new BorderDouble(0); disableMotors.Click += new EventHandler(disableMotors_Click); GuiWidget spacerReleaseShow = new GuiWidget(10 * TextWidget.GlobalPointSizeScaleRatio, 0); homeButtonBar.AddChild(homeIconImageWidget); homeButtonBar.AddChild(homeAllButton); homeButtonBar.AddChild(homeXButton); homeButtonBar.AddChild(homeYButton); homeButtonBar.AddChild(homeZButton); homeButtonBar.AddChild(spacer); homeButtonBar.AddChild(disableMotors); homeButtonBar.AddChild(spacerReleaseShow); return(homeButtonBar); }
static public void CreatePointer(VectorPOD <ColorVertexData> colorVertexData, VectorPOD <int> indexData, Vector3 startPos, Vector3 endPos, double radius, int steps, RGBA_Bytes color) { Vector3 direction = endPos - startPos; Vector3 directionNormal = direction.GetNormal(); Vector3 startSweepDirection = Vector3.GetPerpendicular(startPos, endPos).GetNormal(); int[] tubeStartIndices = new int[steps]; for (int i = 0; i < steps; i++) { // create tube ends verts Vector3 tubeNormal = Vector3.Transform(startSweepDirection, Matrix4X4.CreateRotation(direction, MathHelper.Tau / (steps * 2) + MathHelper.Tau / (steps) * i)); Vector3 offset = Vector3.Transform(startSweepDirection * radius, Matrix4X4.CreateRotation(direction, MathHelper.Tau / (steps * 2) + MathHelper.Tau / (steps) * i)); Vector3 tubeStart = startPos + offset; tubeStartIndices[i] = colorVertexData.Count; colorVertexData.Add(new ColorVertexData(tubeStart, tubeNormal, color)); Vector3 tubeEnd = endPos + offset; } int tipEndIndex = colorVertexData.Count; colorVertexData.Add(new ColorVertexData(endPos, directionNormal, color)); for (int i = 0; i < steps; i++) { // create tube polys indexData.Add(tubeStartIndices[i]); indexData.Add(tubeStartIndices[(i + 1) % steps]); indexData.Add(tipEndIndex); } }
public WrappingTextWidget(string text, double pointSize = 12, Justification justification = Justification.Left, RGBA_Bytes textColor = new RGBA_Bytes(), bool ellipsisIfClipped = true, bool underline = false, RGBA_Bytes backgroundColor = new RGBA_Bytes()) { unwrappedMessage = text; messageContainer = new TextWidget(text, 0, 0, pointSize, justification, textColor, ellipsisIfClipped, underline); this.BackgroundColor = backgroundColor; messageContainer.AutoExpandBoundsToText = true; messageContainer.HAnchor = HAnchor.ParentLeft; messageContainer.VAnchor = VAnchor.ParentBottom; this.HAnchor = HAnchor.ParentLeftRight; this.VAnchor = VAnchor.FitToChildren; AddChild(messageContainer); }
protected void CreateGuiElements() { this.Cursor = Cursors.Hand; linkButtonFactory.fontSize = 10; linkButtonFactory.textColor = RGBA_Bytes.White; WidgetTextColor = RGBA_Bytes.Black; WidgetBackgroundColor = RGBA_Bytes.White; SetDisplayAttributes(); FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.LeftToRight); mainContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; mainContainer.VAnchor = VAnchor.ParentBottomTop; { partLabel = new TextWidget(this.ItemName.Replace('_', ' '), pointSize: 14); GuiWidget primaryContainer = new GuiWidget(); primaryContainer.HAnchor = HAnchor.ParentLeftRight; primaryContainer.VAnchor = VAnchor.ParentBottomTop; primaryContainer.Name = "Row Item " + partLabel.Text; FlowLayoutWidget primaryFlow = new FlowLayoutWidget(FlowDirection.LeftToRight); primaryFlow.HAnchor = HAnchor.ParentLeftRight; primaryFlow.VAnchor = VAnchor.ParentBottomTop; selectionCheckBoxContainer = new GuiWidget(); selectionCheckBoxContainer.VAnchor = VAnchor.ParentBottomTop; selectionCheckBoxContainer.Width = 40; selectionCheckBoxContainer.Visible = false; selectionCheckBoxContainer.Margin = new BorderDouble(left: 6); selectionCheckBox = new CheckBox(""); selectionCheckBox.Click += selectionCheckBox_Click; selectionCheckBox.Name = "Row Item Select Checkbox"; selectionCheckBox.VAnchor = VAnchor.ParentCenter; selectionCheckBox.HAnchor = HAnchor.ParentCenter; selectionCheckBoxContainer.AddChild(selectionCheckBox); middleColumn = new GuiWidget(0.0, 0.0); middleColumn.HAnchor = Agg.UI.HAnchor.ParentLeftRight; middleColumn.VAnchor = Agg.UI.VAnchor.ParentBottomTop; middleColumn.Margin = new BorderDouble(10, 3); { partLabel.TextColor = WidgetTextColor; partLabel.MinimumSize = new Vector2(1, 18); partLabel.VAnchor = VAnchor.ParentCenter; middleColumn.AddChild(partLabel); bool mouseDownOnMiddle = false; middleColumn.MouseDown += (sender, e) => { // Abort normal processing for view helpers if (this.IsViewHelperItem) { return; } mouseDownOnMiddle = true; }; middleColumn.MouseUp += (sender, e) => { if (mouseDownOnMiddle & middleColumn.LocalBounds.Contains(e.Position)) { if (this.libraryDataView.EditMode) { if (this.IsSelectedItem) { libraryDataView.SelectedItems.Remove(this); } else { libraryDataView.SelectedItems.Add(this); } Invalidate(); } else { // we only have single selection if (this.IsSelectedItem) { // It is already selected, do nothing. } else { libraryDataView.ClearSelectedItems(); libraryDataView.SelectedItems.Add(this); Invalidate(); } } } mouseDownOnMiddle = false; }; } primaryFlow.AddChild(selectionCheckBoxContainer); primaryFlow.AddChild(thumbnailWidget); primaryFlow.AddChild(middleColumn); primaryContainer.AddChild(primaryFlow); rightButtonOverlay = GetItemActionButtons(); rightButtonOverlay.Visible = false; mainContainer.AddChild(primaryContainer); mainContainer.AddChild(rightButtonOverlay); } this.AddChild(mainContainer); AddHandlers(); }
//-------------------------------------------------------------------- ///<summary> ///</summary> ///<param name="x"></param> ///<param name="y"></param> ///<param name="c"></param> public void CopyPixel(int x, int y, RGBA_Bytes c) { PixelFormat.BlendPixel(x, y, c, _alphaMask.Pixel(x, y)); }