/// <summary> /// Setups the Add Component Menu Window instance for the given specs. /// </summary> /// <param name="setInspector"> The inspector which is opening the menu. </param> /// <param name="items"> Root items of the menu. </param> /// <param name="groupsByLabel"> All groups in the menu flattened, with full label path of group as key in dictionary. </param> /// <param name="itemsByLabel"> All non-group leaf items in the menu flattened, with full label path of item as key in dictionary. </param> /// <param name="tickedItems"> Items that are ticked in the menu. </param> /// <param name="unrollPosition"> The position where the menu should open. </param> /// <param name="onMenuItemClicked"> Action to invoke when a menu item is clicked. </param> /// <param name="onMenuClosed"> Action to invoke when the menu is closed. </param> /// <param name="menuTitle"> Title for menu. </param> /// <param name="canTickMultipleItems"> Is it possible for multiple items to be ticked in the menu simultaneously? </param> private void Setup([NotNull] IInspector setInspector, [NotNull] List <PopupMenuItem> items, [NotNull] Dictionary <string, PopupMenuItem> groupsByLabel, [NotNull] Dictionary <string, PopupMenuItem> itemsByLabel, [CanBeNull] List <PopupMenuItem> tickedItems, Rect unrollPosition, Action <PopupMenuItem> onMenuItemClicked, Action onMenuClosed, GUIContent menuTitle, bool canTickMultipleItems) { #if DEV_MODE && DEBUG_SETUP Debug.Log(GetType().Name + ".Setup() with instance=" + (instance == null ? "null" : "NotNull") + ", setInspector=" + setInspector); #endif inspector = setInspector; onClosed = onMenuClosed; inspector.InspectorDrawer.Manager.IgnoreAllMouseInputs = true; if (drawer == null) { drawer = PopupMenu.Create(inspector, items, groupsByLabel, itemsByLabel, unrollPosition, onMenuItemClicked, Close, menuTitle); } else { drawer.Setup(inspector, items, groupsByLabel, itemsByLabel, unrollPosition, onMenuItemClicked, Close, menuTitle); } drawer.SetTickedMembers(tickedItems, canTickMultipleItems); ShowAsDropDown(unrollPosition, new Vector2(unrollPosition.width, drawer.TotalHeight)); #if DEV_MODE && PI_ASSERTATIONS if (drawer.OnCurrentViewItemCountChanged != null) { Debug.LogError("PopupMenuWindow.OnCurrentViewItemCountChanged (" + drawer.OnCurrentViewItemCountChanged.GetInvocationList().Length + ") != null: " + StringUtils.ToString(drawer.OnCurrentViewItemCountChanged)); } #endif //UPDATE: fix for bug where invocation list Count would keep growing //drawer.OnCurrentViewItemCountChanged += UpdateHeight; drawer.OnCurrentViewItemCountChanged = UpdateHeight; }
private void AddToActiveInstances([NotNull] IInspector inspector) { activeInstances.Add(inspector); var inspectorType = inspector.GetType(); List <IInspector> activeInstancesOfSameType; if (!activeInstancesByType.TryGetValue(inspectorType, out activeInstancesOfSameType)) { activeInstancesOfSameType = new List <IInspector>(1); activeInstancesByType[inspectorType] = activeInstancesOfSameType; } activeInstancesOfSameType.Add(inspector); InstanceUniqueNames.Add(GenerateUniqueName(inspector)); #if DEV_MODE Debug.Assert(activeInstances.Count == InstanceUniqueNames.Count); #endif if (OnNewInspectorRegistered != null) { OnNewInspectorRegistered(inspector); } }
private string GenerateUniqueName(IInspector inspector) { var type = inspector.GetType(); List <IInspector> activeInstancesOfSameType; if (!activeInstancesByType.TryGetValue(type, out activeInstancesOfSameType)) { #if DEV_MODE Debug.LogError("GenerateUniqueName for inspector but activeInstancesByType did not yet contain the inspector"); #endif return(type.Name); } int count = activeInstancesOfSameType.Count; if (count <= 1) { #if DEV_MODE && PI_ASSERTATIONS Debug.Assert(count == 1 && activeInstancesOfSameType[0] == inspector); #endif return(type.Name); } return(type.Name + " (" + StringUtils.ToString(count) + ")"); }
public InspectionResultsViewModel(RubberduckParserState state, IInspector inspector, VBE vbe, INavigateCommand navigateCommand, IClipboardWriter clipboard, IGeneralConfigService configService, IOperatingSystem operatingSystem) { _state = state; _inspector = inspector; _vbe = vbe; _navigateCommand = navigateCommand; _clipboard = clipboard; _configService = configService; _operatingSystem = operatingSystem; _refreshCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), async param => await Task.Run(() => ExecuteRefreshCommandAsync()), CanExecuteRefreshCommand); _disableInspectionCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteDisableInspectionCommand); _quickFixCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixCommand, CanExecuteQuickFixCommand); _quickFixInModuleCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInModuleCommand, _ => _state.Status == ParserState.Ready); _quickFixInProjectCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInProjectCommand, _ => _state.Status == ParserState.Ready); _copyResultsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCopyResultsCommand, CanExecuteCopyResultsCommand); _openSettingsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), OpenSettings); _configService.SettingsChanged += _configService_SettingsChanged; _setInspectionTypeGroupingCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param => { GroupByInspectionType = (bool)param; GroupByLocation = !(bool)param; }); _setLocationGroupingCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param => { GroupByLocation = (bool)param; GroupByInspectionType = !(bool)param; }); _state.StateChanged += _state_StateChanged; }
/// <inheritdoc/> public virtual void Setup(IInspector setInspector) { inspector = setInspector; inspector.State.OnInspectedTargetsChanged -= OnInspectedTargetsChanged; inspector.State.OnInspectedTargetsChanged += OnInspectedTargetsChanged; items = ToolbarUtility.GetItemsForToolbar(setInspector, this); visibleItems = items; UpdateVisibleItems(); updateToolbarItemBounds = true; inspector.State.OnWidthChanged += UpdateToolbarItemBounds; #if UNITY_2019_3_OR_NEWER if (DrawGUI.IsProSkin) { lineAboveColor = inspector.Preferences.theme.ComponentSeparatorLine; lineBelowColor = inspector.Preferences.theme.ComponentSeparatorLine; //lineBelowColor = new Color32(32, 32, 32, 255); } else { lineAboveColor = new Color32(153, 153, 153, 255); lineBelowColor = new Color32(153, 153, 153, 255); //lineBelowColor = inspector.Preferences.theme.ComponentSeparatorLine; } //new Color32(165, 165, 165, 255) what I had for light skin for both #endif }
public static AddComponentMenuDrawer CreateNewBackgroundInstance(IInspector setInspector, IGameObjectDrawer target) { var result = new AddComponentMenuDrawer(); result.SetupWithoutOpening(setInspector, target); return(result); }
IInspector GetInspector <T>() { IInspector <T> inspector = default; switch (Target) { case InspectorTarget.Inspector: inspector = InspectorRegistry.GetInspector <T>(); break; case InspectorTarget.PropertyInspector: inspector = InspectorRegistry.GetPropertyInspector <T>(Property); break; case InspectorTarget.AttributeInspector: inspector = InspectorRegistry.GetAttributeInspector <T>(Property); break; case InspectorTarget.None: default: throw new ArgumentOutOfRangeException(); } if (null != inspector) { inspector.Context = new InspectorContext <T>( Root, PropertyPath, Property, Property.GetAttributes() ); } return(inspector); }
public RubberduckMenu(VBE vbe, AddIn addIn, IGeneralConfigService configService, IRubberduckParser parser, IActiveCodePaneEditor editor, IInspector inspector) : base(vbe, addIn) { _addIn = addIn; _parser = parser; _configService = configService; var testExplorer = new TestExplorerWindow(); var testEngine = new TestEngine(); var testGridViewSort = new GridViewSort<TestExplorerItem>(RubberduckUI.Result, false); var testPresenter = new TestExplorerDockablePresenter(vbe, addIn, testExplorer, testEngine, testGridViewSort); _testMenu = new TestMenu(vbe, addIn, testExplorer, testPresenter); var codeExplorer = new CodeExplorerWindow(); var codePresenter = new CodeExplorerDockablePresenter(parser, vbe, addIn, codeExplorer); codePresenter.RunAllTests += CodePresenterRunAllAllTests; codePresenter.RunInspections += codePresenter_RunInspections; codePresenter.Rename += codePresenter_Rename; codePresenter.FindAllReferences += codePresenter_FindAllReferences; codePresenter.FindAllImplementations += codePresenter_FindAllImplementations; _codeExplorerMenu = new CodeExplorerMenu(vbe, addIn, codeExplorer, codePresenter); var todoSettings = configService.LoadConfiguration().UserSettings.ToDoListSettings; var todoExplorer = new ToDoExplorerWindow(); var todoGridViewSort = new GridViewSort<ToDoItem>(RubberduckUI.Priority, false); var todoPresenter = new ToDoExplorerDockablePresenter(parser, todoSettings.ToDoMarkers, vbe, addIn, todoExplorer, todoGridViewSort); _todoItemsMenu = new ToDoItemsMenu(vbe, addIn, todoExplorer, todoPresenter); var inspectionExplorer = new CodeInspectionsWindow(); var inspectionGridViewSort = new GridViewSort<CodeInspectionResultGridViewItem>(RubberduckUI.Component, false); var inspectionPresenter = new CodeInspectionsDockablePresenter(inspector, vbe, addIn, inspectionExplorer, inspectionGridViewSort); _codeInspectionsMenu = new CodeInspectionsMenu(vbe, addIn, inspectionExplorer, inspectionPresenter); _refactorMenu = new RefactorMenu(IDE, AddIn, parser, editor); }
private void ShowTextEditorPopupMenu(IInspector inspector) { var menu = Menu.Create(); if (editor.hasSelection && !editor.isPasswordField) { menu.Add("Cut", () => { Clipboard.Copy(editor.SelectedText); editor.DeleteSelection(); }); menu.Add("Copy", () => Clipboard.Copy(editor.SelectedText)); } if (editor.CanPaste()) { menu.Add("Paste", () => editor.Paste()); } var searchBox = inspector.Toolbar.GetItemByType(typeof(ISearchBoxToolbarItem)); if (searchBox != null && inspector.Manager.MouseoveredInspectorPart == InspectorPart.Toolbar || inspector.Manager.SelectedInspectorPart == InspectorPart.Toolbar) { ContextMenuUtility.Open(menu, true, inspector, InspectorPart.Toolbar, null, searchBox); } else { #if DEV_MODE Debug.LogWarning("Filter.ShowTextEditorPopupMenu called but subject was not ISearchBoxToolbarItem on inspector toolbar. Calling ContextMenuUtility with a null subject."); #endif ContextMenuUtility.Open(menu, null); } }
public void OnMouseoveredInspectorChanged(IInspector from, IInspector to) { // DragExited, DrawPerformed, MouseUp etc. are not called when it happens outside EditorWindow bounds. // Because of this we clear MouseDown info when cursor leaves EditorWindow bounds. #if DEV_MODE && DEBUG_ON_MOUSEOVERED_INSPECTOR_CHANGED Debug.Log(StringUtils.ToColorizedString("RightClickInfo.OnMouseoveredInspectorChanged(", from, " => ", to, " with MouseButtonIsDown=", MouseButtonIsDown, ", mouseoveredInspectorLeftDuringDrag=", mouseoveredInspectorLeftDuringDrag, ", IsClick=", IsClick)); #endif if (to == null) { if (mouseButtonIsDown) { #if DEV_MODE Debug.LogWarning("Cursor left " + from + " bounds with MouseButtonIsDown=" + StringUtils.True + ". Setting IsClick and MouseButtonIsDown to " + StringUtils.False + " for now."); #endif mouseoveredInspectorLeftDuringDrag = true; IsClick = false; MouseButtonIsDown = false; } else { mouseoveredInspectorLeftDuringDrag = false; } } }
/// <summary> /// Creates the Add Component Menu Window if in editor mode. /// This is attached to the Add Component button being clicked. /// </summary> /// <param name="inspector"> The inspector which contains the target. </param> /// <param name="target"> Target onto which components should be added. </param> /// <param name="unrollPosition"> The position above or below which the window should open. </param> /// <param name="onClosed"> This action is invoked when the editor window is closed. </param> public static void CreateIfInEditorMode(IInspector inspector, IGameObjectDrawer target, Rect unrollPosition, Action onClosed) { if (Platform.EditorMode) { Create(inspector, target, unrollPosition, onClosed); } }
public static bool OpenSelectedOrFirstFoundInstance(IInspector selectedInspector) { var selectedControl = selectedInspector.FocusedDrawer; if (selectedControl != null) { for (var next = selectedControl; next != null; next = next.Parent) { var go = next as IGameObjectDrawer; if (go != null) { var addComponentButton = go.AddComponentButton; addComponentButton.Select(ReasonSelectionChanged.KeyPressShortcut); addComponentButton.Open(); return(true); } } } var inspected = selectedInspector.State.drawers.Members; for (int n = 0; n < inspected.Length; n++) { var go = inspected[n] as IGameObjectDrawer; if (go != null) { var addComponentButton = go.AddComponentButton; addComponentButton.Select(ReasonSelectionChanged.KeyPressShortcut); addComponentButton.Open(); return(true); } } return(false); }
/// <summary> /// Waits until the active inspector has finished rendering and then opens the menu. /// Delaying the opening of the menu like this can help avoid with some graphical glitches that can happen if the menu is opened in the middle of an inspector being drawn. /// </summary> /// <param name="menu"> Menu that should be opened. </param> /// <param name="disposeAfter"> Should the menu object be disposed after menu has been opened? Set this to false if the Menu is cached and reused, otherwise set this true. </param> /// <param name="inspector"> Inspector for which the context menu is being opened. Null if not opening for any inspector. </param> /// <param name="inspectorPart"> Part of the inspector for which the context menu is being opened. None if not opening for any inspector. </param> /// <param name="subject"> IDrawer for which the context menu is opened. Null if context menu doesn't belong to any IDrawer (e.g. toolbar menu item). </param> /// <param name="part"> Part of the subject for which the context menu is opened. E.g. reference to the targeted toolbar item. Can be null. </param> /// <param name="doOnMenuClosed"> Delegate to be called once menu has closed. Set to ContextMenuUtility.SelectLastContextMenuSubject to select the context menu subject once the context menu window has been closed. </param> public static void Open([NotNull] Menu menu, bool disposeAfter, [CanBeNull] IInspector inspector, InspectorPart inspectorPart, [CanBeNull] IDrawer subject, [CanBeNull] object part, Action <object> doOnMenuClosed = null) { #if DEV_MODE Debug.Assert(menu.Count > 0); Debug.Assert(inspector != null || subject == null); #endif openingMenu = menu; openingMenuInspector = inspector; openingMenuInspectorPart = inspectorPart; openingMenuSubject = new DrawerTarget(subject); openingMenuPart = part; openingMenuPosition = null; disposeMenuAfterOpening = disposeAfter; onMenuClosed = doOnMenuClosed; if (IsSafeToChangeInspectorContents || inspector == null) { #if DEV_MODE Debug.Log("Opening context menu immediately"); #endif OpenContextMenu(); } else { openDelayCounter = 2; } }
/// <summary> /// Called when the inspector whose viewport is under the cursor is changed while an IReorderable or Objects are being dragged /// </summary> /// <param name="newlyMouseoveredInspector"> /// The inspector whose viewport is now being mouseovered</param> /// <param name="reordering"> /// The IReorderable currently being dragged. </param> /// <param name="draggedObjects"> /// The Object references currently being dragged. </param> public void OnDropTargetInspectorChanged(IInspector newlyMouseoveredInspector, IReorderable reordering, Object[] draggedObjects) { inspector = newlyMouseoveredInspector; if (inspector == null) { Clear(); return; } if (reordering != null) { UpdateReorderingOptions(reordering); } else { UpdateReorderingOptions(draggedObjects); } UpdateDropTarget(); #if DEV_MODE //Debug.Log("OnDropTargetInspectorChanged(" + StringUtils.ToString(newlyMouseoveredInspector) + "): " + StringUtils.ToString(inspector) + " parentOptions: " + StringUtils.ToString(dropTargetParentOptions)); #endif }
/// <summary> /// Get adoxio_Inspector from adoxio_events /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='adoxioEventid'> /// key: adoxio_eventid of adoxio_event /// </param> /// <param name='select'> /// Select properties to be returned /// </param> /// <param name='expand'> /// Expand related entities /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <MicrosoftDynamicsCRMsystemuser> GetAsync(this IInspector operations, string adoxioEventid, IList <string> select = default(IList <string>), IList <string> expand = default(IList <string>), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.GetWithHttpMessagesAsync(adoxioEventid, select, expand, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Creates the Add Component Menu Window if in editor mode. /// This is attached to the Add Component button being clicked. /// </summary> /// <param name="setInspector"> The inspector which is opening the menu. </param> /// <param name="items"> Root items of the menu. </param> /// <param name="groupsByLabel"> All groups in the menu flattened, with full label path of group as key in dictionary. </param> /// <param name="itemsByLabel"> All non-group leaf items in the menu flattened, with full label path of item as key in dictionary. </param> /// <param name="tickedItems"> items that are ticked in the menu. </param> /// <param name="canTickMultipleItems"> Is it possible to have mutliple items ticked in the menu simultaneously? </param> /// <param name="unrollPosition"> The position above or below which the menu should open. </param> /// <param name="onMenuItemClicked"> Action to invoke when a menu item is clicked. </param> /// <param name="onClosed"> (Optional) Action to invoke when the menu is closed. </param> /// <param name="menuTitle"> Title for menu. Use GUIContent.none to hide the titlebar. </param> public static void CreateIfInEditorMode([NotNull] IInspector setInspector, [NotNull] List <PopupMenuItem> items, [NotNull] Dictionary <string, PopupMenuItem> groupsByLabel, [NotNull] Dictionary <string, PopupMenuItem> itemsByLabel, [CanBeNull] List <PopupMenuItem> tickedItems, bool canTickMultipleItems, Rect unrollPosition, Action <PopupMenuItem> onMenuItemClicked, [CanBeNull] Action onClosed, GUIContent menuTitle) { if (Platform.EditorMode) { Create(setInspector, items, groupsByLabel, itemsByLabel, tickedItems, canTickMultipleItems, unrollPosition, onMenuItemClicked, onClosed, menuTitle); } }
public IAssetDrawer GetForAssets([NotNull] IInspector inspector, [NotNull] Object[] targets, [CanBeNull] IParentDrawer parent) { #if UNITY_EDITOR Object[] assetImporters; Type customEditorType; var drawerType = GetDrawerTypeForAssets(targets, out assetImporters, out customEditorType); if (typeof(ICustomEditorAssetDrawer).IsAssignableFrom(drawerType)) { #if DEV_MODE && DEBUG_GET_FOR_ASSET Debug.Log("GetForAssetWithEditor(" + StringUtils.TypeToString(targets[0]) + "): " + drawerType.Name + " with assetImporters=" + StringUtils.TypesToString(assetImporters) + ", customEditorType=" + StringUtils.ToString(customEditorType)); #endif return(GetForAssetWithEditor(drawerType, customEditorType, targets, assetImporters, parent, inspector)); } #else var drawerType = GetDrawerTypeForAssets(targets); #endif #if DEV_MODE || SAFE_MODE if (!typeof(IEditorlessAssetDrawer).IsAssignableFrom(drawerType)) { #if DEV_MODE Debug.LogError("DrawerProvider.GetForAsset returned drawerType " + drawerType.Name + " which did not implement ICustomEditorAssetDrawer nor IEditorlessAssetDrawer"); #endif drawerType = typeof(AssetDrawer); } #endif return(GetForAssetsWithoutEditor(drawerType, targets, parent, inspector)); }
/// <summary> /// Creates the Add Component Menu Window if it doesn't already exist. /// </summary> /// <param name="inspector"> The inspector which contains the target. </param> /// <param name="target"> Target onto which components should be added. </param> /// <param name="unrollPosition">The position above or below which the window should open. </param> /// <param name="onClosed"> This action is invoked when the editor window is closed. </param> public static void Create(IInspector inspector, IGameObjectDrawer target, Rect unrollPosition, Action onClosed) { if (instance != null) { return; } instance = CreateInstance <AddComponentMenuWindow>(); #if DEV_MODE && PI_ASSERTATIONS Debug.Assert(instance.IsVisible()); #endif try { instance.Setup(inspector, target, unrollPosition, onClosed); } #if DEV_MODE catch (Exception e) { Debug.LogError(e); #else catch { #endif if (instance != null) { Destroy(instance); } RestoreClickControls(); } }
public Events(IBootloader bootloader, IInspector inspector = null) { this.Bootloader = bootloader; this.inspector = inspector; Env = bootloader.Env; backupUpdate(); }
/// <inheritdoc /> protected override void Setup(Component[] setTargets, IParentDrawer setParent, IInspector setInspector, Type setEditorType) { inspector = setInspector; hasExecuteMethodItems = base.HasExecuteMethodIcon && HasExecuteMethodMenuItems(); var firstTarget = setTargets[0]; if (!HeadlessMode && firstTarget != null && firstTarget.HasEnabledProperty()) { hasEnabledFlag = true; var monoBehaviour = firstTarget as MonoBehaviour; if (monoBehaviour != null) { //Unity doesn't show the enabled flag in the inspector unless //the Behaviour contains certain methods. However, it can be //useful to have it be there anyways for various reasons. createCustomEnabledFlag = !monoBehaviour.HasEnabledFlagInEditor(); #if DEV_MODE && DEBUG_CUSTOM_ENABLED_FLAG if (createCustomEnabledFlag) { Debug.Log(ToString() + " - Creating custom enabled flag for " + firstTarget.GetType()); } #endif } } base.Setup(setTargets, setParent, setInspector, setEditorType); #if DEV_MODE && DEBUG_ENABLED_FLAG Debug.Log(ToString() + " hasEnabledFlag: " + hasEnabledFlag); #endif }
public void OnPressedMouseDown(IInspector setInspector, IDrawer overControl) { if (overControl != null) { var e = Event.current; MouseDownPos = e.mousePosition; var overField = overControl as IFieldDrawer; if (overField != null && overField.CanReadFromFieldWithoutSideEffects) { MouseDownOverDrawerValues = overControl.GetValues(); } else { MouseDownOverDrawerValues = ArrayPool <object> .ZeroSizeArray; } var setDraggingPrefixOfControl = overControl as IDraggablePrefix; if (setDraggingPrefixOfControl != null && setDraggingPrefixOfControl.DraggingPrefix) { draggingPrefixOfDrawer = setDraggingPrefixOfControl; draggingPrefixOfDrawer.OnPrefixDragStart(e); } } }
public void Setup(IInspector setInspector, List <PopupMenuItem> setItems, Dictionary <string, PopupMenuItem> setGroupsByLabel, Dictionary <string, PopupMenuItem> setItemsByLabel, Rect openPosition, Action <PopupMenuItem> setOnMenuItemClicked, Action setOnClosed, GUIContent setLabel) { inspector = null; label = setLabel; //TO DO: Set active item using current value for fields activeGroup = null; itemsFiltered.Clear(); lastAppliedFilter = ""; filter = ""; setFilter = ""; currentViewLabel.text = label.text; currentViewLabel.tooltip = label.tooltip; onClosed = setOnClosed; onMenuItemClicked = setOnMenuItemClicked; inspector = setInspector; rootItems = setItems; groupsByLabel = setGroupsByLabel; itemsByLabel = setItemsByLabel; searchableListBuilt = false; RebuildIntructionsInChildren(); Open(openPosition); }
public static IInspectorToolbarItem[] GetItemsForToolbar([NotNull] IInspector inspector, [NotNull] IInspectorToolbar toolbar) { if (toolbarItemsByToolbarType == null) { BuildDictionaries(); } Type[] itemTypes; if (!toolbarItemsByToolbarType.TryGetValue(toolbar.GetType(), out itemTypes)) { return(ArrayPool <IInspectorToolbarItem> .ZeroSizeArray); } int count = itemTypes.Length; IInspectorToolbarItem[] items = new IInspectorToolbarItem[count]; for (int n = count - 1; n >= 0; n--) { var itemType = itemTypes[n]; var item = (IInspectorToolbarItem)itemType.CreateInstance(); var alignment = ((ToolbarItemForAttribute)itemType.GetCustomAttributes(typeof(ToolbarItemForAttribute), false)[0]).alignment; item.Setup(inspector, toolbar, alignment); items[n] = item; } return(items); }
bool IExpectation.Matches(IInspector inspector) { if (inspector is TInspector) return Matches((TInspector)inspector); return false; }
/// <summary> /// The Run method executes the code and allows for an injected inspector /// to perform inspection operations and return a break code if desired. /// /// Inspectors inspect each line of code. While the inspector cannot alter /// the linePointer or accumulator values, it can alter the single command /// that it inspects, enabling some debugging. /// </summary> public long Run(IInspector inspector = null, bool WriteOut = true) { if (inspector != null) { Inspector = inspector; } while (linePointer <= Code.Length) { GBCommand Cmd = ParseLine(Code[linePointer - 1]); long inspection = inspector.Inspect(ref Cmd, linePointer, Accumulator); if (BreakValue(inspection, Cmd)) { return(Break(Cmd, WriteOut)); } long execution = Command[Cmd.Name].Run(Cmd.Value, ref linePointer, ref Accumulator); History.Add(Cmd); if (BreakValue(execution, Cmd)) { return(Break(Cmd, WriteOut)); } } return(Break(new GBCommand("COMPLETE", 0))); }
public CustomInspectorElement(PropertyPath basePath, IInspector inspector, PropertyElement root) { m_Root = root; binding = this; m_BasePath = basePath; name = inspector.Type.Name; Inspector = inspector; try { m_Content = Inspector.Build(); if (null == m_Content) { return; } HasInspector = true; // If `IInspector.Build` was not overridden, it returns this element as its content. if (this != m_Content) { Add(m_Content); RegisterBindings(m_Content); } } catch (Exception exception) { Debug.LogException(exception); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); _insp = ProviderVisitorInspector.GetInspector(); if(_pianta.GestoreInformazioni != null) { _types = _pianta.GestoreInformazioni.GetTypeProviders(); AggiornaTextBox(); } _aggiungiButton.Click += AggiungiProviderVisitor; _finalizzaButton.Click += FinalizzaGestore; providers = new Dictionary<string, Type>(); foreach (Type prov in _insp.GetListProvider()) { providers.Add(prov.Name, prov); } _providerComboBox.DataSource = new BindingSource(providers, null); _providerComboBox.DisplayMember = "Key"; _providerComboBox.ValueMember = "Value"; visitors = new Dictionary<string, Type>(); foreach (Type visit in _insp.GetListVisitor()) { visitors.Add(visit.Name, visit); } _visitorComboBox.DataSource = new BindingSource(visitors, null); _visitorComboBox.DisplayMember = "Key"; _visitorComboBox.ValueMember = "Value"; }
public InspectionResultsViewModel( RubberduckParserState state, IInspector inspector, IQuickFixProvider quickFixProvider, INavigateCommand navigateCommand, ReparseCommand reparseCommand, IClipboardWriter clipboard, IGeneralConfigService configService, ISettingsFormFactory settingsFormFactory, IUiDispatcher uiDispatcher) { _state = state; _inspector = inspector; _quickFixProvider = quickFixProvider; NavigateCommand = navigateCommand; _clipboard = clipboard; _configService = configService; _settingsFormFactory = settingsFormFactory; _uiDispatcher = uiDispatcher; RefreshCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), o => { IsRefreshing = true; IsBusy = true; reparseCommand.Execute(o); }, o => !IsBusy && reparseCommand.CanExecute(o)); DisableInspectionCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteDisableInspectionCommand); QuickFixCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixCommand, CanExecuteQuickFixCommand); QuickFixInProcedureCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInProcedureCommand, _ => SelectedItem != null && _state.Status == ParserState.Ready); QuickFixInModuleCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInModuleCommand, _ => SelectedItem != null && _state.Status == ParserState.Ready); QuickFixInProjectCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInProjectCommand, _ => SelectedItem != null && _state.Status == ParserState.Ready); QuickFixInAllProjectsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInAllProjectsCommand, _ => SelectedItem != null && _state.Status == ParserState.Ready); CopyResultsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCopyResultsCommand, CanExecuteCopyResultsCommand); OpenInspectionSettings = new DelegateCommand(LogManager.GetCurrentClassLogger(), OpenSettings); _configService.SettingsChanged += _configService_SettingsChanged; // todo: remove I/O work in constructor _runInspectionsOnReparse = _configService.LoadConfiguration().UserSettings.CodeInspectionSettings.RunInspectionsOnSuccessfulParse; SetInspectionTypeGroupingCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param => { GroupByInspectionType = (bool)param; GroupByLocation = !(bool)param; }); SetLocationGroupingCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param => { GroupByLocation = (bool)param; GroupByInspectionType = !(bool)param; }); _state.StateChanged += HandleStateChanged; BindingOperations.CollectionRegistering += BindingOperations_CollectionRegistering; }
/// <summary> /// Sets mouseovered inspector part to given value. Optionally clears controls. /// </summary> /// <param name="setInspector"> The inspector to set as the mouseovered inspector. Can be null. </param> /// <param name="clearControls"> /// True to also clear mouseovered selectable and right-clickable drawer. /// If setInspector is null, drawer will get cleared regardless of the value of this flag. /// </param> /// <returns> True if mouseovered inspector changed. </returns> public bool SetInspector([CanBeNull] IInspector setInspector, bool clearControls) { #if DEV_MODE && PI_ASSERTATIONS if (setInspector == null && !clearControls) { Debug.LogWarning("Mouseovered.SetInspector setInspector was " + StringUtils.Null + " but clearControls was " + StringUtils.False); } #endif bool changed; if (setInspector != inspector) { changed = true; #if DEV_MODE && DEBUG_SET_INSPECTOR Debug.Log(StringUtils.ToColorizedString("Mouseovered.SetInspector(", setInspector, ")")); #endif var inspectorWas = Inspector; Inspector = setInspector; if (setInspector == null) { InspectorPart = InspectorPart.None; ClearControls(); } else if (clearControls) { ClearControls(); } if (onInspectorChanged != null) { onInspectorChanged(inspectorWas, setInspector); } } else if (clearControls) { #if DEV_MODE && PI_ASSERTATIONS if (inspectorPart == InspectorPart.Viewport) { Debug.LogWarning("Mouseovered.SetInspector was called with clearControls " + StringUtils.True + " but inspector did not change and inspectorPart " + StringUtils.ToColorizedString(inspectorPart)); } #endif changed = ClearControls(); } else { changed = false; } #if DEV_MODE && PI_ASSERTATIONS Debug.Assert(Inspector == setInspector); AssertStateIsValid(); #endif return(changed); }
private static string GetTableName(IInspector classInstance) { var attributes = classInstance.EntityType.GetCustomAttributes(typeof (UseTableNameOfAttribute), false); return string.Join("_", !attributes.Any() ? classInstance.EntityType.FullName.Split('.').Skip(1) : ((UseTableNameOfAttribute) attributes[0]).UsesTableNameOf.FullName.Split('.').Skip(1)); }
static void RegisterBindings(IInspector inspector, PropertyPath pathToValue, VisualElement toBind, PropertyElement root) { var fullPath = new PropertyPath(); fullPath.PushPath(inspector.PropertyPath); fullPath.PushPath(pathToValue); root.RegisterBindings(fullPath, toBind); }
public void Clear() { Parent = null; MemberIndex = -1; inspector = null; dropTargetParentOptions.Clear(); }
public void Setup(IInspector setInspector, IGameObjectDrawer setTarget, Rect openPosition, Action setOnClosed) { onClosed = setOnClosed; SetTarget(setInspector, setTarget); Open(openPosition); setFilter = FilterString; }
public ComponentsFrm(IBootloader bootloader, IInspector inspector) { this.bootloader = bootloader; this.inspector = inspector; InitializeComponent(); Icon = Resource.Package_32; Util.fixDGVRowHeight(dgvComponents); }
/// <summary> /// </summary> /// <exception cref="InvalidOperationException">Thrown when <see cref="_inspector_Reset"/> is <c>null</c>.</exception> /// <param name="inspector"></param> /// <param name="vbe"></param> /// <param name="addin"></param> /// <param name="window"></param> public CodeInspectionsDockablePresenter(IInspector inspector, VBE vbe, AddIn addin, CodeInspectionsWindow window, GridViewSort<CodeInspectionResultGridViewItem> gridViewSort) :base(vbe, addin, window) { _inspector = inspector; _inspector.IssuesFound += _inspector_IssuesFound; _inspector.Reset += _inspector_Reset; _inspector.Parsing += _inspector_Parsing; _inspector.ParseCompleted += _inspector_ParseCompleted; _gridViewSort = gridViewSort; Control.RefreshCodeInspections += Control_RefreshCodeInspections; Control.NavigateCodeIssue += Control_NavigateCodeIssue; Control.QuickFix += Control_QuickFix; Control.CopyResults += Control_CopyResultsToClipboard; Control.Cancel += Control_Cancel; Control.SortColumn += SortColumn; }
public InspectionResultsViewModel(RubberduckParserState state, IInspector inspector, VBE vbe, INavigateCommand navigateCommand, IClipboardWriter clipboard, IGeneralConfigService configService) { _dispatcher = Dispatcher.CurrentDispatcher; _state = state; _inspector = inspector; _vbe = vbe; _navigateCommand = navigateCommand; _clipboard = clipboard; _configService = configService; _refreshCommand = new DelegateCommand(async param => await Task.Run(() => ExecuteRefreshCommandAsync(param)), CanExecuteRefreshCommand); _disableInspectionCommand = new DelegateCommand(ExecuteDisableInspectionCommand); _quickFixCommand = new DelegateCommand(ExecuteQuickFixCommand, CanExecuteQuickFixCommand); _quickFixInModuleCommand = new DelegateCommand(ExecuteQuickFixInModuleCommand); _quickFixInProjectCommand = new DelegateCommand(ExecuteQuickFixInProjectCommand); _copyResultsCommand = new DelegateCommand(ExecuteCopyResultsCommand, CanExecuteCopyResultsCommand); _state.StateChanged += _state_StateChanged; }
/// <param name="binder"></param> public EventsFrm(IBinder binder) { InitializeComponent(); this.binder = binder; inspector = new Inspector(binder.Bootloader); logic = new Logic.Events(binder.Bootloader); textEditor.codeCompletionInit(inspector); Icon = Resource.Package_32; toolTip.SetToolTip(pictureBoxWarnWait, Resource.StringWarnForWaiting); #if DEBUG this.Text = String.Format("{0} [Debug version]", Settings.APP_NAME); toolStripMenuDebugMode.Checked = true; toolStripMenuDebugMode.Enabled = false; toolStripMenuVersion.Text = String.Format("based on {0}", Version.branchSha1); #else if(Version.branchName.ToLower() != "releases") { this.Text = String.Format("{0} [Unofficial release]", Settings.APP_NAME); } toolStripMenuVersion.Text = String.Format("v{0} [ {1} ]", Version.numberString, Version.branchSha1); #endif btnApply.Location = new Point((statusStrip.Location.X - btnApply.Width) - 10, btnApply.Location.Y); // Fixes for dataGridView component with the height property Util.fixDGVRowHeight(dgvOWP); Util.fixDGVRowHeight(dgvActions); Util.fixDGVRowHeight(dgvCEFilters); Util.fixDGVRowHeight(dgvEnvCmd); Util.fixDGVRowHeight(dgvOperations); }
public CodeInspectionsToolbar(VBE vbe, IInspector inspector) { _vbe = vbe; _inspector = inspector; }
public DomParser(IInspector inspector) { Inspector = inspector; }
public ToolContext(IEnvironment env) { Log.Trace("Initialization of the clean context for testing."); bootloader = new Bootloader(env, uvariable); bootloader.register(); inspector = new Inspector(bootloader); script = new Script(bootloader); msbuild = new MSBuild.Parser(env, uvariable); }
public void OnConnectionGUI( IInspector inspector ) { // string addedTag; float newFloat; Texture2D[] tagsToggle = new Texture2D[ 2 ]; bool selectDestination = false; tagsToggle[ 1 ] = Resources.Tag; Spacer(); GUILayout.BeginHorizontal(); GUILayout.Space( 15.0f ); if( GUILayout.Button( ( showConnection ) ? Resources.Expanded : Resources.Collapsed, Resources.ListStyle, GUILayout.Width( Resources.DefaultListItemHeight ), GUILayout.Height( Resources.DefaultListItemHeight ) ) ) { showConnection = !showConnection; } if( GUILayout.Toggle( Editor.Instance.SelectedConnection.Enabled, "", GUILayout.Width( Resources.DefaultListItemHeight ), GUILayout.Height( Resources.DefaultListItemHeight ) ) != Editor.Instance.SelectedConnection.Enabled ) { Editor.Instance.SelectedConnection.Enabled = !Editor.Instance.SelectedConnection.Enabled; Editor.Instance.SaveCollection(); } // GUILayout.Label( Resources.Connection, GUILayout.Width( Resources.DefaultListItemHeight ), GUILayout.Height( Resources.DefaultListItemHeight ) ); tagsToggle[ 0 ] = Resources.Connection; connectionTags = ( GUILayout.Toolbar( connectionTags ? 1 : 0, tagsToggle, GUILayout.Height( 20.0f ) ) == 1 ); GUILayout.Label( "Connection", GUILayout.MinWidth( 20.0f ) ); GUILayout.FlexibleSpace(); // connectionTags = GUILayout.Toggle( connectionTags, Resources.Tag, GUI.skin.GetStyle( "ToolbarButton" ) ); if( GUILayout.Button( Resources.Help, GUI.skin.GetStyle( "Label" ) ) ) { Resources.Documentation( "Connection" ); } GUILayout.EndHorizontal(); if( showConnection ) { if( !connectionTags ) // Connection properties { GUILayout.BeginHorizontal(); GUILayout.Space( 15.0f ); GUILayout.BeginVertical(); // Connection origin EditorGUILayout.LabelField( "From", Editor.Instance.SelectedConnection.From.ToString() ); // Connection destination (selectable) GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal( GUILayout.Width( Resources.DefaultLeftColumnWidth ) ); GUILayout.FlexibleSpace(); GUILayout.Label( "To" ); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if( GUILayout.Button( Editor.Instance.SelectedConnection.To.ToString() ) ) { selectDestination = true; } GUILayout.EndHorizontal(); GUILayout.EndHorizontal(); // Connection width: newFloat = EditorGUILayout.FloatField( "Width", Editor.Instance.SelectedConnection.Width ); if( newFloat != Editor.Instance.SelectedConnection.Width ) { Editor.Instance.SelectedConnection.Width = newFloat; Editor.Instance.SaveCollection(); } // Connection weight factor: newFloat = EditorGUILayout.FloatField( "Weight factor", Editor.Instance.SelectedConnection.WeightFactor ); if( newFloat != Editor.Instance.SelectedConnection.WeightFactor ) { Editor.Instance.SelectedConnection.WeightFactor = newFloat; Editor.Instance.SaveCollection(); } // Return connections: GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal( GUILayout.Width( Resources.DefaultLeftColumnWidth ) ); GUILayout.FlexibleSpace(); GUILayout.Label( "Return connections" ); GUILayout.EndHorizontal(); GUILayout.BeginVertical(); if( Editor.Instance.SelectedConnection.To.Connections.Length == 0 ) { GUILayout.Label( "None" ); } else { foreach( ConnectionAsset returnConnection in Editor.Instance.SelectedConnection.To.Connections ) { if( returnConnection.To == Editor.Instance.SelectedConnection.From && GUILayout.Button( returnConnection.ToString() ) ) { Editor.Instance.SelectedNode.Clear(); Editor.Instance.SelectedNode.Add( returnConnection.From ); Editor.Instance.SelectedConnection = returnConnection; if( Browser.Instance != null ) { Browser.Instance.SelectionUpdate = true; } Editor.Instance.UpdateScene(); } } } GUILayout.EndVertical(); GUILayout.EndHorizontal(); if( selectDestination ) { Editor.Instance.SelectedNode.Add( Editor.Instance.SelectedConnection.To ); Editor.Instance.SelectedNode.RemoveAt( 0 ); Editor.Instance.SelectedConnection = null; Browser.Instance.CurrentHighlight = Browser.ItemType.Node; Editor.Instance.UpdateScene(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } else // Connection tags { selectedConnectionTag = OnTagListGUI( Editor.Instance.SelectedConnection, selectedConnectionTag ); } } }
public void OnGUI( IInspector inspector ) { if( Editor.Instance != null && Editor.Instance.Asset != null ) { // Selected network properties sheet and functions if( Editor.Instance.SelectedNetwork != null ) { OnNetworkGUI( inspector ); // Selected node properties sheet and functions if( Editor.Instance.SelectedNode.Count > 0 ) { OnNodeGUI( inspector ); // Selected connection properties sheet and functions if( Editor.Instance.SelectedConnection != null ) { OnConnectionGUI( inspector ); } } } else { Spacer(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label( "No PathBrowser selection." ); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } if( GUI.changed ) { Editor.Instance.UpdateScene(); } } Spacer(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label( Resources.Logo, GUILayout.Width( 20.0f ), GUILayout.Height( 20.0f ) ); GUILayout.BeginVertical(); GUILayout.Space( 2.0f ); GUILayout.Label( Resources.Version ); GUILayout.EndVertical(); GUILayout.EndHorizontal(); }
public void OnNetworkGUI( IInspector inspector ) { Vector3 newPosition, newSize; if( tagsToggle == null ) { tagsToggle = new Texture2D[ 2 ]; } tagsToggle[ 1 ] = Resources.Tag; EditorGUILayout.Separator(); GUILayout.BeginHorizontal(); GUILayout.Space( 15.0f ); if( GUILayout.Button( ( showNetwork ) ? Resources.Expanded : Resources.Collapsed, Resources.ListStyle, GUILayout.Width( Resources.DefaultListItemHeight ), GUILayout.Height( Resources.DefaultListItemHeight ) ) ) { showNetwork = !showNetwork; } if( GUILayout.Toggle( Editor.Instance.SelectedNetwork.Enabled, "", GUILayout.Width( Resources.DefaultListItemHeight ), GUILayout.Height( Resources.DefaultListItemHeight ) ) != Editor.Instance.SelectedNetwork.Enabled ) { Editor.Instance.SelectedNetwork.Enabled = !Editor.Instance.SelectedNetwork.Enabled; Editor.Instance.SaveCollection(); } tagsToggle[ 0 ] = Resources.Network; networkTags = ( GUILayout.Toolbar( networkTags ? 1 : 0, tagsToggle, GUILayout.Height( 20.0f ) ) == 1 ); // GUILayout.Label( Resources.Network, GUILayout.Width( Resources.DefaultListItemHeight ), GUILayout.Height( Resources.DefaultListItemHeight ) ); GUILayout.Label( Editor.Instance.SelectedNetwork.Name + ( ( Editor.Instance.SelectedNetwork is WaypointNetworkAsset ) ? " (waypoint network)" : ( ( Editor.Instance.SelectedNetwork is GridNetworkAsset ) ? " (grid network)" : " (navmesh)" ) ), GUILayout.MinWidth( 20.0f ) ); GUILayout.FlexibleSpace(); if( GUILayout.Button( Resources.Help, GUI.skin.GetStyle( "Label" ) ) ) { Resources.Documentation( "Network" ); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space( 15.0f ); GUILayout.BeginVertical(); if( showNetwork && !networkTags ) { newPosition = ( Editor.Instance.SelectedNetwork is GridNetworkAsset ) ? Editor.Instance.SelectedNetwork.Position : EditorGUILayout.Vector3Field( "Position", Editor.Instance.SelectedNetwork.Position ); newSize = ( Editor.Instance.SelectedNetwork is GridNetworkAsset ) ? Editor.Instance.SelectedNetwork.Position : EditorGUILayout.Vector3Field( "Size", Editor.Instance.SelectedNetwork.Size ); if( newPosition != Editor.Instance.SelectedNetwork.Position || newSize != Editor.Instance.SelectedNetwork.Size ) { Editor.Instance.SelectedNetwork.Position = newPosition; Editor.Instance.SelectedNetwork.Size = newSize; Editor.Instance.SaveCollection(); } if( Editor.Instance.SelectedNetwork is WaypointNetworkAsset ) { if( Editor.Instance.SelectedNetwork.Nodes.Length > 1 ) { GUILayout.BeginHorizontal(); if( GUILayout.Button( "Auto-connect", GUILayout.Width( Resources.DefaultLeftColumnWidth ) ) ) { ( ( WaypointNetworkAsset )Editor.Instance.SelectedNetwork ).AutoConnect( inspector.Transform, ( blockingLayers == -1 ) ? -1 : 1 << blockingLayers.value, connectionWidthNetwork ); Editor.Instance.UpdateScene(); Editor.Instance.SaveCollection(); } GUILayout.BeginVertical(); blockingLayers = Resources.LayerMaskField( blockingLayers ); connectionWidthNetwork = EditorGUILayout.FloatField( "Connection width", connectionWidthNetwork ); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal( GUILayout.Width( Resources.DefaultLeftColumnWidth ) ); GUILayout.FlexibleSpace(); GUILayout.Label( "Connections" ); GUILayout.EndHorizontal(); if( GUILayout.Button( "Disconnect" ) && EditorUtility.DisplayDialog( "Disconnect network?", "Are you sure that you wish to disconnect all waypoints in this network? All information on the existing connections, including tags will be lost.\n\nWARNING: This cannot be undone.", "Disconnect", "Cancel" ) ) { ( ( WaypointNetworkAsset )Editor.Instance.SelectedNetwork ).Disconnect(); Editor.Instance.SaveCollection(); } GUILayout.EndHorizontal(); } } else if( Editor.Instance.SelectedNetwork is NavmeshAsset ) { GUILayout.BeginHorizontal(); meshReference = ( Mesh )EditorGUILayout.ObjectField( "Base mesh", meshReference, typeof( Mesh ) ); if( meshReference != null ) { if( GUILayout.Button( "Autosize" ) ) { Bounds b = meshReference.bounds; Editor.Instance.SelectedNetwork.Position = b.center; Editor.Instance.SelectedNetwork.Size = b.size; Editor.Instance.SaveCollection(); } if( GUILayout.Button( "Build" ) && ( Editor.Instance.SelectedNetwork.Nodes.Length == 0 || EditorUtility.DisplayDialog( "Rebuild?", "Are you certain that you wish to rebuild the navmesh '" + Editor.Instance.SelectedNetwork.ToString() + "'?\n\nWARNING: All current data in the navmesh will be lost. This cannot be undone.", "Rebuild", "Cancel" ) ) ) { ( ( NavmeshAsset )Editor.Instance.SelectedNetwork ).Generate( meshReference ); Editor.Instance.SaveCollection(); } } GUILayout.EndHorizontal(); } else if( Editor.Instance.SelectedNetwork is GridNetworkAsset ) { GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal( GUILayout.Width( Resources.DefaultLeftColumnWidth ) ); GUILayout.FlexibleSpace(); GUILayout.Label( "Connections" ); GUILayout.EndHorizontal(); if( GUILayout.Button( "Disconnect" ) && EditorUtility.DisplayDialog( "Disconnect network?", "Are you sure that you wish to disconnect all grid nodes in this network? All information on the existing connections, including tags will be lost.\n\nWARNING: This cannot be undone.", "Disconnect", "Cancel" ) ) { ( ( GridNetworkAsset )Editor.Instance.SelectedNetwork ).Disconnect(); Editor.Instance.UpdateScene(); Editor.Instance.SaveCollection(); } GUILayout.EndHorizontal(); } } else if( showNetwork ) { selectedNetworkTag = OnTagListGUI( Editor.Instance.SelectedNetwork, selectedNetworkTag ); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); }
public bool Matches(IInspector inspector) { return !expectation.Matches(inspector); }
// TODO: In multiple node selections: Show a grid-node on the list in red if its target is null. Also don't connect it if its target is null. public void OnNodeGUI( IInspector inspector ) { bool /*newBool, */askedForConnections, addToConnections, selectTarget = false; CellAsset mergedCell; string addedTag; int[] sharedTags; Vector3 newVector3; float newFloat; NetworkAsset targetNetwork; NetworkNodeAsset targetNode; Texture2D[] tagsToggle = new Texture2D[ 2 ]; tagsToggle[ 1 ] = Resources.Tag; //GUILayout.Label( "", Resources.TextLineStyle, GUILayout.Height( 1 ) ); Spacer(); // Node properties // if( Editor.Instance.SelectedNode.Count == 1 ) // Singular selection { GUILayout.BeginHorizontal(); GUILayout.Space( 15.0f ); if( GUILayout.Button( ( showNode ) ? Resources.Expanded : Resources.Collapsed, Resources.ListStyle, GUILayout.Width( Resources.DefaultListItemHeight ), GUILayout.Height( Resources.DefaultListItemHeight ) ) ) { showNode = !showNode; } if( GUILayout.Toggle( ( ( NetworkNodeAsset )Editor.Instance.SelectedNode[ 0 ] ).Enabled, "", GUILayout.Width( Resources.DefaultListItemHeight ), GUILayout.Height( Resources.DefaultListItemHeight ) ) != ( ( NetworkNodeAsset )Editor.Instance.SelectedNode[ 0 ] ).Enabled ) { ( ( NetworkNodeAsset )Editor.Instance.SelectedNode[ 0 ] ).Enabled = !( ( NetworkNodeAsset )Editor.Instance.SelectedNode[ 0 ] ).Enabled; Editor.Instance.SaveCollection(); } tagsToggle[ 0 ] = Resources.Waypoint; nodeTags = ( GUILayout.Toolbar( nodeTags ? 1 : 0, tagsToggle, GUILayout.Height( 20.0f ) ) == 1 ); GUILayout.Label( ( ( NetworkNodeAsset )Editor.Instance.SelectedNode[ 0 ] ).Name + ( ( Editor.Instance.SelectedNode[ 0 ] is WaypointAsset ) ? " (waypoint)" : ( Editor.Instance.SelectedNode[ 0 ] is CellAsset ) ? " (navmesh cell)" : " (grid node)" ), GUILayout.MinWidth( 20.0f ) ); GUILayout.FlexibleSpace(); if( GUILayout.Button( Resources.Help, GUI.skin.GetStyle( "Label" ) ) ) { Resources.Documentation( "Node" ); } GUILayout.EndHorizontal(); if( showNode && !nodeTags ) { GUILayout.BeginHorizontal(); GUILayout.Space( 15.0f ); GUILayout.BeginVertical(); if( Editor.Instance.SelectedNode[ 0 ] is WaypointAsset ) // Waypoint specific properties { // Position newVector3 = EditorGUILayout.Vector3Field( "Position", ( Editor.Instance.SelectedNode[ 0 ] as WaypointAsset ).Position ); if( ( Editor.Instance.SelectedNode[ 0 ] as WaypointAsset ).Position != newVector3 ) { ( Editor.Instance.SelectedNode[ 0 ] as WaypointAsset ).Position = newVector3; Editor.Instance.SaveCollection(); } /* // Positioner GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal( GUILayout.Width( Resources.DefaultLeftColumnWidth ) ); GUILayout.FlexibleSpace(); GUILayout.Label( "Positioner" ); GUILayout.EndHorizontal(); if( Editor.Instance.GetWaypointPositioner( Editor.Instance.SelectedNetwork.Name, ( Editor.Instance.SelectedNode[ 0 ] as WaypointAsset ).Name ) == null ) { if( GUILayout.Button( "Create" ) ) { Editor.Instance.CreateWaypointPositioner( Editor.Instance.SelectedNetwork.Name, ( Editor.Instance.SelectedNode[ 0 ] as WaypointAsset ).Name, ( Editor.Instance.SelectedNode[ 0 ] as WaypointAsset ).Position ); } } else { GUILayout.BeginVertical(); if( GUILayout.Button( "Select" ) ) { Editor.Instance.SelectWaypointPositioner( Editor.Instance.GetWaypointPositioner( Editor.Instance.SelectedNetwork.Name, ( Editor.Instance.SelectedNode[ 0 ] as WaypointAsset ).Name ) ); } newBool = GUILayout.Toggle( ( Editor.Instance.SelectedNode[ 0 ] as WaypointAsset ).DisableRuntime, "Disable at runtime" ); if( newBool != ( Editor.Instance.SelectedNode[ 0 ] as WaypointAsset ).DisableRuntime ) { ( Editor.Instance.SelectedNode[ 0 ] as WaypointAsset ).DisableRuntime = newBool; Editor.Instance.SaveCollection(); } GUILayout.EndVertical(); } GUILayout.EndHorizontal();*/ // Radius newFloat = EditorGUILayout.FloatField( "Radius", ( Editor.Instance.SelectedNode[ 0 ] as WaypointAsset ).Radius ); if( newFloat != ( ( WaypointAsset )Editor.Instance.SelectedNode[ 0 ] ).Radius ) { ( ( WaypointAsset )Editor.Instance.SelectedNode[ 0 ] ).Radius = newFloat; Editor.Instance.SaveCollection(); } // Disconnect GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal( GUILayout.Width( Resources.DefaultLeftColumnWidth ) ); GUILayout.FlexibleSpace(); GUILayout.Label( "Connections" ); GUILayout.EndHorizontal(); if( GUILayout.Button( "Disconnect" ) ) { ( ( WaypointAsset )Editor.Instance.SelectedNode[ 0 ] ).Disconnect(); Editor.Instance.UpdateScene(); Editor.Instance.SaveCollection(); } GUILayout.EndHorizontal(); } else if( Editor.Instance.SelectedNode[ 0 ] is GridNodeAsset ) // Grid node specific properties { GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal( GUILayout.Width( Resources.DefaultLeftColumnWidth ) ); GUILayout.FlexibleSpace(); GUILayout.Label( "Target" ); GUILayout.EndHorizontal(); GUILayout.BeginVertical(); if( ( ( GridNodeAsset )Editor.Instance.SelectedNode[ 0 ] ).Target != null ) { if( GUILayout.Button( ( ( GridNodeAsset )Editor.Instance.SelectedNode[ 0 ] ).Target.Network.ToString() + "." + ( ( GridNodeAsset )Editor.Instance.SelectedNode[ 0 ] ).Target.ToString() ) ) // Select target { selectTarget = true; } } else { GUILayout.Label( "No target" ); } targetNetwork = ( NetworkAsset )Resources.PulldownPopup( "Network", new ArrayList( Editor.Instance.Collection.Networks ), "No networks in collection" ); targetNode = ( NetworkNodeAsset )Resources.PulldownPopup( "Node", ( ( GridNodeAsset )Editor.Instance.SelectedNode[ 0 ] ).Target == null ? new ArrayList() : new ArrayList( ( ( GridNodeAsset )Editor.Instance.SelectedNode[ 0 ] ).Target.Network.Nodes ), "No nodes in network" ); if( targetNetwork != null && targetNetwork.Nodes.Length > 0 ) { ( ( GridNodeAsset )Editor.Instance.SelectedNode[ 0 ] ).Target = targetNetwork.Nodes[ 0 ]; Editor.Instance.SaveCollection(); } else if( targetNode != null ) { ( ( GridNodeAsset )Editor.Instance.SelectedNode[ 0 ] ).Target = targetNode; Editor.Instance.SaveCollection(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); // Disconnect GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal( GUILayout.Width( Resources.DefaultLeftColumnWidth ) ); GUILayout.FlexibleSpace(); GUILayout.Label( "Connections" ); GUILayout.EndHorizontal(); if( GUILayout.Button( "Disconnect" ) ) { ( ( WaypointAsset )Editor.Instance.SelectedNode[ 0 ] ).Disconnect(); Editor.Instance.UpdateScene(); Editor.Instance.SaveCollection(); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); if( selectTarget ) { Editor.Instance.SelectedNetwork = ( ( GridNodeAsset )Editor.Instance.SelectedNode[ 0 ] ).Target.Network; Editor.Instance.SelectedNode.Add( ( ( GridNodeAsset )Editor.Instance.SelectedNode[ 0 ] ).Target ); Editor.Instance.SelectedNode.RemoveAt( 0 ); Browser.Instance.CurrentHighlight = Browser.ItemType.Node; Editor.Instance.UpdateScene(); } } } else if( Editor.Instance.SelectedNode.Count > 1 ) // Multiple selection { GUILayout.BeginHorizontal(); GUILayout.Space( 15.0f ); if( GUILayout.Button( ( showNode ) ? Resources.Expanded : Resources.Collapsed, Resources.ListStyle, GUILayout.Width( Resources.DefaultListItemHeight ), GUILayout.Height( Resources.DefaultListItemHeight ) ) ) { showNode = !showNode; } tagsToggle[ 0 ] = Resources.Waypoint; nodeTags = ( GUILayout.Toolbar( nodeTags ? 1 : 0, tagsToggle, GUILayout.Height( 20.0f ) ) == 1 ); // GUILayout.Label( Resources.Waypoint, GUILayout.Width( Resources.DefaultListItemHeight ), GUILayout.Height( Resources.DefaultListItemHeight ) ); GUILayout.Label( "Nodes", GUILayout.MinWidth( 20.0f ) ); GUILayout.FlexibleSpace(); // nodeTags = GUILayout.Toggle( nodeTags, Resources.Tag, GUI.skin.GetStyle( "ToolbarButton" ) ); if( GUILayout.Button( Resources.Help, GUI.skin.GetStyle( "Label" ) ) ) { Resources.Documentation( "Node" ); } GUILayout.EndHorizontal(); if( showNode ) { GUILayout.BeginHorizontal(); GUILayout.Space( 15.0f ); GUILayout.BeginVertical(); foreach( NetworkNodeAsset node in Editor.Instance.SelectedNode ) // List all nodes in selection { if( Editor.Instance.SelectedNode[ 0 ] is GridNodeAsset && ( ( GridNodeAsset )Editor.Instance.SelectedNode[ 0 ] ).Target == null ) { GUI.color = Color.red; } GUILayout.Label( node.Name + ( ( Editor.Instance.SelectedNode[ 0 ] is WaypointAsset ) ? " (waypoint)" : ( ( Editor.Instance.SelectedNode[ 0 ] is GridNodeAsset ) ? " (grid node)" : " (navmesh cell)" ) ) ); GUI.color = Color.white; } if( !nodeTags && Editor.Instance.SelectedNode[ 0 ] is WaypointAsset ) // Make connect and disconnect available if multiple waypoints are selected { GUILayout.BeginHorizontal(); if( GUILayout.Button( "Connect", GUILayout.Width( Resources.DefaultLeftColumnWidth ) ) ) // Connect { for( int i = 0; i < Editor.Instance.SelectedNode.Count - 1; i++ ) { ( Editor.Instance.SelectedNode[ i ] as WaypointAsset ).ConnectTo( Editor.Instance.SelectedNode[ i + 1 ] as NetworkNodeAsset, connectionWidthNode ); if( bidirectionalConnect ) { ( Editor.Instance.SelectedNode[ i + 1 ] as WaypointAsset ).ConnectTo( Editor.Instance.SelectedNode[ i ] as NetworkNodeAsset, connectionWidthNode ); } } Editor.Instance.SaveCollection(); Editor.Instance.SelectedNode.Clear(); } GUILayout.BeginVertical(); connectionWidthNode = EditorGUILayout.FloatField( "Connection width", connectionWidthNode ); bidirectionalConnect = GUILayout.Toggle( bidirectionalConnect, "Bi-directional" ); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal( GUILayout.Width( Resources.DefaultLeftColumnWidth ) ); GUILayout.FlexibleSpace(); GUILayout.Label( "Connections" ); GUILayout.EndHorizontal(); if( GUILayout.Button( "Disconnect" ) && EditorUtility.DisplayDialog( "Remove all connections?", "Are you sure that you wish to remove all connections from the selected waypoints?\n\nWARNING: Disconnect on multi-selections removes all connections going from the selected waypoints to any other waypoint - whether it is part of the selection or not. This cannot be undone.", "Disconnect", "Cancel" ) ) // Disconnect { foreach( WaypointAsset waypoint in Editor.Instance.SelectedNode ) { waypoint.Disconnect(); } Editor.Instance.SaveCollection(); } GUILayout.EndHorizontal(); } else if( !nodeTags && Editor.Instance.SelectedNode[ 0 ] is GridNodeAsset ) // Make connect and disconnect available if multiple grid nodes are selected { GUILayout.BeginHorizontal(); if( GUILayout.Button( "Connect", GUILayout.Width( Resources.DefaultLeftColumnWidth ) ) ) // Connect { for( int i = 0; i < Editor.Instance.SelectedNode.Count - 1; i++ ) { ( Editor.Instance.SelectedNode[ i ] as GridNodeAsset ).ConnectTo( Editor.Instance.SelectedNode[ i + 1 ] as GridNodeAsset, connectionWidthNode ); if( bidirectionalConnect ) { ( Editor.Instance.SelectedNode[ i + 1 ] as GridNodeAsset ).ConnectTo( Editor.Instance.SelectedNode[ i ] as GridNodeAsset, connectionWidthNode ); } } Editor.Instance.SaveCollection(); Editor.Instance.SelectedNode.Clear(); } GUILayout.BeginVertical(); connectionWidthNode = EditorGUILayout.FloatField( "Connection width", connectionWidthNode ); bidirectionalConnect = GUILayout.Toggle( bidirectionalConnect, "Bi-directional" ); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal( GUILayout.Width( Resources.DefaultLeftColumnWidth ) ); GUILayout.FlexibleSpace(); GUILayout.Label( "Connections" ); GUILayout.EndHorizontal(); if( GUILayout.Button( "Disconnect" ) && EditorUtility.DisplayDialog( "Remove all connections?", "Are you sure that you wish to remove all connections from the selected grid nodes?\n\nWARNING: Disconnect on multi-selections removes all connections going from the selected grid nodes to any other grid node - whether it is part of the selection or not. This cannot be undone.", "Disconnect", "Cancel" ) ) // Disconnect { foreach( GridNodeAsset node in Editor.Instance.SelectedNode ) { node.Disconnect(); } Editor.Instance.SaveCollection(); } GUILayout.EndHorizontal(); } else if( !nodeTags && Editor.Instance.SelectedNode[ 0 ] is CellAsset ) // Make merge available if cell assets are selected { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if( GUILayout.Button( "Merge" ) ) { mergedCell = CellAsset.Merge( Editor.Instance.SelectedNode ); ( ( NavmeshAsset )Editor.Instance.SelectedNetwork ).ReplaceConnections( Editor.Instance.SelectedNode, mergedCell ); foreach( CellAsset oldCell in Editor.Instance.SelectedNode ) { ( ( NavmeshAsset )Editor.Instance.SelectedNetwork ).Remove( oldCell ); } ( ( NavmeshAsset )Editor.Instance.SelectedNetwork ).Add( mergedCell ); Editor.Instance.SelectedNode.Clear(); Debug.Log( "TODO: Control should scan all cell networks for connections leading to any of the cells and these should be replaced by new connections to the new cell" ); Editor.Instance.SaveCollection(); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } } if( !showNode || !nodeTags ) { return; } // Node tags toolbar // sharedTags = Resources.SharedTags( Editor.Instance.SelectedNode ); GUILayout.BeginHorizontal( /*"Toolbar"*/ ); Spacer(); //GUILayout.Label( "Tags" ); //GUILayout.FlexibleSpace(); addedTag = Resources.PulldownPopup( "Add tag", new ArrayList( Editor.Instance.Collection.Tags ), "No tags in collection" ) as string; if( addedTag != null ) // Add the new tag { askedForConnections = false; addToConnections = false; foreach( NetworkNodeAsset node in Editor.Instance.SelectedNode ) // Apply the tag to all nodes in selection { node.AddTag( addedTag ); if( !askedForConnections && node.Connections.Length > 0 ) // Ask if the tag should be applied to all connections from the nodes in the selection { askedForConnections = true; if( EditorUtility.DisplayDialog( "Apply to connections?", "Should the tag \"" + addedTag + "\" be applied to the connections from the selection as well?", "Apply", "Do not apply" ) ) { addToConnections = true; } } if( addToConnections ) // Apply the tag to all connections of the node { foreach( ConnectionAsset connection in node.Connections ) { connection.AddTag( addedTag ); } } } Editor.Instance.SaveCollection(); } if( ( /*Editor.Instance.SelectedNode.Count > 1 && */System.Array.IndexOf( sharedTags, selectedNodeTag ) != -1 ) && GUILayout.Button( "Delete", GUILayout.Height( 15.0f ) ) ) { foreach( TaggedAsset asset in Editor.Instance.SelectedNode ) { asset.RemoveTag( selectedNodeTag ); } Editor.Instance.SaveCollection(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); // Node tags list // GUILayout.BeginHorizontal(); Spacer(); GUILayout.BeginVertical(); if( Editor.Instance.SelectedNode.Count == 1 ) { if( ( Editor.Instance.SelectedNode[ 0 ] as NetworkNodeAsset ).Tags.Length == 0 ) { GUILayout.Label( "No tags added" ); } else { selectedNodeTag = ( int )Resources.SelectList( ( Editor.Instance.SelectedNode[ 0 ] as NetworkNodeAsset ).Tags, selectedNodeTag, OnTagListItemGUI ); } } else { if( sharedTags.Length > 0 ) { selectedNodeTag = ( int )Resources.SelectList( sharedTags, selectedNodeTag, OnTagListItemGUI ); } else { GUILayout.Label( "No shared tags in selection" ); } } GUILayout.EndVertical(); GUILayout.EndHorizontal(); }
public DomParser(IInspector inspector, IMSBuild msbuild = null) { Inspector = inspector; MSBuild = msbuild; }
/// <param name="binder"></param> public EventsFrm(IBinder binder) { InitializeComponent(); this.binder = binder; inspector = new Inspector(binder.Bootloader); logic = new Logic.Events(binder.Bootloader); textEditor.codeCompletionInit(inspector, new MSBuild.Parser(binder.Bootloader.Env, binder.Bootloader.UVariable)); Icon = Resource.Package_32; toolTip.SetToolTip(pictureBoxWarnWait, Resource.StringWarnForWaiting); #if DEBUG this.Text = String.Format("{0} [Debug version]", Settings.APP_NAME); toolStripMenuDebugMode.Checked = true; toolStripMenuDebugMode.Enabled = false; toolStripMenuVersion.Text = String.Format("based on {0}", Version.branchSha1); #else if(Version.branchName.ToLower() != "releases") { this.Text = String.Format("{0} [Unofficial release]", Settings.APP_NAME); } toolStripMenuVersion.Text = String.Format("v{0} [ {1} ]", Version.numberString, Version.branchSha1); #endif btnApply.Location = new Point((statusStrip.Location.X - btnApply.Width) - 10, btnApply.Location.Y); //TODO: it was before with original dataGridView... need to check with DataGridViewExt and move it inside if still needed foreach(Control ctrl in Util.getControls(this, c => c.GetType() == typeof(DataGridViewExt))) { Util.fixDGVRowHeight((DataGridViewExt)ctrl); // solves problem with the height property } }
/// <summary> /// Updating model of the data for code completion /// </summary> /// <param name="inspector"></param> public void codeCompletionInit(IInspector inspector) { dom = new DomParser(inspector); Log.Trace("Code completion has been initialized for '{0}'", Name); }
/// <summary> /// Updating model of the data for code completion /// </summary> /// <param name="inspector"></param> /// <param name="msbuild"></param> public void codeCompletionInit(IInspector inspector, IMSBuild msbuild = null) { dom = new DomParser(inspector, msbuild); Log.Trace("Code completion has been initialized for '{0}'", Name); }