/// <summary> /// Sets given object as a source provide of 'Properties Window' inside Visual Studio IDE. /// </summary> /// <param name="currentWindow">Source window, that requests set.</param> /// <param name="sourceObject">Object, which properties will be edited.</param> public void SelectAtProperties(Window2 currentWindow, object sourceObject) { //IVsUIShell shell = parent.GetService(typeof(SVsUIShell)) as IVsUIShell; //Guid guidPropertyBrowser = new Guid(ToolWindowGuids.PropertyBrowser); //IVsWindowFrame frame = null; //if (shell != null) // shell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fForceCreate, ref guidPropertyBrowser, out frame); //if (frame != null) // frame.ShowNoActivate(); ITrackSelection trackSelection = GetService(typeof(STrackSelection)) as ITrackSelection; if (trackSelection != null) { selectedItems.Clear(); if (sourceObject != null) { selectedItems.Add(sourceObject); } selectionContainer.SelectedObjects = selectedItems; trackSelection.OnSelectChange(selectionContainer); } else { if (sourceObject != null && currentWindow != null) { selectedElements[0] = sourceObject; currentWindow.SetSelectionContainer(ref selectedElements); currentWindow.Activate(); } } }
/// <include file='doc\ShellDocumentManager.uex' path='docs/doc[@for="ShellDocumentManager.OnSelectionChanged"]/*' /> /// <devdoc> /// This should be called at any time when the selection itself hasn't /// changed, but the contents of that selection have changed. /// </devdoc> public override void OnSelectionChanged(ISelectionService selection) { // Announce to Visual Studio that the selection has changed. We don't // call base here, because we want this to loop back around through // IVsMonitorSelection. // IDesignerHost host = ActiveDesigner; Debug.Assert(selection == null || selection is ISelectionContainer, "Shell requires that selection service also implement ISelectionContainer"); if (host != null && (selection == null || selection is ISelectionContainer)) { ITrackSelection trackSelection = (ITrackSelection)host.GetService(typeof(ITrackSelection)); if (trackSelection != null) { if (selection is ISelectionContainerOptimized && trackSelection is ITrackSelectionOptimized) { ((ITrackSelectionOptimized)trackSelection).OnSelectChange((ISelectionContainerOptimized)selection); } else { trackSelection.OnSelectChange((ISelectionContainer)selection); } } } }
public ITrackSelection GetITrackSelectionService() { if (trackSel == null) { trackSel = GetService(typeof(STrackSelection)) as ITrackSelection; } return(trackSel); }
/// <summary> /// Updates the Properties window with the public properties of the selection objects. /// </summary> public void ApplySelection() { ITrackSelection track = TrackSelection; if (track != null) { track.OnSelectChange((ISelectionContainer)_selectionContainer); } }
/// <summary> // Update the selection in the Properties window. /// </summary> public void UpdateSelection() { ITrackSelection track = TrackSelection; if (track != null) { track.OnSelectChange((ISelectionContainer)selectionContainer); } }
/// <summary> /// Updates the Properties window with the public properties of the selection objects. /// </summary> public void ApplySelection() { ThreadHelper.ThrowIfNotOnUIThread(); ITrackSelection track = TrackSelection; if (track != null) { track.OnSelectChange((ISelectionContainer)_selectionContainer); } }
protected override void OnCreate() { base.OnCreate(); // set up our property window tracking SelectionContainer selContainer = new SelectionContainer(); selContainer.SelectableObjects = objectsForInspection; selContainer.SelectedObjects = objectsForInspection; ITrackSelection trackSelectionRef = GetService(typeof(STrackSelection)) as ITrackSelection; trackSelectionRef.OnSelectChange(selContainer); }
public static void UpdateSubAspectProperties(PointOfInterest point, TreeNode node, ITrackSelection trackSel) { VSSubAspectProperties prop = new VSSubAspectProperties(point, node); ArrayList listObjects = new ArrayList(); listObjects.Add(prop); selContainer = new SelectionContainer(true, false); selContainer.SelectableObjects = listObjects; selContainer.SelectedObjects = listObjects; trackSel.OnSelectChange((ISelectionContainer)selContainer); }
public void OnSelectChanged(object p) { selContainer = new Microsoft.VisualStudio.Shell.SelectionContainer(true, false); ArrayList items = new ArrayList(); items.Add(p); selContainer.SelectableObjects = items; selContainer.SelectedObjects = items; ITrackSelection track = TrackSelection; if (track != null) { track.OnSelectChange((ISelectionContainer)selContainer); } }
public void OnTracksChanged(TrackGroupArray p0, TrackSelectionArray p1) { var trackGroupArray = new TrackGroup[p0.Length]; for (var i = 0; i < p0.Length; i++) { trackGroupArray[i] = p0.Get(i); } var trackSelectionArray = new ITrackSelection[p1.Length]; for (var i = 0; i < p1.Length; i++) { trackSelectionArray[i] = p1.Get(i); } TracksChanged?.Invoke(trackGroupArray, trackSelectionArray); }
protected void UpdatePropertyGrid(object selection) { object[] selectedObjects; if (selection == null) { selectedObjects = null; } else { selectedObjects = new object[] { selection } }; _selectionContainer.SelectableObjects = selectedObjects; _selectionContainer.SelectedObjects = selectedObjects; ITrackSelection trackSelection = (ITrackSelection)_serviceProvider.GetService(typeof(SVsTrackSelectionEx)); ErrorHandler.ThrowOnFailure(trackSelection.OnSelectChange(_selectionContainer)); }
public void TrackSelection() { SelectedTextBox = editorControl.tbDropData; if (frame == null) { var shell = GetService(typeof(SVsUIShell)) as IVsUIShell; if (shell != null) { var guidPropertyBrowser = new Guid(ToolWindowGuids.PropertyBrowser); shell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fForceCreate, ref guidPropertyBrowser, out frame); } } if (frame != null) { frame.Show(); } if (mySelContainer == null) { mySelContainer = new SelectionContainer(); } mySelItems = new System.Collections.ArrayList(); var selected = SelectedTextBox; if (selected != null) { mySelItems.Add(selected); } mySelContainer.SelectedObjects = mySelItems; ITrackSelection track = GetService(typeof(STrackSelection)) as ITrackSelection; if (track != null) { track.OnSelectChange(mySelContainer); } }
private void TrackSelection() { if (frame == null) { var shell = parent.GetVsService(typeof(SVsUIShell)) as IVsUIShell; if (shell != null) { var guidPropertyBrowser = new Guid(ToolWindowGuids.PropertyBrowser); shell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fForceCreate, ref guidPropertyBrowser, out frame); } } if (frame != null) { frame.Show(); } if (mySelContainer == null) { mySelContainer = new SelectionContainer(); } mySelItems = new System.Collections.ArrayList(); var selected = listBox.SelectedItem as TodoItem; if (selected != null) { mySelItems.Add(selected); } mySelContainer.SelectedObjects = mySelItems; ITrackSelection track = parent.GetVsService(typeof(STrackSelection)) as ITrackSelection; if (track != null) { track.OnSelectChange(mySelContainer); } }
public static T Get <T>(this IServiceProvider serviceProvider) { if (typeof(T) == typeof(ITrackSelection)) { return((T)(trackSelection ?? (trackSelection = VisualStudioDTE.GetITrackSelection(VisualStudioIds.TeamExplorerToolWindowId.ToGuid())))); } if (serviceProvider != null) { if (vsServiceMapping.ContainsKey(typeof(T))) { return((T)serviceProvider.GetService(vsServiceMapping[typeof(T)])); } if (typeof(T) == typeof(VersionControlExt)) { return((T)Get <DTE2>(serviceProvider).GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt")); } return((T)serviceProvider.GetService(typeof(T))); } return(default(T)); }
private void TrackSelection(UIControlBase control) { if (frame == null) { IVsUIShell shell = GetService(typeof(SVsUIShell)) as IVsUIShell; if (shell != null) { Guid guidPropertyBrowser = new Guid(ToolWindowGuids.PropertyBrowser); shell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fForceCreate, ref guidPropertyBrowser, out frame); } } if (frame != null) { frame.Show(); } if (mySelContainer == null) { mySelContainer = new Microsoft.VisualStudio.Shell.SelectionContainer(); } mySelItems = new System.Collections.ArrayList(); if (control != null) { mySelItems.Add(control); } mySelContainer.SelectedObjects = mySelItems; ITrackSelection track = GetService(typeof(STrackSelection)) as ITrackSelection; if (track != null) { track.OnSelectChange(mySelContainer); } }
private void Control_Loaded(object sender, System.Windows.RoutedEventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); // Subscribe to the error list event service so we // can properly update the data context of this control when the selection changes. if (this.sarifErrorListEventSelectionService != null) { this.sarifErrorListEventSelectionService.NavigatedItemChanged += this.SarifListErrorItemNavigated; this.UpdateDataContext(this.sarifErrorListEventSelectionService.NavigatedItem); } // Subscribe to the caret listener service so we can ensure the proper call tree node // is selected when the caret enters a tag representing a call tree node. if (this.textViewCaretListenerService != null) { this.textViewCaretListenerService.CaretEnteredTag += this.TextViewCaretListenerService_CaretEnteredTag; } // Update the selection. this._trackSelection = this.GetService(typeof(STrackSelection)) as ITrackSelection; this._trackSelection.OnSelectChange(this._selectionContainer); }
public ITrackSelection GetITrackSelectionService() { if (trackSel == null) trackSel = GetService(typeof(STrackSelection)) as ITrackSelection; return trackSel; }
/// <summary> /// Initialization routine for the Editor. Loads the list of properties for the document /// which will show up in the properties window /// </summary> /// <param name="package"></param> private void PrivateInit(XSharpProjectPackage package) { myPackage = package; loading = false; gettingCheckoutStatus = false; trackSel = null; Control.CheckForIllegalCrossThreadCalls = false; // Create an ArrayList to store the objects that can be selected ArrayList listObjects = new ArrayList(); // Create the object that will show the document's properties // on the properties window. VOEditorProperties prop = new VOEditorProperties(this); listObjects.Add(prop); // Create the SelectionContainer object. selContainer = new Microsoft.VisualStudio.Shell.SelectionContainer(true, false); selContainer.SelectableObjects = listObjects; selContainer.SelectedObjects = listObjects; // Create and initialize the editor this.editorControl = new VOWEDControl(); this.editorControl.IsDirtyChanged = new EventHandler(IsDirtyChangedHandler); this.editorControl.TriggerSave = new EventHandler(TriggerSaveHandler); setupCommands(); this.editorControl.StatusBarMessage = new StatusBarMessageDelegate(StatusBarMessageHandler); }
/// <summary> /// Initialization routine for the editor. Loads the list of properties for the nuset document /// which will show up in the properties window /// </summary> /// <param name="package"> /// The package /// </param> private void PrivateInit(NuSetPackage package) { this.myPackage = package; this.editorIsLoading = false; this.editorIsGettingCheckoutStatus = false; this.trackSelection = null; Control.CheckForIllegalCrossThreadCalls = false; // Create an ArrayList to store the objects that can be selected var listObjects = new ArrayList(); // Create the object that will show the document's properties // on the properties window. var prop = new EditorProperties(this); listObjects.Add(prop); // Create the SelectionContainer object. this.selectionContainer = new SelectionContainer(true, false) { SelectableObjects = listObjects, SelectedObjects = listObjects }; // Create and initialize the editor var resources = new ComponentResourceManager(typeof(EditorPane)); this.EditorControl = new MyEditor(); resources.ApplyResources(this.EditorControl, "EditorControl", CultureInfo.CurrentUICulture); // Event handlers for macro recording. this.EditorControl.RichTextBoxControl.TextChanged += this.OnTextChange; this.EditorControl.RichTextBoxControl.MouseDown += this.OnMouseClick; this.EditorControl.RichTextBoxControl.SelectionChanged += this.OnSelectionChanged; this.EditorControl.RichTextBoxControl.KeyDown += this.OnKeyDown; // Handle Focus event this.EditorControl.RichTextBoxControl.GotFocus += this.OnGotFocus; // Call the helper function that will do all of the command setup work this.SetupCommands(); }
// -------------------------------------------------------------------------------------------- /// <summary> /// Creates a new selection tracker instance. /// </summary> /// <param name="provider">Service provider to obtain the selection tracker from.</param> /// <param name="selectableRO">Is the collection of selectable objects read only?</param> /// <param name="selectedRO">Is the collection of selected objects read only?</param> // -------------------------------------------------------------------------------------------- public SelectionTracker(IServiceProvider provider, bool selectableRO, bool selectedRO) { _TrackSelection = provider.GetService <STrackSelection, ITrackSelection>(); _Container = new SelectionContainer(selectableRO, selectedRO); Unselect(); }
/// <summary> /// Initialization routine for the Editor. Loads the list of properties for the resx-aggregator document /// which will show up in the properties window /// </summary> /// <param name="package"></param> private void PrivateInit(ResX_AggregatorPackage package) { myPackage = package; loading = false; gettingCheckoutStatus = false; trackSel = null; Control.CheckForIllegalCrossThreadCalls = false; // Create an ArrayList to store the objects that can be selected ArrayList listObjects = new ArrayList(); // Create the object that will show the document's properties // on the properties window. EditorProperties prop = new EditorProperties(this); listObjects.Add(prop); // Create the SelectionContainer object. selContainer = new Microsoft.VisualStudio.Shell.SelectionContainer(true, false); selContainer.SelectableObjects = listObjects; selContainer.SelectedObjects = listObjects; // Create and initialize the editor System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditorPane)); this.editorControl = new MyEditor(); resources.ApplyResources(this.editorControl, "editorControl", CultureInfo.CurrentUICulture); // Event handlers for macro recording. this.editorControl.RichTextBoxControl.TextChanged += new System.EventHandler(this.OnTextChange); this.editorControl.RichTextBoxControl.MouseDown += new MouseEventHandler(this.OnMouseClick); this.editorControl.RichTextBoxControl.SelectionChanged += new EventHandler(this.OnSelectionChanged); this.editorControl.RichTextBoxControl.KeyDown += new KeyEventHandler(this.OnKeyDown); // Handle Focus event this.editorControl.RichTextBoxControl.GotFocus += new EventHandler(this.OnGotFocus); // Call the helper function that will do all of the command setup work setupCommands(); }
public SelectionService(IServiceProvider serviceProvider) { this.trackSelection = serviceProvider.GetService<ITrackSelection>(); this.selectionContainer = new SelectionContainer(); }
/// <summary> /// Initialization routine for the Editor. Loads the list of properties for the dal document /// which will show up in the properties window /// </summary> /// <param name="package"></param> private void PrivateInit(SimpleDataAccessLayerConfigFileEditorPackage package) { myPackage = package; loading = false; gettingCheckoutStatus = false; trackSel = null; Control.CheckForIllegalCrossThreadCalls = false; // Create an ArrayList to store the objects that can be selected ArrayList listObjects = new ArrayList(); // Create the object that will show the document's properties // on the properties window. EditorProperties prop = new EditorProperties(this); listObjects.Add(prop); // Create the SelectionContainer object. selContainer = new Microsoft.VisualStudio.Shell.SelectionContainer(true, false); selContainer.SelectableObjects = listObjects; selContainer.SelectedObjects = listObjects; // Create and initialize the editor System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditorPane)); this.editorControl = new MyEditor(); resources.ApplyResources(this.editorControl, "editorControl", CultureInfo.CurrentUICulture); // Handle Focus event // I should override this one //this.editorControl.RichTextBoxControl.GotFocus += new EventHandler(this.OnGotFocus); // Call the helper function that will do all of the command setup work // -- no commands here // setupCommands(); }
private void SelectNodeWithProperties(CFGNode node) { IVsWindowFrame frame = null; if (frame == null) { var shell = _parent.GetVsService(typeof(SVsUIShell)) as IVsUIShell; if (shell != null) { var guidPropertyBrowser = new Guid(ToolWindowGuids.PropertyBrowser); shell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fForceCreate, ref guidPropertyBrowser, out frame); } } if (frame != null) { frame.Show(); } var selContainer = new Microsoft.VisualStudio.Shell.SelectionContainer(); var items = new List <CFGNode>(); items.Add(node); selContainer.SelectedObjects = items; ITrackSelection track = _parent.GetVsService(typeof(STrackSelection)) as ITrackSelection; if (track != null) { track.OnSelectChange(selContainer); } if ((Keyboard.Modifiers & ModifierKeys.Control) > 0) { // If control is pressed then to nothing } else { foreach (var v in GraphControl.Graph.Vertices) { if (v.IsSelected) { v.Deselect(); } } DecorateVerticesBackground(); } IVsStatusbar statusBar = (IVsStatusbar)_parent.GetVsService(typeof(SVsStatusbar)); // Make sure the status bar is not frozen int frozen; statusBar.IsFrozen(out frozen); if (frozen != 0) { statusBar.FreezeOutput(0); } // Set the status bar text and make its display static. statusBar.SetText(node.MethodName + " (" + node.SourceCodeMappingString + ")"); // Freeze the status bar. statusBar.FreezeOutput(1); }
public SelectionService(IServiceProvider serviceProvider) { this.trackSelection = serviceProvider.GetService <ITrackSelection>(); this.selectionContainer = new SelectionContainer(); }
private static string getTrackStatusString(ITrackSelection selection, TrackGroup group, int trackIndex) { return(getTrackStatusString(selection != null && selection.TrackGroup == group && selection.IndexOf(trackIndex) != C.IndexUnset)); }
/// <summary> /// Initialization routine for the Editor. Loads the list of properties for the dal document /// which will show up in the properties window /// </summary> /// <param name="package"></param> private void PrivateInit(SimpleDataAccessLayerPackage package) { _myPackage = package; _loading = false; _gettingCheckoutStatus = false; _trackSel = null; Control.CheckForIllegalCrossThreadCalls = false; // Create an ArrayList to store the objects that can be selected var listObjects = new ArrayList(); // Create the object that will show the document's properties // on the properties window. var prop = new EditorProperties(this); listObjects.Add(prop); // Create the SelectionContainer object. _selContainer = new SelectionContainer(true, false) { SelectableObjects = listObjects, SelectedObjects = listObjects }; // Create and initialize the editor var resources = new ComponentResourceManager(typeof(EditorPane)); _editorControl = new MainEditorWindow(); //resources.ApplyResources(_editorControl, "editorControl", CultureInfo.CurrentUICulture); // Handle Focus event // I should override this one //this.editorControl.RichTextBoxControl.GotFocus += new EventHandler(this.OnGotFocus); // Call the helper function that will do all of the command setup work // -- no commands here // setupCommands(); }
/// <summary> /// Initialization routine for the Editor. Loads the list of properties for the xml document /// which will show up in the properties window /// </summary> /// <param name="package"></param> private void PrivateInit(PowerShellToolsPackage package, string fileName) { myPackage = package; loading = false; gettingCheckoutStatus = false; trackSel = null; Control.CheckForIllegalCrossThreadCalls = false; // Create an ArrayList to store the objects that can be selected ArrayList listObjects = new ArrayList(); // Create the object that will show the document's properties // on the properties window. EditorProperties prop = new EditorProperties(this); listObjects.Add(prop); // Create the SelectionContainer object. selContainer = new Microsoft.VisualStudio.Shell.SelectionContainer(true, false); selContainer.SelectableObjects = listObjects; selContainer.SelectedObjects = listObjects; // Create and initialize the editor System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditorPane)); this.editorControl = new EditorControl(fileName); resources.ApplyResources(this.editorControl, "editorControl", CultureInfo.CurrentUICulture); }
/// <summary> /// Initialize the propery window by createing the codeWindowHost properties class and a selection container /// </summary> private void InitializePropertiesWindow() { trackSel = null; // Create an ArrayList to store the objects that can be selected ArrayList listObjects = new ArrayList(); //Add a custom type provider to filter the properties TypeDescriptor.AddProvider(new FilteredPropertiesTypeDescriptorProvider(typeof (EditorProperties)), typeof (EditorProperties)); // Create the object that will show the document's properties // on the properties window. EditorProperties prop = new EditorProperties(this); listObjects.Add(prop); // Create the SelectionContainer object. selContainer = new SelectionContainer(true, false); selContainer.SelectableObjects = listObjects; selContainer.SelectedObjects = listObjects; }
/// <summary> /// Initialization routine for the Editor. Loads the list of properties for the pnml document /// which will show up in the properties window /// </summary> /// <param name="package"></param> private void PrivateInit(PetrifierPackage package) { this.package = package; loading = false; gettingCheckoutStatus = false; trackSel = null; Control.CheckForIllegalCrossThreadCalls = false; // Create an ArrayList to store the objects that can be selected ArrayList listObjects = new ArrayList(); // Create the object that will show the document's properties // on the properties window. EditorProperties prop = new EditorProperties(this); listObjects.Add(prop); // Create the SelectionContainer object. selContainer = new Microsoft.VisualStudio.Shell.SelectionContainer(true, false); selContainer.SelectableObjects = listObjects; selContainer.SelectedObjects = listObjects; // Create and initialize the editor System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PetriNetEditorPane)); editorControl = new PetriNetDesigner(); editorControl.SelectionChanged += (sender, args) => { isDirty = true; RefreshObjectSelection(); }; resources.ApplyResources(this.editorControl, "editorControl", CultureInfo.CurrentUICulture); // Call the helper function that will do all of the command setup work setupCommands(); }