⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainform.cs

📁 一个通用的数据库访问层
💻 CS
📖 第 1 页 / 共 3 页
字号:
			this.filterMenuItem.Click += new System.EventHandler(this.filterMenuItem_Click);
			// 
			// clearFilterMenuItem
			// 
			this.clearFilterMenuItem.Index = 7;
			this.clearFilterMenuItem.Text = "&Clear Filter              /";
			this.clearFilterMenuItem.Click += new System.EventHandler(this.clearFilterMenuItem_Click);
			// 
			// menuSeparator4
			// 
			this.menuSeparator4.Index = 8;
			this.menuSeparator4.Text = "-";
			// 
			// hideLeftPanelMenuItem
			// 
			this.hideLeftPanelMenuItem.Index = 9;
			this.hideLeftPanelMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlF1;
			this.hideLeftPanelMenuItem.ShowShortcut = false;
			this.hideLeftPanelMenuItem.Text = "&Left panel on/off    Ctrl+F1";
			this.hideLeftPanelMenuItem.Click += new System.EventHandler(this.hideLeftPanelMenuItem_Click);
			// 
			// hideRightPanelMenuItem
			// 
			this.hideRightPanelMenuItem.Index = 10;
			this.hideRightPanelMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlF2;
			this.hideRightPanelMenuItem.ShowShortcut = false;
			this.hideRightPanelMenuItem.Text = "R&ight panel on/off  Ctrl+F2";
			this.hideRightPanelMenuItem.Click += new System.EventHandler(this.hideRightPanelMenuItem_Click);
			// 
			// menuSeparator5
			// 
			this.menuSeparator5.Index = 11;
			this.menuSeparator5.Text = "-";
			// 
			// refreshMenuItem
			// 
			this.refreshMenuItem.Index = 12;
			this.refreshMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlR;
			this.refreshMenuItem.ShowShortcut = false;
			this.refreshMenuItem.Text = "&Refresh                  Ctrl+R";
			this.refreshMenuItem.Click += new System.EventHandler(this.refreshMenuItem_Click);
			// 
			// helpMenuItem
			// 
			this.helpMenuItem.Index = 2;
			this.helpMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																						 this.aboutMenuItem});
			this.helpMenuItem.Text = "&Help";
			// 
			// aboutMenuItem
			// 
			this.aboutMenuItem.Index = 0;
			this.aboutMenuItem.Text = "&About";
			this.aboutMenuItem.Click += new System.EventHandler(this.aboutMenuItem_Click);
			// 
			// leftDataPanel
			// 
			this.leftDataPanel.Dock = System.Windows.Forms.DockStyle.Left;
			this.leftDataPanel.Location = new System.Drawing.Point(0, 25);
			this.leftDataPanel.Name = "leftDataPanel";
			this.leftDataPanel.Size = new System.Drawing.Size(396, 516);
			this.leftDataPanel.TabIndex = 1;
			// 
			// splitter
			// 
			this.splitter.Location = new System.Drawing.Point(396, 25);
			this.splitter.Name = "splitter";
			this.splitter.Size = new System.Drawing.Size(3, 516);
			this.splitter.TabIndex = 11;
			this.splitter.TabStop = false;
			// 
			// rightDataPanel
			// 
			this.rightDataPanel.Dock = System.Windows.Forms.DockStyle.Fill;
			this.rightDataPanel.Location = new System.Drawing.Point(399, 25);
			this.rightDataPanel.Name = "rightDataPanel";
			this.rightDataPanel.Size = new System.Drawing.Size(393, 516);
			this.rightDataPanel.TabIndex = 2;
			// 
			// operationBar
			// 
			this.operationBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																							this.botConnectionButton,
																							this.botViewButton,
																							this.botEditButton,
																							this.botCopyButton,
																							this.botMoveButton,
																							this.botCreateButton,
																							this.botDeleteButton,
																							this.botDownButton,
																							this.botUpButton});
			this.operationBar.ButtonSize = new System.Drawing.Size(100, 22);
			this.operationBar.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.operationBar.DropDownArrows = true;
			this.operationBar.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.operationBar.Location = new System.Drawing.Point(0, 541);
			this.operationBar.Name = "operationBar";
			this.operationBar.ShowToolTips = true;
			this.operationBar.Size = new System.Drawing.Size(792, 25);
			this.operationBar.TabIndex = 3;
			this.operationBar.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right;
			this.operationBar.Wrappable = false;
			this.operationBar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.operationBar_ButtonClick);
			// 
			// botConnectionButton
			// 
			this.botConnectionButton.Text = "F2 Connect";
			// 
			// botViewButton
			// 
			this.botViewButton.Enabled = false;
			this.botViewButton.Text = "F3 View";
			// 
			// botEditButton
			// 
			this.botEditButton.Enabled = false;
			this.botEditButton.Text = "F4 Edit";
			// 
			// botCopyButton
			// 
			this.botCopyButton.Text = "F5 Copy";
			// 
			// botMoveButton
			// 
			this.botMoveButton.Text = "F6 Move";
			// 
			// botCreateButton
			// 
			this.botCreateButton.Enabled = false;
			this.botCreateButton.Text = "F7 Create";
			// 
			// botDeleteButton
			// 
			this.botDeleteButton.Text = "F8 Delete";
			// 
			// botDownButton
			// 
			this.botDownButton.Text = "F9 Down";
			// 
			// botUpButton
			// 
			this.botUpButton.Text = "F10 Up";
			// 
			// menuItem7
			// 
			this.menuItem7.Index = -1;
			this.menuItem7.Text = "";
			// 
			// toolBar
			// 
			this.toolBar.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
			this.toolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																					   this.toolSep0,
																					   this.toolNewButton,
																					   this.toolOpenButton,
																					   this.toolSaveButton,
																					   this.toolSep1,
																					   this.toolConnectionButton,
																					   this.toolDownButton,
																					   this.toolUpButton,
																					   this.toolRefreshButton,
																					   this.toolSep2,
																					   this.toolOptionsButton});
			this.toolBar.ButtonSize = new System.Drawing.Size(24, 23);
			this.toolBar.DropDownArrows = true;
			this.toolBar.ImageList = this.imageList;
			this.toolBar.Name = "toolBar";
			this.toolBar.ShowToolTips = true;
			this.toolBar.Size = new System.Drawing.Size(792, 25);
			this.toolBar.TabIndex = 12;
			this.toolBar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar_ButtonClick);
			// 
			// toolSep0
			// 
			this.toolSep0.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			// 
			// toolNewButton
			// 
			this.toolNewButton.ImageIndex = 0;
			this.toolNewButton.ToolTipText = "New";
			// 
			// toolOpenButton
			// 
			this.toolOpenButton.ImageIndex = 1;
			this.toolOpenButton.ToolTipText = "Open";
			// 
			// toolSaveButton
			// 
			this.toolSaveButton.ImageIndex = 2;
			this.toolSaveButton.ToolTipText = "Save";
			// 
			// toolSep1
			// 
			this.toolSep1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			// 
			// toolConnectionButton
			// 
			this.toolConnectionButton.ImageIndex = 7;
			this.toolConnectionButton.ToolTipText = "Connection";
			// 
			// toolDownButton
			// 
			this.toolDownButton.ImageIndex = 5;
			this.toolDownButton.ToolTipText = "Down";
			// 
			// toolUpButton
			// 
			this.toolUpButton.ImageIndex = 4;
			this.toolUpButton.ToolTipText = "Up";
			// 
			// toolRefreshButton
			// 
			this.toolRefreshButton.ImageIndex = 8;
			this.toolRefreshButton.ToolTipText = "Refresh";
			// 
			// toolSep2
			// 
			this.toolSep2.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			// 
			// toolOptionsButton
			// 
			this.toolOptionsButton.ImageIndex = 3;
			this.toolOptionsButton.ToolTipText = "Options";
			// 
			// imageList
			// 
			this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
			this.imageList.ImageSize = new System.Drawing.Size(16, 16);
			this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream")));
			this.imageList.TransparentColor = System.Drawing.Color.Red;
			// 
			// MainForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(792, 566);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.rightDataPanel,
																		  this.splitter,
																		  this.leftDataPanel,
																		  this.operationBar,
																		  this.toolBar});
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.KeyPreview = true;
			this.Menu = this.mainMenu;
			this.Name = "MainForm";
			this.Text = "Database Commander";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.Closing += new System.ComponentModel.CancelEventHandler(this.MainForm_Closing);
			this.Load += new System.EventHandler(this.MainForm_Load);
			this.ResumeLayout(false);

		}
		#endregion

		#region MainForm events 
		protected override bool ProcessCmdKey( ref Message msg, Keys keyData ) 
		{ 
			if( msg.Msg == 0x100 || msg.Msg == 0x104 ){
				if( keyData == ( Keys.Control | Keys.Tab ) ){
					this.ChangeActivePanel();
					return true;
				}

				if( keyData == ( Keys.Alt | Keys.F1 ) ){
					if( this.focusPanel != this.leftDataPanel ){
						this.ChangeActivePanel();
					}
					this.leftDataPanel.OpenTableComboBox();
					return true;
				}

				if( keyData == ( Keys.Alt | Keys.F2 ) ){
					if( this.focusPanel != this.rightDataPanel ){
						this.ChangeActivePanel();
					}

					this.rightDataPanel.OpenTableComboBox();
					return true;
				}
			}
	 
			return base.ProcessCmdKey(ref msg, keyData); 
		} 

		protected override void WndProc(ref System.Windows.Forms.Message m) 
		{ 
			if ( (WinMessages)m.Msg == WinMessages.WM_AGENT_ACTION) { 
				Utils.AgentPlayer.MovieTypeEnum movieType = ( Utils.AgentPlayer.MovieTypeEnum )(int)m.LParam;
				this.agent.Play( movieType );
			} 
			base.WndProc(ref m); 
		}

		private void MainForm_Load(object sender, System.EventArgs e)
		{
			this.Refresh();
			this.leftDataPanel.Width = this.Width / 2;
			this.operationBar.ButtonSize = new Size ( ( this.Width - 6 ) / this.operationBar.Buttons.Count, this.operationBar.ButtonSize.Height );
			this.Refresh();

			this.options = YariSoft.DBCommander.Misc.OptionsInfo.LoadFromFile( Application.StartupPath + "\\" + optionsFileName );
			this.RefreshToolBars();
			
			this.config = YariSoft.DBCommander.Misc.ConfigInfo.LoadFromFile ( this.options.PreviousConfigFileName );

			this.rightDataPanel.OnNeedSetGridStyle      += new DataPanel.OnNeedSetGridStyleEventHandler		( this.OnNeedSetGridStyle );
			this.leftDataPanel.OnNeedSetGridStyle       += new DataPanel.OnNeedSetGridStyleEventHandler		( this.OnNeedSetGridStyle );

			this.InitConnections();
			this.ChangeActivePanel();		
			this.Refresh();

			this.leftDataPanel.OnChangeDetailLevel		+= new DataPanel.OnChangeDetailLevelEventHandler	( this.RefreshButtons );
			this.leftDataPanel.OnNeedSelectionMasks		+= new DataPanel.OnNeedSelectionMasksEventHandler	( this.OnNeedSelectionMasks );
			this.rightDataPanel.OnChangeDetailLevel  	+= new DataPanel.OnChangeDetailLevelEventHandler	( this.RefreshButtons );
			this.rightDataPanel.OnNeedSelectionMasks	+= new DataPanel.OnNeedSelectionMasksEventHandler	( this.OnNeedSelectionMasks );		
			this.rightDataPanel.OnColumnResize			+= new DataPanel.OnColumnResizeEventHandler			( this.OnColumnResize );
			this.leftDataPanel.OnColumnResize			+= new DataPanel.OnColumnResizeEventHandler			( this.OnColumnResize );

			this.SetIdentityState();
			this.agent.Init ( this.options.AgentOptions, true );
		}

		private void MainForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			if( ! this.CheckChanges() ){
				e.Cancel = true;
				return;
			}
			this.options.PreviousConfigFileName = this.config.FileName;
			this.options.SaveToFile();

			if( this.options.AgentOptions.AgentActive ){
				agent.Hide();
			}
		}

		private void OnPanelGridClick( object owner, object sender, System.EventArgs e)
		{
			if( owner != this.focusPanel ){
				this.ChangeActivePanel();
			}
		}

		private void SetFormCaption()
		{
			this.Text =  applicationName + " - " + this.config.FileName;
		}

		private void InitConnections()
		{
			this.SetFormCaption();
			this.Refresh();
			this.leftDataPanel.Init	( this.config.LeftConnection );
			this.rightDataPanel.Init( this.config.RightConnection );
		}
		#endregion

		#region Toolbars operations
		private void RefreshToolBars()
		{
			if( this.options != null ){
				this.operationBar.Visible	= this.options.ShowFuncBar;
				this.toolBar.Visible		= this.options.ShowToolBar;
			}
		}

		private void toolBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			if( e.Button == this.toolConnectionButton ){
				this.connectionMenuItem_Click( sender, null );
			} else if( e.Button == this.toolUpButton  ){
				this.upMenuItem_Click( sender, null );
			} else if( e.Button == this.toolDownButton  ){
				this.downMenuItem_Click( sender, null );
			} else if( e.Button == this.toolOptionsButton ){
				this.optionsMenuItem_Click( sender, null );
			} else if( e.Button == this.toolNewButton ){
				this.newMenuItem_Click( sender, null );
			} else if( e.Button == this.toolOpenButton ){
				this.openMenuItem_Click( sender, null );
			} else if( e.Button == this.toolSaveButton ){
				this.saveMenuItem_Click( sender, null );
			} else if( e.Button == this.toolRefreshButton ){
				this.refreshMenuItem_Click( sender, null );
			}
		}

		private void operationBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			if( e.Button == this.botConnectionButton ){
				this.connectionMenuItem_Click( sender, null );
			} else if( e.Button == this.botCopyButton ){
				this.copyMenuItem_Click( sender, null );
			} else if ( e.Button == this.botDeleteButton ){
				this.deleteMenuItem_Click( sender, null );
			} else if ( e.Button == this.botMoveButton ){
				this.moveMenuItem_Click( sender, null );
			} else if ( e.Button == this.botDownButton ){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -