/// <summary>
        ///   Renders the specified control using the provided graphics interface
        /// </summary>
        /// <param name="control">Control that will be rendered</param>
        /// <param name="graphics">
        ///   Graphics interface that will be used to draw the control
        /// </param>
        public void Render(
            Controls.Desktop.VerticalSliderControl control, IFlatGuiGraphics graphics
            )
        {
            RectangleF controlBounds = control.GetAbsoluteBounds();

            float thumbHeight = controlBounds.Height * control.ThumbSize;
            float thumbY      = (controlBounds.Height - thumbHeight) * control.ThumbPosition;

            graphics.DrawElement("rail.vertical", ref controlBounds);

            RectangleF thumbBounds = new RectangleF(
                controlBounds.Left, controlBounds.Top + thumbY, controlBounds.Width, thumbHeight
                );

            if (control.ThumbDepressed)
            {
                graphics.DrawElement("slider.vertical.depressed", ref thumbBounds);
            }
            else if (control.MouseOverThumb)
            {
                graphics.DrawElement("slider.vertical.highlighted", ref thumbBounds);
            }
            else
            {
                graphics.DrawElement("slider.vertical.normal", ref thumbBounds);
            }
        }
Пример #2
0
        //Will render itSelf the Compass sprite

        public void Render(CompassControl control, IFlatGuiGraphics graphics)
        {
            if (control.HidedPanel)
            {
                return;
            }
            RectangleF absoluteBound = control.GetAbsoluteBounds();

            //Draw the DayCircle First
            SharpDX.Rectangle sourceRect = new SharpDX.Rectangle(0, 0, 150, 75);
            graphics.DrawCustomTexture(control.DayCircle, ref sourceRect, ref absoluteBound, control.RotationDayCycle, control.sampler);

            //Draw the main WindRose for direction
            graphics.DrawCustomTexture(control.CompassTexture, ref sourceRect, ref absoluteBound, control.Rotation, control.sampler);

            //Draw the Mask Arrow
            SharpDX.Rectangle sourceRectMaskArrow = new SharpDX.Rectangle(0, 0, 150, 150);
            RectangleF        absoluteBoundMask   = new RectangleF(absoluteBound.X, absoluteBound.Y, absoluteBound.Width, 150);

            graphics.DrawCustomTexture(control.MaskArrow, ref sourceRectMaskArrow, ref absoluteBoundMask, 0.0f, control.sampler);

            SharpDX.Rectangle sourceRectSoulStoneIcon = new SharpDX.Rectangle(0, 0, 25, 25);
            RectangleF        absoluteBoundSoulStone  = new RectangleF(absoluteBound.X + 62.5f, absoluteBound.Y + 72.5f, 25, 25);

            graphics.DrawCustomTexture(control.SoulStoneIcon, ref sourceRectSoulStoneIcon, ref absoluteBoundSoulStone, 0.0f, control.sampler, 0, new ByteColor((int)(control.SoulStoneFacing * 255f), 0, 0, 255));
        }
Пример #3
0
        /// <summary>
        ///     Renders the specified control using the provided graphics interface
        /// </summary>
        /// <param name="control">Control that will be rendered</param>
        /// <param name="graphics">
        ///     Graphics interface that will be used to draw the control
        /// </param>
        public void Render(
            GuiVerticalSliderControl control, IFlatGuiGraphics graphics
            )
        {
            var controlBounds = control.GetAbsoluteBounds();

            var thumbHeight = controlBounds.Height * control.ThumbSize;
            var thumbY      = (controlBounds.Height - thumbHeight) * control.ThumbPosition;

            graphics.DrawElement("rail.vertical", controlBounds);

            var thumbBounds = new RectangleF(
                controlBounds.X, controlBounds.Y + thumbY, controlBounds.Width, thumbHeight
                );

            if (control.ThumbDepressed)
            {
                graphics.DrawElement("slider.vertical.depressed", thumbBounds);
            }
            else
            {
                if (control.MouseOverThumb)
                {
                    graphics.DrawElement("slider.vertical.highlighted", thumbBounds);
                }
                else
                {
                    graphics.DrawElement("slider.vertical.normal", thumbBounds);
                }
            }
        }
Пример #4
0
        public void Render(ContextMenuControl control, IFlatGuiGraphics graphics)
        {
            _graphics = graphics;

            RectangleF bounds = control.GetAbsoluteBounds();

            graphics.DrawElement("context", bounds);

            string text = control.Name;

            graphics.DrawString("context", bounds, text);

            var itemBounds = new RectangleF(bounds.X + 3, bounds.Y + 30, bounds.Width - 12, ContextMenuControl.ItemHeight);

            foreach (var item in control.Items)
            {
                if (control.SelectedItems.Contains(control.Items.IndexOf(item)))
                {
                    graphics.DrawElement("context.item.highlighted", itemBounds);
                }
                graphics.DrawString("context.item", itemBounds, item);
                itemBounds.Y += itemBounds.Height;
            }

            control.ListRowLocator = this;
        }
        /// <summary>
        ///   Renders the specified control using the provided graphics interface
        /// </summary>
        /// <param name="control">Control that will be rendered</param>
        /// <param name="graphics">
        ///   Graphics interface that will be used to draw the control
        /// </param>
        public void Render(
            Controls.Desktop.ButtonControl control, IFlatGuiGraphics graphics
            )
        {
            RectangleF controlBounds = control.GetAbsoluteBounds();

            // Determine the style to use for the button
            int stateIndex = 0;

            if (control.Enabled)
            {
                if (control.Depressed)
                {
                    stateIndex = 3;
                }
                else if (control.MouseHovering || control.HasFocus)
                {
                    stateIndex = 2;
                }
                else
                {
                    stateIndex = 1;
                }
            }

            // Draw the button's frame
            graphics.DrawElement(states[stateIndex], controlBounds);

            // If there's text assigned to the button, draw it into the button
            if (!string.IsNullOrEmpty(control.Text))
            {
                graphics.DrawString(states[stateIndex], controlBounds, control.Text);
            }
        }
Пример #6
0
        public void Render(ModelControl control, IFlatGuiGraphics graphics)
        {
            var instance = control.ModelInstance;

            if (control.VoxelEffect == null && control.CubeRenderer == null)
            {
                return;
            }

            var needToRender = control.VoxelEffect != null && control.ModelInstance != null || control.CubeRenderer != null && control.SelectedCube != null;

            if (!needToRender)
            {
                return;
            }

            var bounds      = control.GetAbsoluteBounds();
            var voxelEffect = control.VoxelEffect;
            var context     = graphics.Engine.ImmediateContext;

            float  aspectRatio = bounds.Width / bounds.Height;
            Matrix projection;
            var    fov = (float)Math.PI / 3.6f;

            Matrix.PerspectiveFovLH(fov, aspectRatio, 0.5f, 100f, out projection);
            Matrix view = Matrix.LookAtLH(new Vector3(0, 0, -1.9f), Vector3.Zero, Vector3.UnitY);

            //Set custom ViewPort
            graphics.Engine.SetCustomViewPort(new ViewportF(bounds.X, bounds.Y, bounds.Width, bounds.Height));

            //Rendering the Tool
            RenderStatesRepo.ApplyStates(context, DXStates.Rasters.Default, DXStates.Blenders.Enabled, DXStates.DepthStencils.DepthReadWriteEnabled);

            if (instance != null)
            {
                voxelEffect.Begin(context);
                voxelEffect.CBPerFrame.Values.LightDirection = Vector3.Zero;
                voxelEffect.CBPerFrame.Values.ViewProjection = Matrix.Transpose(view * projection);
                voxelEffect.CBPerFrame.IsDirty = true;

                var state = instance.VoxelModel.GetMainState();
                instance.SetState(state);
                var sphere = BoundingSphere.FromBox(state.BoundingBox);
                var rMax   = 2f * Math.Sin(fov / 2);
                var size   = state.BoundingBox.GetSize();
                var offset = -size / 2 - state.BoundingBox.Minimum;
                var scale  = (float)rMax / sphere.Radius;

                instance.World = Matrix.Translation(offset) * Matrix.Scaling(scale) *
                                 Matrix.RotationY(MathHelper.Pi + MathHelper.PiOver4) * control.AlterTransform *
                                 Matrix.RotationQuaternion(control.Rotation);
                control.VisualVoxelModel.Draw(context, control.VoxelEffect, instance);
            }
            else if (control.SelectedCube != null)
            {
                control.CubeRenderer.Render(context, control.AlterTransform * Matrix.RotationQuaternion(control.Rotation) * view, projection, new Color3(1, 1, 1));
            }

            graphics.Engine.SetScreenViewPort();
        }
Пример #7
0
 /// <summary>
 ///   Renders the specified control using the provided graphics interface
 /// </summary>
 /// <param name="control">Control that will be rendered</param>
 /// <param name="graphics">
 ///   Graphics interface that will be used to draw the control
 /// </param>
 public void Render(
     Controls.Arcade.PanelControl control, IFlatGuiGraphics graphics
     )
 {
     // This is simple! A panel consists of a single element we need to draw.
     graphics.DrawElement("window", control.GetAbsoluteBounds());
 }
Пример #8
0
        /// <summary>
        ///   Renders the specified control using the provided graphics interface
        /// </summary>
        /// <param name="control">Control that will be rendered</param>
        /// <param name="graphics">
        ///   Graphics interface that will be used to draw the control
        /// </param>
        public void Render(
            ContainerWindow control, IFlatGuiGraphics graphics
            )
        {
            var controlBounds = control.GetAbsoluteBounds();

            graphics.DrawElement("utopiawindow", ref controlBounds);
        }
Пример #9
0
        /// <summary>
        ///   Renders the specified control using the provided graphics interface
        /// </summary>
        /// <param name="control">Control that will be rendered</param>
        /// <param name="graphics">
        ///   Graphics interface that will be used to draw the control
        /// </param>
        public void Render(Tile control, IFlatGuiGraphics graphics)
        {
            // Determine the style to use for the button
            int stateIndex = control.IsWright ? 0 : 1;

            // Draw the button's frame
            graphics.DrawElement(States[stateIndex], control.GetAbsoluteBounds());
        }
Пример #10
0
 public void Render(ContainerControl control, IFlatGuiGraphics graphics)
 {
     if (control.DisplayBackground && control.Background != null)
     {
         var absoluteBounds = control.GetAbsoluteBounds();
         graphics.DrawCustomTexture(control.Background, ref absoluteBounds, 0, control.DrawGroupId);
     }
 }
Пример #11
0
        /// <summary>
        /// Renders the specified control.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="graphics">The graphics.</param>
        void IFlatControlRenderer <Bubble> .Render(Bubble control, IFlatGuiGraphics graphics)
        {
            // Draw the button's frame
            var index = control.Status == BubbleStatus.Selected ?
                        (int)control.Color + 6 : (int)control.Color;

            graphics.DrawElement(States[index], control.GetAbsoluteBounds());
        }
        /// <summary>
        ///   Renders the specified control using the provided graphics interface
        /// </summary>
        /// <param name="control">Control that will be rendered</param>
        /// <param name="graphics">
        ///   Graphics interface that will be used to draw the control
        /// </param>
        public void Render(
            Controls.Desktop.InputControl control, IFlatGuiGraphics graphics
            )
        {
            RectangleF controlBounds = control.GetAbsoluteBounds();

            // Draw the control's frame and background
            graphics.DrawElement(Style, controlBounds);

            using (graphics.SetClipRegion(controlBounds)) {
                string text = control.Text ?? string.Empty;

                // Amount by which the text will be moved within the input box in
                // order to keep the caret in view even when the text is wider than
                // the input box.
                float left = 0;

                // Only scroll the text within the input box when it has the input
                // focus and the caret is being shown.
                if (control.HasFocus)
                {
                    // Find out where the cursor is from the left end of the text
                    RectangleF stringSize = graphics.MeasureString(
                        Style, controlBounds, text.Substring(0, control.CaretPosition)
                        );

                    // TODO: Renderer should query the size of the control's frame
                    //   Otherwise text will be visible over the frame, which might look bad
                    //   if a skin uses a frame wider than 2 pixels or in a different color
                    //   than the text.
                    while (stringSize.Width + left > controlBounds.Width)
                    {
                        left -= controlBounds.Width / 10.0f;
                    }
                }

                // Draw the text into the input box
                controlBounds.X += left;
                graphics.DrawString(Style, controlBounds, control.Text);

                // If the input box is in focus, also draw the caret so the user knows
                // where characters will be inserted into the text.
                if (control.HasFocus)
                {
                    if (control.MillisecondsSinceLastCaretMovement % 500 < 250)
                    {
                        graphics.DrawCaret(
                            "input.normal", controlBounds, control.Text, control.CaretPosition
                            );
                    }
                }
            }

            // Let the control know that we can provide it with additional informations
            // about how its text is being rendered
            control.OpeningLocator = this;
            this.graphics          = graphics;
        }
Пример #13
0
        /// <summary>
        ///     Renders the specified control using the provided graphics interface
        /// </summary>
        /// <param name="control">Control that will be rendered</param>
        /// <param name="graphics">
        ///     Graphics interface that will be used to draw the control
        /// </param>
        public void Render(GuiProgressControl control, IFlatGuiGraphics graphics)
        {
            var controlBounds = control.GetAbsoluteBounds();

            graphics.DrawElement("progress", controlBounds);

            controlBounds.Width *= control.Progress;
            graphics.DrawElement("progress.bar", controlBounds);
        }
Пример #14
0
        /// <summary>
        ///   Renders the specified control using the provided graphics interface
        /// </summary>
        /// <param name="control">Control that will be rendered</param>
        /// <param name="graphics">
        ///   Graphics interface that will be used to draw the control
        /// </param>
        public void Render(Controls.Desktop.ListControl control, IFlatGuiGraphics graphics)
        {
            this.graphics = graphics;

            RectangleF controlBounds = control.GetAbsoluteBounds();

            graphics.DrawElement(Style, ref controlBounds);

            // Cache the number of items in the list (as a float, this comes in handy later)
            // and the height of a single item when rendered
            float totalItems = control.Items.Count;
            float rowHeight  = GetRowHeight(controlBounds);

            // Number of items (+fraction) fitting into the list's height
            float itemsInView = controlBounds.Height / rowHeight;

            // Number of items by which the slider can move up and down
            float scrollableArea = Math.Max(totalItems - itemsInView, 0.0f);

            // Index (+fraction) of the item at the top of the list given
            // the slider's current position
            float scrollPosition = control.Slider.ThumbPosition * scrollableArea;

            // Determine the first and the last item we need to draw
            // (no need to draw the whole of the list when only a small subset
            // will end up in the clipping area)
            int firstItem = (int)scrollPosition;
            int lastItem  = (int)Math.Ceiling(scrollPosition + itemsInView);

            lastItem = Math.Min(lastItem, control.Items.Count);

            // Set up a rectangle we can use to track the bounds of the item
            // currently being rendered
            RectangleF itemBounds = controlBounds;

            itemBounds.Y     -= (scrollPosition - firstItem) * rowHeight;
            itemBounds.Height = rowHeight;

            //Force a scissor zone for drawing ! => Will flush the previously accumulated information
            using (graphics.SetClipRegion(ref controlBounds))
            {
                for (int item = firstItem; item < lastItem; ++item)
                {
                    if (control.SelectedItems.Contains(item))
                    {
                        graphics.DrawElement("list.selection", ref itemBounds);
                    }

                    graphics.DrawString(Style, 0, ref itemBounds, control.Items[item].ToString(), false);
                    //graphics.DrawElement("button.normal", itemBounds);
                    itemBounds.Y += rowHeight;
                }
            }

            control.ListRowLocator = this;
        }
        /// <summary>
        ///     Renders the specified control using the provided graphics interface
        /// </summary>
        /// <param name="control">Control that will be rendered</param>
        /// <param name="graphics">
        ///     Graphics interface that will be used to draw the control
        /// </param>
        public void Render(GuiWindowControl control, IFlatGuiGraphics graphics)
        {
            var controlBounds = control.GetAbsoluteBounds();

            graphics.DrawElement("window", controlBounds);

            if (control.Title != null)
            {
                graphics.DrawString("window", controlBounds, control.Title);
            }
        }
Пример #16
0
        /// <summary>
        ///   Renders the specified control using the provided graphics interface
        /// </summary>
        /// <param name="control">Control that will be rendered</param>
        /// <param name="graphics">
        ///   Graphics interface that will be used to draw the control
        /// </param>
        public void Render(
            Controls.ProgressControl control, IFlatGuiGraphics graphics
            )
        {
            RectangleF controlBounds = control.GetAbsoluteBounds();

            graphics.DrawElement("progress", ref controlBounds);

            controlBounds.Width *= control.Progress;
            graphics.DrawElement("progress.bar", ref controlBounds);
        }
Пример #17
0
        /// <summary>
        ///     Renders the specified control using the provided graphics interface
        /// </summary>
        /// <param name="control">Control that will be rendered</param>
        /// <param name="graphics">
        ///     Graphics interface that will be used to draw the control
        /// </param>
        public void Render(GuiLabelControl control, IFlatGuiGraphics graphics)
        {
            var frameName = "label";

            if (control.Style != null)
            {
                frameName = control.Style;
            }

            graphics.DrawString(frameName, control.GetAbsoluteBounds(), control.Text);
        }
Пример #18
0
        /// <summary>
        ///   Renders the specified control using the provided graphics interface
        /// </summary>
        /// <param name="control">Control that will be rendered</param>
        /// <param name="graphics">
        ///   Graphics interface that will be used to draw the control
        /// </param>
        public void Render(Controls.LabelControl control, IFlatGuiGraphics graphics)
        {
            var absoluteBounds = control.GetAbsoluteBounds();

            if (control.CustomFont != null)
            {
                ByteColor color = control.Color;
                graphics.DrawString(control.CustomFont, ref absoluteBounds, control.Suffix == null ? control.Text : control.Text + control.Suffix, ref color, control.Autosizing, -1, control.CustomHorizontalPlacement, control.CustomVerticalPlacement);
            }
            else
            {
                string styleFrame;

                if (control.IsHeaderFont)
                {
                    styleFrame = "labelHeader";
                }
                else
                {
                    switch (control.FontStyle)
                    {
                    case System.Drawing.FontStyle.Bold:
                        styleFrame = "labelBold";
                        break;

                    case System.Drawing.FontStyle.Italic:
                        styleFrame = "labelItalic";
                        break;

                    case System.Drawing.FontStyle.Regular:
                        styleFrame = "label";
                        break;

                    case System.Drawing.FontStyle.Underline:
                        styleFrame = "labelUnderline";
                        break;

                    default:
                        styleFrame = "label";
                        break;
                    }
                }

                if (control.ColorSet)
                {
                    ByteColor color = control.Color;
                    graphics.DrawString(styleFrame, 0, ref absoluteBounds, control.Suffix == null ? control.Text : control.Text + control.Suffix, ref color, control.Autosizing);
                }
                else
                {
                    graphics.DrawString(styleFrame, 0, ref absoluteBounds, control.Suffix == null ? control.Text : control.Text + control.Suffix, control.Autosizing);
                }
            }
        }
Пример #19
0
        /// <summary>
        ///     Renders the specified control using the provided graphics interface
        /// </summary>
        /// <param name="control">Control that will be rendered</param>
        /// <param name="graphics">
        ///     Graphics interface that will be used to draw the control
        /// </param>
        public void Render(GuiListControl control, IFlatGuiGraphics graphics)
        {
            _graphics = graphics;

            var controlBounds = control.GetAbsoluteBounds();

            graphics.DrawElement(_style, controlBounds);

            // Cache the number of items in the list (as a float, this comes in handy later)
            // and the height of a single item when rendered
            float totalItems = control.Items.Count;
            var   rowHeight  = GetRowHeight(controlBounds);

            // Number of items (+fraction) fitting into the list's height
            var itemsInView = controlBounds.Height / rowHeight;

            // Number of items by which the slider can move up and down
            var scrollableArea = Math.Max(totalItems - itemsInView, 0.0f);

            // Index (+fraction) of the item at the top of the list given
            // the slider's current position
            var scrollPosition = control.Slider.ThumbPosition * scrollableArea;

            // Determine the first and the last item we need to draw
            // (no need to draw the whole of the list when only a small subset
            // will end up in the clipping area)
            var firstItem = (int)scrollPosition;
            var lastItem  = (int)Math.Ceiling(scrollPosition + itemsInView);

            lastItem = Math.Min(lastItem, control.Items.Count);

            // Set up a rectangle we can use to track the bounds of the item
            // currently being rendered
            var itemBounds = controlBounds;

            itemBounds.Y     -= (scrollPosition - firstItem) * rowHeight;
            itemBounds.Height = rowHeight;

            using (graphics.SetClipRegion(controlBounds))
            {
                for (var item = firstItem; item < lastItem; ++item)
                {
                    if (control.SelectedItems.Contains(item))
                    {
                        graphics.DrawElement("list.selection", itemBounds);
                    }

                    graphics.DrawString(_style, itemBounds, control.Items[item]);
                    itemBounds.Y += rowHeight;
                }
            }

            control.ListRowLocator = this;
        }
        /// <summary>
        ///   Renders the specified control using the provided graphics interface
        /// </summary>
        /// <param name="control">Control that will be rendered</param>
        /// <param name="graphics">
        ///   Graphics interface that will be used to draw the control
        /// </param>
        public void Render(Controls.Arcade.PanelControl control, IFlatGuiGraphics graphics)
        {
            if (control.HidedPanel)
            {
                return;
            }
            RectangleF absoluteBound = control.GetAbsoluteBounds();
            ByteColor  color         = control.Color;

            // This is simple! A panel consists of a single element we need to draw.
            graphics.DrawElement(control.FrameName, ref absoluteBound, ref color);
        }
Пример #21
0
        /// <summary>
        ///     Renders the specified control using the provided graphics interface
        /// </summary>
        /// <param name="control">Control that will be rendered</param>
        /// <param name="graphics">
        ///     Graphics interface that will be used to draw the control
        /// </param>
        public void Render(GuiOptionControl control, IFlatGuiGraphics graphics)
        {
            // Determine the index of the state we're going to display
            var stateIndex = control.Selected ? 4 : 0;

            if (control.Enabled)
            {
                if (control.Depressed)
                {
                    stateIndex += 3;
                }
                else
                {
                    if (control.MouseHovering)
                    {
                        stateIndex += 2;
                    }
                    else
                    {
                        stateIndex += 1;
                    }
                }
            }

            // Get the pixel coordinates of the region covered by the control on
            // the screen
            var controlBounds = control.GetAbsoluteBounds();
            var width         = controlBounds.Width;

            // Now adjust the bounds to a square of height x height pixels so we can
            // render the graphical portion of the option control
            controlBounds.Width = controlBounds.Height;
            graphics.DrawElement(_states[stateIndex], controlBounds);

            // If the option has text assigned to it, render it too
            if (control.Text != null)
            {
                // Restore the original width, then subtract the region that was covered by
                // the graphical portion of the control.
                controlBounds.Width = width - controlBounds.Height;
                controlBounds.X    += controlBounds.Height;

                // Draw the text that was assigned to the option control
                graphics.DrawString(_states[stateIndex], controlBounds, control.Text);
            }
        }
Пример #22
0
        /// <summary>
        ///   Renders the specified control using the provided graphics interface
        /// </summary>
        /// <param name="control">Control that will be rendered</param>
        /// <param name="graphics">
        ///   Graphics interface that will be used to draw the control
        /// </param>
        public void Render(
            Controls.Desktop.ChoiceControl control, IFlatGuiGraphics graphics
            )
        {
            // Determine the index of the state we're going to display
            int stateIndex = (control.Selected ? 4 : 0);

            if (control.Enabled)
            {
                if (control.Depressed)
                {
                    stateIndex += 3;
                }
                else if (control.MouseHovering)
                {
                    stateIndex += 2;
                }
                else
                {
                    stateIndex += 1;
                }
            }

            // Get the pixel coordinates of the region covered by the control on
            // the screen
            RectangleF controlBounds = control.GetAbsoluteBounds();
            float      width         = controlBounds.Width;

            // Now adjust the bounds to a square of height x height pixels so we can
            // render the graphical portion of the choice control
            controlBounds.Width = controlBounds.Height;
            graphics.DrawElement(states[stateIndex], controlBounds);

            // If the choice has text assigned to it, render it too
            if (!string.IsNullOrEmpty(control.Text))
            {
                // Restore the original width, then subtract the region that was covered by
                // the graphical portion of the control.
                controlBounds.Width = width - controlBounds.Height;
                controlBounds.X    += controlBounds.Height;

                // Draw the text that was assigned to the choice control
                graphics.DrawString(states[stateIndex], controlBounds, control.Text);
            }
        }
Пример #23
0
        public void Render(BorderControl control, IFlatGuiGraphics graphics)
        {
            RectangleF controlBounds = control.GetAbsoluteBounds();

            var minimap = new Rectangle((int)controlBounds.X, (int)controlBounds.Y, (int)controlBounds.Width, (int)controlBounds.Height);

            // Top
            graphics.DrawElement("image", new RectangleF(minimap.X, minimap.Y, minimap.Width, control.BorderSize), control.Texture, control.BorderColor);

            // Bottom
            graphics.DrawElement("image", new RectangleF(minimap.X, minimap.Y + minimap.Height, minimap.Width, control.BorderSize), control.Texture, control.BorderColor);

            // Left
            graphics.DrawElement("image", new RectangleF(minimap.X, minimap.Y, control.BorderSize, minimap.Height), control.Texture, control.BorderColor);

            // Right
            graphics.DrawElement("image", new RectangleF(minimap.X + minimap.Width, minimap.Y, control.BorderSize, minimap.Height + control.BorderSize), control.Texture, control.BorderColor);
        }
Пример #24
0
        public void Render(PaletteButtonControl control, IFlatGuiGraphics graphics)
        {
            RectangleF controlBounds = control.GetAbsoluteBounds();

            // Determine the style to use for the button
            int stateIndex = 0;

            if (control.Enabled)
            {
                if (control.Depressed)
                {
                    stateIndex = 3;
                }
                else if (control.MouseHovering || control.HasFocus)
                {
                    stateIndex = 2;
                }
                else
                {
                    stateIndex = 1;
                }
            }

            // Draw the button's frame
            ByteColor color = control.Color;

            graphics.DrawElement(states[stateIndex], ref controlBounds, ref color);

            RectangleF innerBounds = controlBounds;

            innerBounds.Inflate(-1f, -1f);

            if (control.Texture != null)
            {
                graphics.DrawCustomTexture(control.Texture, ref innerBounds);
            }

            // If there's text assigned to the button, draw it into the button
            if (!string.IsNullOrEmpty(control.Text))
            {
                graphics.DrawString(states[stateIndex], 0, ref controlBounds, control.Text, true);
            }
        }
Пример #25
0
        public void Render(ColorButtonControl control, IFlatGuiGraphics graphics)
        {
            var controlBounds = control.GetAbsoluteBounds();

            // Determine the style to use for the button
            var stateIndex = 0;

            if (control.Enabled)
            {
                if (control.Depressed)
                {
                    stateIndex = 3;
                }
                else if (control.MouseHovering || control.HasFocus)
                {
                    stateIndex = 2;
                }
                else
                {
                    stateIndex = 1;
                }
            }

            if (control.Sticked)
            {
                stateIndex = 3;
            }

            // Draw the button's frame
            graphics.DrawElement(States[stateIndex], ref controlBounds);

            var colorBounds = controlBounds;

            colorBounds.X      += 3;
            colorBounds.Y      += 3;
            colorBounds.Width  -= 6;
            colorBounds.Height -= 6;

            ByteColor color = control.Color;

            graphics.DrawElement(States[4], ref colorBounds, ref color);
        }
        /// <summary>
        ///   Renders the specified control using the provided graphics interface
        /// </summary>
        /// <param name="control">Control that will be rendered</param>
        /// <param name="graphics">
        ///   Graphics interface that will be used to draw the control
        /// </param>
        public void Render(
            Controls.Desktop.WindowControl control, IFlatGuiGraphics graphics
            )
        {
            RectangleF controlBounds = control.GetAbsoluteBounds();

            if (control.CustomWindowImage == null)
            {
                graphics.DrawElement("window", ref controlBounds);
            }
            else
            {
                graphics.DrawCustomTexture(control.CustomWindowImage, ref controlBounds, 0, control.DrawGroupId);
            }

            if (control.Title != null)
            {
                graphics.DrawString("window", 0, ref controlBounds, control.Title, false);
            }
        }
Пример #27
0
        /// <summary>
        ///     Renders the specified control using the provided graphics interface
        /// </summary>
        /// <param name="control">Control that will be rendered</param>
        /// <param name="graphics">
        ///     Graphics interface that will be used to draw the control
        /// </param>
        public void Render(GuiButtonControl control, IFlatGuiGraphics graphics)
        {
            var controlBounds = control.GetAbsoluteBounds();

            // Determine the style to use for the button
            var stateIndex = 0;

            if (control.Enabled)
            {
                if (control.Depressed)
                {
                    stateIndex = 3;
                }
                else
                {
                    if (control.MouseHovering || control.HasFocus)
                    {
                        stateIndex = 2;
                    }
                    else
                    {
                        stateIndex = 1;
                    }
                }
            }

            // Draw the button's frame
            graphics.DrawElement(_states[stateIndex], controlBounds);

            // If there's image assigned to the button, draw it into the button
            if (control.Texture != null)
            {
                graphics.DrawImage(controlBounds, control.Texture, control.SourceRectangle);
            }

            // If there's text assigned to the button, draw it into the button
            if (!string.IsNullOrEmpty(control.Text))
            {
                graphics.DrawString(_states[stateIndex], controlBounds, control.Text);
            }
        }
Пример #28
0
        public void Render(QueuedCommandControl control, IFlatGuiGraphics graphics)
        {
            var controlBounds = control.GetAbsoluteBounds();

            // Draw the ability name
            graphics.DrawString("button.normal", controlBounds, control.Command.Ability.Name);

            var avatarBounds = new RectangleF(controlBounds.X, controlBounds.Y, controlBounds.Width, controlBounds.Height);

            avatarBounds.Height -= 10;
            avatarBounds.Width   = avatarBounds.Height;
            avatarBounds.X      += 5;
            avatarBounds.Y      += 5;
            graphics.DrawElement("avatar.icon." + control.Command.Character.Avatar.Icon, avatarBounds);
            var abilityBounds = new RectangleF(controlBounds.X, controlBounds.Y, controlBounds.Width, controlBounds.Height);

            abilityBounds.Height -= 10;
            abilityBounds.Width   = abilityBounds.Height;
            abilityBounds.X      += controlBounds.Width - 5 - abilityBounds.Width;
            abilityBounds.Y      += 5;
            graphics.DrawElement("radialcontrol.images." + control.Command.Ability.ImageName + ".normal", abilityBounds);
        }
Пример #29
0
        public void Render(StickyButtonControl control, IFlatGuiGraphics graphics)
        {
            var controlBounds = control.GetAbsoluteBounds();

            // Determine the style to use for the button
            var stateIndex = 0;

            if (control.Enabled)
            {
                if (control.Depressed)
                {
                    stateIndex = 3;
                }
                else if (control.MouseHovering || control.HasFocus)
                {
                    stateIndex = 2;
                }
                else
                {
                    stateIndex = 1;
                }
            }

            if (control.Sticked)
            {
                stateIndex = 3;
            }

            // Draw the button's frame
            graphics.DrawElement(States[stateIndex], ref controlBounds);

            // If there's text assigned to the button, draw it into the button
            if (!string.IsNullOrEmpty(control.Text))
            {
                graphics.DrawString(States[stateIndex], 0, ref controlBounds, control.Text, false);
            }
        }
Пример #30
0
 /// <summary>
 ///     Renders the specified control using the provided graphics interface
 /// </summary>
 /// <param name="control">Control that will be rendered</param>
 /// <param name="graphics">
 ///     Graphics interface that will be used to draw the control
 /// </param>
 public void Render(GuiLabelControl control, IFlatGuiGraphics graphics)
 {
     graphics.DrawString("label", control.GetAbsoluteBounds(), control.Text);
 }