private void SetProgressBar() { try { if (this.InvokeRequired) { SetProgressBarCallback d = new SetProgressBarCallback(SetProgressBar); Invoke(d); } else { label1.AutoSize = true; label1.BackColor = System.Drawing.SystemColors.ActiveCaption; label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); label1.ForeColor = System.Drawing.Color.Red; label1.Location = new System.Drawing.Point(50, 45); label1.Name = "label1"; label1.Size = new System.Drawing.Size(231, 14); label1.Text = "正在压缩修复数据库,请稍后。。。"; label1.Visible = true; AccessBase ab = new AccessBase(); string[] strFile = ab.Compact(); string[] strFile1 = ab.Compact1(); progressBar1.Visible = true; progressBar1.Minimum = 1; progressBar1.Maximum = strFile1.Length + strFile.Length + 1; progressBar1.Value = 1; progressBar1.Step = 1; for (int i = 0; i < strFile.Length; i++) { string strfilenameTemp = strFile[i].Replace(".mdb", ".ldb"); if (File.Exists(strfilenameTemp)) { File.Delete(strfilenameTemp); } try { ab.Compact(strFile[i]); } catch { } progressBar1.PerformStep(); Thread.Sleep(100); } for (int i = 0; i < strFile1.Length; i++) { string strfilenameTemp = strFile1[i].Replace(".mdb", ".ldb"); if (File.Exists(strfilenameTemp)) { File.Delete(strfilenameTemp); } try { ab.Compact(strFile1[i]); } catch { } progressBar1.PerformStep(); Thread.Sleep(100); } if (ab != null) { ab = null; } this.Hide(); FrmMain f = new FrmMain(); f.Show(); f = null; } } catch { } }
/// <summary> /// 构造函数 /// </summary> /// <param name="frm"></param> /// <param name="ctl"></param> public MenuHelper(FrmMain frm, Control ctl) { frmMain = frm; BuildMainMenu(ctl); }
/// <summary> /// 加载主窗体菜单 /// </summary> /// <param name="frmMain"></param> /// <returns></returns> public static bool LoadMenuPanel(FrmMain frmMain) { // 加载主菜单 MenuStrip menuStrip = new MenuStrip(); menuHelper_Main = new MenuHelper(frmMain, menuStrip); frmMain.Controls.Add(menuStrip); // 返回 return true; }
/// <summary> /// 加载主窗体菜单 /// </summary> /// <param name="frmMain"></param> /// <param name="notifyIcon"></param> /// <returns></returns> public static bool LoadNotifyMenu(FrmMain frmMain, NotifyIcon notifyIcon) { // 加载任务栏菜单 ContextMenuStrip menuNotify = new ContextMenuStrip(); menuHelper_Notify = new MenuHelper(frmMain, menuNotify); notifyIcon.ContextMenuStrip = menuNotify; // 菜单 notifyIcon.Text = frmMain.Text; // 标题 notifyIcon.Visible = true; // 显示 // 事件: 双击 隐藏/显示窗体 notifyIcon.DoubleClick += delegate { if (frmMain.WindowState != FormWindowState.Minimized) { frmMain.WindowState = FormWindowState.Minimized; frmMain.Visible = false; } else { frmMain.WindowState = FormWindowState.Maximized; frmMain.Visible = true; frmMain.Activate(); } }; return true; }
/// <summary> /// 加载界面布局 /// </summary> /// <returns></returns> public static bool LoadFaceLayout(FrmMain frmMain, KJRichTextBox rtxtSysMsg) { _RtxtSysMsg = rtxtSysMsg; // 加载数据面板 Panel pnl = new Panel(); pnl.Dock = DockStyle.Fill; //pnl.BackColor = System.Drawing.Color.YellowGreen; frmMain.Controls.Add(pnl); #region [ 数据面板: 加载系统消息面板 ] // 加载数据面板中的内容 tcMsg.Dock = DockStyle.Fill; rtxtSysMsg.Visible = false; pnl.Controls.Add(rtxtSysMsg); // 系统消息面板 //TabPage tpSysMsg = new TabPage("系统消息"); //rtxtSysMsg.Dock = DockStyle.Fill; //tpSysMsg.Controls.Add(rtxtSysMsg); //tcMsg.Controls.Add(tpSysMsg); pnl.Controls.Add(tcMsg); #endregion // 加载传输分站面板 gbBox.Text = "被巡检的传输分站信息"; gbBox.Dock = DockStyle.Left; gbBox.Width = 175; frmMain.Controls.Add(gbBox); return true; }