コード例 #1
0
        private void axCommandBars_Customization( object sender, Demo_G.O.S.E.GUI.CommandBars.ActiveX._DCommandBarsEvents_CustomizationEvent eventArgs )
		{
			eventArgs.options.ShowRibbonQuickAccessPage = true;

			Demo_G.O.S.E.GUI.CommandBars.CommandBarControls cmbControls = null;
			cmbControls = CommandBars.DesignerControls;
			Demo_G.O.S.E.GUI.CommandBars.CommandBarControl cmbControl = null;

			if (cmbControls.Count == 0)
			{
				string tempCaption1 = "&新建";
				bool tempBeginGroup2 = false;
				string tempDescriptionText3 = "Create a new document";
				string tempCategory4 = "文件";
				cmbControl = cmbControls.Add(Demo_G.O.S.E.GUI.CommandBars.XTPControlType.xtpControlButton, ResourceId.ID_FILE_NEW, tempCaption1, tempBeginGroup2, tempDescriptionText3);
				cmbControl.Style = Demo_G.O.S.E.GUI.CommandBars.XTPButtonStyle.xtpButtonAutomatic;
				cmbControl.Category = tempCategory4;

				string tempCaption5 = "&打开";
				bool tempBeginGroup6 = false;
				string tempDescriptionText7 = "Open an existing document";
				cmbControl = cmbControls.Add(Demo_G.O.S.E.GUI.CommandBars.XTPControlType.xtpControlButton,  ResourceId.ID_FILE_OPEN,  tempCaption5,  tempBeginGroup6,  tempDescriptionText7);
				cmbControl.Style = Demo_G.O.S.E.GUI.CommandBars.XTPButtonStyle.xtpButtonAutomatic;
				cmbControl.Category = tempCategory4;

				string tempCaption9 = "&保存";
				bool tempBeginGroup10 = false;
				string tempDescriptionText11 = "Save the active document";
				cmbControl = cmbControls.Add(Demo_G.O.S.E.GUI.CommandBars.XTPControlType.xtpControlButton,  ResourceId.ID_FILE_SAVE,  tempCaption9,  tempBeginGroup10,  tempDescriptionText11);
				cmbControl.Style = Demo_G.O.S.E.GUI.CommandBars.XTPButtonStyle.xtpButtonAutomatic;
				cmbControl.Category = tempCategory4;

				string tempCaption13 = "&Print";
				bool tempBeginGroup14 = false;
				string tempDescriptionText15 = "Print the active document";
				cmbControl = cmbControls.Add(Demo_G.O.S.E.GUI.CommandBars.XTPControlType.xtpControlButton,  ResourceId.ID_FILE_PRINT,  tempCaption13,  tempBeginGroup14,  tempDescriptionText15);
				cmbControl.Style = Demo_G.O.S.E.GUI.CommandBars.XTPButtonStyle.xtpButtonAutomatic;
				cmbControl.Category = tempCategory4;

				string tempCaption17 = "Print Set&up";
				bool tempBeginGroup18 = false;
				string tempDescriptionText19 = "Print Setup";
				cmbControl = cmbControls.Add(Demo_G.O.S.E.GUI.CommandBars.XTPControlType.xtpControlButton,  ResourceId.ID_FILE_PRINT_SETUP,  tempCaption17,  tempBeginGroup18,  tempDescriptionText19);
				cmbControl.Style = Demo_G.O.S.E.GUI.CommandBars.XTPButtonStyle.xtpButtonAutomatic;
				cmbControl.Category = tempCategory4;

				string tempCategory24 = "Edit";
				string tempCaption29 = "&Paste";
				bool tempBeginGroup30 = false;
				string tempDescriptionText31 = "Insert Clipboard contents";
				cmbControl = cmbControls.Add(Demo_G.O.S.E.GUI.CommandBars.XTPControlType.xtpControlButton,  ResourceId.ID_EDIT_PASTE,  tempCaption29,  tempBeginGroup30,  tempDescriptionText31);
				cmbControl.Style = Demo_G.O.S.E.GUI.CommandBars.XTPButtonStyle.xtpButtonAutomatic;
				cmbControl.Category = tempCategory24;

				string tempCaption57 = "About";
				bool tempBeginGroup58 = false;
				string tempDescriptionText59 = "";
				string tempCategory60 = "Help";
				cmbControl = cmbControls.Add(Demo_G.O.S.E.GUI.CommandBars.XTPControlType.xtpControlButton,  ResourceId.ID_APP_ABOUT,  tempCaption57,  tempBeginGroup58,  tempDescriptionText59);
				cmbControl.Style = Demo_G.O.S.E.GUI.CommandBars.XTPButtonStyle.xtpButtonAutomatic;
				cmbControl.Category = tempCategory60;
			}
		}
コード例 #2
0
        private void axCommandBars_Execute( object sender, Demo_G.O.S.E.GUI.CommandBars.ActiveX._DCommandBarsEvents_ExecuteEvent eventArgs )
		{
			switch (eventArgs.control.Id)
			{	
				case (int)Demo_G.O.S.E.GUI.CommandBars.XTPCommandBarsSpecialCommands.XTP_ID_RIBBONCUSTOMIZE:
					CommandBars.ShowCustomizeDialog(3);
					break;
				case ResourceId.ID_APP_ABOUT:
					MessageBox.Show("Version " + System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileMajorPart + "." + System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileMinorPart);
					break;
				case ResourceId.ID_FILE_NEW:
                    //LoadNewDoc("");
					break;
				case ResourceId.ID_APP_EXIT:
					this.Close();
					break;
				case (int)Demo_G.O.S.E.GUI.CommandBars.XTPCommandBarsSpecialCommands.XTP_ID_RIBBONCONTROLTAB:
					System.Diagnostics.Debug.WriteLine("Selected Tab has Changed");
					break;
				case ResourceId.ID_FILE_PRINT_PREVIEW:
                    //LoadPrintPreview();
					break;
				case ResourceId.ID_VIEW_STATUS_BAR:
					CommandBars.StatusBar.Visible = !CommandBars.StatusBar.Visible;
					CommandBars.RecalcLayout();
					break;
				case ResourceId.ID_VIEW_WORKSPACE:
					eventArgs.control.Checked = !eventArgs.control.Checked;
					CommandBars.ShowTabWorkspace(eventArgs.control.Checked);
					break;
				case ResourceId.ID_WINDOW_ARRANGE:
					this.LayoutMdi(MdiLayout.ArrangeIcons);
					break;
				case ResourceId.ID_WINDOW_NEW:
                    //LoadNewDoc("");
					break;
				case ResourceId.ID_PREVIEW_PREVIEW_CLOSE:
					RibbonBar().FindTab(ResourceId.ID_TAB_PRINT_PREVIEW).Visible = false;
					RibbonBar().FindTab(ResourceId.ID_TAB_HOME).Visible = true;
					RibbonBar().FindTab(ResourceId.ID_TAB_EDIT).Visible = true;
					RibbonBar().FindTab(ResourceId.ID_TAB_VIEW).Visible = true;
					this.ActiveMdiChild.Close();
					this.ActiveMdiChild.WindowState = FormWindowState.Normal;
					if (RibbonBar().FindControl(Demo_G.O.S.E.GUI.CommandBars.XTPControlType.xtpControlCheckBox, ResourceId.ID_VIEW_WORKSPACE, false,true).Checked) 
					{
						CommandBars.ShowTabWorkspace(true);
					}					
					RibbonBar().FindTab(ResourceId.ID_TAB_HOME).Selected = true;
					break;
				case ResourceId.ID_PREVIEW_PRINT_PRINT:
				case ResourceId.ID_FILE_PRINT:
					// create and show...
					PrintDialog printDialog1 = new PrintDialog();
					printDialog1.AllowSomePages = true;

					// Show the help button.
					printDialog1.ShowHelp = true;
			
					System.Drawing.Printing.PrintDocument docToPrint = 
						new System.Drawing.Printing.PrintDocument();
					
					printDialog1.Document = docToPrint;

                    if (printDialog1.ShowDialog(CommandBars) == DialogResult.OK)
					{
						
					} 

					break;
				case ResourceId.ID_FILE_CLOSE:
					this.ActiveMdiChild.Close();
					break;
				case ResourceId.ID_FILE_SAVE:
				case ResourceId.ID_FILE_SAVE_AS:
					SaveFileDialog SaveDialog = new SaveFileDialog();
					SaveDialog.ShowDialog(CommandBars);
					break;
				case ResourceId.ID_FILE_OPEN:
					OpenFileDialog openFileDialog1 = new OpenFileDialog();

					openFileDialog1.InitialDirectory = "c:\\" ;
					openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ;
					openFileDialog1.FilterIndex = 2 ;
					openFileDialog1.RestoreDirectory = true ;

                    if (openFileDialog1.ShowDialog(CommandBars) == DialogResult.OK)
					{
						if(openFileDialog1.FileName.Length != 0)
						{
                            //LoadNewDoc(openFileDialog1.FileName);
						}
					}
					break;
				case ResourceId.ID_EDIT_SELECT_ALL:
				case ResourceId.ID_EDIT_SELECT:
					System.Windows.Forms.RichTextBox rtfText = (System.Windows.Forms.RichTextBox)this.ActiveMdiChild.Controls[0];
					rtfText.SelectAll();
					break;
				case ResourceId.ID_EDIT_UNDO:
					rtfText = (System.Windows.Forms.RichTextBox)this.ActiveMdiChild.Controls[0];
					rtfText.Undo();
					break;
				case ResourceId.ID_EDIT_CUT:
					rtfText = (System.Windows.Forms.RichTextBox)this.ActiveMdiChild.Controls[0];
					rtfText.Cut();
					break;
				case ResourceId.ID_EDIT_COPY:
					rtfText = (System.Windows.Forms.RichTextBox)this.ActiveMdiChild.Controls[0];
					rtfText.Copy();
					break;
				case ResourceId.ID_EDIT_PASTE:
					rtfText = (System.Windows.Forms.RichTextBox)this.ActiveMdiChild.Controls[0];
					rtfText.Paste();
					break;
				default:
					MessageBox.Show(eventArgs.control.Caption + " clicked", "Button Clicked");
					break;	
			};
		}
コード例 #3
0
        private void axCommandBars_UpdateEvent( object sender, Demo_G.O.S.E.GUI.CommandBars.ActiveX._DCommandBarsEvents_UpdateEvent eventArgs )
		{
			switch (eventArgs.control.Id)
			{	
				case ResourceId.ID_VIEW_STATUS_BAR:
					eventArgs.control.Checked = CommandBars.StatusBar.Visible;
					break;
				case ResourceId.ID_FILE_PRINT_PREVIEW:
				case ResourceId.ID_FILE_PRINT:
				case ResourceId.ID_FILE_CLOSE:
				case ResourceId.ID_FILE_SAVE:
				case ResourceId.ID_WINDOW_ARRANGE:
				case ResourceId.ID_WINDOW_NEW:
				case ResourceId.ID_WINDOW_SWITCH:
					eventArgs.control.Enabled = (this.MdiChildren.Length != 0 ? true : false);
					break;
				case (int)Demo_G.O.S.E.GUI.CommandBars.XTPCommandBarsSpecialCommands.XTP_ID_RIBBONCONTROLTAB:
					if (RibbonBar().FindTab(ResourceId.ID_TAB_PRINT_PREVIEW).Visible == true) 
					{
						RibbonBar().FindTab(ResourceId.ID_TAB_EDIT).Visible = false;
					}
					else if (this.MdiChildren.Length != 0) 
					{
						RibbonBar().FindTab(ResourceId.ID_TAB_EDIT).Visible = (this.MdiChildren.Length != 0 ? true : false);
					}
					break;
				case ResourceId.ID_EDIT_REPLACE:
				case ResourceId.ID_EDIT_FIND:
				case ResourceId.ID_EDIT_SELECT_ALL:
					if (this.MdiChildren.Length == 0) 
					{
						eventArgs.control.Enabled = false;
					}
					else
					{
						System.Windows.Forms.RichTextBox rtfText = (System.Windows.Forms.RichTextBox)this.ActiveMdiChild.Controls[0];
						eventArgs.control.Enabled = rtfText.CanSelect;
					}
					break;
				case ResourceId.ID_EDIT_CUT:
				case ResourceId.ID_EDIT_COPY:
					if (this.MdiChildren.Length == 0) 
					{
						eventArgs.control.Enabled = false;
					}
					else
					{
						System.Windows.Forms.RichTextBox rtfText = (System.Windows.Forms.RichTextBox)this.ActiveMdiChild.Controls[0];
						eventArgs.control.Enabled = (rtfText.SelectionLength == 0 ? false : true);
					}
					break;
				case ResourceId.ID_EDIT_UNDO:
					if (this.MdiChildren.Length == 0) 
					{
						eventArgs.control.Enabled = false;
					}
					else
					{
						System.Windows.Forms.RichTextBox rtfText = (System.Windows.Forms.RichTextBox)this.ActiveMdiChild.Controls[0];
						eventArgs.control.Enabled = rtfText.CanUndo;
					}
					break;
				case ResourceId.ID_EDIT_PASTE:
				case ResourceId.ID_EDIT_PASTE_SPECIAL:
					if (this.MdiChildren.Length == 0) 
					{
						eventArgs.control.Enabled = false;
					}
					else
					{
						System.Windows.Forms.RichTextBox rtfText = (System.Windows.Forms.RichTextBox)this.ActiveMdiChild.Controls[0];
						System.Windows.Forms.DataFormats.Format myFormat = System.Windows.Forms.DataFormats.GetFormat(DataFormats.Text);
						eventArgs.control.Enabled = rtfText.CanPaste(myFormat);
					}
					break;
			};
			
		}