Ejemplo n.º 1
0
        public void DrawText(string text, Rectangle bound, CellStyle style, CellDisplayState state = CellDisplayState.Default)
        {
            //var pattern = style.FontBrush.GetBrushByState(bound, state);
            //if (pattern != null)
            //    Context.Pattern = pattern;

            DrawText(text, bound, style.Font, style.FontBrush.GetColorByState(state), style.Alignment);
        }
Ejemplo n.º 2
0
        public Pattern GetBrushByState(Rectangle rect, CellDisplayState state)
        {
            Color color = GetColorByState(state);

            if (color == ColorEmpty)
            {
                return(null);
            }
            return(GetBrush(rect, color));
        }
Ejemplo n.º 3
0
        public void FillRectangle(CellStyle style, Rectangle bound, CellDisplayState state = CellDisplayState.Default)
        {
            Context.SetColor(style.BackBrush.GetColorByState(state));
            var pattern = style.BackBrush.GetBrushByState(bound, state);

            if (pattern != null)
            {
                Context.Pattern = pattern;
            }

            FillRectangle(bound);
        }
        public static CellState ToCellState(this CellDisplayState displayState)
        {
            switch (displayState)
            {
            case CellDisplayState.Wall:
                return(CellState.Filled);

            case CellDisplayState.PathWillReturn:
                return(CellState.Empty);

            case CellDisplayState.Path:
                return(CellState.Empty);

            default:
                throw new ArgumentOutOfRangeException(nameof(displayState), displayState, null);
            }
        }
Ejemplo n.º 5
0
        public void DrawGroup(CellStyle style, LayoutGroup group, Rectangle bound, CellDisplayState state, Rectangle gliph)
        {
            var textLayout = group.GetTextLayout();
            var text       = new Rectangle(bound.X + 11, bound.Y + (bound.Height - group.TextSize.Height) / 2D, group.TextSize.Width, group.TextSize.Height);

            DrawCell(style, textLayout, bound, text, state);

            DrawGlyph(group.IsExpand ? GlyphType.ChevronDown : GlyphType.ChevronRight, gliph, style, state);

            var pen = style.FontBrush.GetColorByState(state);

            if (pen != CellStyleBrush.ColorEmpty)
            {
                Context.SetColor(pen);
                Context.MoveTo(bound.X + text.Width + 25, bound.Y + bound.Height / 2);
                Context.LineTo(bound.Right - 30, bound.Y + bound.Height / 2);
                Context.Stroke();
            }
        }
Ejemplo n.º 6
0
        public Color GetColorByState(CellDisplayState state)
        {
            var c = this.Color;

            if (state == CellDisplayState.Selected)
            {
                c = this.ColorSelect;
            }
            else if (state == CellDisplayState.Alternate)
            {
                c = this.ColorAlternate;
            }
            else if (state == CellDisplayState.Hover)
            {
                c = this.ColorHover;
            }
            else if (state == CellDisplayState.Pressed)
            {
                c = this.ColorPress;
            }
            return(c);
        }
Ejemplo n.º 7
0
        public void DrawCell(CellStyle style, object formated, Rectangle bound, Rectangle textBound, CellDisplayState state)
        {
            if (bound.Width <= 0)
            {
                return;
            }
            //Context.Save();
            //Context.Rectangle(bound);
            //Context.Clip();
            var backColor = style.BackBrush.GetColorByState(state);

            if (backColor != CellStyleBrush.ColorEmpty)
            {
                using (DrawingPath path = GetRoundedRect(bound, style.Round))
                {
                    Context.SetColor(backColor);
                    var pattern = style.BackBrush.GetBrushByState(bound, state);
                    if (pattern != null)
                    {
                        Context.Pattern = pattern;
                    }
                    Context.AppendPath(path);
                    Context.Fill();
                    if (pattern != null)
                    {
                        pattern.Dispose();
                    }
                }
            }

            if (formated != null)
            {
                if (formated is string && ((string)formated).Length > 0)
                {
                    DrawText((string)formated, textBound, style, state);
                }
                else if (formated is TextLayout)
                {
                    DrawText((TextLayout)formated, textBound, style, state);
                }
                else if (formated is GlyphType)
                {
                    DrawGlyph((GlyphType)formated, textBound, style, state);
                }
                else if (formated is Image)
                {
                    DrawImage((Image)formated, textBound);
                }
                else if (formated is CheckedState)
                {
                    textBound.Width = textBound.Height;
                    DrawCheckBox((CheckedState)formated, textBound, style.FontBrush.GetColorByState(state));
                }
            }

            var penColor = style.BorderBrush.GetColorByState(state);

            if (penColor != CellStyleBrush.ColorEmpty && style.LineWidth > 0)
            {
                Context.SetLineWidth(style.LineWidth);
                Context.SetColor(penColor);
                var pattern = style.BorderBrush.GetBrushByState(bound, state);
                if (pattern != null)
                {
                    Context.Pattern = pattern;
                }
                using (var borderPath = GetRoundedRect(bound.Inflate(-0.5, -0.5), style.Round))
                {
                    Context.AppendPath(borderPath);
                    Context.Stroke();
                }
            }
            //Context.Restore();
        }
Ejemplo n.º 8
0
 public void DrawGlyph(GlyphType type, Rectangle bound, CellStyle style, CellDisplayState state = CellDisplayState.Default)
 {
     DrawGlyph(type, bound, style.FontBrush.GetColorByState(state));
 }
Ejemplo n.º 9
0
 public MazeGenerationResult(Point point, CellState state, CellDisplayState displayState)
 {
     Point        = point;
     State        = state;
     DisplayState = displayState;
 }
Ejemplo n.º 10
0
 public Cell(CellState state = CellState.Filled, CellDisplayState displayState = CellDisplayState.Wall)
 {
     State        = state;
     DisplayState = displayState;
 }
Ejemplo n.º 11
0
 protected override void OnMouseExited(EventArgs args)
 {
     base.OnMouseExited(args);
     State = CellDisplayState.Default;
 }
Ejemplo n.º 12
0
 protected override void OnMouseEntered(EventArgs args)
 {
     base.OnMouseEntered(args);
     State = CellDisplayState.Hover;
 }
        private void A(MazeGenerationResults results, int x, int y, CellState state = CellState.Empty, CellDisplayState displayState = CellDisplayState.Path)
        {
            var point = new Point(x, y);
            //var cell = Map.GetCell(point);
            //cell.State = state;
            //cell.DisplayState = displayState;
            var result = new MazeGenerationResult(point, state, displayState);

            results.Add(result);
        }
Ejemplo n.º 14
0
        protected void ChangeCell(MazeGenerationResults results, Point point, ICell cell, CellState state, CellDisplayState displayState)
        {
            cell.State        = state;
            cell.DisplayState = displayState;
            var result = new MazeGenerationResult(point, state, displayState);

            results?.Add(result);
        }
Ejemplo n.º 15
0
        protected void ChangeCell(MazeGenerationResults results, Point point, CellState state, CellDisplayState displayState)
        {
            var cell = Map.GetCell(point);

            ChangeCell(results, point, cell, state, displayState);
        }
Ejemplo n.º 16
0
 public void DrawRectangle(CellStyle style, Rectangle bound, CellDisplayState state = CellDisplayState.Default)
 {
     Context.SetLineWidth(style.LineWidth);
     Context.SetColor(style.BorderBrush.GetColorByState(state));
     DrawRectangle(bound);
 }
Ejemplo n.º 17
0
 protected override void OnButtonPressed(ButtonEventArgs args)
 {
     base.OnButtonPressed(args);
     State = CellDisplayState.Pressed;
 }
Ejemplo n.º 18
0
 public void DrawText(TextLayout textLayout, Rectangle bound, CellStyle style, CellDisplayState state = CellDisplayState.Default)
 {
     if (textLayout.Font != style.Font)
     {
         textLayout.Font = style.Font;
     }
     if (textLayout.TextAlignment != style.Alignment)
     {
         textLayout.TextAlignment = style.Alignment;
     }
     DrawText(textLayout, bound, style.FontBrush.GetColorByState(state));
 }
Ejemplo n.º 19
0
 protected override void OnButtonReleased(ButtonEventArgs args)
 {
     base.OnButtonReleased(args);
     Click?.Invoke(this, args);
     State = CellDisplayState.Default;
 }