/// <summary> /// 格式化选择的控件 /// </summary> /// <param name="pCurrentCtl"></param> /// <param name="pType"></param> public override void ExecCommand(CommandID cmdID) { DIYReport.ReportModel.RptSingleObj rptObj = DesignEnviroment.CurrentRptObj as DIYReport.ReportModel.RptSingleObj; if (rptObj == null) { return; } if (cmdID.Equals(FormattingCommands.BackColor)) { System.Windows.Forms.ColorDialog backColor = new ColorDialog(); backColor.Color = rptObj.BackgroundColor; if (backColor.ShowDialog() == System.Windows.Forms.DialogResult.OK) { rptObj.BackgroundColor = backColor.Color; } } else if (cmdID.Equals(FormattingCommands.ForeColor)) { System.Windows.Forms.ColorDialog foreColor = new ColorDialog(); foreColor.Color = rptObj.ForeColor; if (foreColor.ShowDialog() == System.Windows.Forms.DialogResult.OK) { rptObj.ForeColor = foreColor.Color; } } else { //Debug.Assert(false,"该cmdID" + cmdID.ID.ToString() +"目前还没有处理。"); } }
// THIS should not stay here, creation of a custom command or of the real thing should be handled in the designeractionpanel itself public override MenuCommand FindCommand(CommandID commandId) { if (_panel != null && _menuService != null) { // if the command we're looking for is handled by the panel, just tell VS that this command is disabled. otherwise let it through as usual... foreach (CommandID candidateCommandId in _panel.FilteredCommandIDs) { // VisualStudio shell implements a mutable derived class from the base CommandID. The mutable class compares overridden properties instead of the read-only backing fields when testing equality of command IDs. Thus Equals method is asymmetrical derived class's override that compares properties is the accurate one. if (commandId.Equals(candidateCommandId)) { MenuCommand dummyMC = new MenuCommand(delegate { }, commandId) { Enabled = false }; return(dummyMC); } } // in case of a ctrl-tab we need to close the DAP if (_daUISvc != null && commandId.Guid == s_vSStandardCommandSet97 && commandId.ID == 1124) { _daUISvc.HideUI(null); } } return(base.FindCommand(commandId)); // this will route the request to the parent behavior }
public bool IsOperationSupported( Guid source, CommandID command, object context) { if (command == null) { throw new ArgumentNullException("command"); } if (command.Equals(DeployCommand)) { IVsDataExplorerConnection explorerConnection = context as IVsDataExplorerConnection; if (explorerConnection == null) { throw new ArgumentException(); } RegistryKey key = Registry.LocalMachine.OpenSubKey( @"SOFTWARE\Company\DeployTechnology"); if (key == null) { return(false); } key.Close(); } return(true); }
public void Equals_Object_ReturnsExpected(CommandID commandId, object other, bool expected) { Assert.Equal(expected, commandId.Equals(other)); if (other is CommandID) { Assert.Equal(expected, commandId.GetHashCode().Equals(other.GetHashCode())); } }
public bool HandlesCommand(CommandID commandId) { bool result = _commandId.Equals(commandId); if (result && _handlesCommand != null) { result = _handlesCommand(); } return(result); }
public string GetUnsupportedReason( Guid source, CommandID command, object context) { if (command == null) { throw new ArgumentNullException("command"); } if (command.Equals(DeployCommand) && !IsOperationSupported(source, command, context)) { // Note: This string should be localized return("In order to deploy a database you need to install our deployment technology."); } return(null); }
//格式化选择的控件 private void FormatCtl(Rectangle pRect, CommandID cmdID) { DesignControlList ctlList = DesignerHost.SectionList.GetActiveSection().DesignControls; foreach (DesignControl ctl in ctlList) { if (!ctl.IsSelected) { continue; } DIYReport.Interface.IRptSingleObj dataObj = ctl.DataObj; if (cmdID.Equals(StandardCommands.AlignLeft)) { dataObj.Location = new Point(pRect.Left, ctl.Top); } else if (cmdID.Equals(StandardCommands.AlignTop)) { dataObj.Location = new Point(ctl.Left, pRect.Top); } else if (cmdID.Equals(StandardCommands.AlignRight)) { dataObj.Location = new Point(pRect.Right - ctl.Width, ctl.Top); } else if (cmdID.Equals(StandardCommands.AlignBottom)) { dataObj.Location = new Point(ctl.Left, pRect.Top + pRect.Height - ctl.Height); //ctl.Top = pRect.Top + pRect.Height - ctl.Height ; } else if (cmdID.Equals(StandardCommands.SizeToControlWidth)) { dataObj.Size = new Size(pRect.Width, ctl.Height); //ctl.Width = pRect.Width ; } else if (cmdID.Equals(StandardCommands.SizeToControlHeight)) { dataObj.Size = new Size(ctl.Width, pRect.Height); //ctl.Height = pRect.Height ; } else { Debug.Assert(false, "Command" + cmdID.ID.ToString() + "没有处理。"); return; } } DesignerHost.SectionList.GetActiveSection().DesignControls.ShowFocusHandle(true); }
public bool HandlesCommand(CommandID commandId) { return(_commandId.Equals(commandId) && _handlesCommand()); }
/// <include file='doc\MenuCommandService.uex' path='docs/doc[@for="MenuCommandService.FindCommand1"]/*' /> /// <devdoc> /// Locates the requested command. This will throw an appropriate /// ComFailException if the command couldn't be found. /// </devdoc> private MenuCommand FindCommand(Guid guid, int id, ref int hrReturn) { // The hresult we will return. We start with unknown group, and // then if we find a group match, we will switch this to // OLECMDERR_E_NOTSUPPORTED. // hrReturn = NativeMethods.OLECMDERR_E_UNKNOWNGROUP; Debug.WriteLineIf(Switches.MENUSERVICE.TraceVerbose, "Searching for command: " + guid.ToString() + " : " + id.ToString()); for (int i = 0; i < commandCount; i++) { CommandID cid = commands[i].CommandID; if (cid.ID == id) { Debug.WriteLineIf(Switches.MENUSERVICE.TraceVerbose, "\t...Found command"); if (cid.Guid.Equals(guid)) { Debug.WriteLineIf(Switches.MENUSERVICE.TraceVerbose, "\t...Found group"); hrReturn = NativeMethods.S_OK; return(commands[i]); } } } // Next, search the verb list as well. // EnsureVerbs(); if (verbs != null) { int currentID = StandardCommands.VerbFirst.ID; foreach (DesignerVerb verb in verbs) { CommandID cid = verb.CommandID; if (cid.ID == id) { Debug.WriteLineIf(Switches.MENUSERVICE.TraceVerbose, "\t...Found verb"); if (cid.Guid.Equals(guid)) { Debug.WriteLineIf(Switches.MENUSERVICE.TraceVerbose, "\t...Found group"); hrReturn = NativeMethods.S_OK; return(verb); } } // We assign virtual sequential IDs to verbs we get from the component. This allows users // to not worry about assigning these IDs themselves. // if (currentID == id) { Debug.WriteLineIf(Switches.MENUSERVICE.TraceVerbose, "\t...Found verb"); if (cid.Guid.Equals(guid)) { Debug.WriteLineIf(Switches.MENUSERVICE.TraceVerbose, "\t...Found group"); hrReturn = NativeMethods.S_OK; return(verb); } } if (cid.Equals(StandardCommands.VerbFirst)) { currentID++; } } } return(null); }
/// <include file='doc\ControlCommandSet.uex' path='docs/doc[@for="ControlCommandSet.OnKeySize"]/*' /> /// <devdoc> /// Called for the various sizing commands we support. /// </devdoc> protected void OnKeySize(object sender, EventArgs e) { // Arrow keys. Begin a drag if the selection isn't locked. // ISelectionService selSvc = SelectionService; ISelectionUIService uiSvc = SelectionUIService; if (uiSvc != null && selSvc != null) { //added to remove the selection rectangle: bug(54692) // uiSvc.Visible = false; object comp = selSvc.PrimarySelection; if (comp != null && comp is IComponent) { PropertyDescriptor lockedProp = TypeDescriptor.GetProperties(comp)["Locked"]; if (lockedProp == null || (lockedProp.PropertyType == typeof(bool) && ((bool)lockedProp.GetValue(comp))) == false) { SelectionRules rules = SelectionRules.Visible; CommandID cmd = ((MenuCommand)sender).CommandID; bool invertSnap = false; int moveOffsetX = 0; int moveOffsetY = 0; if (cmd.Equals(MenuCommands.KeySizeHeightDecrease)) { moveOffsetY = -1; rules |= SelectionRules.BottomSizeable; } else if (cmd.Equals(MenuCommands.KeySizeHeightIncrease)) { moveOffsetY = 1; rules |= SelectionRules.BottomSizeable; } else if (cmd.Equals(MenuCommands.KeySizeWidthDecrease)) { moveOffsetX = -1; rules |= SelectionRules.RightSizeable; } else if (cmd.Equals(MenuCommands.KeySizeWidthIncrease)) { moveOffsetX = 1; rules |= SelectionRules.RightSizeable; } else if (cmd.Equals(MenuCommands.KeyNudgeHeightDecrease)) { moveOffsetY = -1; invertSnap = true; rules |= SelectionRules.BottomSizeable; } else if (cmd.Equals(MenuCommands.KeyNudgeHeightIncrease)) { moveOffsetY = 1; invertSnap = true; rules |= SelectionRules.BottomSizeable; } else if (cmd.Equals(MenuCommands.KeyNudgeWidthDecrease)) { moveOffsetX = -1; invertSnap = true; rules |= SelectionRules.RightSizeable; } else if (cmd.Equals(MenuCommands.KeyNudgeWidthIncrease)) { moveOffsetX = 1; invertSnap = true; rules |= SelectionRules.RightSizeable; } else { Debug.Fail("Unknown command mapped to OnKeySize: " + cmd.ToString()); } if (uiSvc.BeginDrag(rules, 0, 0)) { bool snapOn = false; Size snapSize = Size.Empty; IComponent snapComponent = null; PropertyDescriptor snapProperty = null; // Gets the needed snap information // IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); DesignerTransaction trans = null; try { if (host != null) { GetSnapInformation(host, (IComponent)comp, out snapSize, out snapComponent, out snapProperty); if (selSvc.SelectionCount > 1) { trans = host.CreateTransaction(SR.GetString(SR.DragDropSizeComponents, selSvc.SelectionCount)); } else { trans = host.CreateTransaction(SR.GetString(SR.DragDropSizeComponent, ((IComponent)comp).Site.Name)); } if (snapProperty != null) { snapOn = (bool)snapProperty.GetValue(snapComponent); if (invertSnap) { snapOn = !snapOn; snapProperty.SetValue(snapComponent, snapOn); } } } if (snapOn && !snapSize.IsEmpty) { moveOffsetX *= snapSize.Width; moveOffsetY *= snapSize.Height; } // Now move the controls the correct # of pixels. // uiSvc.DragMoved(new Rectangle(0, 0, moveOffsetX, moveOffsetY)); uiSvc.EndDrag(false); if (host != null) { if (invertSnap && snapProperty != null) { snapOn = !snapOn; snapProperty.SetValue(snapComponent, snapOn); } } } finally { if (trans != null) { trans.Commit(); uiSvc.Visible = true; } } } } } uiSvc.Visible = true; } }
public override void ExecCommand(CommandID cmdID) { DesignSection designSe = this.DesignerHost.SectionList.GetActiveSection(); if (cmdID.Equals(RptDesignCommands.InsertTopMarginBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.TopMargin); } else if (cmdID.Equals(RptDesignCommands.InsertReportHeaderBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.ReportTitle); } else if (cmdID.Equals(RptDesignCommands.InsertPageHeaderBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.PageHead); } else if (cmdID.Equals(RptDesignCommands.InsertGroupHeaderBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.GroupHead); } else if (cmdID.Equals(RptDesignCommands.InsertDetailBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.Detail); } else if (cmdID.Equals(RptDesignCommands.InsertGroupFooterBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.GroupFooter); } else if (cmdID.Equals(RptDesignCommands.InsertPageFooterBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.PageFooter); } else if (cmdID.Equals(RptDesignCommands.InsertReportFooterBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.ReportBottom); } else if (cmdID.Equals(RptDesignCommands.InsertBottomMarginBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.BottomMargin); } else if (cmdID.Equals(StandardCommands.Delete)) { this.DesignerHost.DeleteSelectedControls(); } else if (cmdID.Equals(StandardCommands.Cut)) { this.DesignerHost.Cut(); } else if (cmdID.Equals(StandardCommands.Copy)) //Redo { this.DesignerHost.Copy(); } else if (cmdID.Equals(StandardCommands.Paste)) //Redo { this.DesignerHost.Past(); } else { Debug.Assert(false, "该命令" + cmdID.ToString() + "目前还没有进行处理。"); } }
/// <summary> /// 绘制控件选择控件类型相关。 /// </summary> /// <param name="cmdID"></param> public void ExecRptCtlType(CommandID cmdID) { DIYReport.ReportModel.RptObjType type = DIYReport.ReportModel.RptObjType.None; if (cmdID.Equals(RptDesignCommands.RptNone)) { type = DIYReport.ReportModel.RptObjType.None; } else if (cmdID.Equals(RptDesignCommands.RptLabel)) { type = DIYReport.ReportModel.RptObjType.Text; } else if (cmdID.Equals(RptDesignCommands.RptFieldText)) { type = DIYReport.ReportModel.RptObjType.FieldTextBox; } else if (cmdID.Equals(RptDesignCommands.RptFieldImage)) { type = DIYReport.ReportModel.RptObjType.FieldImage; } else if (cmdID.Equals(RptDesignCommands.RptPictureBox)) { type = DIYReport.ReportModel.RptObjType.Image; } else if (cmdID.Equals(RptDesignCommands.RptCheckBox)) { type = DIYReport.ReportModel.RptObjType.CheckBox; } else if (cmdID.Equals(RptDesignCommands.RptSubReport)) { type = DIYReport.ReportModel.RptObjType.SubReport; } else if (cmdID.Equals(RptDesignCommands.RptBarCode)) { type = DIYReport.ReportModel.RptObjType.BarCode; } else if (cmdID.Equals(RptDesignCommands.RptOleObject)) { type = DIYReport.ReportModel.RptObjType.OleObject; } else if (cmdID.Equals(RptDesignCommands.RptLine)) { type = DIYReport.ReportModel.RptObjType.Line; } else if (cmdID.Equals(RptDesignCommands.RptFrame)) { type = DIYReport.ReportModel.RptObjType.Rect; } else if (cmdID.Equals(RptDesignCommands.RptHViewSpecFieldBox)) { type = DIYReport.ReportModel.RptObjType.HViewSpecField; } else if (cmdID.Equals(RptDesignCommands.RptExpressBox)) { type = DIYReport.ReportModel.RptObjType.Express; } else if (cmdID.Equals(RptDesignCommands.RptRichTextBox)) { type = DIYReport.ReportModel.RptObjType.RichTextBox; } else { Debug.Assert(false, "Command" + cmdID.ID.ToString() + "没有处理。"); } DesignEnviroment.DrawControlType = type; DesignEnviroment.IsCreateControl = type != DIYReport.ReportModel.RptObjType.None; }
/// <summary> /// 执行命令 /// </summary> /// <param name="cmdID"></param> public override void ExecCommand(CommandID cmdID) { DesignSection designSe = this.DesignerHost.SectionList.GetActiveSection(); //this.DesignerHost.Cursor = Cursors.WaitCursor ; //switch(cmdID){ if (cmdID.Equals(StandardCommands.HorizSpaceConcatenate)) //向左边靠齐 { designSe.DesignControls.DockToLeft(); } else if (cmdID.Equals(StandardCommands.VertSpaceConcatenate)) { //向右边靠齐 designSe.DesignControls.DockToTop(); } else if (cmdID.Equals(UICommands.ControlHandle)) //显示方向控制盘 { FrmArrowOperate.ShowArrowForm(this.DesignerHost.SectionList, this.DesignerHost.ParentForm); } else if (cmdID.Equals(UICommands.SetObjProperty)) { //显示属性窗口 OnSetObjProperty(); } else if (cmdID.Equals(UICommands.ShowProperty)) { //显示属性窗口 //DesignEnviroment.ShowPropertyForm(this.DesignerHost.ParentForm,true); //Debug.Assert(false,"ShowProperty "); } else if (cmdID.Equals(StandardCommands.Delete)) { //删除控件 this.DesignerHost.DeleteSelectedControls(); } else if (cmdID.Equals(UICommands.Print)) //打印 { using (DIYReport.Print.SwPrintView print = new DIYReport.Print.SwPrintView(this.DesignerHost.DataObj.DataSource, this.DesignerHost.DataObj)){ print.Printer(); } } else if (cmdID.Equals(UICommands.Preview)) //打印预览 { using (DIYReport.Print.SwPrintView printView = new DIYReport.Print.SwPrintView(this.DesignerHost.DataObj.DataSource, this.DesignerHost.DataObj)){ printView.ShowPreview(); } } else if (cmdID.Equals(UICommands.PageSetup)) //打印页面设置 { DIYReport.Print.RptPageSetting.ShowPageSetupDialog(this.DesignerHost.DataObj); } else if (cmdID.Equals(UICommands.SaveFile)) //保存报表 { DIYReport.ReportXmlHelper.Save(this.DesignerHost.DataObj); //this.DesignerHost.ReportIO.SaveReport(,this.DesignerHost.DataObj.RptFilePath); DIYReport.UserDIY.DesignEnviroment.DesignHasChanged = false; } else if (cmdID.Equals(UICommands.OpenFile)) //打开报表 { DIYReport.ReportModel.RptReport report = DIYReport.ReportXmlHelper.Open(); if (report != null) { this.DesignerHost.OpenReport(report); } } else if (cmdID.Equals(UICommands.Output)) //导出 { bool b = DIYReport.ReportXmlHelper.Save(this.DesignerHost.DataObj); if (b) { MessageBox.Show("打印模板导出成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else if (cmdID.Equals(UICommands.Import)) //导入 { DialogResult re = MessageBox.Show("导入打印模板将会清空当前模板,是否继续?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information); DIYReport.ReportModel.RptReport oldCurrentReport = DIYReport.UserDIY.DesignEnviroment.CurrentReport; DIYReport.ReportModel.RptReport report = DIYReport.ReportXmlHelper.Open(); if (report != null) { report.IDEX = System.Guid.NewGuid(); if (oldCurrentReport != null) { if (oldCurrentReport.DataSource != null) { report.Tag = oldCurrentReport.Tag; report.UserParamList = oldCurrentReport.UserParamList; report.DataSource = oldCurrentReport.DataSource; report.DesignField = oldCurrentReport.DesignField; } else { report.DataSource = DIYReport.UserDIY.DesignEnviroment.DataSource; report.DesignField = DIYReport.UserDIY.DesignEnviroment.DesignField; } report.SubReportCommand = oldCurrentReport.SubReportCommand; foreach (DIYReport.ReportModel.RptReport subReport in oldCurrentReport.SubReports.Values) { report.SubReports.Add(subReport.Name, subReport); } } this.DesignerHost.OpenReport(report); } } else if (cmdID.Equals(UICommands.NewReport)) //新增报表 { DIYReport.ReportModel.RptReport report = DIYReport.ReportModel.RptReport.NewReport(); this.DesignerHost.OpenReport(report); } else if (cmdID.Equals(StandardCommands.Undo)) //Undo { this.DesignerHost.UndoMgr.Undo(); } else if (cmdID.Equals(StandardCommands.Redo)) //Redo { this.DesignerHost.UndoMgr.Redo(); } else if (cmdID.Equals(StandardCommands.Cut)) { this.DesignerHost.Cut(); } else if (cmdID.Equals(StandardCommands.Copy)) //Redo { this.DesignerHost.Copy(); } else if (cmdID.Equals(StandardCommands.Paste)) //Redo { this.DesignerHost.Past(); } else if (cmdID.Equals(UICommands.SortAndGroup)) //显示分组和排序 { IList fieldsList = this.DesignerHost.DataObj.DesignField; DIYReport.GroupAndSort.frmSortAndGroup frm = new DIYReport.GroupAndSort.frmSortAndGroup(fieldsList); frm.AfterSortAndGroup += new DIYReport.GroupAndSort.SortAndGroupEventHandler(frm_AfterSortAndGroup); frm.ShowDialog(); } else { Debug.Assert(false, "Command" + cmdID.ID.ToString() + "没有处理。"); } //this.DesignerHost.Cursor = Cursors.Arrow; }