diff --git a/CPF.Toolkit.Demo/Program.cs b/CPF.Toolkit.Demo/Program.cs index 6ae9276..e83b91c 100644 --- a/CPF.Toolkit.Demo/Program.cs +++ b/CPF.Toolkit.Demo/Program.cs @@ -17,7 +17,7 @@ namespace CPF.Toolkit.Demo , (OperatingSystemType.Linux, new CPF.Linux.LinuxPlatform(), new SkiaDrawingFactory { UseGPU = false }) ); - Application.Run(ViewManager.View()); + Application.Run(ViewManager.View()); } } } diff --git a/CPF.Toolkit.Demo/TestMdiView.cs b/CPF.Toolkit.Demo/TestMdiView.cs new file mode 100644 index 0000000..2214932 --- /dev/null +++ b/CPF.Toolkit.Demo/TestMdiView.cs @@ -0,0 +1,44 @@ +using CPF; +using CPF.Animation; +using CPF.Charts; +using CPF.Controls; +using CPF.Drawing; +using CPF.Shapes; +using CPF.Styling; +using CPF.Svg; +using CPF.Toolkit.Controls; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace CPF.Toolkit.Demo +{ + public class TestMdiView : Window + { + protected override void InitializeComponent() + { + this.CanResize = true; + this.Title = "标题"; + this.Width = 1280; + this.Height = 720; + this.Background = null; + this.Children.Add(new WindowFrame(this, new Panel + { + Size = SizeField.Fill, + Background = "204,204,204", + Children = + { + new MdiWindow + { + Title = "test", + Content = new Button + { + Content = "test" + }, + } + } + })); + } + } +} diff --git a/CPF.Toolkit/Controls/MdiWindow.cs b/CPF.Toolkit/Controls/MdiWindow.cs new file mode 100644 index 0000000..04b3bfe --- /dev/null +++ b/CPF.Toolkit/Controls/MdiWindow.cs @@ -0,0 +1,92 @@ +using CPF; +using CPF.Animation; +using CPF.Charts; +using CPF.Controls; +using CPF.Drawing; +using CPF.Platform; +using CPF.Shapes; +using CPF.Styling; +using CPF.Svg; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; +using System.Text; + +namespace CPF.Toolkit.Controls +{ + public class MdiWindow : Control, IWindow + { + public WindowState WindowState { get => GetValue(); set => SetValue(value); } + public Image Icon { get => GetValue(); set => SetValue(value); } + public string Title { get => GetValue(); set => SetValue(value); } + public UIElement Content { get => GetValue(); set => SetValue(value); } + //protected override UIElementCollection Children => throw new NotImplementedException(); + WindowFrame frame; + SizeField normalSize = new SizeField(500, 500); + public void Close() + { + + } + + public void DragMove() + { + } + + protected override void InitializeComponent() + { + this.Size = this.normalSize; + this.frame = base.Children.Add(new WindowFrame(this, this.Content)); + frame.MaximizeBox = true; + + var caption = frame.Find().FirstOrDefault(x => x.Name == "caption"); + caption.Background = "white"; + caption.BorderType = BorderType.BorderThickness; + caption.BorderThickness = new Thickness(0, 0, 0, 1); + caption.BorderFill = "235,235,235"; + + var title = frame.Find().FirstOrDefault(x => x.Name == "title"); + title.Foreground = "black"; + + frame.ControlBoxStroke = "black"; + } + + protected override void OnPropertyChanged(string propertyName, object oldValue, object newValue, PropertyMetadataAttribute propertyMetadata) + { + switch (propertyName) + { + case nameof(WindowState): + switch (this.WindowState) + { + case WindowState.Normal: + { + this.Size = this.normalSize; + } + break; + case WindowState.Minimized: + break; + case WindowState.Maximized: + { + this.Size = SizeField.Fill; + } + break; + case WindowState.FullScreen: + break; + } + break; + + case nameof(Width): + case nameof(Height): + case nameof(Size): + { + if (WindowState == WindowState.Normal) + { + this.Size = this.normalSize; + } + } + break; + } + base.OnPropertyChanged(propertyName, oldValue, newValue, propertyMetadata); + } + } +} diff --git a/CPF/BindingDescribe.cs b/CPF/BindingDescribe.cs index a7346d8..620a815 100644 --- a/CPF/BindingDescribe.cs +++ b/CPF/BindingDescribe.cs @@ -114,6 +114,7 @@ namespace CPF } + /// /// 右边数据绑定到左边,只传递一次数据 /// diff --git a/CPF/Controls/WindowFrame.cs b/CPF/Controls/WindowFrame.cs index 818dd9e..463f3eb 100644 --- a/CPF/Controls/WindowFrame.cs +++ b/CPF/Controls/WindowFrame.cs @@ -10,6 +10,7 @@ using CPF.Effects; using System.ComponentModel; using CPF.Controls; using System.Diagnostics; +using System.Linq; namespace CPF.Controls { @@ -94,10 +95,12 @@ namespace CPF.Controls set { SetValue(value); } } + [PropertyMetadata(typeof(ViewFill), "white")] + public ViewFill ControlBoxStroke { get => GetValue(); set => SetValue(value); } + protected override void InitializeComponent() { - - ViewFill color = "#fff"; + //ViewFill color = "#fff"; ViewFill hoverColor = "255,255,255,40"; Width = "100%"; Height = "100%"; @@ -258,7 +261,11 @@ namespace CPF.Controls EndPoint = new Point(14, 13), StrokeStyle = "2", IsAntiAlias=true, - StrokeFill=color + //StrokeFill=color + Bindings = + { + { nameof(Line.StrokeFill),nameof(this.ControlBoxStroke),this} + } }, Bindings= { @@ -317,15 +324,17 @@ namespace CPF.Controls Name="max", Width = 30, Height = "100%", - Content= - new Rectangle + Content= new Rectangle + { + Width=14, + Height=12, + MarginTop=10, + StrokeStyle="2", + Bindings = { - Width=14, - Height=12, - MarginTop=10, - StrokeStyle="2", - StrokeFill = color - }, + { nameof(Line.StrokeFill),nameof(this.ControlBoxStroke),this} + } + }, Commands = { { @@ -378,7 +387,8 @@ namespace CPF.Controls Width=11, Height=8, StrokeStyle="1.5", - StrokeFill = color + //StrokeFill = color + Bindings = { { nameof(Line.StrokeFill), nameof(this.ControlBoxStroke), this } }, }, new Polyline { @@ -392,7 +402,8 @@ namespace CPF.Controls new Point(9,7), new Point(6,7) }, - StrokeFill = color, + //StrokeFill = color, + Bindings = { { nameof(Line.StrokeFill), nameof(this.ControlBoxStroke), this } }, StrokeStyle="2" } } @@ -452,7 +463,8 @@ namespace CPF.Controls EndPoint = new Point(14, 13), StrokeStyle = "2", IsAntiAlias=true, - StrokeFill=color + //StrokeFill=color + Bindings = { { nameof(Line.StrokeFill), nameof(this.ControlBoxStroke), this } } }, new Line { @@ -462,7 +474,8 @@ namespace CPF.Controls EndPoint = new Point(1, 13), StrokeStyle = "2", IsAntiAlias=true, - StrokeFill=color + //StrokeFill=color + Bindings = { { nameof(Line.StrokeFill), nameof(this.ControlBoxStroke), this } } } } }, diff --git a/CPF/ObjectExtenstions.cs b/CPF/ObjectExtenstions.cs index c7a63b4..8f316c7 100644 --- a/CPF/ObjectExtenstions.cs +++ b/CPF/ObjectExtenstions.cs @@ -13,6 +13,7 @@ using CPF.Threading; using CPF.Controls; using System.Threading.Tasks; using System.Collections.Concurrent; +using System.Diagnostics; namespace CPF {