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); }
public Pattern GetBrushByState(Rectangle rect, CellDisplayState state) { Color color = GetColorByState(state); if (color == ColorEmpty) { return(null); } return(GetBrush(rect, color)); }
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); } }
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(); } }
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); }
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(); }
public void DrawGlyph(GlyphType type, Rectangle bound, CellStyle style, CellDisplayState state = CellDisplayState.Default) { DrawGlyph(type, bound, style.FontBrush.GetColorByState(state)); }
public MazeGenerationResult(Point point, CellState state, CellDisplayState displayState) { Point = point; State = state; DisplayState = displayState; }
public Cell(CellState state = CellState.Filled, CellDisplayState displayState = CellDisplayState.Wall) { State = state; DisplayState = displayState; }
protected override void OnMouseExited(EventArgs args) { base.OnMouseExited(args); State = CellDisplayState.Default; }
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); }
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); }
protected void ChangeCell(MazeGenerationResults results, Point point, CellState state, CellDisplayState displayState) { var cell = Map.GetCell(point); ChangeCell(results, point, cell, state, displayState); }
public void DrawRectangle(CellStyle style, Rectangle bound, CellDisplayState state = CellDisplayState.Default) { Context.SetLineWidth(style.LineWidth); Context.SetColor(style.BorderBrush.GetColorByState(state)); DrawRectangle(bound); }
protected override void OnButtonPressed(ButtonEventArgs args) { base.OnButtonPressed(args); State = CellDisplayState.Pressed; }
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)); }
protected override void OnButtonReleased(ButtonEventArgs args) { base.OnButtonReleased(args); Click?.Invoke(this, args); State = CellDisplayState.Default; }