1 Star 0 Fork 21

持之以恒/基于导航菜单的 WinForm 项目的基础框架

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Shell.cs 3.29 KB
一键复制 编辑 原始数据 按行查看 历史
电脑程序爱好者 提交于 2021-01-25 15:25 +08:00 . init created
using PubSub;
using Syncfusion.Windows.Forms;
using Syncfusion.WinForms.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WinForm.NET4.Sample.CustomControl;
using WinForm.NET4.Sample.Extensions;
namespace WinForm.NET4.Sample
{
public partial class Shell : SfForm
{
string imagepath = "Images\\";
public Shell()
{
InitializeComponent();
/*You may add a rich text if need NOT a captionBar
this.Style.TitleBar.AllowRichText = true;
this.Text = "{\\rtf1\\ansi\\deff0{\\colortbl;\\red255\\green255\\blue255;\\red250\\green0\\blue0;}" + "{\\fonttbl{\\f0 Segoe UI;\r\n}}\\qc\\f0\\fs25 {\\cf1 基础框架代码 - \\cf2 \\b Win Form}}";
*/
this.CenterToScreen();
this.MinimumSize = this.Size;
//Style.Border.Width = 0;
//Style.Border.Color = Color.Black;
var captionBar = new CaptionBar();
captionBar.CaptionMouseUp += Bar_CaptionMouseUp;
this.TitleBarTextControl = captionBar;
//after assign a control to TitleBarTextControl, the client area in this form will be changed,
//need force to add a top padding.
this.Padding = new Padding(0, this.Style.TitleBar.Height + 1, 0, 0);
}
private void Bar_CaptionMouseUp(object sender, int index, EventArgs e)
{
switch (index)
{
case 1:
TabContainer.AddPage(index, new ModuleA.MainForm());
TabContainer.SelectPage(index);
break;
case 2:
TabContainer.AddPage(index, new ModuleB.MainForm());
TabContainer.SelectPage(index);
break;
case 3:
TabContainer.AddPage(index, new ModuleC.MainForm());
break;
default:
break;
}
TabContainer.SelectPage(index);
}
private void Shell_Load(object sender, EventArgs e)
{
(this.TitleBarTextControl as CaptionBar).SelectFirst();
this.toolStripStatusLabelUserInfo.Text
= $"{IdentityContext.Current.UserName}[{IdentityContext.Current.UserType}]";
Hub.Default.Subscribe<string>(this, message =>
{
//if (this.toolStripStatusLabelMsg.)
//{
// //Action<bool> actionDelegate = (x) => { this.btnSyncData.Enabled = x; };
// //this.btnSyncData.Invoke(actionDelegate, !notify.DisableRemoteOpt);
//}
//else
//{
// //this.btnSyncData.Enabled = !notify.DisableRemoteOpt;
//}
this.toolStripStatusLabelMsg.Text = message;
timerClearMessage.Enabled = true;
});
}
private void timerClearMessage_Tick(object sender, EventArgs e)
{
this.toolStripStatusLabelMsg.Text = string.Empty;
timerClearMessage.Enabled = false;
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/lilizai/WinFormSample.NET4.git
git@gitee.com:lilizai/WinFormSample.NET4.git
lilizai
WinFormSample.NET4
基于导航菜单的 WinForm 项目的基础框架
master

搜索帮助