private static void UpdateMenuItemShortcuts( object sender, Borland.Studio.ToolsAPI.FileNotificationEventArgs args ) { if ((args.NotifyCode == OTAFileNotification.ofnPackageInstalled) || (args.NotifyCode == OTAFileNotification.ofnPackageUninstalled) || (args.NotifyCode == OTAFileNotification.ofnFileOpened)) { //foreach (ShortcutRecord record in getInstance()) { foreach (Elements.ShortcutRecord record in Instance.table.Values) { record.MenuItem.Shortcut = record.Shortcut; } } }
/// <summary> /// Executes. /// </summary> /// <param name="editor">Source editor</param> public void Execute(Borland.Studio.ToolsAPI.IOTASourceEditor editor) { int lineNumber = OtaUtils.GetCurrentLineNumber(); string last = OtaUtils.GetLineOf(editor, lineNumber - 1); if (last == null || last.StartsWith(@"///", StringComparison.Ordinal)) { return; } IList<CodeDomInfo> list = new List<CodeDomInfo>(); CodeDomProvider.LoadMethodInfoInto(list, OtaUtils.GetCurrentModule()); CodeDomProvider.LoadFieldInfoInto(list, OtaUtils.GetCurrentModule()); CodeDomProvider.LoadEventInfoInto(list, OtaUtils.GetCurrentModule()); CodeDomProvider.LoadTypeInfoInto(list, OtaUtils.GetCurrentModule()); for(int i = 0; i < list.Count; i++) { CodeDomInfo info = (CodeDomInfo)list[i]; if (info != null && info.LineNumber == lineNumber + 1) { OtaUtils.InsertText(editor, info.GenerateXmlComments()); return; } } }
///<summary> ///Adds a menu shortcut. ///</summary> ///<param name="item">Menu item</param> ///<param name="shortcut">Shortcut</param> internal void Add( Borland.Studio.ToolsAPI.IOTAMenuItem item, int shortcut ) { if (item != null) { if (shortcut != 0) { if (String.IsNullOrEmpty(item.Name)) { LoggingService.Warn("noname menu"); } else { // This.Add(new ShortcutRecord(item, shortcut)); table.Add(item.Text, new Elements.ShortcutRecord(item, shortcut)); } } else { LoggingService.Warn("zero shortcut"); } //if (this.Count == 1) { if (table.Count == 1) { StartFileNotification(); } } else { LoggingService.Warn("null menu"); } }
internal static IKey GetKeyFrom(Borland.Studio.ToolsAPI.IOTASourceEditor editor) { // IsBackSpace: backspace is pressed. // IsEnter: row is changed, and Enter is pressed. // IsBlockEdit: IDE AutoCompletion or Code Insight fills, or // Cut/Copy,or Indent/unindent, or block edit. // IsError: GetCharBeforeCursor error. //bool IsBackSpace = false; //bool IsEnter = false; //bool IsBlockEdit = false; //bool IsError = false; IOTAEditView view = OtaUtils.GetEditView(editor); if (view == null) { LoggingService.Warn("null view"); return InvalidKey.Instance; } if (!initialized) { LoggingService.Info("initial row"); LoggingService.Info("initial column"); SavePoint(view); initialized = true; // initial state, no action. return InvalidKey.Instance; } char result = OtaUtils.GetCharBeforeCursor(editor); // check key. // TODO: what is 9, seems it leads to bug. if (result == char.MinValue) { LoggingService.Info("min char"); SavePoint(view); return InvalidKey.Instance; } if (lastPoint.Y != view.LastEditRow) { //LoggingService.AddDebug("Row changed. reget column."); // if (view.LastEditRow == lastPoint.Row + 1) { // IsEnter = true; // LoggingService.Info("Enter next row."); // } else { // IsBlockEdit = true; // LoggingService.Info("Move to other row."); // } SavePoint(view); return InvalidKey.Instance; } // same row. if (view.LastEditColumn == lastPoint.X) { LoggingService.Info("initial column"); } else if (view.LastEditColumn == lastPoint.X + 1) { LoggingService.Info("Normal user input"); } else if (view.LastEditColumn == lastPoint.X + 2) { //if (LastIsEnter()) LoggingService.Info("Enter after XML tag"); } else if (view.LastEditColumn == lastPoint.X - 1) { //IsBackSpace = true; SavePoint(view); return InvalidKey.Instance; // normally the left is greater than or equal to the right. } else { //IsBlockEdit = true; LoggingService.Info("movement is " + (view.LastEditColumn - lastPoint.X)); SavePoint(view); return InvalidKey.Instance; } SavePoint(view); return new TriggerKey(result); }
/// <summary> /// Constructor. /// </summary> /// <param name="item">Menu item</param> /// <param name="shortcut">Shortcut value</param> /// <returns></returns> internal ShortcutRecord( Borland.Studio.ToolsAPI.IOTAMenuItem item, int shortcut ) { this.menuItem = item; this.shortcut = shortcut; }
private static Borland.Studio.ToolsAPI.IOTAMenuItem AddMenuItem(string parentName, Borland.Studio.ToolsAPI.OTAMenuItemLocation location, string name, string text, string imageName) { LoggingService.EnterMethod(); Borland.Studio.ToolsAPI.IOTAMainMenuService menuService = GetMainMenuService(); IOTAMenuItem item = null; if (menuService != null) { IntPtr ptr = Lextm.Drawing.ImageLoader.GetImageDataPtr(imageName); if ((String.IsNullOrEmpty(name)) || ((menuService.GetMenuItem(name) == null))) { // avoid created menus but create separators. item = menuService.AddMenuItem(parentName, location, name, text, ptr); if (ptr != IntPtr.Zero) { // only action with a bitmap can be listed in the category item.Category = MenuItemCategory; } } else { LoggingService.Warn(String.Format(CultureInfo.InvariantCulture, "existed menu item {0}", name)); } } else { LoggingService.Warn("null service"); } LoggingService.LeaveMethod(); return item; }