同步操作将从 BinGoo/CPFUI 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
using CPF;using CPF.Controls;using CPF.Drawing;using System;using CPFUI.IControl;using System.Reflection.Metadata;using CPF.Shapes;using CPFUI.IControl.Process;using CPF.Threading;namespace CPFUIDemo{public class Window1 : Window{OfficeMenuHelper officeMenuHelper = new OfficeMenuHelper();OfficMenu officMenu;MacMenu macmenu;TabBarControl tabBarControl;IPadViewControl ipadViewControl;private IMListBox listBox;private MenuControl MenuList;IMChatBox chatBox;public char Hour1{get { return GetValue<char>(); }set { SetValue(value); }}public char Hour2{get { return GetValue<char>(); }set { SetValue(value); }}public char Minute1{get { return GetValue<char>(); }set { SetValue(value); }}public char Minute2{get { return GetValue<char>(); }set { SetValue(value); }}public char Second1{get { return GetValue<char>(); }set { SetValue(value); }}public char Second2{get { return GetValue<char>(); }set { SetValue(value); }}protected override void InitializeComponent(){LoadStyleFile("res://CPFUIDemo/Stylesheet1.css");//加载样式文件,文件需要设置为内嵌资源LoadStyleFile("res://CPFUI/Style/Css/Normal.css",true);Title = "标题";Width = 1300;Height = 868;Background = null;CanResize = true;macmenu = new MacMenu(){//Background=Color.Red,Spacing = 4,ChangedCoefficient = 1.5,MaxSize = 120,MinSize = 60,MarginBottom = 0,};tabBarControl = new TabBarControl{ItemHeight = 50,ItemWidth = 100,Orientation = Orientation.Horizontal,MarginLeft = 0,MarginTop = 0,MarginRight = 0,MarginBottom=0,Background = Color.White,Height = 50,ChangedMove = true};ipadViewControl = new IPadViewControl{ClipToBounds = true,CornerRadius = "0",ItemHeight = 60,ItemWidth = 80,MatrixColumns=4,MatrixRows=4,Background = Color.White,Height =500,Width=400,ChangedMove = true};listBox = new IMListBox(){Width = 276,MarginRight = 0,MarginTop = 0,MarginBottom = 0,};officMenu = new OfficMenu{Classes = "TabMenu",Height = 140,Width=800,MarginLeft = 0,MarginRight = 0,MarginTop = 0,OfficeMenuList = officeMenuHelper.GetOfficeMenuList("首页")};MenuList = new MenuControl(){GroupForeground=Color.WhiteSmoke,ItemNormalForeground = Color.White,ItemSelectedForeground=Color.White,MarginRight= 0,MarginLeft = 0,MarginTop = 0,MarginBottom = 0,};for (int i = 0;i < 5;i++){MenuGroupItem imGroup = new MenuGroupItem(){MarginLeft = 0,MarginRight = 0,};imGroup.Caption = "菜单组";for (int j = 0;j < 3;j++){imGroup.AddItem(new CPFUI.IControl.MenuControlItem(){MarginLeft = 0,MarginRight = 0,Image = "res://CPFUIDemo/Resources/首页.png",Text = "首页"});}MenuList.AddGroup(imGroup);}chatBox = new IMChatBox{MarginRight = 276,MarginTop = 0,MarginBottom = 150,MarginLeft = 230,};//macmenu.MacItemMouseDown += Macmenu_MacItemMouseDown;Children.Add(new WindowFrame(this, new Panel{Width = "100%",Height = "100%",Children ={chatBox,listBox,MenuList,new Border{Background=Color.DodgerBlue,MarginLeft = 0,MarginTop = 0,Width=230,MarginBottom = 0,BorderType = BorderType.BorderStroke,BorderStroke = new Stroke(0),ShadowBlur = 8,ShadowColor = Color.FromArgb(150, 70, 70, 70),CornerRadius = new CornerRadius(14),IsAntiAlias = true,Child=MenuList},//new CodeText//{// MarginTop=0,// MarginRight=0,// Width=500,// MarginBottom=150//}}}){MaximizeBox=true});if (!DesignMode)//设计模式下不执行,也可以用#if !DesignMode{}CreatChatBox();CreatChatBox2();CreatChatBox1();}private void OfficMenu_OnTabHeadMenuClick(object sender, OfficeHeaderEvenArgs e){officMenu.OfficeMenuList = officeMenuHelper.GetOfficeMenuList(e.TabName);}private void OfficMenu_OnTabMenuClick(object sender, OfficeMenuEvenArgs e){}private void Macmenu_MacItemMouseDown(object sender, CPF.Input.MouseButtonEventArgs e){MacMenuItem item = sender as MacMenuItem;MessageBox.Show(item.Caption);}public void CreatMacMenu(){for (int i = 1; i < 10; i++){macmenu.AddMacMenuItem(new MacMenuItem() { Caption = $"系统菜单{i}", Icon = string.Format("res://CPFUIDemo/Resources/{0}.png", i) });}}public void CreatTabBar(){for (int i = 1; i < 10; i++){tabBarControl.AddTabBarItem(new TabBarItemTemplate() { TabBarBackground = Color.FromArgb(80, 0, 0, 0), Text="TabBar",Image = string.Format("res://CPFUIDemo/Resources/{0}.png", i) });}}public void CreatIpadView(){for (int i = 0; i < 50; i++){ipadViewControl.AddTabBarItem(new IPadViewItemTemplate() {TabBarBackground = Color.FromArgb(0, 0, 0, 0), Text = "Item"+i, Image = string.Format("res://CPFUIDemo/Resources/{0}.png",i%10) });}}string[] groupnames = new string[] {"我的设备"," ╔--╗ "," ┊执┊ ╔--╗"," ┊子┊ ┊与┊"," ┊之┊ ┊子┊"," ┊手┊ ┊携┊"," ╚--╝ ┊老┊"," ╚--╝"};public void CreatIMListbox(){for (int i = 0; i < groupnames.Length; i++){IMGroup group = new IMGroup();group.Text = groupnames[i];listBox.AddGroup(group);for (int j = 0; j < 10; j++){IMListBoxItem item = new IMListBoxItem(new UserInfo(){NickName = "BinGoo1",Description= "太懒了,什么都没有~~!",HeadImage = "https://q1.itc.cn/q_70/images03/20240320/fcf023d835c54f78bac6c7efc98fbb4c.jpeg"});listBox.AddItem(group,item);}}}public void CreatChatBox(){chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.Text,DateTime = DateTime.Now,Information = "仿IPad桌面菜单",},new MessageModel{MsgType = EMsgType.Custom,DateTime = DateTime.Now,Information =ipadViewControl},},SendReceiveType = EChatType.Receive,User = new UserInfo(){NickName = "BinGoo",HeadImage = "https://q1.itc.cn/q_70/images03/20240320/fcf023d835c54f78bac6c7efc98fbb4c.jpeg"}});chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.Text,DateTime = DateTime.Now,Information = "加载进度条",},new MessageModel{MsgType = EMsgType.Custom,DateTime = DateTime.Now,Information =new Panel{Children ={new CircularProgress{TickColor=Color.OrangeRed,Rotation=Direction.Anticlockwise,MarginLeft = 0,Width=100,Height=100,Interval=120},new CircularProgress{TickColor=Color.Green,Rotation=Direction.Anticlockwise,GraphType=GraphType.Ellipse,MarginLeft = 100,Width=100,Height=100,Interval=60},new CircularProgress{TickColor=Color.Black,Rotation=Direction.Clockwise,MarginLeft = 200,Width=100,Height=100,Interval=80},new CircularProgress{TickColor=Color.DodgerBlue,Rotation=Direction.Clockwise,GraphType=GraphType.Ellipse,IsChangeSize=true,MarginLeft = 300,Width=100,Height=100,Interval=30},}}},},SendReceiveType = EChatType.Receive,User = new UserInfo(){NickName = "BinGoo",HeadImage = "https://q1.itc.cn/q_70/images03/20240320/fcf023d835c54f78bac6c7efc98fbb4c.jpeg"}});}public void CreatChatBox2(){chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.Text,DateTime = DateTime.Now,Information = "笔记本小键盘",},new MessageModel{MsgType = EMsgType.Custom,DateTime = DateTime.Now,Information =new KeyBorderLetter{ }},},SendReceiveType = EChatType.Receive,User = new UserInfo(){NickName = "BinGoo",HeadImage = "https://q1.itc.cn/q_70/images03/20240320/fcf023d835c54f78bac6c7efc98fbb4c.jpeg"}});chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.Text,DateTime = DateTime.Now,Information = "全键盘",},new MessageModel{MsgType = EMsgType.Custom,DateTime = DateTime.Now,Information =new KeyBorderAll{ }},},SendReceiveType = EChatType.Receive,User = new UserInfo(){NickName = "BinGoo",HeadImage = "https://q1.itc.cn/q_70/images03/20240320/fcf023d835c54f78bac6c7efc98fbb4c.jpeg"}}); chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.Text,DateTime = DateTime.Now,Information = "数字键盘",},new MessageModel{MsgType = EMsgType.Custom,DateTime = DateTime.Now,Information =new KeyBorderNumber{ }},},SendReceiveType = EChatType.Receive,User = new UserInfo(){NickName = "BinGoo",HeadImage = "https://q1.itc.cn/q_70/images03/20240320/fcf023d835c54f78bac6c7efc98fbb4c.jpeg"}});}public void CreatChatBox1(){MindNode MindNode = new MindNode { Left = 100, Top = 5, Caption = "节点", Size = new SizeField(100, 50), GraphType = MindNodeGraphType.Circle };MindNode MindNode1 = new MindNode { Left = 100, Top = 70, Caption = "节点", Size = new SizeField(100, 50), GraphType = MindNodeGraphType.Rectangle, Orientation = MindNodeOrientation.Bottom };MindNode MindNode2 = new MindNode { Left = 100, Top = 140, Caption = "节点", Size = new SizeField(100, 50), GraphType = MindNodeGraphType.Rectangle, Orientation = MindNodeOrientation.Bottom };MindNode MindNode3 = new MindNode { Left = 100, Top = 210, Caption = "节点", Size = new SizeField(100, 50), GraphType = MindNodeGraphType.Rectangle, Orientation = MindNodeOrientation.Bottom };MindNode MindNode4 = new MindNode { Left = 100, Top = 280, Caption = "节点", Size = new SizeField(100, 50), GraphType = MindNodeGraphType.Rhombus, Orientation = MindNodeOrientation.Bottom };MindNode3.NextNode.Add(MindNode4);MindNode2.NextNode.Add(MindNode3);MindNode1.NextNode.Add(MindNode2);MindNode.NextNode.Add(MindNode1);chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.Text,DateTime = DateTime.Now,Information = "按钮Button",},new MessageModel{MsgType = EMsgType.Custom,DateTime = DateTime.Now,Information =new StackPanel{Orientation=Orientation.Horizontal,Children ={new ButtonEx{MarginBottom=0,BackColor=Color.Orange,Foreground=Color.White,Width=50,Height=30,CornerRadius="15",Content=new Ellipse{IsAntiAlias = true,Width = 20,Height = 20,StrokeFill = Color.Transparent,Fill = string.Format("url({0}) Clamp Fill 0,0,0,0", "res://CPFUIDemo/Resources/error.png")}},new ButtonEx{MarginBottom=0,BackColor=Color.Orange,Foreground=Color.White,Width=50,Height=30,CornerRadius="15",Content="按钮"},new ButtonEx(){MarginBottom=0,MarginLeft=5,BackColor=Color.OrangeRed,Foreground=Color.White,Width=70,Height=40,Content=new Ellipse{IsAntiAlias = true,Width = 30,Height = 30,StrokeFill = Color.Transparent,Fill = string.Format("url({0}) Clamp Fill 0,0,0,0", "res://CPFUIDemo/Resources/success.png")}},new ButtonEx(){MarginBottom=0,MarginLeft=5,BackColor=Color.DarkGreen,Foreground=Color.White,Width=90,Height=50,Content="按钮"},new ButtonEx(){MarginBottom=0,MarginLeft=5,BackColor=Color.FromRgb(30, 159, 255),Foreground=Color.White,Width=120,Height=60,Content="按钮"},}}},},SendReceiveType = EChatType.Receive,User = new UserInfo(){NickName = "BinGoo",HeadImage = "https://q1.itc.cn/q_70/images03/20240320/fcf023d835c54f78bac6c7efc98fbb4c.jpeg"}});chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.Text,DateTime = DateTime.Now,Information = "PageControl",},new MessageModel{MsgType = EMsgType.Custom,DateTime = DateTime.Now,Information =new PageControl(){Background=Color.White,PageCount=20,}},},SendReceiveType = EChatType.Receive,User = new UserInfo(){NickName = "BinGoo",HeadImage = "https://q1.itc.cn/q_70/images03/20240320/fcf023d835c54f78bac6c7efc98fbb4c.jpeg"}});chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.Text,DateTime = DateTime.Now,Information = "颜色拾取器",},new MessageModel{MsgType = EMsgType.Custom,DateTime = DateTime.Now,Information =new ColorExtractorControl(){Background=Color.White,}},},SendReceiveType = EChatType.Receive,User = new UserInfo(){NickName = "BinGoo",HeadImage = "https://q1.itc.cn/q_70/images03/20240320/fcf023d835c54f78bac6c7efc98fbb4c.jpeg"}});chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.Text,DateTime = DateTime.Now,Information = "这是一个仿office菜单",},new MessageModel{MsgType = EMsgType.Custom,DateTime = DateTime.Now,Information =officMenu},},SendReceiveType = EChatType.Receive,User = new UserInfo(){NickName = "BinGoo",HeadImage = "https://q1.itc.cn/q_70/images03/20240320/fcf023d835c54f78bac6c7efc98fbb4c.jpeg"}});officMenu.AddTabHeader("开始", true);officMenu.AddTabHeader("插入", false);officMenu.AddTabHeader("页面", false);officMenu.OfficeMenuList = officeMenuHelper.GetOfficeMenuList("开始");officMenu.CreatMenu("开始");officMenu.OnTabMenuClick += OfficMenu_OnTabMenuClick; ;officMenu.OnTabHeadMenuClick += OfficMenu_OnTabHeadMenuClick;chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.Text,DateTime = DateTime.Now,Information = "这是一个可拖拽的Tab菜单",},new MessageModel{MsgType = EMsgType.Custom,DateTime = DateTime.Now,Information =tabBarControl},},SendReceiveType = EChatType.Receive,User = new UserInfo(){NickName = "BinGoo",HeadImage = "https://q1.itc.cn/q_70/images03/20240320/fcf023d835c54f78bac6c7efc98fbb4c.jpeg"}});chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.Text,DateTime = DateTime.Now,Information = "一款模仿苹果程序邬的菜单",},new MessageModel{MsgType = EMsgType.Custom,DateTime = DateTime.Now,Information =macmenu},},SendReceiveType = EChatType.Receive,User = new UserInfo(){NickName = "BinGoo",HeadImage = "https://q1.itc.cn/q_70/images03/20240320/fcf023d835c54f78bac6c7efc98fbb4c.jpeg"}});chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.Text,DateTime = DateTime.Now,Information = "这是一个流程图控件",},new MessageModel{MsgType = EMsgType.Custom,DateTime = DateTime.Now,Information =new MindControl{Width=500,Height=340,MindNode=MindNode}},},SendReceiveType = EChatType.Receive,User = new UserInfo(){NickName = "BinGoo",HeadImage = "https://q1.itc.cn/q_70/images03/20240320/fcf023d835c54f78bac6c7efc98fbb4c.jpeg"}});chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.Image,DateTime = DateTime.Now,Information = "https://b0.bdstatic.com/a3dc2283f738942f0253834688a56413.jpg@h_1280",}},SendReceiveType = EChatType.Send,User = new UserInfo(){NickName = "张三",HeadImage = "https://q6.itc.cn/q_70/images03/20240308/f5c4defaf1c8400aa54dc1e1b6535ebd.jpeg"}});chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.File,DateTime = DateTime.Now,Information = "CPF源码",},},SendReceiveType = EChatType.Send,User = new UserInfo(){NickName = "张三",HeadImage = "https://q6.itc.cn/q_70/images03/20240308/f5c4defaf1c8400aa54dc1e1b6535ebd.jpeg"}});chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.Text,DateTime = DateTime.Now,Information = "这是一条图文消息",},new MessageModel{MsgType = EMsgType.Image,DateTime = DateTime.Now,Information = "https://img2.baidu.com/it/u=3202947311,1179654885&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",}},SendReceiveType = EChatType.Receive,User = new UserInfo(){NickName = "BinGoo",HeadImage = "https://q1.itc.cn/q_70/images03/20240320/fcf023d835c54f78bac6c7efc98fbb4c.jpeg"}});chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.Text,DateTime = DateTime.Now,Information = "头像选择",},new MessageModel{MsgType = EMsgType.Custom,DateTime = DateTime.Now,Information = new PictrueCropper{MarginLeft = 35,MarginTop = 20,SourceImg = "res://CPFUIDemo/Resources/拿铁.jpeg",Width = 300,Height = 300}}},SendReceiveType = EChatType.Receive,User = new UserInfo(){NickName = "BinGoo",HeadImage = "https://q1.itc.cn/q_70/images03/20240320/fcf023d835c54f78bac6c7efc98fbb4c.jpeg"}});chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.Text,DateTime = DateTime.Now,Information = "简洁、直观、强悍的netcore跨平台UI开发框架\r\n框架理念和WPF类似,但是没有Xaml,直接用CSS和C#代码描述。\r\n全面支持国产化,支持国产Linux + 龙芯、飞腾、兆芯、海光等CPU平台",}},SendReceiveType = EChatType.Receive,User = new UserInfo(){NickName = "BinGoo",HeadImage = "https://q1.itc.cn/q_70/images03/20240320/fcf023d835c54f78bac6c7efc98fbb4c.jpeg"}});chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.Custom,DateTime = DateTime.Now,Information = new StackPanel{Height=50,Orientation=Orientation.Horizontal,Children ={new LedNumber{ForeColor=Color.Red,Width=18,Height=30,LineWidth=4,Value=Hour1,MarginRight=15,Bindings ={{nameof(LedNumber.Value),nameof(Hour1),this,BindingMode.TwoWay }}},new LedNumber{ForeColor=Color.Red,Width=18,Height=30,LineWidth=4,Value=Hour2,MarginRight=15,Bindings ={{nameof(LedNumber.Value),nameof(Hour2),this,BindingMode.TwoWay }}},new LedNumber{ForeColor=Color.Red,Width=5,Height=30,LineWidth=4,Value=':',MarginRight=15,},new LedNumber{ForeColor=Color.Red,Width=18,Height=30,LineWidth=4,Value=Minute1,MarginRight=15,Bindings ={{nameof(LedNumber.Value),nameof(Minute1),this,BindingMode.TwoWay}}},new LedNumber{ForeColor=Color.Red,Width=18,Height=30,LineWidth=4,Value=Minute2,MarginRight=15,Bindings ={{nameof(LedNumber.Value),nameof(Minute2),this,BindingMode.TwoWay}}},new LedNumber{ForeColor=Color.Red,Width=5,Height=30,LineWidth=4,Value=':',MarginRight=15,},new LedNumber{ForeColor=Color.Red,Width=18,Height=30,LineWidth=4,Value=Minute1,MarginRight=15,Bindings ={{nameof(LedNumber.Value),nameof(Second1),this,BindingMode.TwoWay }}},new LedNumber{ForeColor=Color.Red,Width=18,Height=30,LineWidth=4,Value=Minute2,MarginRight=15,Bindings ={{nameof(LedNumber.Value),nameof(Second2),this,BindingMode.TwoWay}}},}},}},SendReceiveType = EChatType.Receive,User = new UserInfo(){NickName = "BinGoo",HeadImage = "https://q1.itc.cn/q_70/images03/20240320/fcf023d835c54f78bac6c7efc98fbb4c.jpeg"}});chatBox.AddMessage(new MessagesInfo(){Data ={new MessageModel{MsgType = EMsgType.Text,DateTime = DateTime.Now,Information = "这是一条自定义控件消息",},new MessageModel{MsgType = EMsgType.Custom,DateTime = DateTime.Now,Information =new StackPanel{Orientation= Orientation.Horizontal,Children ={new TextBlock{ Text="是否打开:"},new Switch{OffColor=Color.Silver,Width=45,Height=20},}}},},SendReceiveType = EChatType.Receive,User = new UserInfo(){NickName = "BinGoo",HeadImage = "https://q1.itc.cn/q_70/images03/20240320/fcf023d835c54f78bac6c7efc98fbb4c.jpeg"}});CreatMacMenu();}#if !DesignMode //用户代码写到这里,设计器下不执行,防止设计器出错protected override void OnInitialized(){base.OnInitialized();DispatcherTimer m_Timer = new DispatcherTimer();m_Timer.Interval = TimeSpan.FromSeconds(1);m_Timer.Tick += M_Timer_Tick; ;m_Timer.IsEnabled = false;m_Timer.Start();CreatTabBar();CreatIMListbox();CreatIpadView();}private void M_Timer_Tick(object sender, EventArgs e){string hour = DateTime.Now.Hour.ToString("D2");string minute = DateTime.Now.Minute.ToString("D2");string second = DateTime.Now.Second.ToString("D2");Hour1 = hour[0];Hour2 = hour[1];Minute1 = minute[0];Minute2 = minute[1];Second1 = second[0];Second2 = second[1];Invalidate();}//用户代码#endif}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。