private void LayoutRowCentered(IGUIContext ctx, RectangleF bounds)
        {
            if (this.Children.Count > 0)
            {
                float contentWidth = Children.Where(c => c.Visible).Sum(c => c.Bounds.Width + c.Margin.Width)
                                     + ((Children.Count(c => c.Visible)) * Padding.Width);

                RectangleF r  = bounds;
                float      dh = ItemDistance / 2;

                // ALWAYS ADD THE OFFSET FROM THE BOUNDS  !!

                r.X = ((r.Width) / 2f) - (contentWidth / 2f) + bounds.Left;
                for (int i = 0; i < Children.Count; i++)
                {
                    Widget child = Children [i];
                    if (child.Visible)
                    {
                        float w = child.Bounds.Width;
                        r.X    += dh + child.Margin.Left;
                        r.Width = w;
                        LayoutChild(ctx, child, r);
                        r.X += w + dh + child.Margin.Right;
                    }
                }
            }
        }
        public override void Update(IGUIContext ctx)
        {
            try {
                if (AutoScroll && ScrollBars != ScrollBars.None)
                {
                    float offsetX = 0;
                    float offsetY = 0;

                    if (HScrollBar != null && HScrollBar.IsVisibleEnabled)
                    {
                        offsetX = HScrollBar.Value;
                    }
                    if (VScrollBar != null && VScrollBar.IsVisibleEnabled)
                    {
                        offsetY = VScrollBar.Value;
                    }

                    Bounds.Offset(-offsetX, -offsetY);
                }

                base.Update(ctx);
            } catch (Exception ex) {
                ex.LogError();
            }
        }
Beispiel #3
0
        /*** ***/
        public override void OnLayout(IGUIContext ctx, RectangleF bounds)
        {
            if (IsLayoutSuspended)
            {
                return;
            }
            bounds.Height = PreferredSize(ctx).Height;
            this.SetBounds(bounds);
            float maxRight = bounds.Right;

            if (HamburgerMenuVisible)
            {
                HamburgerMenu.OnLayout(ctx, bounds);
                maxRight = Right - Padding.Width - (HamburgerMenu.Width * 2);
            }

            float x = Left + Padding.Left;

            //Children.OfType<ToolBarButton>().Where(c => !c.IsOverlay && c.MenuItem != null)
            Children.OfType <Widget>().Where(c => !c.IsOverlay && c != HamburgerMenu).ForEach(c => {
                if (c.IsOverlay)
                {
                }
                else if (x > maxRight)
                {
                    c.Visible = false;
                }
                else
                {
                    c.Visible = true;
                    c.OnLayout(ctx, new RectangleF(x, Bounds.Top + Padding.Top + c.Margin.Top, c.PreferredSize(ctx).Width + c.Margin.Width, Bounds.Height - Padding.Height));
                    x += c.Width + c.Margin.Width;
                }
            });
        }
        protected override void LayoutChildren(IGUIContext ctx, RectangleF bounds)
        {
            bool overFlow = TabBar.IsOverflow;

            ScrollLeftButton.Visible  = overFlow;
            ScrollRightButton.Visible = overFlow;

            if (overFlow)
            {
                ScrollLeftButton.Enabled  = TabBar.CanScrollRight;
                ScrollRightButton.Enabled = TabBar.CanScrollLeft;
                SizeF      sz = TabBar.PreferredSize(ctx, bounds.Size);
                RectangleF rb = new RectangleF(bounds.Left - 1, bounds.Top, bounds.Width + 2, sz.Height);
                LayoutChild(ctx, ScrollLeftButton, rb);
                LayoutChild(ctx, ScrollRightButton, rb);
                RectangleF centerBounds = rb;
                centerBounds.Inflate(-ScrollLeftButton.Width, 0);
                LayoutChild(ctx, TabBar, centerBounds);
            }
            else
            {
                LayoutChild(ctx, TabBar, bounds);
            }

            TabPage tp = SelectedTab;

            if (tp != null)
            {
                LayoutChild(ctx, tp, new RectangleF(bounds.Left, bounds.Top + TabBar.Height + TabBar.Margin.Bottom,
                                                    bounds.Width, bounds.Height - TabBar.Height - TabBar.Margin.Bottom));
            }
        }
Beispiel #5
0
        public PanelManager(IGUIContext ctx)
            : base(ctx)
        {
            MenuPanel = new Panel("menupanel", Docking.Top);
            AddChild(MenuPanel);

            StatusPanel = new Panel("statuspanel", Docking.Bottom);
            AddChild(StatusPanel);

            MainMenu = new GuiMenu("mainmenu");
            MenuBar  = new MenuBar("mainmenubar", MainMenu);
            ToolBar  = new ToolBar("maintoolbar", MainMenu);

            MenuPanel.AddChild(MenuBar);
            MenuPanel.AddChild(ToolBar);

            StatusBar = new StatusBar("mainstatusbar");
            StatusPanel.AddChild(StatusBar);

            LeftSideBar = new ScrollableContainer("leftsidebar", Docking.Left);
            AddChild(LeftSideBar);

            MainSplitter = new SplitContainer("mainsplitter", SplitOrientation.Vertical, -0.25f);
            AddChild(MainSplitter);

            TabMain = new TabContainer("maintabs");
            MainSplitter.Panel1.AddChild(TabMain);

            RightSideBarVisible = false;
        }
Beispiel #6
0
        public void LoadImage(string filepath, IGUIContext ctx, float opacity = 1f)
        {
            if (m_ImageFilePath != filepath)
            {
                m_ImageFilePath = filepath;

                if (Image != null)
                {
                    Image.Dispose();
                    Image = null;
                }

                if (String.IsNullOrEmpty(filepath) || ctx == null)
                {
                    return;
                }

                try {
                    Image         = TextureImage.FromFile(filepath, ctx);
                    Image.Opacity = opacity;
                } catch (Exception ex) {
                    ex.LogError();
                }
            }
        }
        /// <summary>
        ///   Sets values for the chart and draws them.
        /// </summary>
        /// <param name="graphics">
        ///   Graphics object used for drawing.
        /// </param>
		protected void DoDraw(IGUIContext ctx, Rectangle bounds)
        {
            if (m_values != null && m_values.Length > 0) 
            {                
                float width = bounds.Width - m_leftMargin - m_rightMargin;
				float height = bounds.Height - m_topMargin - m_bottomMargin;
                
				// if the width or height if <=0 an exception would be thrown -> exit method..
                if (width <= 0 || height <= 0)
                    return;
				
                if (m_pieChart != null)
                    m_pieChart.Dispose();
				
                if (m_colors != null && m_colors.Length > 0)
					m_pieChart = new PieChart3D(ctx, bounds.Left + m_leftMargin, bounds.Top + m_topMargin, width, height, m_values, m_colors, m_sliceRelativeHeight, m_texts);
                else
					m_pieChart = new PieChart3D(ctx, bounds.Left + m_leftMargin, bounds.Top + m_topMargin, width, height, m_values, m_sliceRelativeHeight, m_texts);
				
                m_pieChart.FitToBoundingRectangle = m_fitChart;
                m_pieChart.InitialAngle = m_initialAngle;
                m_pieChart.SliceRelativeDisplacements = m_relativeSliceDisplacements;
                m_pieChart.EdgeColorType = m_edgeColorType;
                m_pieChart.EdgeLineWidth = m_edgeLineWidth;
                m_pieChart.ShadowStyle = m_shadowStyle;
                m_pieChart.HighlightedIndex = m_highlightedIndex;
                m_pieChart.Draw(ctx, bounds);

                m_pieChart.Font = this.Font;
                m_pieChart.ForeColor = this.ForeColor;
                m_pieChart.PlaceTexts(ctx);				               
            }
        }
Beispiel #8
0
        public override void Update(IGUIContext ctx)
        {
            if (Bounds.Width <= 0 || Bounds.Height <= 0)
            {
                return;
            }

            using (var clip = new ClipBoundClip(ctx, Bounds, true)) {
                if (!clip.IsEmptyClip)
                {
                    Button.Update(ctx);

                    try {
                        RectangleF bounds = Bounds;
                        bounds.Width -= Bounds.Height;
                        this.OnPaint(ctx, bounds);
                    } catch (Exception ex) {
                        ex.LogError();
                    } finally {
                        //ctx.ResetClip ();
                    }
                }
            }

            if (DropDownWindow != null && DropDownWindow.Visible)
            {
                DropDownWindow.Update(ctx);
            }
        }
        // *** this is never called ..

        /***
         * void LayoutCells(IGUIContext ctx)
         * {
         *      for (int i = 0; i < Table.Rows.Count; i++) {
         *              WidgetTableRow row = Table.Rows [i];
         *              for (int k = 0; k < row.Cells.Count; k++) {
         *                      WidgetTableCell cell = row.Cells [k];
         *                      if (cell != null && cell.Widget != null)
         *                              //cell.Widget.OnLayout (ctx, cell.Widget.Bounds);
         *                              cell.Widget.OnLayout (ctx, cell.Bounds);
         *              }
         *      }
         * }
         ***/


        /*** ***/
        void UpdateColumnWidthsCollapsed(IGUIContext ctx, SizeF proposedSize)
        {
            float width = proposedSize.Width;

            Table.Columns.ForEach(col => col.Width = width);
            Width = width;
        }
 protected override void LayoutChildren(IGUIContext ctx, RectangleF bounds)
 {
     if (Font != null && Menu != null)
     {
         DocumentSize = new SizeF(bounds.Width, Menu.Count * LineHeight);
     }
 }
        public void LoadTextureImageFromFile(string filepath, IGUIContext ctx)
        {
            filepath = filepath.FixedExpandedPath();

            if (m_ImageFilePath != filepath)
            {
                m_ImageFilePath = filepath;

                if (Image != null)
                {
                    Image.Dispose();
                    Image = null;
                }

                if (String.IsNullOrEmpty(filepath) || ctx == null)
                {
                    return;
                }

                try {
                    Image = TextureImage.FromFile(filepath, ctx);
                } catch (Exception ex) {
                    ex.LogError();
                }
            }
        }
Beispiel #12
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            //base.OnPaint (ctx, bounds);

            if (Icon != 0 && IconFont != null)
            {
                float h = bounds.Height;
                float w = bounds.Right - h;
                if (Dock == Docking.Fill && Text == null)
                {
                    ctx.DrawLine(Style.BorderColorPen, w, bounds.Top, w, bounds.Bottom - 0.5f);
                }

                RectangleF rt = new RectangleF(w, bounds.Top + TextOffsetY, h, h);

                if (IconColor != Color.Empty && Enabled)
                {
                    using (Brush brush = new SolidBrush(IconColor)) {
                        ctx.DrawString(Icon.ToString(), IconFont, brush, rt, FontFormat.DefaultIconFontFormatCenter);
                    }
                }
                else
                {
                    ctx.DrawString(Icon.ToString(), IconFont, Style.ForeColorBrush, rt, FontFormat.DefaultIconFontFormatCenter);
                }
            }
        }
Beispiel #13
0
 /// <summary>
 ///   Draws top sides of all pie slices.
 /// </summary>
 /// <param name="graphics">
 ///   <c>Graphics</c> used for drawing.
 /// </param>
 protected void DrawTops(IGUIContext graphics)
 {
     foreach (PieSlice slice in m_pieSlices)
     {
         slice.DrawTop(graphics);
     }
 }
Beispiel #14
0
 public virtual void FillRectangle(IGUIContext ctx, Widget widget)
 {
     if (BackColorBrush.Color != Color.Empty)
     {
         ctx.FillRectangle(BackColorBrush, widget.Bounds);
     }
 }
Beispiel #15
0
        public static void DrawEllipse(this IGUIContext ctx, Pen pen, float cx, float cy, float radiusX, float radiusY, float scale = 1)
        {
            float r        = (Math.Abs(radiusX) + Math.Abs(radiusY)) / 2f;
            float da       = (float)(Math.Acos(r / (r + 0.125f)) * 2f / scale);
            int   numSteps = (int)Math.Round(Tau / da);

            if (numSteps < 1 || da < float.Epsilon)
            {
                return;
            }

            using (new PaintWrapper(RenderingFlags.HighQuality)) {
                GL.Color4(pen.Color);
                pen.DoGL();
                GL.LineWidth(pen.Width);
                GL.Begin(PrimitiveType.LineLoop);
                float angle = 0;
                for (int i = 0; i < numSteps; i++)
                {
                    GL.Vertex2((Math.Cos(angle) * radiusX) + cx, (Math.Sin(angle) * radiusY) + cy);
                    angle += da;
                }
                GL.Vertex2((radiusY * Math.Cos(0)) + cx, (radiusX * Math.Sin(0)) + cy);
                GL.End();
                pen.UndoGL();
            }
        }
        public SizeF PreferredSize(IGUIContext ctx, SizeF proposedSize)
        {
            //if (CachedPreferredSize == SizeF.Empty) {
            if (proposedSize != CachedProposedSize)
            {
                CachedProposedSize = proposedSize;

                if (CollapsibleColumnsWidth > 0 && proposedSize.Width < CollapsibleColumnsWidth)
                {
                    UpdateColumnWidthsCollapsed(ctx, proposedSize);
                    UpdateRowHeightsCollapsed(ctx, proposedSize);
                }
                else
                {
                    UpdateColumnWidthsNormal(ctx, proposedSize);
                    UpdateRowHeightsNormal(ctx, proposedSize);
                }

                CachedPreferredSize = new SizeF(Width, Height);
            }
            else
            {
                //Console.WriteLine ("kein Layout erforderlich.");
            }
            return(CachedPreferredSize);
        }
Beispiel #17
0
        // ******************************************
        // LINES

        public static void DrawLine(this IGUIContext ctx, Pen pen, float x1, float y1, float x2, float y2)
        {
            using (new PaintWrapper(RenderingFlags.HighQuality)) {
                pen.DoGL();

                if (Math.Abs(y1 - y2) < float.Epsilon)
                {
                    y1 -= 0.5f;
                    y2  = y1;
                }
                else if (Math.Abs(x1 - x2) < float.Epsilon)
                {
                    x1 -= 0.5f;
                    x2  = x1;
                }

                GL.Color4(pen.Color);
                GL.LineWidth(pen.Width);
                GL.Begin(PrimitiveType.Lines);
                GL.Vertex2(x2, y2);
                GL.Vertex2(x1, y1);
                GL.End();
                pen.UndoGL();
            }
        }
        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);
                }
            }
        }
Beispiel #20
0
        public override void Update(IGUIContext ctx)
        {
            // We start a new round here.
            // Ensure the stack is empty
            ctx.ClipBoundStack.Clear();
            // The root container sets the first clip-bounds without combining
            // all later should combine the clips..
            using (var clip = new ClipBoundClip(ctx, Bounds, false)) {
                base.Update(ctx);
            }

            try {
                Overlays.RWLock.EnterReadLock();
                //for (int i = 0; i < Overlays.Count; i++) {
                for (int i = Overlays.Count - 1; i >= 0; i--)
                {
                    Widget w = Overlays [i];
                    w.Update(ctx);
                }
            } catch (Exception ex) {
                ex.LogError();
            }
            finally {
                Overlays.RWLock.ExitReadLock();
            }
        }
Beispiel #21
0
		public override void OnLayout (IGUIContext ctx, RectangleF bounds)
		{			
			if (Distance > 0) {
				if (Distance < 1) {
					float oldDistance = Distance;
					float distance = Math.Max(bounds.Height * Distance, Math.Min(bounds.Height - MinDistanceFar, (bounds.Height * Distance).Ceil()));
					float y = Math.Max (bounds.Top + MinDistanceNear, bounds.Top + distance);
					SetBounds (new RectangleF (bounds.Left, y, bounds.Width, SplitterWidth));
					Distance = Math.Max(oldDistance, (int)(distance / bounds.Height));
				} else {
					float oldDistance = Distance;
					float distance = Math.Max(MinDistanceNear, Math.Min(bounds.Height - MinDistanceFar, Distance));
					SetBounds (new RectangleF (bounds.Left, bounds.Top + distance, bounds.Width, SplitterWidth));
					Distance = Math.Max(1.05f, Math.Max(oldDistance, distance));
				}
			} else if (Distance < 0) {
				if (Distance > -1) {
					float oldDistance = Distance;
					float distance = (Math.Min (Distance * bounds.Height, Math.Max(MinDistanceNear, Math.Abs(Distance) * bounds.Height)));
					float y = Math.Max (bounds.Top + MinDistanceNear, bounds.Bottom + distance);
					SetBounds (new RectangleF (bounds.Left, y, bounds.Width, SplitterWidth));
					Distance = Math.Max(-0.95f, Math.Min(-0.05f, Math.Min(oldDistance, distance / bounds.Height)));
				} else {
					float oldDistance = Distance;
					float distance = -(Math.Max (MinDistanceFar, Math.Abs(Distance)));
					float y = Math.Max (bounds.Top + MinDistanceNear, bounds.Bottom + distance);
					SetBounds (new RectangleF (bounds.Left, y, bounds.Width, SplitterWidth));
					Distance = Math.Min(-1.05f, Math.Min(oldDistance, distance));
				}
			} else {
				// Distance == 0
				SetBounds (new RectangleF (bounds.Left, bounds.Top, bounds.Width, SplitterWidth));
			}
		}
        public static TextureImage FromBitmap(Bitmap bmp, IGUIContext ctx, string key, Size size = default(Size))
        {
            if (bmp == null || bmp.Width < 1 || bmp.Height < 1)
            {
                return(null);
            }

            try {
                TextureImage retVal = new TextureImage(key);
                if (size != Size.Empty && size != bmp.Size)
                {
                    using (Bitmap bmpScaled = new Bitmap(bmp, size))
                    {
                        retVal.TextureID = LoadTexture(bmpScaled, ctx);
                        retVal.Size      = bmpScaled.Size;
                        retVal.PixFormat = bmpScaled.PixelFormat;
                    }
                }
                else
                {
                    retVal.TextureID = LoadTexture(bmp, ctx);
                    retVal.Size      = bmp.Size;
                    retVal.PixFormat = bmp.PixelFormat;
                }
                return(retVal);
            } catch (Exception ex) {
                ex.LogError();
                throw;
            }
        }
        public override void DrawHourLabel(IGUIContext gfx, RectangleF rect, int hour)
        {
            lock (m_SyncObj)
            {
                using (var pen = new Pen(Theme.HourLabelColor, 1.5f))
                    using (var brush = new SolidBrush(Theme.HourLabelColor))
                    {
                        rect.X     += 2;
                        rect.Width -= 2;

                        RectangleF HourRectangle = rect;
                        //HourRectangle.Offset(0, 1);
                        HourRectangle.Width = rect.Width;
                        gfx.DrawString(hour.ToString("##00"), HourFont, brush, HourRectangle, m_HourLabelFormat);

                        float delta = (rect.Width * 2f / 3f) - 4;
                        rect.X     += delta;
                        rect.Width -= delta;
                        rect.Height = rect.Height / 2f;
                        //rect.Y += 1;

                        gfx.DrawString("00", MinuteFont, brush, rect, m_HourLabelFormat);
                        gfx.DrawLine(pen, rect.Left + 2, rect.Bottom - 1, rect.Right - 7, rect.Bottom - 1);

                        rect.Y += rect.Height - 1;
                        gfx.DrawString("30", MinuteFont, brush, rect, m_HourLabelFormat);
                    }
            }
        }
        static int LoadTexture(Bitmap bmp, IGUIContext ctx, int id = -1)
        {
            using (new PaintWrapper(RenderingFlags.HighQuality)) {
                GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);
                GL.Enable(EnableCap.Texture2D);

                if (id < 0)
                {
                    id = GL.GenTexture();
                }
                GL.BindTexture(TextureTarget.Texture2D, id);

                // We will not upload mipmaps, so disable mipmapping (otherwise the texture will not appear).
                // We can use GL.GenerateMipmaps() or GL.Ext.GenerateMipmaps() to create
                // mipmaps automatically. In that case, use TextureMinFilter.LinearMipmapLinear to enable them.
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);

                BitmapData data = null;
                try {
                    data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                    GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0,
                                  OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
                } catch (Exception ex) {
                    ex.LogError();
                } finally {
                    bmp.UnlockBits(data);
                }

                return(id);
            }
        }
Beispiel #25
0
        public static ImageList FromFolder(IGUIContext ctx, string folderPath, string name = null, bool includeSubFolders = false, Size imageSize = default(Size))
        {
            try {
                folderPath = folderPath.BackSlash(false).FixedExpandedPath();
                if (String.IsNullOrEmpty(folderPath) || !Directory.Exists(folderPath))
                {
                    return(null);
                }
                if (String.IsNullOrEmpty(name))
                {
                    name = Path.GetDirectoryName(folderPath);
                }
                FileEnumerator enu = new FileEnumerator(folderPath, includeSubFolders);
                enu.FileMask = "*.png;*.jpg;*.jpeg;*.gif;*.tif;*.tiff";
                enu.ScanToList();
                if (enu.Count > 0)
                {
                    ImageList ret = new ImageList(ctx, name, imageSize, true);
                    foreach (var path in enu.FileList)
                    {
                        ret.AddImage(Path.GetFileName(path), path);
                    }
                    return(ret);
                }
            } catch (Exception ex) {
                ex.LogError();
            }

            return(null);
        }
Beispiel #26
0
 public static void FillRectangle(this IGUIContext ctx, HatchBrush brush, RectangleF r)
 {
     using (new PaintWrapper(RenderingFlags.HighQuality)) {
         GL.Color4(brush.Color);
         GL.Rect(r);
     }
 }
Beispiel #27
0
        public override SizeF PreferredSize(IGUIContext ctx, SizeF proposedSize)
        {
            if (CachedPreferredSize == SizeF.Empty)
            {
                if (Children.Count == 0)
                {
                    return(proposedSize);
                }

                float w  = 0;
                float h  = 0;
                float rh = 0;

                foreach (Widget child in Children)
                {
                    SizeF sz = child.PreferredSize(ctx, proposedSize);
                    w += sz.Width;
                    if (rh < sz.Height)
                    {
                        rh = sz.Height;
                    }
                }

                w += Padding.Width;
                h += rh + Padding.Height;

                CachedPreferredSize = new SizeF(proposedSize.Width, h);
            }
            return(CachedPreferredSize);
        }
Beispiel #28
0
        public static void FillRectangle(this IGUIContext ctx, LinearGradientBrush brush, RectangleF r)
        {
            switch (brush.Direction)
            {
            case GradientDirections.Horizontal:
                FillRectangleHorizontal(ctx, brush, r);
                break;

            case GradientDirections.Vertical:
                FillRectangleVertical(ctx, brush, r);
                break;

            case GradientDirections.TopLeft:
                FillRectangleTopLeft(ctx, brush, r);
                break;

            case GradientDirections.ForwardDiagonal:
                FillRectangleForwardDiagonal(ctx, brush, r);
                break;

            case GradientDirections.BackwardDiagonal:
                FillRectangleBackwardDiagonal(ctx, brush, r);
                break;
            }
        }
Beispiel #29
0
        public override SizeF PreferredSize(IGUIContext ctx, SizeF proposedSize)
        {
            SizeF sz = Font.Measure(Text).Inflate(Padding);

            this.MaxSize = sz;
            return(sz);
        }
        private void LayoutRowReverse(IGUIContext ctx, RectangleF bounds)
        {
            float dh = ItemDistance / 2;

            if (this.Children.Count > 0)
            {
                RectangleF r = bounds;
                r.X = bounds.Right;
                for (int i = Children.Count - 1; i >= 0; i--)
                //for (int i = 0; i < Children.Count; i++)
                {
                    Widget child = Children [i];

                    if (child.Visible)
                    {
                        float w = child.Bounds.Width;
                        //r.X -= w + Padding.Right + child.Margin.Right;
                        r.X    -= w + dh + child.Margin.Right;
                        r.Width = w;
                        //r = r.Inflate (child.Margin);
                        LayoutChild(ctx, child, r);
                        //r.X -= Padding.Left + child.Margin.Left;
                        r.X -= dh + child.Margin.Left;
                    }
                }
            }
        }