From 36433178c2ba357dd46682975810a466d3629d15 Mon Sep 17 00:00:00 2001 From: luxiaoqi Date: Fri, 1 Dec 2023 16:23:12 +0800 Subject: [PATCH] 1 --- CPF.Toolkit.Demo/MainView.cs | 16 +- CPF.Toolkit/Controls/MdiHost.cs | 30 ++++ CPF.Toolkit/Controls/MdiWindowRect.cs | 34 ---- CPF.Toolkit/Controls/PageControl.cs | 193 +++++++++++++++++++++++ CPF.Toolkit/Controls/TaskBarPlacement.cs | 12 -- 5 files changed, 237 insertions(+), 48 deletions(-) delete mode 100644 CPF.Toolkit/Controls/MdiWindowRect.cs create mode 100644 CPF.Toolkit/Controls/PageControl.cs delete mode 100644 CPF.Toolkit/Controls/TaskBarPlacement.cs diff --git a/CPF.Toolkit.Demo/MainView.cs b/CPF.Toolkit.Demo/MainView.cs index a6403e2..5dee577 100644 --- a/CPF.Toolkit.Demo/MainView.cs +++ b/CPF.Toolkit.Demo/MainView.cs @@ -6,6 +6,7 @@ using CPF.Drawing; using CPF.Shapes; using CPF.Styling; using CPF.Svg; +using CPF.Toolkit.Controls; using CPF.Toolkit.Dialogs; using System; using System.Collections.Generic; @@ -21,8 +22,8 @@ namespace CPF.Toolkit.Demo protected override void InitializeComponent() { Title = "标题"; - Width = 500; - Height = 400; + Width = 1280; + Height = 720; Background = null; this.DataContext = this.CommandContext = vm; this.CanResize = true; @@ -84,6 +85,17 @@ namespace CPF.Toolkit.Demo { nameof(Button.Click), (s,e) => new TestMdiView().Show() } } }, + + new Panel + { + }, + new PageControl + { + Height = 35, + PageIndex = 1, + PageCount = 100, + Width = "100%", + }, } })); diff --git a/CPF.Toolkit/Controls/MdiHost.cs b/CPF.Toolkit/Controls/MdiHost.cs index 3931c26..9a2afd0 100644 --- a/CPF.Toolkit/Controls/MdiHost.cs +++ b/CPF.Toolkit/Controls/MdiHost.cs @@ -336,5 +336,35 @@ namespace CPF.Toolkit.Controls }); } } + class MdiWindowRect + { + public MdiWindowRect() + { + + } + public MdiWindowRect(float left, float top, float width, float height) + { + this.Left = left; + this.Top = top; + this.Width = width; + this.Height = height; + } + public float Left { get; set; } + public float Top { get; set; } + public float Width { get; set; } + public float Height { get; set; } + + public WindowState OldState { get; set; } + + public override string ToString() + { + return $"left:{this.Left} top:{this.Top} width:{this.Width} height:{this.Height}"; + } + } + } + public enum TaskBarPlacement + { + Top, + Bottom, } } diff --git a/CPF.Toolkit/Controls/MdiWindowRect.cs b/CPF.Toolkit/Controls/MdiWindowRect.cs deleted file mode 100644 index 645a728..0000000 --- a/CPF.Toolkit/Controls/MdiWindowRect.cs +++ /dev/null @@ -1,34 +0,0 @@ -using CPF.Controls; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Text; - -namespace CPF.Toolkit.Controls -{ - internal class MdiWindowRect - { - public MdiWindowRect() - { - - } - public MdiWindowRect(float left, float top, float width, float height) - { - this.Left = left; - this.Top = top; - this.Width = width; - this.Height = height; - } - public float Left { get; set; } - public float Top { get; set; } - public float Width { get; set; } - public float Height { get; set; } - - public WindowState OldState { get; set; } - - public override string ToString() - { - return $"left:{this.Left} top:{this.Top} width:{this.Width} height:{this.Height}"; - } - } -} diff --git a/CPF.Toolkit/Controls/PageControl.cs b/CPF.Toolkit/Controls/PageControl.cs new file mode 100644 index 0000000..8bc7e18 --- /dev/null +++ b/CPF.Toolkit/Controls/PageControl.cs @@ -0,0 +1,193 @@ +using CPF; +using CPF.Animation; +using CPF.Charts; +using CPF.Controls; +using CPF.Drawing; +using CPF.Input; +using CPF.Shapes; +using CPF.Styling; +using CPF.Svg; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; + +namespace CPF.Toolkit.Controls +{ + public class PageControl : Control + { + public PageControl() + { + this.Pages = new ObservableCollection(); + } + public int PageIndex { get => GetValue(); set => SetValue(value); } + public int PageCount { get => GetValue(); set => SetValue(value); } + int pageSize = 10; + + public event EventHandler PageIndexChanged { add => AddHandler(value); remove => RemoveHandler(value); } + + ObservableCollection Pages { get => GetValue>(); set => SetValue(value); } + + protected override void InitializeComponent() + { + this.Size = SizeField.Fill; + this.Children.Add(new StackPanel + { + Orientation = Orientation.Horizontal, + Size = SizeField.Fill, + Children = + { + new Button + { + Content = "上一页", + [nameof(IsEnabled)] = new BindingDescribe(this,nameof(this.PageIndex),BindingMode.OneWay,c => ((int)c) > 1), + }, + new ListBox + { + ItemTemplate = new PageButton + { + [nameof(PageIndexChanged)] = new CommandDescribe((s,e) => this.PageIndex = (e as IndexEventArgs).Index) + }, + ItemsPanel = new StackPanel{Orientation = Orientation.Horizontal,}, + Items = this.Pages, + }, + new TextBlock + { + Text = "……", + [nameof(Visibility)] = new BindingDescribe(this,nameof(this.PageCount),BindingMode.OneWay,c => ((int)c) > this.pageSize ? Visibility.Visible : Visibility.Collapsed) + }, + new Button + { + Content = "100", + [nameof(Visibility)] = new BindingDescribe(this,nameof(this.PageCount),BindingMode.OneWay,c => ((int)c) > this.pageSize ? Visibility.Visible : Visibility.Collapsed) + }, + new Button + { + Content = "下一页", + [nameof(IsEnabled)] = new BindingDescribe(this,nameof(this.PageIndex),BindingMode.OneWay,c => ((int)c) < this.PageCount), + }, + new StackPanel + { + MarginLeft = 10, + Orientation = Orientation.Horizontal, + Children = + { + new TextBlock + { + Text = "1 ", + Foreground = "dodgerblue", + }, + new TextBlock + { + Text = $"/ 100", + }, + } + }, + new TextBlock + { + Text = " 到第几 " + }, + new Border + { + MinHeight = 35, + MinWidth = 35, + MarginLeft = 2, + MarginRight = 2, + Child = new TextBox + { + Width = "100%", + Text = "10", + TextAlignment = TextAlignment.Center, + FontSize = 14, + }, + BorderFill = "silver", + BorderStroke = "1", + CornerRadius = new CornerRadius(2), + IsAntiAlias = true, + UseLayoutRounding = true, + }, + new TextBlock + { + Text = " 页 " , + }, + new Button + { + Content = "确定", + } + } + }); + + foreach (var item in this.Find()) + { + item.FontSize = 14; + } + + foreach (var item in Find