This commit is contained in:
Sakura 2023-11-23 23:46:40 +08:00
parent a6fc04e737
commit 763a3893d6
6 changed files with 167 additions and 16 deletions

View File

@ -17,7 +17,7 @@ namespace CPF.Toolkit.Demo
, (OperatingSystemType.Linux, new CPF.Linux.LinuxPlatform(), new SkiaDrawingFactory { UseGPU = false })
);
Application.Run(ViewManager.View<MainView>());
Application.Run(ViewManager.View<TestMdiView>());
}
}
}

View File

@ -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"
},
}
}
}));
}
}
}

View File

@ -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<WindowState>(); set => SetValue(value); }
public Image Icon { get => GetValue<Image>(); set => SetValue(value); }
public string Title { get => GetValue<string>(); set => SetValue(value); }
public UIElement Content { get => GetValue<UIElement>(); 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<Panel>().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<TextBlock>().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);
}
}
}

View File

@ -114,6 +114,7 @@ namespace CPF
}
/// <summary>
/// 右边数据绑定到左边,只传递一次数据
/// </summary>

View File

@ -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<ViewFill>(); 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 } }
}
}
},

View File

@ -13,6 +13,7 @@ using CPF.Threading;
using CPF.Controls;
using System.Threading.Tasks;
using System.Collections.Concurrent;
using System.Diagnostics;
namespace CPF
{