Exemplo n.º 1
0
 public static TypeFace loadTypeFace(string path)
 {
     var reader = SSAssetManager.OpenStreamReader(path);
     TypeFace newTypeFace = new TypeFace ();
     newTypeFace.ReadSVG(reader.ReadToEnd());
     return newTypeFace;
 }
Exemplo n.º 2
0
        public static TypeFace loadTypeFace(SSAssetManager.Context ctx, string filename)
        {
            var      reader      = ctx.OpenText(filename);
            TypeFace newTypeFace = new TypeFace();

            newTypeFace.ReadSVG(reader.ReadToEnd());
            return(newTypeFace);
        }
Exemplo n.º 3
0
 public HalfEdge(HalfEdge next, HalfEdge previous, HalfEdge opposite, Vector3 position, TypeFace type = TypeFace.NONE)
 {
     m_next     = next;
     m_previous = previous;
     m_opposite = opposite;
     m_position = position;
     m_type     = type;
 }
Exemplo n.º 4
0
    private int index;              // Index ne servant que au debug

    // Constructeurs
    public HalfEdge(int ind, Vector3 position, TypeFace type = TypeFace.NONE)
    {
        m_next     = this;
        m_previous = this;
        m_opposite = this;
        m_position = position;
        m_type     = type;
        index      = ind;
    }
 public TextLabel(string font, int size, TypeFace type, Point position, Color color, string text, bool shadow, bool show)
 {
     Id           = DX9Overlay.TextCreate(font, size, type.HasFlag(TypeFace.BOLD), type.HasFlag(TypeFace.ITALIC), position.X, position.Y, (uint)color.ToArgb(), text, shadow, show);
     _text        = text;
     _shadow      = shadow;
     base.Visible = show;
     _color       = color;
     _position    = position;
 }
Exemplo n.º 6
0
 public TextLabel(String font, int size, TypeFace type, Point pos, Color color, String text, Boolean shadow, Boolean show)
 {
     Id = DX9Overlay.TextCreate(font, size, type.HasFlag(TypeFace.BOLD), type.HasFlag(TypeFace.ITALIC), pos.X, pos.Y, Convert.ToUInt32(DX9Overlay.ToHexValueARGB(color), 16), text, shadow, show);
     this.text = text;
     this.shadow = shadow;
     base.Visible = show;
     this.color = color;
     this.position = pos;
 }
Exemplo n.º 7
0
        public TextScrollWidget(List <string> sourceLines)
        {
            string pathToFont = StaticData.Instance.ReadAllText(Path.Combine("Fonts", "LiberationMono.svg"));

            printer = new TypeFacePrinter("", new StyledTypeFace(TypeFace.LoadFrom(pathToFont), 12));
            printer.DrawFromHintedCache = true;
            this.allSourceLines         = sourceLines;
            this.visibleLines           = sourceLines;
            PrinterOutputCache.Instance.HasChanged.RegisterEvent(RecievedNewLine, ref unregisterEvents);
        }
Exemplo n.º 8
0
        /// <summary>
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            int hash = SEED;

            hash = PRIME_NUMBER * hash + (TypeFace != null ? TypeFace.GetHashCode() : 0);
            hash = PRIME_NUMBER * hash + Height;
            hash = PRIME_NUMBER * hash + (int)Style;
            hash = PRIME_NUMBER * hash + Orientation;
            hash = PRIME_NUMBER * hash + CharSet;
            return(hash);
        }
Exemplo n.º 9
0
        public MenuItemColorStatesView(string name, Color textColor, TypeFace typeFace = null)
        {
            HAnchor    = HAnchor.Stretch | HAnchor.Fit;
            VAnchor    = VAnchor.Fit;
            Selectable = false;

            textWidget = new TextWidget(name, textColor: textColor, typeFace: typeFace)
            {
                AutoExpandBoundsToText = true,
                HAnchor = HAnchor.Left
            };

            AddChild(textWidget);
        }
Exemplo n.º 10
0
        /// <summary>
        /// get processed/scaled vxs
        /// </summary>
        /// <returns></returns>
        public VertexStore GetVxs()
        {
            float scale = TypeFace.CalculateScale(SizeInPoints);// (float)(SizeInPoints * Resolution) / (pointsPerInch * TypeFaceUnitPerEm);
            var   mat   = PixelFarm.Agg.Transform.Affine.NewMatix(
                //scale
                new PixelFarm.Agg.Transform.AffinePlan(
                    PixelFarm.Agg.Transform.AffineMatrixCommand.Scale, scale, scale),
                //translate
                new PixelFarm.Agg.Transform.AffinePlan(
                    PixelFarm.Agg.Transform.AffineMatrixCommand.Translate, 1, 1)
                );
            VertexStore vxs1 = new VertexStore();
            VertexStore vxs2 = new VertexStore();

            return(curveFlattener.MakeVxs(mat.TransformToVxs(ps.Vxs, vxs1), vxs2));
        }
        public override void OnDraw(Graphics2D graphics2D)
        {
#if DEBUG
            ExecutionTimer.Instance.Reset();
            totalDrawTime.Restart();
#endif
            drawTimer.Start();
            base.OnDraw(graphics2D);
            drawTimer.Stop();

#if DEBUG // this is to debug memory allocation and freeing
            totalDrawTime.Stop();
            long memory = GC.GetTotalMemory(false);
            this.Title = string.Format("Allocated = {0:n0} : {1}ms, d{2} Size = {3}x{4}", memory, totalDrawTime.ElapsedMilliseconds, drawCount++, this.Width, this.Height);

#if false
            if (timingWindow == null)
            {
                string   staticDataPath = ApplicationDataStorage.Instance.ApplicationStaticDataPath;
                string   fontPath       = Path.Combine(staticDataPath, "Fonts", "LiberationMono.svg");
                TypeFace boldTypeFace   = TypeFace.LoadSVG(fontPath);
                typeFaceToUse = new StyledTypeFace(boldTypeFace, 12);

                timingWindow = new PerformanceFeedbackWindow();
            }
            {
                if (totalDrawTime.Elapsed.TotalSeconds > .05)
                {
                    timingWindow.ShowResults(totalDrawTime.Elapsed.TotalSeconds);
                }
            }
#endif
#endif

            if (firstDraw)
            {
                Parent.MinimumSize = new Vector2(590, 540);
                firstDraw          = false;
                foreach (string arg in commandLineArgs)
                {
                    if (Path.GetExtension(arg).ToUpper() == ".STL")
                    {
                        new PartPreviewMainWindow(new PrintItemWrapper(new DataStorage.PrintItem(Path.GetFileName(arg), Path.GetFullPath(arg))));
                    }
                }
            }
        }
Exemplo n.º 12
0
        public void DrawString(string text, Font font, TypeFace typeFace, Brush brush, float x, float y,
                               Justification justification = Justification.Left, Baseline baseline = Baseline.BoundsTop)
        {
            SolidBrush colorBrush = brush as SolidBrush;
            //var s1 = new TypeFacePrinter (text, font.SizeInPoints, new MatterHackers.VectorMath.Vector2 (0, 0), Justification.Left, Baseline.BoundsTop);
            var s1 = new TypeFacePrinter(text,
                                         new StyledTypeFace(typeFace, font.SizeInPoints, font.Underline),
                                         new MatterHackers.VectorMath.Vector2(0, 0), justification, baseline);
            var s2 = new VertexSourceApplyTransform(s1, Affine.NewScaling(1, -1));

            if (x != 0.0f || y != 0.0f)
            {
                s2 = new VertexSourceApplyTransform(s2, Affine.NewTranslation(x, y));
            }

            _InternalRender(s2, new RGBA_Bytes((uint)colorBrush.Color.ToArgb()));
        }
Exemplo n.º 13
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            ExecutionTimer.Instance.Reset();

            totalDrawTime.Restart();
            partPreviewDraw.Start();
            base.OnDraw(graphics2D);
            partPreviewDraw.Stop();
            totalDrawTime.Stop();
#if true //DEBUG
#if false
            if (timingWindow == null)
            {
                string   staticDataPath = ApplicationDataStorage.Instance.ApplicationStaticDataPath;
                string   fontPath       = Path.Combine(staticDataPath, "Fonts", "LiberationMono.svg");
                TypeFace boldTypeFace   = TypeFace.LoadSVG(fontPath);
                timingWindow = new PerformanceFeedbackWindow(new StyledTypeFace(boldTypeFace, 12));
                //}
                //{
                timingWindow.ShowResults(totalDrawTime.Elapsed.TotalSeconds);
            }
#endif
#endif
        }
Exemplo n.º 14
0
        /// <summary>
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(Object obj)
        {
            if (obj != null && obj is MgFont)
            {
                MgFont otherFont = (MgFont)obj;

                if (this == otherFont)
                {
                    return(true);
                }
                else
                {
                    if (
                        (Height == otherFont.Height) && (Style == otherFont.Style) && (Orientation == otherFont.Orientation) &&
                        ((TypeFace == null && otherFont.TypeFace == null) || (TypeFace.Equals(otherFont.TypeFace))) &&
                        (CharSet == otherFont.CharSet)
                        )
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 15
0
        public InternalTextEditWidget(string text, double pointSize, bool multiLine, int tabIndex, TypeFace typeFace = null)
        {
            TabIndex = tabIndex;
            TabStop  = true;
            MergeTypingDuringUndo = true;

            internalTextWidget                        = new TextWidget(text, pointSize: pointSize, ellipsisIfClipped: false, textColor: _textColor, typeFace: typeFace);
            internalTextWidget.Selectable             = false;
            internalTextWidget.AutoExpandBoundsToText = true;
            AddChild(internalTextWidget);

            UpdateLocalBounds();

            Multiline = multiLine;

            FixBarPosition(DesiredXPositionOnLine.Set);

            var newUndoData = new TextWidgetUndoCommand(this);

            undoBuffer.Add(newUndoData);

            Cursor = Cursors.IBeam;

            internalTextWidget.TextChanged   += new EventHandler(InternalTextWidget_TextChanged);
            internalTextWidget.BoundsChanged += new EventHandler(InternalTextWidget_BoundsChanged);
        }
Exemplo n.º 16
0
        public MHTextEditWidget(string text = "", double x = 0, double y = 0, double pointSize = 12, double pixelWidth = 0, double pixelHeight = 0, bool multiLine = false, int tabIndex = 0, string messageWhenEmptyAndNotSelected = "", TypeFace typeFace = null)
        {
            Padding = new BorderDouble(3);
            actuallTextEditWidget             = new TextEditWidget(text, x, y, pointSize, pixelWidth, pixelHeight, multiLine, tabIndex: tabIndex, typeFace: typeFace);
            actuallTextEditWidget.HAnchor     = Agg.UI.HAnchor.ParentLeftRight;
            actuallTextEditWidget.MinimumSize = new Vector2(Math.Max(actuallTextEditWidget.MinimumSize.x, pixelWidth), Math.Max(actuallTextEditWidget.MinimumSize.y, pixelHeight));
            actuallTextEditWidget.VAnchor     = Agg.UI.VAnchor.ParentBottom;
            AddChild(actuallTextEditWidget);
            BackgroundColor = RGBA_Bytes.White;
            HAnchor         = HAnchor.FitToChildren;
            VAnchor         = VAnchor.FitToChildren;

            noContentFieldDescription         = new TextWidget(messageWhenEmptyAndNotSelected, textColor: RGBA_Bytes.Gray);
            noContentFieldDescription.VAnchor = VAnchor.ParentBottom;
            noContentFieldDescription.AutoExpandBoundsToText = true;
            AddChild(noContentFieldDescription);
            SetNoContentFieldDescriptionVisibility();
        }
Exemplo n.º 17
0
        public View3DTextCreator(Vector3 viewerVolume, Vector2 bedCenter, MeshViewerWidget.BedShape bedShape)
        {
            boldTypeFace = TypeFace.LoadFrom(StaticData.Instance.ReadAllText(Path.Combine("Fonts", "LiberationSans-Bold.svg")));

            MeshGroupExtraData = new List <PlatingMeshGroupData>();

            FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
            mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;

            FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight);

            centerPartPreviewAndControls.AnchorAll();

            GuiWidget viewArea = new GuiWidget();

            viewArea.AnchorAll();
            {
                meshViewerWidget = new MeshViewerWidget(viewerVolume, bedCenter, bedShape);
                meshViewerWidget.AllowBedRenderingWhenEmpty = true;
                meshViewerWidget.AnchorAll();
            }
            viewArea.AddChild(meshViewerWidget);

            centerPartPreviewAndControls.AddChild(viewArea);
            mainContainerTopToBottom.AddChild(centerPartPreviewAndControls);

            FlowLayoutWidget buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight);

            buttonBottomPanel.HAnchor         = HAnchor.ParentLeftRight;
            buttonBottomPanel.Padding         = new BorderDouble(3, 3);
            buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            buttonRightPanel = CreateRightButtonPanel(viewerVolume.y);

            // add in the plater tools
            {
                FlowLayoutWidget editToolBar = new FlowLayoutWidget();

                processingProgressControl         = new ProgressControl("Finding Parts:".Localize(), ActiveTheme.Instance.PrimaryTextColor, ActiveTheme.Instance.PrimaryAccentColor);
                processingProgressControl.VAnchor = Agg.UI.VAnchor.ParentCenter;
                editToolBar.AddChild(processingProgressControl);
                editToolBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;

                editPlateButtonsContainer = new FlowLayoutWidget();

                textToAddWidget         = new MHTextEditWidget("", pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter Text Here".Localize());
                textToAddWidget.VAnchor = VAnchor.ParentCenter;
                textToAddWidget.Margin  = new BorderDouble(5);
                editPlateButtonsContainer.AddChild(textToAddWidget);
                textToAddWidget.ActualTextEditWidget.EnterPressed += (object sender, KeyEventArgs keyEvent) =>
                {
                    InsertTextNow(textToAddWidget.Text);
                };

                Button insertTextButton = textImageButtonFactory.Generate("Insert".Localize());
                editPlateButtonsContainer.AddChild(insertTextButton);
                insertTextButton.Click += (sender, e) =>
                {
                    InsertTextNow(textToAddWidget.Text);
                };

                KeyDown += (sender, e) =>
                {
                    KeyEventArgs keyEvent = e as KeyEventArgs;
                    if (keyEvent != null && !keyEvent.Handled)
                    {
                        if (keyEvent.KeyCode == Keys.Escape)
                        {
                            if (meshSelectInfo.downOnPart)
                            {
                                meshSelectInfo.downOnPart = false;

                                ScaleRotateTranslate translated = SelectedMeshTransform;
                                translated.translation *= transformOnMouseDown;
                                SelectedMeshTransform   = translated;

                                Invalidate();
                            }
                        }
                    }
                };

                editToolBar.AddChild(editPlateButtonsContainer);
                buttonBottomPanel.AddChild(editToolBar);
            }

            GuiWidget buttonRightPanelHolder = new GuiWidget(HAnchor.FitToChildren, VAnchor.ParentBottomTop);

            centerPartPreviewAndControls.AddChild(buttonRightPanelHolder);
            buttonRightPanelHolder.AddChild(buttonRightPanel);

            viewControls3D = new ViewControls3D(meshViewerWidget);

            viewControls3D.ResetView += (sender, e) =>
            {
                SetDefaultView();
            };

            buttonRightPanelDisabledCover = new Cover(HAnchor.ParentLeftRight, VAnchor.ParentBottomTop);
            buttonRightPanelDisabledCover.BackgroundColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryBackgroundColor, 150);
            buttonRightPanelHolder.AddChild(buttonRightPanelDisabledCover);
            LockEditControls();

            GuiWidget leftRightSpacer = new GuiWidget();

            leftRightSpacer.HAnchor = HAnchor.ParentLeftRight;
            buttonBottomPanel.AddChild(leftRightSpacer);

            closeButton = textImageButtonFactory.Generate("Close".Localize());
            buttonBottomPanel.AddChild(closeButton);

            mainContainerTopToBottom.AddChild(buttonBottomPanel);

            this.AddChild(mainContainerTopToBottom);
            this.AnchorAll();

            meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation;

            AddChild(viewControls3D);

            SetDefaultView();

            AddHandlers();
            UnlockEditControls();
            // but make sure we can't use the right panel yet
            buttonRightPanelDisabledCover.Visible = true;
        }
Exemplo n.º 18
0
        public TextEditWidget(string text = "", double x = 0, double y = 0, double pointSize = 12, double pixelWidth = 0, double pixelHeight = 0, bool multiLine = false, int tabIndex = 0, TypeFace typeFace = null)
        {
            internalTextEditWidget = new InternalTextEditWidget(text, pointSize, multiLine, tabIndex, typeFace: typeFace);
            HookUpToInternalWidget(pixelWidth, pixelHeight);
            OriginRelativeParent = new Vector2(x, y);

            Multiline = multiLine;
        }
        public View3DBrailleBuilder(Vector3 viewerVolume, Vector2 bedCenter, MeshViewerWidget.BedShape bedShape)
        {
            boldTypeFace  = TypeFace.LoadFrom(StaticData.Instance.ReadAllText(Path.Combine("Fonts", "LiberationMono.svg")));
            brailTypeFace = TypeFace.LoadFrom(StaticData.Instance.ReadAllText(Path.Combine("Fonts", "Braille.svg")));

            MeshGroupExtraData = new List <PlatingMeshGroupData>();

            FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
            mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;

            FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight);

            centerPartPreviewAndControls.AnchorAll();

            GuiWidget viewArea = new GuiWidget();

            viewArea.AnchorAll();
            {
                meshViewerWidget = new MeshViewerWidget(viewerVolume, bedCenter, bedShape);
                meshViewerWidget.AllowBedRenderingWhenEmpty = true;
                meshViewerWidget.AnchorAll();
            }
            viewArea.AddChild(meshViewerWidget);

            centerPartPreviewAndControls.AddChild(viewArea);
            mainContainerTopToBottom.AddChild(centerPartPreviewAndControls);

            FlowLayoutWidget buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight);

            buttonBottomPanel.HAnchor         = HAnchor.ParentLeftRight;
            buttonBottomPanel.Padding         = new BorderDouble(3, 3);
            buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            buttonRightPanel = CreateRightButtonPanel(viewerVolume.y);

            // add in the plater tools
            {
                FlowLayoutWidget editToolBar = new FlowLayoutWidget();

                processingProgressControl         = new ProgressControl("Finding Parts:".Localize(), ActiveTheme.Instance.PrimaryTextColor, ActiveTheme.Instance.PrimaryAccentColor);
                processingProgressControl.VAnchor = Agg.UI.VAnchor.ParentCenter;
                editToolBar.AddChild(processingProgressControl);
                editToolBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;

                editPlateButtonsContainer = new FlowLayoutWidget();

                textToAddWidget         = new MHTextEditWidget("", pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter Text Here".Localize());
                textToAddWidget.VAnchor = VAnchor.ParentCenter;
                textToAddWidget.Margin  = new BorderDouble(5);
                editPlateButtonsContainer.AddChild(textToAddWidget);
                textToAddWidget.ActualTextEditWidget.EnterPressed += (object sender, KeyEventArgs keyEvent) =>
                {
                    InsertTextNow(textToAddWidget.Text);
                };

                Button insertTextButton = textImageButtonFactory.Generate("Insert".Localize());
                editPlateButtonsContainer.AddChild(insertTextButton);
                insertTextButton.Click += (sender, e) =>
                {
                    InsertTextNow(textToAddWidget.Text);
                };

                editToolBar.AddChild(editPlateButtonsContainer);
                buttonBottomPanel.AddChild(editToolBar);
            }

            GuiWidget buttonRightPanelHolder = new GuiWidget(HAnchor.FitToChildren, VAnchor.ParentBottomTop);

            centerPartPreviewAndControls.AddChild(buttonRightPanelHolder);
            buttonRightPanelHolder.AddChild(buttonRightPanel);

            viewControls3D = new ViewControls3D(meshViewerWidget);

            buttonRightPanelDisabledCover = new Cover(HAnchor.ParentLeftRight, VAnchor.ParentBottomTop);
            buttonRightPanelDisabledCover.BackgroundColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryBackgroundColor, 150);
            buttonRightPanelHolder.AddChild(buttonRightPanelDisabledCover);
            LockEditControls();

            GuiWidget leftRightSpacer = new GuiWidget();

            leftRightSpacer.HAnchor = HAnchor.ParentLeftRight;
            buttonBottomPanel.AddChild(leftRightSpacer);

            closeButton = textImageButtonFactory.Generate("Close".Localize());
            buttonBottomPanel.AddChild(closeButton);

            mainContainerTopToBottom.AddChild(buttonBottomPanel);

            this.AddChild(mainContainerTopToBottom);
            this.AnchorAll();

            meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation;

            AddChild(viewControls3D);

            // set the view to be a good angle and distance
            meshViewerWidget.TrackballTumbleWidget.TrackBallController.Scale = .06;
            meshViewerWidget.TrackballTumbleWidget.TrackBallController.Rotate(Quaternion.FromEulerAngles(new Vector3(-MathHelper.Tau * .02, 0, 0)));
            meshViewerWidget.TrackballTumbleWidget.TrackBallController.Translate(-new Vector3(bedCenter));

            AddHandlers();
            UnlockEditControls();
            // but make sure we can't use the right panel yet
            buttonRightPanelDisabledCover.Visible = true;

            //meshViewerWidget.RenderType = RenderTypes.Outlines;
            viewControls3D.PartSelectVisible = false;
        }
Exemplo n.º 20
0
        public MHTextEditWidget(string text, ThemeConfig theme, double pixelWidth = 0, double pixelHeight = 0, bool multiLine = false, int tabIndex = 0, string messageWhenEmptyAndNotSelected = "", TypeFace typeFace = null)
        {
            this.Padding = new BorderDouble(3);
            this.HAnchor = HAnchor.Fit;
            this.VAnchor = VAnchor.Fit;
            this.Border  = 1;
            this.theme   = theme;

            this.ActualTextEditWidget = new TextEditWidget(text, 0, 0, theme.DefaultFontSize, pixelWidth, pixelHeight, multiLine, tabIndex: tabIndex, typeFace: typeFace)
            {
                VAnchor         = VAnchor.Bottom,
                BackgroundColor = Color.Transparent
            };

            var internalWidget = this.ActualTextEditWidget.InternalTextEditWidget;

            internalWidget.TextColor     = theme.EditFieldColors.Inactive.TextColor;
            internalWidget.FocusChanged += (s, e) =>
            {
                internalWidget.TextColor            = internalWidget.Focused ? theme.EditFieldColors.Focused.TextColor : theme.EditFieldColors.Inactive.TextColor;
                noContentFieldDescription.TextColor = internalWidget.Focused ? theme.EditFieldColors.Focused.LightTextColor : theme.EditFieldColors.Inactive.LightTextColor;
            };

            this.ActualTextEditWidget.InternalTextEditWidget.BackgroundColor = Color.Transparent;

            this.ActualTextEditWidget.MinimumSize = new Vector2(Math.Max(ActualTextEditWidget.MinimumSize.X, pixelWidth), Math.Max(ActualTextEditWidget.MinimumSize.Y, pixelHeight));
            this.AddChild(this.ActualTextEditWidget);

            this.AddChild(noContentFieldDescription = new TextWidget(messageWhenEmptyAndNotSelected, pointSize: theme.DefaultFontSize, textColor: theme.EditFieldColors.Focused.LightTextColor)
            {
                VAnchor = VAnchor.Top,
                AutoExpandBoundsToText = true
            });

            SetNoContentFieldDescriptionVisibility();
        }
 public SkipIfFirstSpace(double x = 0, double y = 0, double pointSize = 12, Justification justification = Justification.Left, Color textColor = default(Color), bool ellipsisIfClipped = true, bool underline = false, Color backgroundColor = default(Color), TypeFace typeFace = null, bool bold = false)
     : base(" ", x, y, pointSize, justification, textColor, ellipsisIfClipped, underline, backgroundColor, typeFace, bold)
 {
 }
Exemplo n.º 22
0
        public MHTextEditWidget(string text = "", double x = 0, double y = 0, double pointSize = 12, double pixelWidth = 0, double pixelHeight = 0, bool multiLine = false, int tabIndex = 0, string messageWhenEmptyAndNotSelected = "", TypeFace typeFace = null)
        {
            this.Padding         = new BorderDouble(3);
            this.BackgroundColor = Color.White;
            this.HAnchor         = HAnchor.Fit;
            this.VAnchor         = VAnchor.Fit;
            this.Border          = 1;

            this.ActualTextEditWidget = new TextEditWidget(text, x, y, pointSize, pixelWidth, pixelHeight, multiLine, tabIndex: tabIndex, typeFace: typeFace)
            {
                VAnchor = VAnchor.Bottom
            };
            this.ActualTextEditWidget.MinimumSize = new Vector2(Math.Max(ActualTextEditWidget.MinimumSize.X, pixelWidth), Math.Max(ActualTextEditWidget.MinimumSize.Y, pixelHeight));
            this.AddChild(this.ActualTextEditWidget);

            this.AddChild(noContentFieldDescription = new TextWidget(messageWhenEmptyAndNotSelected, textColor: Color.Gray)
            {
                VAnchor = VAnchor.Top,
                AutoExpandBoundsToText = true
            });

            SetNoContentFieldDescriptionVisibility();
        }
Exemplo n.º 23
0
        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);
        }