CPF/CPF.ReoGrid/WPF/SheetTabItem.cs
2024-06-24 10:15:59 +08:00

145 lines
3.5 KiB
C#

using System;
using CPF.Controls;
using CPF.Drawing;
using CPF.ReoGrid.Drawing;
using CPF.ReoGrid.Rendering;
namespace CPF.ReoGrid.WPF
{
internal class SheetTabItem : Decorator
{
[UIPropertyMetadata(false, UIPropertyOptions.AffectsRender)]
public bool IsSelected
{
get
{
return (bool)this.GetValue("IsSelected");
}
set
{
this.SetValue<bool>(value, "IsSelected");
}
}
public SheetTabItem(SheetTabControl owner, string title)
{
this.owner = owner;
this.ChangeTitle(title);
}
public void ChangeTitle(string title)
{
TextBlock child = new TextBlock
{
Text = title,
MarginLeft = 4,
MarginRight = 4
};
base.Child = child;
}
public Color BackColor
{
get
{
return (Color)this.GetValue("BackColor");
}
set
{
this.SetValue<Color>(value, "BackColor");
}
}
public Color TextColor
{
get
{
return (Color)this.GetValue("TextColor");
}
set
{
this.SetValue<Color>(value, "TextColor");
}
}
protected override void OnRender(DrawingContext drawingContext)
{
Size actualSize = base.ActualSize;
float width = actualSize.Width;
float height = actualSize.Height;
CPFPen cpfpen = new CPFPen(this.owner.BorderColor, 1f);
bool isSelected = this.IsSelected;
if (isSelected)
{
Brush fillBrush = (this.BackColor.A > 0) ? new SolidColorBrush(this.BackColor) : "White";
float num = 0f;
float num2 = 0f;
drawingContext.FillRectangle(fillBrush, new Rect(ref num, ref num2, ref width, ref height));
Stroke stroke = cpfpen.Stroke;
Brush brush = cpfpen.Brush;
num = 0f;
num2 = 0f;
Point point = new Point(ref num, ref num2);
float num3 = 0f;
Point point2 = new Point(ref num3, ref height);
drawingContext.DrawLine(stroke, brush, point, point2);
stroke = cpfpen.Stroke;
Brush brush2 = cpfpen.Brush;
num = 0f;
point = new Point(ref width, ref num);
point2 = new Point(ref width, ref height);
drawingContext.DrawLine(stroke, brush2, point, point2);
stroke = cpfpen.Stroke;
Brush brush3 = cpfpen.Brush;
num = 0f;
point = new Point(ref num, ref height);
point2 = new Point(ref width, ref height);
drawingContext.DrawLine(stroke, brush3, point, point2);
stroke = new Stroke(1f);
Brush strokeBrush = "White";
num = 1f;
num2 = 0f;
point = new Point(ref num, ref num2);
num3 = 0f;
point2 = new Point(ref width, ref num3);
drawingContext.DrawLine(stroke, strokeBrush, point, point2);
}
else
{
Brush fillBrush2 = (this.BackColor.A > 0) ? new SolidColorBrush(this.BackColor) : StaticResources.SystemColor_Control;
float num = 0f;
float num2 = 0f;
drawingContext.FillRectangle(fillBrush2, new Rect(ref num, ref num2, ref width, ref height));
int num4 = this.owner.canvas.Children.IndexOf(this);
bool flag = num4 > 0;
Stroke stroke;
Point point;
float num3;
Point point2;
if (flag)
{
stroke = new Stroke(1f);
Brush strokeBrush2 = StaticResources.ControlDarkDarkBrush;
num = 0f;
num2 = 2f;
point = new Point(ref num, ref num2);
num3 = 0f;
float num5 = height - 2f;
point2 = new Point(ref num3, ref num5);
drawingContext.DrawLine(stroke, strokeBrush2, point, point2);
}
stroke = cpfpen.Stroke;
Brush brush4 = cpfpen.Brush;
num = 0f;
num2 = 0f;
point = new Point(ref num, ref num2);
num3 = 0f;
point2 = new Point(ref width, ref num3);
drawingContext.DrawLine(stroke, brush4, point, point2);
}
}
private SheetTabControl owner;
}
}