private void DrawObjectItem(GuidObject guidObject) { var caption = guidObject.ToString(); var selected = guidObject == Selector.SelectedObject && UnityEditor.Selection.activeObject == Selector; var style = selected ? GUIStyles.BlueListItem : GUIStyles.ListItem; Layout.BeginHorizontal(style); Layout.Label(caption, GUIStyles.TightLabel); Layout.FlexibleSpace(); Layout.EndHorizontal(); var rect = GUILayoutUtility.GetLastRect(); if (rect.Contains(Event.current.mousePosition)) { HoveredObject = guidObject; if (IsMouseUp) { SelectGuidObject(guidObject); } } }
public SerializationSettings(SerializationFlags flags, GuidObject internalObject) { this.Flags = flags; this.PartialSerialization = true; this.InternalObjects = new HashSet <GuidObject>(); this.InternalObjects.Add(internalObject); this.DistributedFolder = string.Empty; }
public override bool Equals(object obj) { GuidObject o = obj as GuidObject; if (o != null && this._guid.Equals(o._guid)) { return(true); } return(false); }
public MenuItemContext(Guid menuGuid, bool openedFromKeyboard, GuidObject creatorObject, IEnumerable <GuidObject> guidObjects) { MenuGuid = menuGuid; OpenedFromKeyboard = openedFromKeyboard; this.guidObjects = new List <GuidObject>(); this.guidObjects.Add(creatorObject); if (guidObjects != null) { this.guidObjects.AddRange(guidObjects); } state = new Dictionary <object, object>(); }
public IEnumerable <GuidObject> GetGuidObjects(GuidObject creatorObject, bool openedFromKeyboard) { yield return(new GuidObject(MenuConstants.GUIDOBJ_REPL_EDITOR_GUID, replEditorUI)); var teCtrl = (NewTextEditor)creatorObject.Object; var position = openedFromKeyboard ? teCtrl.TextArea.Caret.Position : teCtrl.GetPositionFromMousePosition(); if (position != null) { yield return(new GuidObject(MenuConstants.GUIDOBJ_TEXTEDITORLOCATION_GUID, new TextEditorLocation(position.Value.Line, position.Value.Column))); } }
public IEnumerable <GuidObject> GetGuidObjects(GuidObject creatorObject, bool openedFromKeyboard) { Debug.Assert(owner.ToolWindowGroupManager != null); if (owner.ToolWindowGroupManager != null) { var twg = owner.ToolWindowGroupManager.GetToolWindowGroup(tabGroup); Debug.Assert(twg != null); if (twg != null) { yield return(new GuidObject(MenuConstants.GUIDOBJ_TOOLWINDOWGROUP_GUID, twg)); } } }
public IEnumerable <GuidObject> GetGuidObjects(GuidObject creatorObject, bool openedFromKeyboard) { var listBox = (ListBox)creatorObject.Object; var searchResult = listBox.SelectedItem as ISearchResult; if (searchResult != null) { yield return(new GuidObject(MenuConstants.GUIDOBJ_SEARCHRESULT_GUID, searchResult)); var @ref = searchResult.Reference; if (@ref != null) { yield return(new GuidObject(MenuConstants.GUIDOBJ_CODE_REFERENCE_GUID, new CodeReference(@ref))); } } }
public void Inspect(GuidObject guidObject) { Layout.ReadonlyTextField("Guid", guidObject.Guid.ToString()); guidObject.ID = EditorGUILayout.TextField("ID", guidObject.ID); if (guidObject is BaseNode node) { InspectNode(node); } if (guidObject is Entity entity) { InspectEntity(entity); } }
public IEnumerable <GuidObject> GetGuidObjects(GuidObject creatorObject, bool openedFromKeyboard) { var iconBarMargin = (IIconBarMargin)creatorObject.Object; yield return(new GuidObject(MenuConstants.GUIDOBJ_TEXTEDITORUICONTEXT_GUID, iconBarMargin.UIContext)); var line = iconBarMargin.GetLineFromMousePosition(); if (line != null) { var objects = new List <IIconBarObject>(textLineObjectManager.GetObjectsOfType <IIconBarObject>()); var filteredObjects = GetIconBarObjects(objects, iconBarMargin.UIContext, line.Value); foreach (var o in filteredObjects) { yield return(new GuidObject(MenuConstants.GUIDOBJ_IICONBAROBJECT_GUID, o)); } } }
public IEnumerable <GuidObject> GetGuidObjects(GuidObject creatorObject, bool openedFromKeyboard) { yield return(new GuidObject(MenuConstants.GUIDOBJ_TEXTEDITORUICONTEXT_GUID, uiContext)); var teCtrl = (TextEditorControl)creatorObject.Object; var position = openedFromKeyboard ? teCtrl.TextEditor.TextArea.Caret.Position : teCtrl.TextEditor.GetPositionFromMousePosition(); if (position != null) { yield return(new GuidObject(MenuConstants.GUIDOBJ_TEXTEDITORLOCATION_GUID, new TextEditorLocation(position.Value.Line, position.Value.Column))); } var @ref = teCtrl.GetReferenceSegmentAt(position); if (@ref != null) { yield return(new GuidObject(MenuConstants.GUIDOBJ_CODE_REFERENCE_GUID, @ref.ToCodeReference())); } }
public void Clear() { GuidObject.ReleaseAll(); ForwardDefinitionList = null; GameData = null; }
protected virtual bool IsValidElement(GuidObject element) => element.Guid == new Guid(MenuConstants.GUIDOBJ_DOCUMENTVIEWERCONTROL_GUID);
internal bool?ShowContextMenu(object evArgs, FrameworkElement ctxMenuElem, Guid topLevelMenuGuid, Guid ownerMenuGuid, GuidObject creatorObject, IGuidObjectsCreator creator, IContextMenuInitializer initCtxMenu, bool openedFromKeyboard) { InitializeMenuItemObjects(); // There could be nested contex menu handler calls, eg. first text editor followed by // the TabControl. We don't wan't the TabControl to disable the text editor's ctx menu. if (prevEventArgs.Target == evArgs) { return(null); } var ctx = new MenuItemContext(topLevelMenuGuid, openedFromKeyboard, creatorObject, creator == null ? null : creator.GetGuidObjects(creatorObject, openedFromKeyboard)); List <MenuItemGroupMD> groups; bool b = guidToGroups.TryGetValue(ownerMenuGuid, out groups); if (!b) { return(false); } var menu = new ContextMenu(); var allItems = CreateMenuItems(ctx, groups, null, null, true); if (allItems.Count == 0) { return(false); } foreach (var i in allItems) { menu.Items.Add(i); } menu.Opened += (s, e) => openedContextMenus.Add(menu); menu.Closed += (s, e) => { openedContextMenus.Remove(menu); ctxMenuElem.ContextMenu = new ContextMenu(); }; if (initCtxMenu != null) { initCtxMenu.Initialize(ctx, menu); } ctxMenuElem.ContextMenu = menu; prevEventArgs.Target = evArgs; return(true); }
public void Select(GuidObject guidObject) { this.SelectedObject = guidObject; Selection.activeObject = this; Utils.RefreshEditors(); }
protected override bool IsValidElement(GuidObject element) { return(element.Guid == new Guid(MenuConstants.GUIDOBJ_TEXTEDITORCONTROL_GUID) || element.Guid == new Guid(MenuConstants.GUIDOBJ_FILES_TREEVIEW_GUID)); }
/// <summary> /// Constructor /// </summary> /// <param name="creatorObject">The owner object (<see cref="IMenuItemContext.CreatorObject"/>)</param> /// <param name="openedFromKeyboard">true if it was opened from the keyboard</param> public GuidObjectsProviderArgs(GuidObject creatorObject, bool openedFromKeyboard) { CreatorObject = creatorObject; OpenedFromKeyboard = openedFromKeyboard; }
protected virtual bool IsValidElement(GuidObject element) { return(element.Guid == new Guid(MenuConstants.GUIDOBJ_TEXTEDITORCONTROL_GUID)); }
public void Unselect() { SelectedObject = null; }
protected override bool IsValidElement(GuidObject element) => element.Guid == new Guid(MenuConstants.GUIDOBJ_DOCUMENTVIEWERCONTROL_GUID) || element.Guid == new Guid(MenuConstants.GUIDOBJ_DOCUMENTS_TREEVIEW_GUID);
public IEnumerable <GuidObject> GetGuidObjects(GuidObject creatorObject, bool openedFromKeyboard) { yield return(new GuidObject(MenuConstants.GUIDOBJ_TABGROUP_GUID, tabGroup)); }
private void SelectGuidObject(GuidObject guidObject) { Selector.Select(guidObject); }
public IEnumerable <GuidObject> GetGuidObjects(GuidObject creatorObject, bool openedFromKeyboard) { yield return(new GuidObject(MenuConstants.GUIDOBJ_TREEVIEW_NODES_ARRAY_GUID, treeView.TopLevelSelection)); }
internal bool?ShowContextMenu(object evArgs, FrameworkElement ctxMenuElem, Guid topLevelMenuGuid, Guid ownerMenuGuid, GuidObject creatorObject, IGuidObjectsProvider provider, IContextMenuInitializer initCtxMenu, bool openedFromKeyboard) { InitializeMenuItemObjects(); // There could be nested context menu handler calls, eg. first text editor followed by // the TabControl. We don't wan't the TabControl to disable the text editor's ctx menu. if (prevEventArgs.Target == evArgs) { return(null); } var ctx = new MenuItemContext(topLevelMenuGuid, openedFromKeyboard, creatorObject, provider?.GetGuidObjects(new GuidObjectsProviderArgs(creatorObject, openedFromKeyboard))); bool b = guidToGroups.TryGetValue(ownerMenuGuid, out var groups); if (!b) { return(false); } var menu = new ContextMenu(); BindBackgroundBrush(menu, isCtxMenu: true); // The owner control could be zoomed (eg. text editor) but the context menu isn't, so make // sure we use 100% zoom here (same as the context menu). double defaultZoom = 1.0; DsImage.SetZoom(menu, defaultZoom); // Also make sure we use Display mode. Let MetroWindow handle it since it has some extra checks var window = Window.GetWindow(ctxMenuElem) as MetroWindow; window?.SetScaleTransform(menu, defaultZoom); var allItems = CreateMenuItems(ctx, groups, null, null, true); if (allItems.Count == 0) { return(false); } foreach (var i in allItems) { menu.Items.Add(i); } menu.Closed += (s, e) => { ctx.Dispose(); ctxMenuElem.ContextMenu = new ContextMenu(); }; if (initCtxMenu != null) { initCtxMenu.Initialize(ctx, menu); } ctxMenuElem.ContextMenu = menu; prevEventArgs.Target = evArgs; return(true); }
public void Select(GuidObject guidObject) { SelectGuidObject(guidObject); }