using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using CPF; using CPF.Drawing; using CPF.Controls; using CPF.Animation; using System.Data; using System.Diagnostics; using CPF.Shapes; using CPF.Svg; using System.Threading; using CPF.Input; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Linq.Expressions; using System.Reflection.Emit; using CPF.Styling; using CPF.Documents; using System.Threading.Tasks; //#if !DesignMode&&!Net4 ////using System.Reactive.Linq; ////using System.Reactive; //using UglyToad.PdfPig; //#endif namespace ConsoleApp1 { public class Window2 : Window { Model model = new Model(); ThreeDEffect2 effect = new ThreeDEffect2 { Depth = 3000, Y = 90, }; DataGridColumn column = new DataGridCheckBoxColumn { Header = "d1fsd", Binding = new DataGridBinding("p2") { BindingMode = BindingMode.TwoWay }, Width = "100", HeaderTemplate = typeof(ColumnTemplate), }; protected override void InitializeComponent() { //var img = Image.FromFile(@"C:\Users\xhm\Desktop\231.gif"); //TopMost = true; Nodes = new Collection { new NodeData { Text="test1", Nodes= { new NodeData { Text="asda" }, new NodeData { Text="asda" }, new NodeData { Text="1asda" }, new NodeData { Text="2asda" }, } }, new NodeData { Text="测试", Nodes= { new NodeData { Text="3asda" }, new NodeData { Text="4asda", Nodes= { new NodeData { Text="6asda" }, new NodeData { Text="7asda" }, } }, new NodeData { Text="6asda" }, new NodeData { Text="7asda" }, new NodeData { Text="4asda", Nodes= { new NodeData { Text="6asda" }, new NodeData { Text="7asda" }, new NodeData { Text="6asda" }, new NodeData { Text="7asda" }, } }, new NodeData { Text="3asda" }, new NodeData { Text="4asda", Nodes= { new NodeData { Text="6asda" }, new NodeData { Text="7asda" }, new NodeData { Text="6asda" }, new NodeData { Text="7asda" }, } }, } } }; List1 = new Collection(); for (int i = 0; i < 10; i++) { List1.Add(new TestClass { test = i.ToString() }); } List2 = new Collection(); //Columns = new Collection(); Title = "CPF演示案例"; Width = 860; Height = 600; Background = null; CanResize = true; MinHeight = 100; MinWidth = 200; DragThickness = 10; Children.Add(new WindowFrame(this, new Panel { Background = null, Width = "100%", Height = "100%", Children = { new Button { MarginTop = 0, Content = "点击生成pdf", [nameof(Button.Content)]= new Obx(a => a.Test1.test.test.test.test.Name), Commands = { { nameof(Button.Click), (a,b)=> { var TabControl = FindPresenterByName("mainTab"); #if !Net4 CPF.Skia.SkiaPdf.CreatePdf(TabControl.SelectedItem.ContentElement,"test.pdf"); #endif } } }, },//内容元素放这里 new TabControl { MarginTop = 20, Name="mainTab", PresenterFor = this, TabStripPlacement= Dock.Left, Width="100%", Height="100%",//SelectedIndex=2, Items= { new TabItemTemplate { Header="基础控件", Content=new Panel { PresenterFor = this, Name = nameof(page1), Width="100%", Height="100%", Background="#fff", Children= { new Button { PresenterFor = this, Name = nameof(btn), Classes="Test", FontStyle= FontStyles.Bold| FontStyles.Italic, Width=150, Height=25, Content="另外一个演示窗体😍", MarginTop=20, MarginLeft=20, [nameof(Button.Click)]=new CommandDescribe((s,e)=> { var w = new Window1(); w.DataContext = model; w.CommandContext = w.DataContext; //w.TopMost=true; w.Show(); }),//Commands= //{ // { // nameof(Button.Click), // (s,e)=> // { // var w = new Window1(); // w.DataContext = model; // w.CommandContext = w.DataContext; // //w.TopMost=true; // w.Show(); // } // } //} }, new CheckBox { IsChecked = null, Content="复选框1", MarginTop="64", MarginLeft="20" }, new CheckBox { Content="复选框2", MarginTop="90", MarginLeft="20", IsThreeState=true }, new RadioButton { IsChecked = true, Content="单选框1", MarginTop="120", MarginLeft="20", GroupName="gn1" }, new RadioButton { Content="单选框2", MarginTop=150, MarginLeft=20, GroupName="gn1" }, new Border { Name="shadowEffect", MarginTop=180, MarginLeft=15, Width=110, Height=33, Background="#fff", BorderType= BorderType.BorderThickness, ShadowBlur=5, ShadowColor="0,0,0,0", Child=new TextBox { Classes= { "Single" }, PresenterFor=this, Name="textbox1", MarginBottom=0, MarginLeft=0, MarginRight=0, MarginTop=0, Text="dfsfs" } },//绑定当前页面里的元素,被绑定的元素需要设置PresenterFor=this new TextBox { Padding = "0,5,0,0", Name="password", PresenterFor=this, Classes= { "Single" }, MarginTop=220, MarginLeft=20, Width=100, Height = 24, Background="#fff", Bindings= { { nameof(TextBox.Text), nameof(TextBox.Text), this.FindPresenter(a=>a.Name=="textbox1") } },//Text="test", PasswordChar='*', CornerRadius="8", IsAntiAlias=true }, new TextBox { Commands = { { nameof(TextBox.MouseDown), nameof(testHandled), this, CommandParameter.EventSender, CommandParameter.EventArgs }, { nameof(TextBox.IsFocused), nameof(textFocus), this, CommandParameter.EventSender, CommandParameter.EventArgs }, { nameof(TextBox.KeyDown), nameof(KeyDownTest), this, CommandParameter.EventSender, CommandParameter.EventArgs }, }, Bindings = { { nameof(TextBox.Document), nameof(Document), this, BindingMode.OneWayToSource }, }, Padding = "5,5,5,5", PresenterFor = this, Name = nameof(textBox), MarginTop=250, MarginLeft=20, Width="40%", Height=258, Background="#FFFFC7", Text="多行文本框😀😁😂😃123haha", IsAllowPasteImage=true, AcceptsTab=true, Styles = { new DocumentStyle { Foreground="#f00" } } }, new ScrollBar { MarginTop = 89, Maximum = 10f, Width = 136, Value = 0.5f, Name = "scrollbar", MarginRight=529, MarginBottom=434, MarginLeft=171, Orientation= Orientation.Horizontal, Background="url(res://ConsoleApp1/Resources/()1.gif) Tile None 0,0,0,0" }, new ScrollBar { Cursor = Cursors.Cross, MarginLeft=373.6f, MarginTop=24.2f, Width=27f, Height=154.5f, Orientation= Orientation.Vertical, Background="#fff" }, new Picture { Source="res://ConsoleApp1/Resources/主页.png", MarginTop=215, MarginLeft=200 }, new Picture { Height = 41, Width = 122, Source="https://dss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo_top-e3b63a0b1b.png", MarginTop=168, MarginLeft=167 }, new ComboBox { //IsVirtualizing=true, PresenterFor = this, Name = nameof(testCombobox),//IsEditable=true, //SelectionMode= SelectionMode.Multiple, //SelectedIndex=2, MarginTop=138, MarginLeft=262, Width=100, Height=25, ItemTemplate=new ListBoxItem { Width="100%", FontSize=14, ContentTemplate=new ContentTemplate { Width="auto", MarginLeft=5, } }, Bindings = { { nameof(ComboBox.Items), nameof(MainModel.TestItems), null, BindingMode.TwoWay }, { nameof(ComboBox.SelectedValue), nameof(MainModel.SelectValue), null, BindingMode.TwoWay }, }, DisplayMemberPath="Item1", SelectedValuePath="Item2",//IsVirtualizing=true IsEditable=true, }, new ScrollViewer { MarginLeft = 421,//HorizontalScrollBarVisibility= ScrollBarVisibility.Disabled, //VerticalScrollBarVisibility= ScrollBarVisibility.Visible, Commands = { { nameof(ScrollViewer.MouseDown), nameof(scrollViewerMouseDown), this, CommandParameter.EventSender, CommandParameter.EventArgs }, { nameof(ScrollViewer.MouseUp), nameof(scrollViewerMouseUp), this, CommandParameter.EventSender, CommandParameter.EventArgs }, }, Content= //new Picture //{ // PresenterFor = this, // Name = nameof(pic), // Source="http://219.239.12.91:5001/bookimage//bookimage3/cate1826979600058c0bd3/file253320e4000582XXXX/253320e4000582XXXX.jpg" //} #if !Net4&&!NETCOREAPP3_0 new GLView { Height = 336, Width = 421, }, #else new WrapPanel { Width="100%", Children = { new Button { Content="123" }, new Button { Content="123" }, new Button { Content="123" }, new Button { Content="123" }, new Button { Content="123" }, new Button { Content="123" }, new Button { Content="123" }, new Button { Content="123" }, new Button { Content="123" }, new Button { Content="123" }, new Button { Content="123" }, new Button { Content="123" }, new Button { Content="123" }, new Button { Content="123" }, } }, #endif Height=300, MarginTop=19, MarginRight=29 }, new Ellipse { StrokeStyle = "10,Solid", Width=145, Height=83, IsAntiAlias=true, Triggers= { new CPF.Styling.Trigger(nameof(IsMouseOver),Relation.Me) { Setters= { { nameof(Ellipse.Fill), "#f00" } } }, }, }, new Expander { MarginTop=350, Header="test", Content= new Button { Content="test内容" } } //.Bind(this,t=>t.FocusFrameFill,s=>s.Background,BindingMode.OneWay) ,// new Button{ Content="test",Commands={ {nameof(Button.Click),(s,e)=>MessageBox.Show("Test") //} } }, //new Calendar{ }, new DatePicker { Width=100, Height=20, MarginTop=100 },//new DatePicker{ Width=100, Height=30}, new NumericUpDown { MarginLeft = 386, MarginTop = 401, Width = 83, Minimum = 0.001, Increment = 0.001, Maximum=100, Value=0.001, Bindings = { } }, new Button { MarginLeft = 175f, MarginTop = 138.2f, Content = "附加样式", Bindings = { { nameof(Button.Foreground), nameof(MainModel.TestBool), null, BindingMode.OneWay, (bool a)=>a?(ViewFill)"#fff":"#000" } }, Commands= { { nameof(Button.Click), (s,e)=> { this.LoadStyleFile("res://ConsoleApp1/testApend.css", true); } } } }, new Button { Commands = { { "Click", nameof(scrollEnd), this, CommandParameter.EventSender, CommandParameter.EventArgs }, }, Height = 30, Width = 98, MarginLeft = 495, MarginTop = 362, Content = "滚动到最底下", }, new Button { Height = 34, Width = 110, MarginLeft = 666, MarginTop = 349, Content = "Button", Commands = { { nameof(Button.Click), (s,e)=> { pic.Source= this.Screen.Screenshot(); } } } }, new EditComboBox { Width = 91,//Bindings = //{ // { // nameof(ComboBox.Items), // nameof(MainModel.TestItems1) // }, //}, [nameof(ComboBox.Items)]=nameof(MainModel.TestItems1),//Commands = //{ // { // nameof(ComboBox.DoubleClick), // nameof(comboBoxtest), // this, // CommandParameter.EventSender, // CommandParameter.EventArgs // }, // { // nameof(ComboBox.IsDropDownOpen), // nameof(TestComboBox), // this, // CommandParameter.EventSender, // CommandParameter.EventArgs // }, //}, PresenterFor = this, Name = nameof(combox), MarginLeft = 200, MarginTop = 25, }, new Slider { TickPlacement = TickPlacement.TopLeft, MarginLeft = 547, MarginTop = 427, Height = 25, Width = 151, }, new Panel { Children = { new SVG { Fill = "#959595", Height = 29, IsAntiAlias = true, Width = 33, Stretch = Stretch.Uniform, Source="" } }, MarginLeft = 383, MarginTop = 450, Height = 58, Width = 121, }, new Button { Commands = { { nameof(Button.Click), nameof(ShowLayer), this, CommandParameter.EventSender, CommandParameter.EventArgs }, }, Height = 21, Width = 105, MarginTop = 62, MarginLeft = 195, Content = "弹出Window2", }, new ProgressBar { Height = 16, Width = 142, MarginTop = 473, MarginLeft = 532,//[nameof(ProgressBar.Value)]="Value", //[nameof(ProgressBar.Value)]=("Value",BindingMode.TwoWay), //[nameof(ProgressBar.Value)]=(null,"Value",BindingMode.TwoWay,a=>a.ToString()), //[nameof(ProgressBar.Value)]=new BindingDescribe(null,"Value",BindingMode.TwoWay,a=>a.ToString()) }, new TextBlock { TextTrimming= TextTrimming.CharacterEllipsis, Height = 59, Width = 41, MarginTop = 397, MarginLeft = 321, Text = "Te\nxtBlock", }, new CPF.Controls.Switch { PresenterFor = this, Name = nameof(_sw), Height = 30, Width = 64, MarginTop = 189, MarginLeft = 300, } .Assign(out var sw), new Button { Commands = { { nameof(Button.Click), nameof(PDF), this, CommandParameter.EventSender, CommandParameter.EventArgs }, }, MarginLeft = 98, MarginTop = 69, Content = "解析PDF"+sw.IsChecked, }, new Viewbox { MarginLeft = 426, MarginTop = 344, Child = new Path("M159.375 196.875A9.375 9.375 0 0 1 140.625 196.875V133.8375L113.83125 89.2125A9.375 9.375 0 1 1 129.91875 79.55625L158.04375 126.43125A9.375 9.375 0 0 1 159.375 131.25V196.875zM121.875 300A9.375 9.375 0 0 1 121.875 281.25H131.25V261.1875A131.26875 131.26875 0 0 1 69.88125 27.3L58.59375 16.0125A9.375 9.375 0 0 1 71.85 2.7375L85.8375 16.725A130.6875 130.6875 0 0 1 150 0A130.6875 130.6875 0 0 1 214.1625 16.725L228.15 2.7375A9.375 9.375 0 0 1 241.4062500000001 16.0125L230.1375 27.3A131.26875 131.26875 0 0 1 168.75 261.1875V281.25H178.125A9.375 9.375 0 0 1 178.125 300H121.875zM141.3375 243.4125A114.24375 114.24375 0 0 0 158.6625 243.4125A112.5 112.5 0 1 0 141.3375 243.4125zM0 234.375C0 220.25625 6.24375 207.58125 16.125 198.99375A150.65625 150.65625 0 0 0 82.25625 265.125A46.875 46.875 0 0 1 0 234.375zM253.125 281.25C239.00625 281.25 226.33125 275.00625 217.74375 265.125A150.65625 150.65625 0 0 0 283.875 198.99375A46.875 46.875 0 0 1 253.125 281.25z") { IsAntiAlias = true, StrokeStyle = "10,Solid", }, Height = 30, Width = 35, }, } } }, new TabItemTemplate { Header="动画",//IsSelected=true, Content=new Panel { Width="100%", Height="100%", Children= { new Button { Content="弹窗动画", Width=100, Height=25, MarginLeft=20, MarginTop=20, Commands= { { nameof(Button.Click), (s,e)=> ShowDialogForm() } } } .AfterStyle(a=> { a.Background="#0f0"; }), new Button { Content="缓动动画1", Width=100, Height=25, MarginLeft=160, MarginTop=20, Commands= { { nameof(Button.Click), (s,e)=> Animation((Button)s,new QuadraticEase()) } } }, new Button { Content="缓动动画2", Width=100, Height=25, MarginLeft=260, MarginTop=20, Commands= { { nameof(Button.Click), (s,e)=> Animation((Button)s,new CubicEase()) } } }, new Button { Content="缓动动画3", Width=100, Height=25, MarginLeft=360, MarginTop=20, Commands= { { nameof(Button.Click), (s,e)=> Animation((Button)s,new ElasticEase()) } } }, new Button { Content="缓动动画4", Width=100, Height=25, MarginLeft=460, MarginTop=20, Commands= { { nameof(Button.Click), (s,e)=> Animation((Button)s,new ExponentialEase()) } } }, new Button { Content="缓动动画5", Width=100, Height=25, MarginLeft=560, MarginTop=20, Commands= { { nameof(Button.Click), (s,e)=> Animation((Button)s,new QuinticEase()) } } }, new Button { Content="缓动动画6", Width=100, Height=25, MarginLeft=660, MarginTop=20, Commands= { { nameof(Button.Click), (s,e)=> Animation((Button)s,new SineEase()) } } }, new Button { Content=new Panel { Children= { new SVG("res://ConsoleApp1/test.svg") { MarginLeft = 0, MarginTop = 0, Height = 106, Width=178, Stretch= Stretch.Fill, }, new Picture { Stretch = Stretch.Fill, Source = "res://ConsoleApp1/Resources/te.gif", Height = 60, Width =80, } }, }, Width=104, Height=55, MarginLeft=60, MarginTop=130, Commands= { { nameof(Button.Click), (s,e)=> Animation((Button)s) } } }, new Path("M 150,10 T 250,100 80,280") { //ClipToBounds = true, Height = 98, IsAntiAlias = true, StrokeStyle = new Stroke(1,DashStyles.Custom,0,new float[] { 10, 5, 2, 5 },CapStyles.Round,LineJoins.Round),//StrokeFill="url(res://ConsoleApp1/Resources/icon.png)", }, new Slider { MarginLeft = 602, MarginTop = 258, Maximum = 100f, Width = 179.1f, Bindings= { { nameof(Slider.Value), nameof(TestValue), this } } }, new Picture { Stretch = Stretch.Fill, Source = "res://ConsoleApp1/Resources/loading.gif", Height = 103, Width = 114, MarginLeft = 24, MarginTop = 299, }, new Picture { Stretch = Stretch.Fill, Source = "res://ConsoleApp1/Resources/te.gif", Height = 110, Width = 230, MarginLeft = 557, MarginTop = 310, }, new Line { IsHitTestOnPath=true, Commands = { { nameof(Line.MouseDown), nameof(lineMouseDown), this, CommandParameter.EventSender, CommandParameter.EventArgs }, }, }, new test { Width=793, Height=81, MarginLeft=16, MarginBottom=42, Valeft = 5, Commands= { { nameof(SVG.MouseUp), (a,b)=> (a as test).Animation(a as test) } } }, new StackPanel { Children = { new NativeElement { Height = 142, Width = 159, BackColor=Color.Blue, } }, MarginTop = 56, Height = 172, Width = 167, }, } } }, new TabItemTemplate { Header="布局", Content=new Panel { Name = "布局", PresenterFor = this, Width="100%", Height="100%", Children= { new StackPanel { MarginLeft=10, MarginTop=10, Orientation= Orientation.Vertical, Children= { new Button { Content="StackPanel的Vertical" }, new Button { Content="按钮" }, new Button { Content="按钮" }, new Button { Content="按钮" }, } }, new StackPanel { BorderStroke = "5,Solid", BorderFill = "#B4B4B4", MarginLeft=80, MarginTop=50, Orientation= Orientation.Horizontal, Children= { new Button { Content="StackPanel的Horizontal" }, new Button { Content="按钮" }, new Button { Content="Margin调间距", MarginLeft=5 }, new Button { Content="按钮" }, } }, new WrapPanel { MarginRight=10, MarginTop=10, Width="50%", Orientation= Orientation.Horizontal, Children= { new Button { Content="WrapPanel的Horizontal" }, new Button { Content="按钮" }, new Button { Content="Margin调间距", MarginLeft=5 }, new Button { Content="按钮" }, new Button { Content="宽度不够" }, new Button { Content="可以自动换行" }, } }, new Grid { RenderTransform=new RotateTransform(10), Name="testGrid", Background="#999", Width="80%", Height="60%", MarginTop=120, MarginLeft=20, ColumnDefinitions= { new ColumnDefinition { Width="40*" }, new ColumnDefinition { Width = "30*" }, new ColumnDefinition { Width="200", [nameof(ColumnDefinition.Width)]=nameof(MainModel.ColumnWidth) }, }, RowDefinitions= { new RowDefinition { Height="30*" }, new RowDefinition { Height="30*" }, new RowDefinition { Height="30*" } }, Children= { new WrapPanel { Name="test", Background="#a2f", Width="100%", Height="100%", Children= { new Button { Content="水平浮动布局231" }, new Button { Content="按钮2" }, new Button { Content="按钮3" }, new Button { Content="按钮4" }, new Button { Content="按钮5" }, } }, { new WrapPanel { Orientation= Orientation.Vertical, Background="#27a", Width="100%", Height="100%", Children= { new Button { Content="垂直浮动布局" }, new Button { Content="按钮2" }, new Button { Content="按钮3" }, new Button { Content="按钮4" }, new Button { Content="按钮5" }, } }, 1, 1 }, { new TextBlock { Background="#ac2", Width="100%", Height="100%", Text="Grid布局。。。" }, 2, 1 }, { new Panel { Background="#b1a", MarginLeft=0, MarginRight=0, Children= { new Button { Content="跨列", Width="50%" } } }, 0, 2, 2 }, { new TextBlock { Background="#186", Height="100%", Text="跨行" }, 2, 1, 1, 2 }, new TextBox { MarginLeft=10, Size=SizeField.Fill, Text="元素变换,可以旋转,倾斜,缩放等操作", Attacheds= { { Grid.ColumnIndex, 1 } } }, new Button { Content=new SVG("res://ConsoleApp1/test.svg") { MarginLeft = 0, MarginTop = 0, Height = 85, Width=170, Stretch= Stretch.Uniform, }, Width=104, Height=55, MarginLeft=60, MarginTop=120, Commands= { { nameof(Button.Click), (s,e)=> Animation((Button)s) } } } }, }, new DockPanel { LastChildFill = false, Width=200, Height=200, MarginRight=0, MarginTop=50, Background="#f00", Children = { new Button { Content="Right", Height="100%", Attacheds = { { DockPanel.Dock, Dock.Right } } }, } }, new Slider { Maximum = 300, Value = 200, MarginLeft = 252, MarginTop = 76, Height = 23, Width = 219,//[nameof(Slider.Value)]= new Obx(a => a.Type.Name), [nameof(Slider.Value)]= new BindingDescribe(null, nameof(MainModel.ColumnWidth),BindingMode.OneWayToSource,null,a=>new GridLength((float)(double)a)) }, } } }, new TabItemTemplate { Header="ListBox", Content=new Panel { Width="100%", Height="100%", Children= { new ListBox { SelectionMode = SelectionMode.Multiple, AlternationCount = 2, Width=300, Height=500, ItemTemplate=typeof(ListBoxItemTemplate), Bindings= { { nameof(ListBox.Items), nameof(Items), this } }, }, new Button { Commands = { { nameof(Button.Click), nameof(TestClear), this, CommandParameter.EventSender, CommandParameter.EventArgs }, }, Height = 25, Width = 80, MarginTop = 47, MarginLeft = 536, Content = "Button", }, new DataGrid { PresenterFor = this, Name = nameof(testGrid), Height = 113, Width = 132, MarginTop = 72, MarginLeft = 47, }, new Button { Commands = { { nameof(Button.Click), nameof(addColumnClick), this, CommandParameter.EventSender, CommandParameter.EventArgs }, }, MarginTop = 218, MarginLeft = 47, Content = "添加列", }, } } }, new TabItemTemplate { Header="DataGrid", Content=new Panel { Width="100%", Height="100%", Children= { new DataGrid { ContextMenu=new ContextMenu { Items= { new MenuItem { Header="123" } } }, PresenterFor = this, Name = nameof(testDataGrid),//IsVirtualizing=false, Width = 544, Height = 344,//VirtualizationMode= VirtualizationMode.Standard, Background = "#fff",//CustomScrollData=customScrollData, ItemTemplate=typeof(DataGridRowTemplate), AlternationCount=2, SelectionUnit= DataGridSelectionUnit.Cell,//SelectionMode= DataGridSelectionMode.Single, Columns = { new DataGridComboBoxColumn { Header="dfsd", Binding=new DataGridBinding("p1",BindingMode.TwoWay), Width="100", Items= { "0", "1", "2", "3" },//Visibility= Visibility.Collapsed }, column, new DataGridTextColumn { Header="3dfsd", Binding=new DataGridBinding("p3") { BindingMode= BindingMode.TwoWay }, Width="100", }, new DataGridTextColumn { Header="输入类型验证", Binding=new DataGridBinding("p4") { BindingMode= BindingMode.TwoWay }, Width="100", }, new DataGridTextColumn { Header="3dfsd", Binding=new DataGridBinding("p3") { BindingMode= BindingMode.TwoWay }, Width="100", }, new DataGridTextColumn { Header="输入类型验证", Binding=new DataGridBinding("p4") { BindingMode= BindingMode.TwoWay }, Width="100", }, new DataGridTextColumn { Header="3dfsd", Binding=new DataGridBinding("p3") { BindingMode= BindingMode.TwoWay }, Width="100", }, new DataGridTextColumn { Header="输入类型验证", Binding=new DataGridBinding("p4") { BindingMode= BindingMode.TwoWay }, Width="100", }, new DataGridTextColumn { Header="3dfsd", Binding=new DataGridBinding("p3") { BindingMode= BindingMode.TwoWay }, Width="100", }, new DataGridTextColumn { Header="输入类型验证", Binding=new DataGridBinding("p4") { BindingMode= BindingMode.TwoWay }, Width="100", }, new DataGridTextColumn { Header="3dfsd", Binding=new DataGridBinding("p3") { BindingMode= BindingMode.TwoWay }, Width="100", }, new DataGridTextColumn { Header="输入类型验证", Binding=new DataGridBinding("p4") { BindingMode= BindingMode.TwoWay }, Width="100", }, new DataGridTextColumn { Header="3dfsd", Binding=new DataGridBinding("p3") { BindingMode= BindingMode.TwoWay }, Width="100", }, new DataGridTextColumn { Header="输入类型验证", Binding=new DataGridBinding("p4") { BindingMode= BindingMode.TwoWay }, Width="100", }, new DataGridTextColumn { Header="输入类型验证", Binding=new DataGridBinding("p4") { BindingMode= BindingMode.TwoWay }, Width="100", }, new DataGridTextColumn { Header="3dfsd", Binding=new DataGridBinding("p3") { BindingMode= BindingMode.TwoWay }, Width="100", }, new DataGridTextColumn { Header="输入类型验证", Binding=new DataGridBinding("p4") { BindingMode= BindingMode.TwoWay }, Width="100", }, new DataGridTextColumn { Header="3dfsd", Binding=new DataGridBinding("p3") { BindingMode= BindingMode.TwoWay }, Width="100", }, new DataGridTextColumn { Header="输入类型验证", Binding=new DataGridBinding("p4") { BindingMode= BindingMode.TwoWay }, Width="100", } //new DataGridTemplateColumn //{ // Header="自定义模板", // Binding=new DataGridBinding("p5"), // Width="*", // CellTemplate=typeof(CellTemplate) //}, }, Bindings = { { nameof(DataGrid.Items), nameof(Data), this },//{ // nameof(DataGrid.Items), // nameof(ItemCollection), // this, // BindingMode.OneWayToSource //},//{ nameof(DataGrid.Columns), nameof(Columns),this } } }, new Button { Commands = { { nameof(Button.Click), nameof(AddTest), this, CommandParameter.EventSender, CommandParameter.EventArgs }, }, MarginLeft = 245, MarginTop = 21, Content = "添加", }, new Button { Commands = { { nameof(Button.Click), nameof(ClearData), this, CommandParameter.EventSender, CommandParameter.EventArgs }, }, MarginLeft = 355, MarginTop = 21, Content = "清除", }, new Button { Commands = { { nameof(Button.Click), nameof(addColumn), this, CommandParameter.EventSender, CommandParameter.EventArgs }, }, MarginLeft = 442, MarginTop = 17, Content = "addColumn", }, } } }, new TabItemTemplate { Header="TreeView", Content=new Panel { Width="100%", Height="100%", Children= { new TreeView { PresenterFor = this, Name = nameof(testTreeVIew), Bindings = { { "SelectedValue", nameof(SelectNode), this, BindingMode.OneWayToSource }, { "Items", "Nodes", this }, }, Width=300, Height=500, DisplayMemberPath=nameof(NodeData.Text), ItemsMemberPath=nameof(NodeData.Nodes),//HeaderTemplate=typeof(TreeViewItemContentTemplate), //ItemTemplate=typeof(TreeViewItemTemplate), //Items=new TreeViewItem[]{ new TreeViewItem { Header="24" } } }, new Button { Commands = { { "Click", nameof(addItem), this, CommandParameter.EventSender, CommandParameter.EventArgs }, }, MarginLeft = 599, MarginTop = 24, Content = "添加子节点", }, new Button { MarginLeft = 597, MarginTop = 66, Commands = { { "Click", nameof(RemoveItem), this, CommandParameter.EventSender, CommandParameter.EventArgs }, }, Content = "删除节点", }, } } }, new TabItemTemplate { //[nameof(Name)]=nameof(Button.Content), //[nameof(Name)]=(nameof(Button.Content),BindingMode.TwoWay), //[nameof(MouseDown)]=new Action((a,b)=>{ }), Header="test", Content= new Panel { Commands = { { nameof(Button.TouchMove), nameof(TouchDownTest), this, CommandParameter.EventSender, CommandParameter.EventArgs }, }, Size=SizeField.Fill, Children = { new SVG("res://ConsoleApp1/test.svg") { Commands = { { nameof(SVG.MouseUp), nameof(svgMouseUP), this, CommandParameter.EventSender, CommandParameter.EventArgs }, }, MarginLeft = 442, MarginTop = 50, Height = 199, Width=245, Stretch= Stretch.Uniform, } //new Border //{ // BorderFill="#f00", // BorderStroke="1", // Child=new Border // { // Size=SizeField.Fill, // BorderFill="#0f0", // BorderStroke="1", // Child=new StackPanel // { // Children = // { // new TextBlock{Text="432sd"}, // new TextBlock{Text="gdfsa"}, // new TextBlock{Text="gsdsd"}, // new TextBlock{Text="gfdfs"}, // } // } // } //} , new Viewbox { Stretch = Stretch.Uniform, Child = new Button { Commands = { { nameof(Button.MouseUp), nameof(ShowPopup), this, CommandParameter.EventSender, CommandParameter.EventArgs }, }, Height = 79, Width = 88, Content = "弹窗测试", }, MarginLeft = 16, MarginTop = 84, Height = 116, Width = 190, }, new WrapPanel { Height = 66, Width = 78, } .LoopCreate(10,i=>new Button { Content=i }), new Border { Child = new Button { MarginTop = 17, MarginLeft = 21, Content = "Button", }, Height = 69, Width = 131, MarginTop = 42, MarginLeft = 275, }, new Button { Height = 30, Width = 95, MarginTop = 152, MarginLeft = 295, Content = "Button", }, new CheckBox { MarginTop = 26.2f, MarginLeft = 101.8f, Content = "CheckBox", }, new Panel { MarginLeft = 30, MarginTop = 281, IsGroup = true, Children = { new Button { Width = 26, Height = "100%", MarginRight = 0, Content = new Polyline { Points = { { 0, 0 }, { 5, 5 }, { 10, 0 } }, IsAntiAlias=true }, ContextMenu=new ContextMenu { Items = { new MenuItem { StaysOpenOnClick=true, Header="123" }, new Separator { }, new MenuItem { Header="1233423", Items = { new MenuItem { Header="45242" } } }, } }, Commands = { { nameof(Button.MouseUp), (s,e)=> { var E=e as MouseButtonEventArgs; if (E.MouseButton== MouseButton.Left) { var cm = (s as UIElement).ContextMenu; if (cm != null) { cm.DataContext = DataContext; cm.CommandContext = CommandContext; cm.PlacementTarget = s as UIElement; cm.Placement= PlacementMode.Padding; cm.PopupMarginLeft=0; cm.PopupMarginTop="100%"; cm.IsOpen = true; } } else { E.Handled=true; } } } } }, new TextBlock { MarginLeft = 11, Text = "带下拉菜单", Commands = { { nameof(MouseDown), (s,e)=> { (s as UIElement).Parent.GetChildren()[0].ContextMenu.Items.Add(new MenuItem { Header="test" }); } } } }, }, Height = 31, Width = 129, } } } }, new TabItemTemplate { Content = new Page1 { Height = "100%", Width = "100%", }, Header = "TabItem", }, new TestTabItem { Content = new Panel { Children = { new Grid { Children = { new TextBox { MarginLeft=10, Size=SizeField.Fill, Text="元素变换,可以旋转,倾斜,缩放等操作1111111111111111111111111111111111111111111111111111111111111112", Attacheds= { { Grid.ColumnIndex, 1 } } } }, Height = 228, Width = "100%", ColumnDefinitions = { new ColumnDefinition { Width=250 }, new ColumnDefinition { Width="*" }, } }, }, Height = "100%", Width = "100%", }, Header = new StackPanel { Orientation = Orientation.Horizontal, Classes = "imgAndText", IsGroup = true, Children = { new SVG { Fill = "#959595", Height = 28, IsAntiAlias = true, Width = 28, Stretch = Stretch.Uniform, Source="" }, new TextBlock { MarginLeft = 5f, Classes = "text", Text = "文字", }, }, }, Triggers = { new Trigger(nameof(TestTabItem.IsMouseOver), Relation.Me) { Setters = { { nameof(TestTabItem.Foreground), "#419EFF" }, { nameof(TestTabItem.Background), "#ecf5ff" } } }, new Trigger(nameof(TestTabItem.IsSelected), Relation.Me) { Setters = { { nameof(TestTabItem.Foreground), "white" }, { nameof(TestTabItem.Background), "#3a8ee6" } } } } }, new TabItemTemplate { Header = "生成pdf", Content = new Panel { Size = new SizeField("100%","100%"), }, }, new TabItemTemplate { Header = "TextBox", Content = new Panel { Size = new SizeField("100%","100%"), Children = { // new CodeTextBox // { // MarginTop = 0, // MarginLeft = 0, // Width="70%", // Height=519, // FontSize = 20, // WordWarp = false, // FontFamily = "新宋体", // HScrollBarVisibility = ScrollBarVisibility.Visible, // VScrollBarVisibility = ScrollBarVisibility.Visible, // SelectionFill = "153,201,239", // Text = @"new TabItemTemplate{ // Header = ""生成pdf"", // Content = new Panel{ // Size = new SizeField(""100%"",""100%""), // }, //", // Background="255,255,255", // Styles= // { // new DocumentStyle // { // Foreground = "#008000" // }, // new DocumentStyle // { // Foreground = "128,0,0" // }, // new DocumentStyle // { // Foreground = "DarkBlue" // }, // new DocumentStyle // { // Foreground = "143,8,196" // }, // new DocumentStyle // { // Foreground = "31,86,173" // }, // new DocumentStyle // { // Foreground = "#8000FF" // }, // new DocumentStyle // { // Foreground = "#c3c3fd" // }, // }, // KeywordsStyles= // { // new KeywordsStyle // { // Keywords = @"(\/\/.*|\/\*[\s\S]*?\*\/)",// 匹配注释 // IsRegex =true, // StyleId = 0 // }, // new KeywordsStyle // { // Keywords = @"(""(?:[^""\\]|\\[\s\S])*""|'(?:[^'\\]|\\[\s\S])*')",// 匹配字符串 // IsRegex=true, // StyleId = 1 // }, // new KeywordsStyle // { // Keywords = @"\b(var|for|if|else|return|this|while|new|function|switch|case|typeof|do|in|throw|try|catch|finally|with|instance|delete|void|break|continue)\b",//匹配关键词,关键词顺序改了下 // IsRegex = true, // StyleId = 2 // },/*new KeywordsStyle // { // Keywords = @"(?:[^\W\d]|\$)[\$\w]*",// 匹配普通的变量名 // IsRegex =true, // StyleId = 4 // },*/ // //new KeywordsStyle // //{ // // Keywords = @"(0[xX][0-9a-fA-F]+|\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|\.\d+(?:[eE][+-]?\d+)?)",// 匹配数字,修复了匹配 // // IsRegex =true, // // StyleId = -1 // //}, // //new KeywordsStyle // //{ // // Keywords = @"(?:^|[^\)\]\}])(\/(?!\*)(?:\\.|[^\\\/\n])+?\/[gim]*)",//匹配正则 // // IsRegex =true, // // StyleId = -1 // //}, // } // }, new CodeTextBox { //FontSize=16, AcceptsTab=true, MarginBottom = 22, MarginRight = 208, Background = "#FFFFFF", MarginLeft = 3, MarginTop = -1, IsUndoEnabled=true,//Text="231231\n3\n4\n5\n6\n7\n8\n4\n5\n6\n7\n8\n7\n8\n4\n5\n6\n7\n81dfssssssssssssssssssssssssa\n2\n3\n4\n5\n6\n7\n8\n9asddffsfsfs\n10\n11\n12", Styles= { new CodeStyle { Foreground = "#008000",//Background="#00ff00", }, new CodeStyle { Foreground = "128,0,0",//Background="#00ffff", }, new CodeStyle { Foreground = "DarkBlue",//Background="#0f0fff", }, new CodeStyle { Foreground = "143,8,196",// Background="#ff00ff", }, new CodeStyle { Foreground = "31,86,173" }, new CodeStyle { Foreground = "#8000FF" }, new CodeStyle { Foreground = "#c3c3fd" }, }, KeywordsStyles= { new KeywordsStyle { Keywords = @"\b(var|for|if|else|return|this|while|new|function|switch|case|typeof|do|in|throw|try|catch|finally|with|instance|delete|void|break|continue)\b",//匹配关键词,关键词顺序改了下 IsRegex = true, StyleId = 2 }, new KeywordsStyle { Keywords = @"(\/\/.*|\/\*[\s\S]*?\*\/)",// 匹配注释 IsRegex =true, StyleId = 0 }, new KeywordsStyle { Keywords = @"(""(?:[^""\\]|\\[\s\S])*""|'(?:[^'\\]|\\[\s\S])*')",// 匹配字符串 IsRegex=true, StyleId = 1 },/*new KeywordsStyle { Keywords = @"(?:[^\W\d]|\$)[\$\w]*",// 匹配普通的变量名 IsRegex =true, StyleId = 4 },*/ //new KeywordsStyle //{ // Keywords = @"(0[xX][0-9a-fA-F]+|\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|\.\d+(?:[eE][+-]?\d+)?)",// 匹配数字,修复了匹配 // IsRegex =true, // StyleId = -1 //}, //new KeywordsStyle //{ // Keywords = @"(?:^|[^\)\]\}])(\/(?!\*)(?:\\.|[^\\\/\n])+?\/[gim]*)",//匹配正则 // IsRegex =true, // StyleId = -1 //}, } }, new TextBox { MarginBottom = 22, MarginTop = 0, MarginRight = 0, Width=207, FontSize = 13, SelectionFill = "153,201,239", Text = @" new TabItemTemplate{ Header = ""生成pdf"", Content = new Panel{ Size = new SizeField(""100%"",""100%""), }, } ", Background="255,255,255", Styles= { new DocumentStyle { Foreground = "#008000" }, new DocumentStyle { Foreground = "128,0,0" }, new DocumentStyle { Foreground = "DarkBlue" }, new DocumentStyle { Foreground = "143,8,196" }, new DocumentStyle { Foreground = "31,86,173" }, new DocumentStyle { Foreground = "#8000FF" }, new DocumentStyle { Foreground = "#c3c3fd" }, }, KeywordsStyles= { new KeywordsStyle { Keywords = @"\b(var|for|if|else|return|this|while|new|function|switch|case|typeof|do|in|throw|try|catch|finally|with|instance|delete|void|break|continue)\b",//匹配关键词,关键词顺序改了下 IsRegex = true, StyleId = 2 }, new KeywordsStyle { Keywords = @"(\/\/.*|\/\*[\s\S]*?\*\/)",// 匹配注释 IsRegex =true, StyleId = 0 }, new KeywordsStyle { Keywords = @"(""(?:[^""\\]|\\[\s\S])*""|'(?:[^'\\]|\\[\s\S])*')",// 匹配字符串 IsRegex=true, StyleId = 1 },//new KeywordsStyle //{ // Keywords = @"(?:[^\W\d]|\$)[\$\w]*",// 匹配普通的变量名 // IsRegex =true, // StyleId = 4 //}, //new KeywordsStyle //{ // Keywords = @"(0[xX][0-9a-fA-F]+|\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|\.\d+(?:[eE][+-]?\d+)?)",// 匹配数字,修复了匹配 // IsRegex =true, // StyleId = -1 //}, //new KeywordsStyle //{ // Keywords = @"(?:^|[^\)\]\}])(\/(?!\*)(?:\\.|[^\\\/\n])+?\/[gim]*)",//匹配正则 // IsRegex =true, // StyleId = -1 //}, } } }, }, }, new TabItemTemplate { Header="多级绑定", Content=new Panel { Name = "多级绑定", PresenterFor = this, Width="100%", Height="100%", Children= { new StackPanel { MarginLeft=10, MarginTop=10, Orientation= Orientation.Vertical, Children= { new TextBlock { [nameof(TextBlock.Text)]= new Obx(a => a.Test1.test.test.test.test.Name, BindingMode.OneWay), Name = "hmbb" },//new TextBox //{ // Width = 130, // Height= 60, // Background =Color.Gray, // [nameof(TextBox.Text)]= new Obx(a => a.Test1.test.test.test.test.Name, // BindingMode.OneWayToSource), //}, new Button { Content="创建对象", [nameof(Button.Click)]=new CommandDescribe((s,e)=> { data a = new data(); a.test.test.test.Name = "666666"; (DataContext as MainModel).Test1.test = a; }) }, new Button { Content="删除对象", [nameof(Button.Click)]=new CommandDescribe((s,e)=> { data a = new data(); a.test.test.Name = "666666"; (DataContext as MainModel).Test1.test.test = null; }) }, new Button { Content="添加对象", [nameof(Button.Click)]=new CommandDescribe((s,e)=> { data a = new data(); a.test.test.Name = "666666"; (DataContext as MainModel).Test1.test.test = a; }) }, } }, } } }, new TabItemTemplate { Header="布局", Content=new Panel { Name = "布局", PresenterFor = this, Width="100%", Height="100%", Children= { new StackPanel { MarginLeft=10, MarginTop=10, Orientation= Orientation.Vertical, Children= { new Button { Content="StackPanel的Vertical" }, new Button { Content="按钮" }, new Button { Content="按钮" }, new Button { Content="按钮" }, } }, new StackPanel { BorderStroke = "5,Solid", BorderFill = "#B4B4B4", MarginLeft=80, MarginTop=50, Orientation= Orientation.Horizontal, Children= { new Button { Content="StackPanel的Horizontal" }, new Button { Content="按钮" }, new Button { Content="Margin调间距", MarginLeft=5 }, new Button { Content="按钮" }, } }, new WrapPanel { MarginRight=10, MarginTop=10, Width="50%", Orientation= Orientation.Horizontal, Children= { new Button { Content="WrapPanel的Horizontal" }, new Button { Content="按钮" }, new Button { Content="Margin调间距", MarginLeft=5 }, new Button { Content="按钮" }, new Button { Content="宽度不够" }, new Button { Content="可以自动换行" }, } }, new Grid { RenderTransform=new RotateTransform(10), Name="testGrid", Background="#999", Width="80%", Height="60%", MarginTop=120, MarginLeft=20, ColumnDefinitions= { new ColumnDefinition { Width="40*" }, new ColumnDefinition { Width = "30*" }, new ColumnDefinition { Width="200", [nameof(ColumnDefinition.Width)]=nameof(MainModel.ColumnWidth) }, }, RowDefinitions= { new RowDefinition { Height="30*" }, new RowDefinition { Height="30*" }, new RowDefinition { Height="30*" } }, Children= { new WrapPanel { Name="test", Background="#a2f", Width="100%", Height="100%", Children= { new Button { Content="水平浮动布局231" }, new Button { Content="按钮2" }, new Button { Content="按钮3" }, new Button { Content="按钮4" }, new Button { Content="按钮5" }, } }, { new WrapPanel { Orientation= Orientation.Vertical, Background="#27a", Width="100%", Height="100%", Children= { new Button { Content="垂直浮动布局" }, new Button { Content="按钮2" }, new Button { Content="按钮3" }, new Button { Content="按钮4" }, new Button { Content="按钮5" }, } }, 1, 1 }, { new TextBlock { Background="#ac2", Width="100%", Height="100%", Text="Grid布局。。。" }, 2, 1 }, { new Panel { Background="#b1a", MarginLeft=0, MarginRight=0, Children= { new Button { Content="跨列", Width="50%" } } }, 0, 2, 2 }, { new TextBlock { Background="#186", Height="100%", Text="跨行" }, 2, 1, 1, 2 }, new TextBox { MarginLeft=10, Size=SizeField.Fill, Text="元素变换,可以旋转,倾斜,缩放等操作", Attacheds= { { Grid.ColumnIndex, 1 } } }, new Button { Content=new SVG("res://ConsoleApp1/test.svg") { MarginLeft = 0, MarginTop = 0, Height = 85, Width=170, Stretch= Stretch.Uniform, }, Width=104, Height=55, MarginLeft=60, MarginTop=120, Commands= { { nameof(Button.Click), (s,e)=> Animation((Button)s) } } } }, }, new DockPanel { LastChildFill = false, Width=200, Height=200, MarginRight=0, MarginTop=50, Background="#f00", Children = { new Button { Content="Right", Height="100%", Attacheds = { { DockPanel.Dock, Dock.Right } } }, } }, new Slider { Maximum = 300, Value = 200, MarginLeft = 252, MarginTop = 76, Height = 23, Width = 219, [nameof(Slider.Value)]=new BindingDescribe(null, nameof(MainModel.ColumnWidth),BindingMode.OneWayToSource,null,a=>new GridLength((float)(double)a)) }, } } }, new TabItemTemplate { Header="布局", Content=new Panel { Name = "布局", PresenterFor = this, Width="100%", Height="100%", Children= { new StackPanel { MarginLeft=10, MarginTop=10, Orientation= Orientation.Vertical, Children= { new Button { Content="StackPanel的Vertical" }, new Button { Content="按钮" }, new Button { Content="按钮" }, new Button { Content="按钮" }, } }, new StackPanel { BorderStroke = "5,Solid", BorderFill = "#B4B4B4", MarginLeft=80, MarginTop=50, Orientation= Orientation.Horizontal, Children= { new Button { Content="StackPanel的Horizontal" }, new Button { Content="按钮" }, new Button { Content="Margin调间距", MarginLeft=5 }, new Button { Content="按钮" }, } }, new WrapPanel { MarginRight=10, MarginTop=10, Width="50%", Orientation= Orientation.Horizontal, Children= { new Button { Content="WrapPanel的Horizontal" }, new Button { Content="按钮" }, new Button { Content="Margin调间距", MarginLeft=5 }, new Button { Content="按钮" }, new Button { Content="宽度不够" }, new Button { Content="可以自动换行" }, } }, new Grid { RenderTransform=new RotateTransform(10), Name="testGrid", Background="#999", Width="80%", Height="60%", MarginTop=120, MarginLeft=20, ColumnDefinitions= { new ColumnDefinition { Width="40*" }, new ColumnDefinition { Width = "30*" }, new ColumnDefinition { Width="200", [nameof(ColumnDefinition.Width)]=nameof(MainModel.ColumnWidth) }, }, RowDefinitions= { new RowDefinition { Height="30*" }, new RowDefinition { Height="30*" }, new RowDefinition { Height="30*" } }, Children= { new WrapPanel { Name="test", Background="#a2f", Width="100%", Height="100%", Children= { new Button { Content="水平浮动布局231" }, new Button { Content="按钮2" }, new Button { Content="按钮3" }, new Button { Content="按钮4" }, new Button { Content="按钮5" }, } }, { new WrapPanel { Orientation= Orientation.Vertical, Background="#27a", Width="100%", Height="100%", Children= { new Button { Content="垂直浮动布局" }, new Button { Content="按钮2" }, new Button { Content="按钮3" }, new Button { Content="按钮4" }, new Button { Content="按钮5" }, } }, 1, 1 }, { new TextBlock { Background="#ac2", Width="100%", Height="100%", Text="Grid布局。。。" }, 2, 1 }, { new Panel { Background="#b1a", MarginLeft=0, MarginRight=0, Children= { new Button { Content="跨列", Width="50%" } } }, 0, 2, 2 }, { new TextBlock { Background="#186", Height="100%", Text="跨行" }, 2, 1, 1, 2 }, new TextBox { MarginLeft=10, Size=SizeField.Fill, Text="元素变换,可以旋转,倾斜,缩放等操作", Attacheds= { { Grid.ColumnIndex, 1 } } }, new Button { Content=new SVG("res://ConsoleApp1/test.svg") { MarginLeft = 0, MarginTop = 0, Height = 85, Width=170, Stretch= Stretch.Uniform, }, Width=104, Height=55, MarginLeft=60, MarginTop=120, Commands= { { nameof(Button.Click), (s,e)=> Animation((Button)s) } } } }, }, new DockPanel { LastChildFill = false, Width=200, Height=200, MarginRight=0, MarginTop=50, Background="#f00", Children = { new Button { Content="Right", Height="100%", Attacheds = { { DockPanel.Dock, Dock.Right } } }, } }, new Slider { Maximum = 300, Value = 200, MarginLeft = 252, MarginTop = 76, Height = 23, Width = 219, [nameof(Slider.Value)]=new BindingDescribe(null, nameof(MainModel.ColumnWidth),BindingMode.OneWayToSource,null,a=>new GridLength((float)(double)a)) }, } } }, new TabItemTemplate { Header="布局", Content=new Panel { Name = "布局", PresenterFor = this, Width="100%", Height="100%", Children= { new StackPanel { MarginLeft=10, MarginTop=10, Orientation= Orientation.Vertical, Children= { new Button { Content="StackPanel的Vertical" }, new Button { Content="按钮" }, new Button { Content="按钮" }, new Button { Content="按钮" }, } }, new StackPanel { BorderStroke = "5,Solid", BorderFill = "#B4B4B4", MarginLeft=80, MarginTop=50, Orientation= Orientation.Horizontal, Children= { new Button { Content="StackPanel的Horizontal" }, new Button { Content="按钮" }, new Button { Content="Margin调间距", MarginLeft=5 }, new Button { Content="按钮" }, } }, new WrapPanel { MarginRight=10, MarginTop=10, Width="50%", Orientation= Orientation.Horizontal, Children= { new Button { Content="WrapPanel的Horizontal" }, new Button { Content="按钮" }, new Button { Content="Margin调间距", MarginLeft=5 }, new Button { Content="按钮" }, new Button { Content="宽度不够" }, new Button { Content="可以自动换行" }, } }, new Grid { RenderTransform=new RotateTransform(10), Name="testGrid", Background="#999", Width="80%", Height="60%", MarginTop=120, MarginLeft=20, ColumnDefinitions= { new ColumnDefinition { Width="40*" }, new ColumnDefinition { Width = "30*" }, new ColumnDefinition { Width="200", [nameof(ColumnDefinition.Width)]=nameof(MainModel.ColumnWidth) }, }, RowDefinitions= { new RowDefinition { Height="30*" }, new RowDefinition { Height="30*" }, new RowDefinition { Height="30*" } }, Children= { new WrapPanel { Name="test", Background="#a2f", Width="100%", Height="100%", Children= { new Button { Content="水平浮动布局231" }, new Button { Content="按钮2" }, new Button { Content="按钮3" }, new Button { Content="按钮4" }, new Button { Content="按钮5" }, } }, { new WrapPanel { Orientation= Orientation.Vertical, Background="#27a", Width="100%", Height="100%", Children= { new Button { Content="垂直浮动布局" }, new Button { Content="按钮2" }, new Button { Content="按钮3" }, new Button { Content="按钮4" }, new Button { Content="按钮5" }, } }, 1, 1 }, { new TextBlock { Background="#ac2", Width="100%", Height="100%", Text="Grid布局。。。" }, 2, 1 }, { new Panel { Background="#b1a", MarginLeft=0, MarginRight=0, Children= { new Button { Content="跨列", Width="50%" } } }, 0, 2, 2 }, { new TextBlock { Background="#186", Height="100%", Text="跨行" }, 2, 1, 1, 2 }, new TextBox { MarginLeft=10, Size=SizeField.Fill, Text="元素变换,可以旋转,倾斜,缩放等操作", Attacheds= { { Grid.ColumnIndex, 1 } } }, new Button { Content=new SVG("res://ConsoleApp1/test.svg") { MarginLeft = 0, MarginTop = 0, Height = 85, Width=170, Stretch= Stretch.Uniform, }, Width=104, Height=55, MarginLeft=60, MarginTop=120, Commands= { { nameof(Button.Click), (s,e)=> Animation((Button)s) } } } }, }, new DockPanel { LastChildFill = false, Width=200, Height=200, MarginRight=0, MarginTop=50, Background="#f00", Children = { new Button { Content="Right", Height="100%",//Attacheds = //{ // { // DockPanel.Dock, // Dock.Right // } //}, [DockPanel.Dock] = Dock.Right, } .Assign(out var testBtn), } }, new Slider { Maximum = 300, Value = 200, MarginLeft = 252, MarginTop = 76, Height = 23, Width = 219, [nameof(Slider.Value)]=new BindingDescribe(null, nameof(MainModel.ColumnWidth),BindingMode.OneWayToSource,null,a=>new GridLength((float)(double)a)) }, } } } },//SelectedIndex=1 } } }) { MaximizeBox = true, ShadowBlur = 10, #if !DesignMode //Effect = effect #endif }); LoadStyleFile("res://ConsoleApp1/Stylesheet3.css"); //加载样式文件,文件需要设置为内嵌资源 Console.WriteLine(testBtn[DockPanel.Dock]); if (!DesignMode)//设计模式下不执行 { //var type = Grid.ColumnIndex.GetType(); //var f = typeof(Grid).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static); //var attached = f[0].GetValue(null, null); //var pt = typeof(CPF.OptionalParameter<>).MakeGenericType(f[0].PropertyType.GetGenericArguments()); //var v = (attached as Delegate).DynamicInvoke(this, Activator.CreateInstance(pt)); //var p = typeof(Grid).GetProperty("Grid.RowIndex", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static); } } CPF.Controls.Switch _sw; DataGrid testDataGrid; DataGrid testGrid; TreeView testTreeVIew; Button btn; Panel page1; ComboBox combox; ComboBox testCombobox; Picture pic; StackPanel stackPanel; TextBox textBox; public float TestValue { get { return GetValue(); } set { SetValue(value); } } //PathGeometry pathGeometry = "M159.375 196.875A9.375 9.375 0 0 1 140.625 196.875V133.8375L113.83125 89.2125A9.375 9.375 0 1 1 129.91875 79.55625L158.04375 126.43125A9.375 9.375 0 0 1 159.375 131.25V196.875zM121.875 300A9.375 9.375 0 0 1 121.875 281.25H131.25V261.1875A131.26875 131.26875 0 0 1 69.88125 27.3L58.59375 16.0125A9.375 9.375 0 0 1 71.85 2.7375L85.8375 16.725A130.6875 130.6875 0 0 1 150 0A130.6875 130.6875 0 0 1 214.1625 16.725L228.15 2.7375A9.375 9.375 0 0 1 241.4062500000001 16.0125L230.1375 27.3A131.26875 131.26875 0 0 1 168.75 261.1875V281.25H178.125A9.375 9.375 0 0 1 178.125 300H121.875zM141.3375 243.4125A114.24375 114.24375 0 0 0 158.6625 243.4125A112.5 112.5 0 1 0 141.3375 243.4125zM0 234.375C0 220.25625 6.24375 207.58125 16.125 198.99375A150.65625 150.65625 0 0 0 82.25625 265.125A46.875 46.875 0 0 1 0 234.375zM253.125 281.25C239.00625 281.25 226.33125 275.00625 217.74375 265.125A150.65625 150.65625 0 0 0 283.875 198.99375A46.875 46.875 0 0 1 253.125 281.25z"; //Stopwatch stopwatch = new Stopwatch(); //int frameCount; protected override void OnRender(DrawingContext dc) { base.OnRender(dc); //frameCount++; //if (stopwatch.ElapsedMilliseconds >= 500) //{ // Debug.WriteLine(frameCount * 1000 / stopwatch.ElapsedMilliseconds); // stopwatch.Restart(); // frameCount = 0; //} //else if (!stopwatch.IsRunning) //{ // stopwatch.Start(); //} //dc.DrawPath("#f00", new Stroke(1), pathGeometry); } protected override void OnElementInitialize(UIElement element) { if (element is Button button) { button.SetTemplate((s, c) => { c.Add(new StackPanel { Orientation = Orientation.Horizontal, Children = { new Ellipse { Width = 15, Height = 15,IsAntiAlias=true,Fill="#f00" }, new Border { Name = "contentPresenter", Height = "100%", BorderFill = null, PresenterFor = s, }, } }); }); } if (element.Tag == null) { element.Tag = 1; } else { element.Tag = 1 + (int)element.Tag; } base.OnElementInitialize(element); } [PropertyMetadata(-1)] public int SelectIndex { get { return GetValue(); } set { SetValue(value); } } public Collection List1 { get { return GetValue>(); } set { SetValue(value); } } public Collection List2 { get { return GetValue>(); } set { SetValue(value); } } void test() { //var panel = this.FindPresenter().First(a => a.Name == "testPanel"); //Stopwatch stopwatch = new Stopwatch(); //stopwatch.Start(); //panel.Children.DisposeChildren(); //Debug.WriteLine("清除:" + stopwatch.ElapsedMilliseconds); //System.Threading.Thread.Sleep(1000); //stopwatch.Restart(); //for (int i = 0; i < 1000; i++) //{ // panel.Children.Add(new Button { Content = "test测试", Width = 100, Height = 50 }); //} //stopwatch.Stop(); //Debug.WriteLine("添加:" + stopwatch.ElapsedMilliseconds); } protected async override void OnInitialized() { //testTreeVIew.Items = Nodes; //(DataContext as MainModel).TestItems1 = new Collection(); //for (int i = 0; i < 10; i++) //{ // (DataContext as MainModel).TestItems1.Add(i.ToString()); //} _sw = FindPresenterByName(nameof(_sw)); _sw.IsChecked = true; base.OnInitialized(); Items = new Collection(); for (int i = 0; i < 100; i++) { Items.Add(new ItemData { Name = "马大云" + i, Introduce = "哈哈---" + i }); } //Columns.Add(new DataGridTextColumn { Header = "任务名称", Width = "60*", CanUserSort = false }); //Columns.Add(new DataGridTextColumn { Header = "", Width = "20*", CanUserSort = false }); CPF.Styling.ResourceManager.GetImage("res://ConsoleApp1/Resources/主页.png", a => { var data = new DataTable(); for (int i = 0; i < 9; i++) { data.Columns.Add("p" + (i + 1).ToString()); } data.Columns[1].DataType = typeof(bool); data.Columns[3].DataType = typeof(int); data.Columns[5].DataType = typeof(Image); data.Columns[7].DataType = typeof(Button); for (int i = 0; i < 180; i++) { var row = data.NewRow(); for (int j = 0; j < 9; j++) { if (j != 1) { if (j == 5) { row[j] = a; } else if (j == 7) { row[7] = new Button { Content = "test" + i, Width = "100%" }; } else { row[j] = i; } } } row[0] = i % 3; row[1] = true; data.Rows.Add(row); } Data = data.ToItems(); }); Icon = await CPF.Styling.ResourceManager.GetImage("res://ConsoleApp1/Resources/icon.png"); textBox = FindPresenterByName(nameof(textBox)); stackPanel = FindPresenterByName(nameof(stackPanel)); //for (int i = 0; i < 50000; i++) //{ // stackPanel.Children.Add(new Button { Content="test"}); //} pic = FindPresenterByName(nameof(pic)); btn = FindPresenterByName