Example #1
0
        /// <summary>
        /// Draw the image and the displaystring of the specified cell.
        /// </summary>
        /// <param name="p_Cell"></param>
        /// <param name="p_CellPosition"></param>
        /// <param name="e">Paint arguments</param>
        /// <param name="p_ClientRectangle">Rectangle position where draw the current cell, relative to the current view,</param>
        /// <param name="p_Status"></param>
        protected override void DrawCell_ImageAndText(Cells.ICellVirtual p_Cell,
                                                      Position p_CellPosition,
                                                      PaintEventArgs e,
                                                      Rectangle p_ClientRectangle,
                                                      DrawCellStatus p_Status)
        {
            RectangleBorder l_Border    = Border;
            Color           l_ForeColor = ForeColor;

            if (p_Status == DrawCellStatus.Focus)
            {
                l_Border    = FocusBorder;
                l_ForeColor = FocusForeColor;
            }
            else if (p_Status == DrawCellStatus.Selected)
            {
                l_Border    = SelectionBorder;
                l_ForeColor = SelectionForeColor;
            }

            Font l_CurrentFont = GetCellFont();

            //Image and Text
            Utility.PaintImageAndText(e.Graphics,
                                      p_ClientRectangle,
                                      Image,
                                      ImageAlignment,
                                      ImageStretch,
                                      p_Cell.GetDisplayText(p_CellPosition),
                                      StringFormat,
                                      AlignTextToImage,
                                      l_Border,
                                      l_ForeColor,
                                      l_CurrentFont);
        }
Example #2
0
        /// <summary>
        /// Draw the borders of the specified cell.
        /// </summary>
        /// <param name="p_Cell"></param>
        /// <param name="p_CellPosition"></param>
        /// <param name="e">Paint arguments</param>
        /// <param name="p_ClientRectangle">Rectangle position where draw the current cell, relative to the current view,</param>
        /// <param name="p_Status"></param>
        protected override void DrawCell_Border(Cells.ICellVirtual p_Cell,
                                                Position p_CellPosition,
                                                PaintEventArgs e,
                                                Rectangle p_ClientRectangle,
                                                DrawCellStatus p_Status)
        {
            RectangleBorder l_Border = Border;

            l_Border.SetColor(BorderColor);
            if (p_Status == DrawCellStatus.Focus)
            {
                l_Border = FocusBorder;
            }
            else if (p_Status == DrawCellStatus.Selected)
            {
                l_Border = SelectionBorder;
            }

            ControlPaint.DrawBorder(e.Graphics, p_ClientRectangle,
                                    l_Border.Left.Color,
                                    l_Border.Left.Width,
                                    ButtonBorderStyle.Solid,
                                    l_Border.Top.Color,
                                    l_Border.Top.Width,
                                    ButtonBorderStyle.Solid,
                                    l_Border.Right.Color,
                                    l_Border.Right.Width,
                                    ButtonBorderStyle.Solid,
                                    l_Border.Bottom.Color,
                                    l_Border.Bottom.Width,
                                    ButtonBorderStyle.Solid);
        }
Example #3
0
    public void Draw(SpriteBatch sb)
    {
        switch (Irbis.Irbis.debug)
        {
        case 5:
            goto case 4;

        case 4:
            goto case 3;

        case 3:
            goto case 2;

        case 2:
            animationFrame.Update(currentFrame.ToString(), true);
            animationFrame.Draw(sb, (position * Irbis.Irbis.screenScale).ToPoint());
            if (attackCollider != Rectangle.Empty)
            {
                RectangleBorder.Draw(sb, attackCollider, Color.Magenta, depth + 0.001f);
            }
            RectangleBorder.Draw(sb, collider, Color.Magenta, true);
            goto case 1;

        case 1:
            goto default;

        default:
            sb.Draw(tex, position * Irbis.Irbis.screenScale, animationSourceRect, Color.White, 0f, Vector2.Zero, Irbis.Irbis.screenScale, SpriteEffects.None, depth);
            break;
        }
    }
Example #4
0
        /// <summary>
        /// Draw the image and the display string of the specified cell.
        /// </summary>
        /// <param name="p_Cell">The cell.</param>
        /// <param name="p_CellPosition">The cell position.</param>
        /// <param name="e">Paint arguments</param>
        /// <param name="p_ClientRectangle">Rectangle position where draw the current cell, relative to the current view,</param>
        /// <param name="p_Status">Cell status</param>
        protected override void DrawCell_ImageAndText(Cells.ICellVirtual p_Cell, Position p_CellPosition, PaintEventArgs e, Rectangle p_ClientRectangle, DrawCellStatus p_Status)
        {
            if (p_ClientRectangle.Width == 0 || p_ClientRectangle.Height == 0)
            {
                return;
            }

            RectangleBorder l_Border    = Border;
            Color           l_ForeColor = ForeColor;

            IExpandCell l_Cell   = (IExpandCell)p_Cell;
            bool        l_Status = l_Cell.GetStateValue(p_CellPosition);

            Image l_StateImage = GetImageForState(l_Status);

            Font l_CurrentFont = GetCellFont();

            // Image and Text
            VisualModelBase.PaintImageAndText(e.Graphics,
                                              p_ClientRectangle,
                                              l_StateImage,
                                              ContentAlignment.MiddleCenter,
                                              false, // unused
                                              null,  // unused
                                              StringFormat,
                                              false, // unused
                                              l_Border,
                                              l_ForeColor,
                                              l_CurrentFont,
                                              false,
                                              false);
        }
Example #5
0
        public CellView(BaseAppointmentBook parent, CellViewModel cellDisplay, bool selected = false)
        {
            TextAlignment  = DevAge.Drawing.ContentAlignment.MiddleLeft;
            Border         = DevAge.Drawing.RectangleBorder.NoBorder;
            base.BackColor = cellDisplay.BackColor;
            base.ForeColor = cellDisplay.TextColor;
            base.Font      = new Font(base.Font ?? Control.DefaultFont, cellDisplay.FontStyle);
            base.Padding   = new DevAge.Drawing.Padding(selected ? 0 : 1);
            var border = new RectangleBorder {
                Top    = BorderLine.NoBorder,
                Left   = BorderLine.NoBorder,
                Right  = BorderLine.NoBorder,
                Bottom = BorderLine.NoBorder
            };

            if (cellDisplay.Traits.HasFlag(CellTraits.Filled))
            {
                border.Left  = selected ? parent.SelectedAppointmentBorderLine : parent.AppointmentBorderLine;
                border.Right = selected ? parent.SelectedAppointmentBorderLine : parent.AppointmentBorderLine;
            }
            if (cellDisplay.Traits.HasFlag(CellTraits.Top))
            {
                border.Top = selected ? parent.SelectedAppointmentBorderLine : parent.AppointmentBorderLine;
            }
            if (cellDisplay.Traits.HasFlag(CellTraits.Bottom))
            {
                border.Bottom = selected ? parent.SelectedAppointmentBorderLine : parent.AppointmentBorderLine;
            }

            base.Border = border;
        }
Example #6
0
 private void SyncBorders()
 {
     Border = new RectangleBorder(new Border(HeaderLightColor, HeaderLightBorderWidth),
                                  new Border(HeaderShadowColor, HeaderShadowBorderWidth),
                                  new Border(HeaderLightColor, HeaderLightBorderWidth),
                                  new Border(HeaderShadowColor, HeaderShadowBorderWidth));
 }
        private static RectangleBorder BuildBorder(Color?bottomBorderColor)
        {
            RectangleBorder border;

            if (bottomBorderColor.HasValue)
            {
                border = new RectangleBorder
                {
                    Bottom = new BorderLine
                    {
                        Color = bottomBorderColor.Value,
                        Width = 1
                    },
                    Left  = BorderLine.NoBorder,
                    Top   = BorderLine.NoBorder,
                    Right = BorderLine.NoBorder
                };
            }
            else
            {
                border = new RectangleBorder
                {
                    Bottom = BorderLine.NoBorder,
                    Left   = BorderLine.NoBorder,
                    Top    = BorderLine.NoBorder,
                    Right  = BorderLine.NoBorder
                };
            }
            return(border);
        }
Example #8
0
    public void Draw(SpriteBatch sb)
    {
        switch (Irbis.Irbis.debug)
        {
        case 5:
            goto case 4;

        case 4:
            goto case 3;

        case 3:
            RectangleBorder.Draw(sb, bossArena, Color.Red, true);
            if (currentAnimation == 1)
            {
                Vector2 left  = Irbis.Irbis.Lerp(previousHands[0], castingHands[currentFrame][0], timeSinceLastFrame / animationSpeed[currentAnimation]);
                Vector2 right = Irbis.Irbis.Lerp(previousHands[1], castingHands[currentFrame][1], timeSinceLastFrame / animationSpeed[currentAnimation]);
                sb.Draw(Irbis.Irbis.nullTex, (left + position) * Irbis.Irbis.screenScale, null, Color.DeepSkyBlue, 0f, Vector2.Zero, Irbis.Irbis.screenScale, SpriteEffects.None, 0.8f);
                sb.Draw(Irbis.Irbis.nullTex, (right + position) * Irbis.Irbis.screenScale, null, Color.DeepSkyBlue, 0f, Vector2.Zero, Irbis.Irbis.screenScale, SpriteEffects.None, 0.8f);
            }
            if (attackCollider != Rectangle.Empty)
            {
                RectangleBorder.Draw(sb, attackCollider, Color.Red, true);
            }
            goto case 2;

        case 2:
            animationFrame.Update(currentFrame.ToString(), true);
            animationFrame.Draw(sb, ((position + (standardCollider.Location - new Point(24)).ToVector2()) * Irbis.Irbis.screenScale).ToPoint());
            RectangleBorder.Draw(sb, collider, Color.Magenta, true);
            goto case 1;

        case 1:
            goto default;

        default:
            for (int i = firenovas.Count - 1; i >= 0; i--)
            {
                firenovas[i].Draw(sb);
            }
            for (int i = fireballs.Count - 1; i >= 0; i--)
            {
                fireballs[i].Draw(sb);
            }
            for (int i = bolts.Count - 1; i >= 0; i--)
            {
                bolts[i].Draw(sb);
            }
            foreach (Lazor l in lazers)
            {
                l.Draw(sb);
            }
            if (exploding)
            {
                sb.Draw(Irbis.Irbis.explosiontex, explosionLocation * Irbis.Irbis.screenScale, explosionSourceRect, Color.SteelBlue, 0f, new Vector2(64f), Irbis.Irbis.screenScale, SpriteEffects.None, depth);
            }
            sb.Draw(tex, position * Irbis.Irbis.screenScale, animationSourceRect, Color.White, 0f, origin, Irbis.Irbis.screenScale, SpriteEffects.None, depth);
            break;
        }
    }
Example #9
0
 public void Draw(SpriteBatch sb)
 {
     text.Draw(sb);
     if (drawBorder)
     {
         RectangleBorder.Draw(sb, bounds, buttonBorderColor, false);
     }
 }
Example #10
0
 public void DrawRectangle(Rect rect, SchemeColor color, RectangleBorder border = RectangleBorder.None)
 {
     if (action != ImGuiAction.Build)
     {
         return;
     }
     rects.Add(new DrawCommand <RectangleBorder>(rect, border, color));
 }
Example #11
0
        public void ApplyColors()
        {
            GridColor = ColorThemeHelper.ColorBetween(WindowColor, ForeColor, 0.5f);
            var ln = new BorderLine(GridColor, 1);

            DefaultBorderF = new RectangleBorder(ln, ln, ln, ln);
            DefaultBorder3 = new RectangleBorder(BorderLine.NoBorder, ln, ln, ln);
            DefaultBorder  = new RectangleBorder(ln, ln);

            titleModel.ForeColor     = ForeColor;
            titleModel.BackColor     = ColorThemeHelper.ColorBetween(BackColor, ForeColor, 0.1f);
            titleModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            titleModel.Border        = DefaultBorderF;

            titleModel2.ForeColor     = ForeColor;
            titleModel2.BackColor     = BackColor;
            titleModel2.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            titleModel2.Border        = DefaultBorder;

            titleDataCellModel.ForeColor     = ForeColor;
            titleDataCellModel.BackColor     = titleModel.BackColor;
            titleDataCellModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight;
            titleDataCellModel.Border        = DefaultBorderF;

            rowHeaderModel.ForeColor     = ForeColor;
            rowHeaderModel.BackColor     = BackColor;
            rowHeaderModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            rowHeaderModel.Border        = DefaultBorder3;

            rowHeaderModelRed.ForeColor     = Color.White;
            rowHeaderModelRed.BackColor     = Color.IndianRed;
            rowHeaderModelRed.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            rowHeaderModelRed.Border        = DefaultBorder3;

            captionModel.ForeColor = ForeColor;
            captionModel.BackColor = BackColor;
            captionModel.Border    = DefaultBorder;

            dataCellModel.ForeColor = ForeColor;
            dataCellModel.BackColor = WindowColor;
            dataCellModel.Border    = DefaultBorder;

            dataCellMultiLineModel.ForeColor     = ForeColor;
            dataCellMultiLineModel.BackColor     = WindowColor;
            dataCellMultiLineModel.Border        = DefaultBorder;
            dataCellMultiLineModel.TextAlignment = ContentAlignment.TopLeft;
            dataCellMultiLineModel.WordWrap      = true;

            dataCellModelAllignRight.ForeColor     = ForeColor;
            dataCellModelAllignRight.BackColor     = WindowColor;
            dataCellModelAllignRight.TextAlignment = ContentAlignment.MiddleRight;
            dataCellModelAllignRight.Border        = DefaultBorder;

            dataCellCheckBox.ForeColor = ForeColor;
            dataCellCheckBox.BackColor = WindowColor;
            dataCellCheckBox.Border    = DefaultBorder;
        }
Example #12
0
        private void Register()
        {
            RectangleBorder border1 = new RectangleBorder(null);

            _borderMap.Add(border1.Name, border1.GetType());
            EllipseBorder border2 = new EllipseBorder(null);

            _borderMap.Add(border2.Name, border2.GetType());
        }
Example #13
0
 public EmptyCellView(BaseAppointmentBook parent)
 {
     Border = new RectangleBorder {
         Top    = BorderLine.NoBorder,
         Left   = BorderLine.NoBorder,
         Right  = BorderLine.NoBorder,
         Bottom = parent.HorizontalBorderLine
     };
 }
Example #14
0
 public PmsImageBox()
     : base()
 {
     //默认大小
     Size            = new Size(100, 50);
     Border          = new RectangleBorder(this);
     this.BorderName = Border.Name;
     //this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
 }
Example #15
0
        /// <summary>
        /// Draw the image and the displaystring of the specified cell.
        /// </summary>
        /// <param name="p_Cell">The cell.</param>
        /// <param name="p_CellPosition">The cell position.</param>
        /// <param name="e">Paint arguments</param>
        /// <param name="p_ClientRectangle">Rectangle position where draw the current cell, relative to the current view,</param>
        /// <param name="p_Status">Cell status</param>
        protected override void DrawCell_ImageAndText(ICellVirtual p_Cell,
                                                      Position p_CellPosition,
                                                      PaintEventArgs e,
                                                      Rectangle p_ClientRectangle,
                                                      DrawCellStatus p_Status)
        {
            bool l_lastExpandedCell;

            ICell cell = p_Cell as ICell;

            if (cell == null)
            { // this must be a Virtual Cell.
                l_lastExpandedCell = false;
            }
            else
            {     // this is a Real Cell
                if (cell.Grid.Rows[cell.Row].Height == 0)
                { // It is safe to quit now if this cell isn't visible.
                    return;
                }
                l_lastExpandedCell = cell.IsLastExpandedCell;
            }

            RectangleBorder l_Border    = Border;
            Color           l_ForeColor = ForeColor;

            if (p_Status == DrawCellStatus.Focus)
            {
                l_Border    = FocusBorder;
                l_ForeColor = FocusForeColor;
            }
            else if (p_Status == DrawCellStatus.Selected)
            {
                l_Border    = SelectionBorder;
                l_ForeColor = SelectionForeColor;
            }

            Font l_CurrentFont = GetCellFont();

            bool l_Expand = ExpandedCell;

            // Image and Text
            VisualModelBase.PaintImageAndText(e.Graphics,
                                              p_ClientRectangle,
                                              Image,
                                              ImageAlignment,
                                              ImageStretch,
                                              p_Cell.GetDisplayText(p_CellPosition),
                                              StringFormat,
                                              AlignTextToImage,
                                              l_Border,
                                              l_ForeColor,
                                              l_CurrentFont,
                                              l_Expand,
                                              l_lastExpandedCell);
        }
Example #16
0
 public void Draw(SpriteBatch sb)
 {
     if (Irbis.Irbis.debug > 1)
     {
         RectangleBorder.Draw(sb, area, Color.Green, true);
         RectangleBorder.Draw(sb, new Rectangle(position.ToPoint(), renderTarget1.Bounds.Size), Color.Green, true);
     }
     sb.Draw(renderTarget1, position * Irbis.Irbis.screenScale, null, Color.White, 0f, Vector2.Zero, Irbis.Irbis.screenScale, SpriteEffects.None, depth1);
     sb.Draw(renderTarget2, position * Irbis.Irbis.screenScale, null, Color.White, 0f, Vector2.Zero, Irbis.Irbis.screenScale, SpriteEffects.None, depth2);
 }
Example #17
0
 public void Draw(SpriteBatch sb)
 {
     if (Irbis.Irbis.debug > 1)
     {
         RectangleBorder.Draw(sb, area, Color.Green, true);
     }
     foreach (GrassBlade g in bladeList)
     {
         g.Draw(sb);
     }
 }
Example #18
0
        internal override void DrawBorder(SDL.SDL_Rect position, RectangleBorder border)
        {
            RenderingUtils.GetBorderParameters(pixelsPerUnit, border, out var top, out var side, out var bottom);
            RenderingUtils.GetBorderBatch(position, top, side, bottom, ref blitMapping);
            var bm = blitMapping;

            for (var i = 0; i < bm.Length; i++)
            {
                ref var cur = ref bm[i];
                SDL.SDL_BlitScaled(RenderingUtils.CircleSurface, ref cur.texture, surface, ref cur.position);
            }
Example #19
0
        public new static void Initialize()
        {
            if (t_Initialized) // Only do this once per thread.
            {
                return;
            }

            t_DefaultBorder = RectangleBorder.NoBorder; // Make sure we set this first; it's used for new Header().
            t_Initialized   = true;                     // Mark it initialized for the current thread so we don't overwrite them again.
            t_DefaultHeader = new Header();             // Must be after we mark us initialized, or we get infinite recursion!
        }
Example #20
0
 public void Draw(SpriteBatch sb)
 {
     if (Irbis.Irbis.debug > 1)
     {
         RectangleBorder.Draw(sb, Collider, Color.SaddleBrown, true);
     }
     if (draw)
     {
         sb.Draw(texture, position * scale, null, color, rotation, origin, scale, SpriteEffects.None, depth);
     }
 }
            public FlatHeaderVisual()
            {
                _background = new BackgroundSolid(Color.Empty);

                BackColor = Color.FromKnownColor(KnownColor.Control);

                var darkdarkControl = Utilities.CalculateLightDarkColor(BackColor, -0.2f);
                var darkB           = new BorderLine(darkdarkControl, 1);

                _border = new RectangleBorder(darkB, darkB);
            }
Example #22
0
 public void Draw(SpriteBatch sb)
 {
     if (Irbis.Irbis.debug > 1)
     // notice that this is drawing Area and not area
     {
         RectangleBorder.Draw(sb, Area, Color.Green, true);
     }
     foreach (GrassBlade g in bladeList)
     {
         g.Draw(sb);
     }
 }
Example #23
0
        public Header(float gradientAngle)
        {
            GradientAngle = gradientAngle;

            mBackground = new BackgroundLinearGradient(Color.Empty, Color.Empty, GradientAngle);

            BackColor = Color.FromKnownColor(KnownColor.Control);

            Color darkdarkControl = Utilities.CalculateLightDarkColor(BackColor, -0.2f);
            BorderLine darkB = new BorderLine(darkdarkControl, 1);
            mBorder = new RectangleBorder(darkB, darkB);
        }
Example #24
0
        public Header(float gradientAngle)
        {
            GradientAngle = gradientAngle;

            mBackground = new BackgroundLinearGradient(Color.Empty, Color.Empty, GradientAngle);

            BackColor = Color.FromKnownColor(KnownColor.Control);

            Color      darkdarkControl = Utilities.CalculateLightDarkColor(BackColor, -0.2f);
            BorderLine darkB           = new BorderLine(darkdarkControl, 1);

            mBorder = new RectangleBorder(darkB, darkB);
        }
Example #25
0
        /// <summary>
        /// Use default setting
        /// </summary>
        /// <param name="isReadOnly">if set to <c>true</c> this cell is is read only.</param>
        protected VisualModelBase(bool isReadOnly)
        {
            this.backColor = Color.FromKnownColor(KnownColor.Window);
            this.foreColor = Color.FromKnownColor(KnownColor.WindowText);

            this.font = null; // new Font(FontFamily.GenericSansSerif,8.25f); if null the grid font is used

            this.stringFormat = (StringFormat)StringFormat.GenericDefault.Clone();
            TextAlignment     = ContentAlignment.MiddleLeft;
            WordWrap          = false;
            this.border       = RectangleBorder.Default;
            this.isReadOnly   = isReadOnly;
        }
Example #26
0
    // Internal function to create button from constructors
    void createButton(Vector2 location, Vector2 size, string text, UnityEngine.Events.UnityAction call, Color colour, int id)
    {
        // Create objects
        button     = new GameObject("button" + text + id);
        background = new GameObject("buttonBg" + text + id);
        border     = new RectangleBorder(background.transform, colour, size);

        // Mark it as dialog (this can be changed with applytag)
        button.tag     = "dialog";
        background.tag = "dialog";

        Game game = Game.Get();

        background.transform.parent = game.uICanvas.transform;

        RectTransform transBg = background.AddComponent <RectTransform>();

        transBg.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, location.y * UIScaler.GetPixelsPerUnit(), size.y * UIScaler.GetPixelsPerUnit());
        transBg.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, location.x * UIScaler.GetPixelsPerUnit(), size.x * UIScaler.GetPixelsPerUnit());

        button.transform.parent = background.transform;

        RectTransform transBt = button.AddComponent <RectTransform>();

        transBt.SetParent(transBg);

        transBt.localPosition = Vector2.zero;
        transBt.localScale    = transBg.localScale;
        transBt.sizeDelta     = transBg.sizeDelta;

        button.AddComponent <CanvasRenderer>();
        background.AddComponent <CanvasRenderer>();

        UnityEngine.UI.Image uiImage = background.AddComponent <UnityEngine.UI.Image>();
        // Background is partially transparent black
        uiImage.color = new Color(0, 0, 0, (float)0.9);

        UnityEngine.UI.Button uiButton = background.AddComponent <UnityEngine.UI.Button>();
        uiButton.interactable = true;
        uiButton.onClick.AddListener(call);

        uiText           = button.AddComponent <UnityEngine.UI.Text>();
        uiText.color     = colour;
        uiText.text      = text;
        uiText.alignment = TextAnchor.MiddleCenter;
        uiText.font      = game.gameType.GetFont();
        uiText.material  = uiText.font.material;
        // Default to medium font size
        uiText.fontSize = UIScaler.GetMediumFont();
    }
Example #27
0
        /// <summary>
        /// Initializes the overrideable defaults to their initial default values.
        /// </summary>
        /// <remarks>The first thread to load this class will initialize its own copies of these thread-wide defaults
        /// automatically.  Other threads will initialize their own copies of these defaults upon first access, or
        /// they may call this method to force initialization.  It is safe to call this more than once, but
        /// only the first call has an effect.  Thereafter the same initialized defaults in this class are
        /// shared across the entire UI thread (but not between threads), including any changes to these defaults.
        /// This is necessary to avoid sharing the System.Windows.Forms.Cursor objects between threads in a
        /// multi-UI-thread scenario and other un-threadsafe issues.</remarks>
        public static void Initialize()
        {
            if (t_Initialized) // Only do this once per thread.
            {
                return;
            }

            t_DefaultBorder = new RectangleBorder(new BorderLine(Color.LightGray, 1),
                                                  new BorderLine(Color.LightGray, 1));
            t_DefaultPadding   = new DevAge.Drawing.Padding(2);
            t_DefaultBackColor = Color.FromKnownColor(KnownColor.Window);
            t_DefaultForeColor = Color.FromKnownColor(KnownColor.WindowText);
            t_DefaultAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft;
            t_Initialized      = true; // Mark this thread as initialized, so we don't override these again.
        }
Example #28
0
        /// <summary>
        /// Draw the image and the displaystring of the specified cell.
        /// </summary>
        /// <param name="p_Cell">The cell.</param>
        /// <param name="p_CellPosition">The cell position.</param>
        /// <param name="e">Paint arguments</param>
        /// <param name="p_ClientRectangle">Rectangle position where draw the current cell, relative to the current view,</param>
        /// <param name="p_Status">Cell status</param>
        protected override void DrawCell_ImageAndText(ICellVirtual p_Cell, Position p_CellPosition, System.Windows.Forms.PaintEventArgs e, System.Drawing.Rectangle p_ClientRectangle, DrawCellStatus p_Status)
        {
            //base.DrawCell_ImageAndText (p_Cell, p_CellPosition, e, p_ClientRectangle, p_ForeColor, p_CellBorder);
            if (p_ClientRectangle.Width == 0 || p_ClientRectangle.Height == 0)
            {
                return;
            }

            RectangleBorder l_Border    = Border;
            Color           l_ForeColor = ForeColor;

            if (p_Status == DrawCellStatus.Focus)
            {
                l_Border    = FocusBorder;
                l_ForeColor = FocusForeColor;
            }
            else if (p_Status == DrawCellStatus.Selected)
            {
                l_Border    = SelectionBorder;
                l_ForeColor = SelectionForeColor;
            }

            ICellCheckBox  l_CheckBox = (ICellCheckBox)p_Cell;
            CheckBoxStatus l_Status   = l_CheckBox.GetCheckBoxStatus(p_CellPosition);

            Image l_CheckImage = GetImageForState(l_Status.Checked, p_Cell.Grid.MouseCellPosition == p_CellPosition, l_Status.CheckEnable);

            Font l_CurrentFont = GetCellFont();

            bool l_lastExpandedCell = p_Cell is ICell && ((ICell)p_Cell).IsLastExpandedCell;

            // Image and Text
            VisualModelBase.PaintImageAndText(e.Graphics,
                                              p_ClientRectangle,
                                              l_CheckImage,
                                              checkBoxAlignment,
                                              ImageStretch,
                                              l_Status.Caption,
                                              StringFormat,
                                              AlignTextToImage,
                                              l_Border,
                                              l_ForeColor,
                                              l_CurrentFont,
                                              false,
                                              l_lastExpandedCell);
        }
Example #29
0
        /// <summary>
        /// Draw the image and the displaystring of the specified cell.
        /// </summary>
        /// <param name="p_Cell">The cell.</param>
        /// <param name="p_CellPosition">The cell position.</param>
        /// <param name="e">Paint arguments</param>
        /// <param name="p_ClientRectangle">Rectangle position where draw the current cell,
        /// relative to the current view,</param>
        /// <param name="p_Status">Cell status</param>
        protected override void DrawCell_ImageAndText(
            ICellVirtual p_Cell, Position p_CellPosition, System.Windows.Forms.PaintEventArgs e,
            System.Drawing.Rectangle p_ClientRectangle, DrawCellStatus p_Status)
        {
            if (p_ClientRectangle.Width == 0 || p_ClientRectangle.Height == 0)
            {
                return;
            }

            RectangleBorder l_Border    = Border;
            Color           l_ForeColor = ForeColor;

            if (p_Status == DrawCellStatus.Focus)
            {
                l_Border    = FocusBorder;
                l_ForeColor = FocusForeColor;
            }
            else if (p_Status == DrawCellStatus.Selected)
            {
                l_Border    = SelectionBorder;
                l_ForeColor = SelectionForeColor;
            }

            ICellBitmapCell l_BitmapCell  = (ICellBitmapCell)p_Cell;
            Font            l_CurrentFont = GetCellFont();

            Image l_Image = (Image)l_BitmapCell.GetBitmap(p_CellPosition);

            bool l_lastExpandedCell = p_Cell is ICell && ((ICell)p_Cell).IsLastExpandedCell;

            // Image and Text
            VisualModelBase.PaintImageAndText(e.Graphics,
                                              p_ClientRectangle,
                                              l_Image,
                                              imageAlignment,
                                              ImageStretch,
                                              string.Empty, // p_Cell.GetDisplayText(p_CellPosition),
                                              StringFormat,
                                              AlignTextToImage,
                                              l_Border,
                                              l_ForeColor,
                                              l_CurrentFont,
                                              false,
                                              l_lastExpandedCell);
        }
Example #30
0
 public void Draw(SpriteBatch sb)
 {
     sb.Draw(mainBackground, mainBackgroundVector, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.3f);
     //sb.Draw(itemWindow, itemWindowVector, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.3f);
     //sb.Draw(itemInfo, itemInfoVector, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.3f);
     //sb.Draw(pointsWindow, pointsWindowVector, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.3f);
     pointsPrint.statement = "Points: " + Irbis.Irbis.onslaughtSpawner.Points.ToString();
     pointsPrint.Draw(sb);
     infoTitlePrint.Draw(sb);
     infoPrint.Draw(sb);
     pricePrint.Draw(sb);
     RectangleBorder.Draw(sb, currentSelectionRect, Color.White, 0.5f);
     for (int i = 0; i < icons.Length; i++)
     {
         sb.Draw(icons[i], iconPositions[i], icons[i].Bounds, Color.White, 0f, Vector2.Zero, Irbis.Irbis.screenScale, SpriteEffects.None, 0.4f);
         //prints[i].Draw(sb);
     }
 }
Example #31
0
 public void Draw(SpriteBatch sb)
 {
     if (screenScale)
     {
         if (drawOverlay)
         {
             sb.Draw(overlayTexture, origin, overlaySourceRect, overlayColor, 0f, Vector2.Zero, Irbis.Irbis.screenScale, SpriteEffects.None, overlayDepth);
         }
         sb.Draw(fillTexture, valueLocation, valueRect, fillColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, fillDepth);
         if (drawText)
         {
             printValue.Draw(sb, (printLocation * Irbis.Irbis.screenScale).ToPoint());
         }
         if (drawBorder)
         {
             RectangleBorder.Draw(sb, bounds, borderColor, true);
         }
         if (drawBackground) /* draw background */ } {
 }
Example #32
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Common"/> class.
        /// Use default setting
        /// </summary>
        /// <param name="isReadOnly">if set to <c>true</c> is read only.</param>
        public Common(bool isReadOnly)
            : base(isReadOnly)
        {
            this.selectionBackColor = Color.Yellow;
              this.selectionForeColor = Color.Black;
              this.focusBackColor = Color.LightBlue;
              this.focusForeColor = ForeColor;

              this.cellImage = null;
              this.imageAlignment = ContentAlignment.MiddleLeft;
              this.doImageStretch = false;
              this.doAlignTextToImage = true;

              // Border
              this.focusBorder = Border;
              this.selectionBorder = Border;

              this.ExpandedCell = false;
        }
Example #33
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Common"/> class.
        /// </summary>
        /// <remarks>
        /// Copy Constructor.  This method duplicates all the reference field (Image, Font, StringFormat) creating a new instance.
        /// </remarks>
        /// <param name="source">The source.</param>
        /// <param name="isReadOnly">if set to <c>true</c> is read only.</param>
        public Common(Common source, bool isReadOnly)
            : base(source, isReadOnly)
        {
            // Duplicate the reference fields
              Image l_tmpImage = null;
              if (source.cellImage != null)
              {
            l_tmpImage = ImageClone(source.cellImage);
              }

              this.selectionBackColor = source.selectionBackColor;
              this.selectionForeColor = source.selectionForeColor;
              this.focusBackColor = source.focusBackColor;
              this.focusForeColor = source.focusForeColor;
              this.cellImage = l_tmpImage;
              this.imageAlignment = source.imageAlignment;
              this.doImageStretch = source.ImageStretch;
              this.doAlignTextToImage = source.doAlignTextToImage;
              this.focusBorder = source.focusBorder;
              this.selectionBorder = source.selectionBorder;

              ExpandedCell = false;
        }
Example #34
0
 private void SyncBorders()
 {
     Border = new RectangleBorder(new Border(HeaderLightColor, HeaderLightBorderWidth),
             new Border(HeaderShadowColor, HeaderShadowBorderWidth),
             new Border(HeaderLightColor, HeaderLightBorderWidth),
             new Border(HeaderShadowColor, HeaderShadowBorderWidth));
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="VisualModelBase"/> class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="isReadOnly">if set to <c>true</c> model is read only.</param>
        /// <remarks>
        /// Copy Constructor.
        /// This method duplicates all reference fields (Image, Font, StringFormat) to create a new instance.
        /// </remarks>
        protected VisualModelBase(VisualModelBase source, bool isReadOnly)
        {
            // Duplicate the reference fieldsD
              Font l_tmpFont = null;
              if (source.font != null)
              {
            l_tmpFont = (Font)source.font.Clone();
              }
              StringFormat l_tmpStringFormat = null;
              if (source.stringFormat != null)
              {
            l_tmpStringFormat = (StringFormat)source.stringFormat.Clone();
              }

              this.isReadOnly = isReadOnly;
              this.backColor = source.backColor;
              this.foreColor = source.foreColor;
              this.font = l_tmpFont;
              this.stringFormat = l_tmpStringFormat;
              this.border = source.border;
        }
        /// <summary>
        /// Returns the minimum required size of the current cell, calculating using the
        /// current DisplayString, Image and Borders information.
        /// </summary>
        /// <param name="p_Graphics">GDI+ drawing surface</param>
        /// <param name="p_DisplayText">The display text.</param>
        /// <param name="p_StringFormat">The string format.</param>
        /// <param name="p_Font">The font.</param>
        /// <param name="p_Image">The image.</param>
        /// <param name="p_ImageAlignment">The image alignment.</param>
        /// <param name="p_AlignTextToImage">if set to <c>true</c> align text to image.</param>
        /// <param name="p_ImageStretch">if set to <c>true</c> image stretch.</param>
        /// <param name="p_Border">The border.</param>
        /// <returns></returns>
        protected static SizeF CalculateRequiredSize(Graphics p_Graphics,
      string p_DisplayText,
      StringFormat p_StringFormat,
      Font p_Font,
      Image p_Image,
      ContentAlignment p_ImageAlignment,
      bool p_AlignTextToImage,
      bool p_ImageStretch,
      RectangleBorder p_Border)
        {
            SizeF l_ReqSize;

              // Calculate Text Size
              if (p_DisplayText != null && p_DisplayText.Length > 0)
              {
            l_ReqSize = p_Graphics.MeasureString(p_DisplayText, p_Font, MaxStringWidth, p_StringFormat);
            l_ReqSize.Width += 2; // 2 extra space to always fit the text
            l_ReqSize.Height += 2; // 2 extra space to always fit the text
              }
              else
              {
            l_ReqSize = new SizeF(0, 0);
              }

              // Calculate Image Size
              if (p_Image != null)
              {
            // Check whether align Text To Image
            if (p_ImageStretch == false && p_AlignTextToImage &&
              p_DisplayText != null && p_DisplayText.Length > 0)
            {
              if (AlignmentUtility.IsBottom(p_ImageAlignment) && AlignmentUtility.IsBottom(p_StringFormat))
              {
            l_ReqSize.Height += p_Image.Height;
              }
              else if (AlignmentUtility.IsTop(p_ImageAlignment) && AlignmentUtility.IsTop(p_StringFormat))
              {
            l_ReqSize.Height += p_Image.Height;
              }
              else // Max between Image and Text
              {
            if (p_Image.Height > l_ReqSize.Height)
            {
              l_ReqSize.Height = p_Image.Height;
            }
              }

              if (AlignmentUtility.IsLeft(p_ImageAlignment) && AlignmentUtility.IsLeft(p_StringFormat))
              {
            l_ReqSize.Width += p_Image.Width;
              }
              else if (AlignmentUtility.IsRight(p_ImageAlignment) && AlignmentUtility.IsRight(p_StringFormat))
              {
            l_ReqSize.Width += p_Image.Width;
              }
              else // Max between Image and Text
              {
            if (p_Image.Width > l_ReqSize.Width)
            {
              l_ReqSize.Width = p_Image.Width;
            }
              }
            }
            else
            {
              // Max between Image and Text
              if (p_Image.Height > l_ReqSize.Height)
              {
            l_ReqSize.Height = p_Image.Height;
              }
              if (p_Image.Width > l_ReqSize.Width)
              {
            l_ReqSize.Width = p_Image.Width;
              }
            }
              }

              // Add Border Width
              l_ReqSize.Width += p_Border.Left.Width + p_Border.Right.Width;
              l_ReqSize.Height += p_Border.Top.Width + p_Border.Bottom.Width;

              return l_ReqSize;
        }
        /// <summary>
        /// Paint the Text and the Image passed
        /// </summary>
        /// <param name="g">Graphics device where you can render your image and text</param>
        /// <param name="p_displayRectangle">Relative rectangle based on the display area</param>
        /// <param name="p_Image">Image to draw. Can be null.</param>
        /// <param name="p_ImageAlignment">Alignment of the image</param>
        /// <param name="p_ImageStretch">True to make the draw the image with the same size of the cell</param>
        /// <param name="p_Text">Text to draw (can be null)</param>
        /// <param name="p_StringFormat">String format (can be null)</param>
        /// <param name="p_AlignTextToImage">True to align the text with the image</param>
        /// <param name="p_Border">Cell Border</param>
        /// <param name="p_TextColor">Text Color</param>
        /// <param name="p_TextFont">Text Font(can be null)</param>
        /// <param name="p_ExpandedCell">if set to <c>true</c> cell is expanded.</param>
        /// <param name="p_LastExpandedCell">if set to <c>true</c> cell is last expanded cell.</param>
        protected static void PaintImageAndText(Graphics g,
      Rectangle p_displayRectangle,
      Image p_Image,
      ContentAlignment p_ImageAlignment,
      bool p_ImageStretch,
      string p_Text,
      StringFormat p_StringFormat,
      bool p_AlignTextToImage,
      RectangleBorder p_Border,
      Color p_TextColor,
      Font p_TextFont,
      bool p_ExpandedCell,
      bool p_LastExpandedCell)
        {
            // Calculate Rectangle with no border
              Rectangle l_CellRectNoBorder = p_Border.RemoveBorderFromRectangle(p_displayRectangle);

              // Draw image
              if (p_Image != null)
              {
            if (p_ImageStretch) // stretch image
            {
              g.DrawImage(p_Image, l_CellRectNoBorder);
            }
            else
            {
              PointF l_PointImage = CalculateObjAlignment(p_ImageAlignment,
            (int)l_CellRectNoBorder.Left, (int)l_CellRectNoBorder.Top,
            (int)l_CellRectNoBorder.Width, (int)l_CellRectNoBorder.Height,
            p_Image.Width, p_Image.Height);

              RectangleF l_RectDrawImage = l_CellRectNoBorder;
              l_RectDrawImage.Intersect(new RectangleF(l_PointImage, p_Image.PhysicalDimension));

              // Truncate the Rectangle for approximation problem
              g.DrawImage(p_Image, Rectangle.Truncate(l_RectDrawImage));
            }
              }

              // Draw Text
              if (p_Text != null && p_Text.Length > 0)
              {
            if (l_CellRectNoBorder.Width > 0 && l_CellRectNoBorder.Height > 0)
            {
              RectangleF l_RectDrawText = l_CellRectNoBorder;

              // Align Text To Image
              if (p_Image != null && p_ImageStretch == false && p_AlignTextToImage)
              {
            if (AlignmentUtility.IsBottom(p_ImageAlignment) && AlignmentUtility.IsBottom(p_StringFormat))
            {
              l_RectDrawText.Height -= p_Image.Height;
            }
            if (AlignmentUtility.IsTop(p_ImageAlignment) && AlignmentUtility.IsTop(p_StringFormat))
            {
              l_RectDrawText.Y += p_Image.Height;
              l_RectDrawText.Height -= p_Image.Height;
            }
            if (AlignmentUtility.IsLeft(p_ImageAlignment) && AlignmentUtility.IsLeft(p_StringFormat))
            {
              l_RectDrawText.X += p_Image.Width;
              l_RectDrawText.Width -= p_Image.Width;
            }
            if (AlignmentUtility.IsRight(p_ImageAlignment) && AlignmentUtility.IsRight(p_StringFormat))
            {
              l_RectDrawText.Width -= p_Image.Width;
            }
              }

              try
              {
            SolidBrush textBrush = new SolidBrush(p_TextColor);
            g.DrawString(p_Text,
              p_TextFont,
              textBrush,
              l_RectDrawText,
              p_StringFormat);
              }
              catch (Exception ex)
              { // Very long strings can cause a GDI+ exception here.
            LoggerManager.Log(LogLevels.Error, "Cell rendering failed unexpectedly because: " + ex.Message);
              }
            }
              }

              // Draw expanded lines
              if (p_ExpandedCell)
              {
            Pen forePenDark = new Pen(Color.DarkGray, SystemInformation.BorderSize.Height);
            // horizontal line
            Point lineLeft = new Point(l_CellRectNoBorder.Left + (int)((l_CellRectNoBorder.Right - l_CellRectNoBorder.Left) / 2f), l_CellRectNoBorder.Top + (int)((l_CellRectNoBorder.Bottom - l_CellRectNoBorder.Top) / 2f));
            Point lineRight = new Point(l_CellRectNoBorder.Right, (int)(l_CellRectNoBorder.Top + (l_CellRectNoBorder.Bottom - l_CellRectNoBorder.Top) / 2f));
            Point lineTop = new Point(l_CellRectNoBorder.Left + (int)((l_CellRectNoBorder.Right - l_CellRectNoBorder.Left) / 2f), l_CellRectNoBorder.Top);
            Point lineBottom;
            if (p_LastExpandedCell == false)
            {
              lineBottom = new Point(l_CellRectNoBorder.Left + (int)((l_CellRectNoBorder.Right - l_CellRectNoBorder.Left) / 2f), l_CellRectNoBorder.Bottom);
            }
            else
            {
              lineBottom = new Point(l_CellRectNoBorder.Left + (int)((l_CellRectNoBorder.Right - l_CellRectNoBorder.Left) / 2f), l_CellRectNoBorder.Top + (int)((l_CellRectNoBorder.Bottom - l_CellRectNoBorder.Top) / 2f));
            }
            g.DrawLine(forePenDark, lineTop, lineBottom);
            g.DrawLine(forePenDark, lineLeft, lineRight);
              }
        }
        /// <summary>
        /// Use default setting
        /// </summary>
        /// <param name="isReadOnly">if set to <c>true</c> this cell is is read only.</param>
        protected VisualModelBase(bool isReadOnly)
        {
            this.backColor = Color.FromKnownColor(KnownColor.Window);
              this.foreColor = Color.FromKnownColor(KnownColor.WindowText);

              this.font = null; // new Font(FontFamily.GenericSansSerif,8.25f); if null the grid font is used

              this.stringFormat = (StringFormat)StringFormat.GenericDefault.Clone();
              TextAlignment = ContentAlignment.MiddleLeft;
              WordWrap = false;
              this.border = RectangleBorder.Default;
              this.isReadOnly = isReadOnly;
        }