internal static Action Create(ViewModelController controller, string name) { using (new UndoRedo.DontLogBlock(controller)) { return(new Action(controller, controller.StateMachine.Actions, name)); } }
internal static Group Create(ViewModelController controller, IconControls.OptionsPropertiesPage optionsPage, ViewModel.Layer currentLayer) { using (new UndoRedo.DontLogBlock(controller)) { return(new Group(controller, optionsPage.GroupRootName, currentLayer)); } }
public void VsTextViewCreated(IVsTextView textViewAdapter) { TextView = AdapterService.GetWpfTextView(textViewAdapter); if (TextView == null) { return; } TextBuffer = TextView.TextBuffer as ITextBuffer2; if (TextBuffer == null) { return; } if (TextView.TextBuffer.Properties.ContainsProperty(typeof(ITextDocument))) { FileName = (TextView.TextBuffer.Properties[typeof(ITextDocument)] as ITextDocument).FilePath; if (System.IO.Path.GetExtension(FileName).ToLower() == EditorFactory.Extension.ToLower() && textViewAdapter.GetBuffer(out IVsTextLines textLines) == VSConstants.S_OK) { Model = ViewModelCoordinator.GetViewModel(FileName, textLines); TextView.Closed += TextViewClosedHandler; TextBuffer.ChangedOnBackground += TextBufferChangedHandler; IsRegisteredForChangeTracking = true; } } }
internal static EventType Create(ViewModelController controller, IconControls.OptionsPropertiesPage optionsPage) { using (new UndoRedo.DontLogBlock(controller)) { return(new EventType(controller, optionsPage.EventTypeRootName)); } }
// Constructor for Redo internal ActionReference(ViewModelController controller, UndoRedo.AddActionReferenceRecord redoRecord) : base(controller, redoRecord) { using (new UndoRedo.DontLogBlock(controller)) { Transition = Find(redoRecord.TransitionId) as Transition; Action = Find(redoRecord.ActionId) as Action; } }
internal static ViewModel.ViewModelController GetViewModel(string fileName, IVsTextLines textLines) { lock (ViewModels) { if (!ViewModels.ContainsKey(fileName)) { ViewModels.Add(fileName, new ViewModel.ViewModelController(textLines, fileName)); } ViewModel.ViewModelController viewModelController = ViewModels[fileName]; viewModelController.ReferenceCount++; return(viewModelController); } }
internal static void ReleaseViewModel(string fileName) { lock (ViewModels) { if (ViewModels.ContainsKey(fileName)) { ViewModel.ViewModelController viewModelController = ViewModels[fileName]; if (--viewModelController.ReferenceCount == 0) { ViewModels.Remove(fileName); viewModelController.Dispose(); } } } }
// Constructor for new object creation through commands private Action(ViewModelController controller, IEnumerable <ObjectModel.NamedObject> existingObjectList, string rootName) : base(controller, existingObjectList, rootName) { }
// Constructor for new object creation during DeserializationCleanup internal Action(ViewModelController controller, string name) : base(controller, name) { }
// Constructor for new object creation through commands private Group(ViewModelController controller, string rootName, ViewModel.Layer currentLayer) : base(controller, controller.StateMachine.Groups, rootName, currentLayer) { }
// Constructor for new object creation through commands private TransitionHost(ViewModelController controller, string rootName, ViewModel.Layer currentLayer) : base(controller, controller.StateMachine.States, rootName, currentLayer) { TransitionsFrom = new ObservableCollection <ObjectModel.ITransition>(); TransitionsTo = new ObservableCollection <ObjectModel.ITransition>(); }
// Constructor for general use public ActionReference(ViewModelController controller, Transition transition, Action action) : base(controller) { Transition = transition; Action = action; Action.Removing += ActionIsBeingRemovedHandler; }
// Constructor for new object creation through commands private EventType(ViewModelController controller, string rootName) : base(controller, controller.StateMachine.EventTypes, rootName) { }
/// <summary> /// Called after the WindowPane has been sited with an IServiceProvider from the environment /// protected override void Initialize() { ThreadHelper.ThrowIfNotOnUIThread(); base.Initialize(); // Create and initialize the editor #region Register with IOleComponentManager IOleComponentManager componentManager = (IOleComponentManager)GetService(typeof(SOleComponentManager)); if (this._componentId == 0 && componentManager != null) { OLECRINFO[] crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime; crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff; crinfo[0].uIdleTimeInterval = 100; int hr = componentManager.FRegisterComponent(this, crinfo, out this._componentId); ErrorHandler.Succeeded(hr); } #endregion ComponentResourceManager resources = new ComponentResourceManager(typeof(EditorPane)); #region Hook Undo Manager // Attach an IOleUndoManager to our WindowFrame. Merely calling QueryService // for the IOleUndoManager on the site of our IVsWindowPane causes an IOleUndoManager // to be created and attached to the IVsWindowFrame. The WindowFrame automaticall // manages to route the undo related commands to the IOleUndoManager object. // Thus, our only responsibilty after this point is to add IOleUndoUnits to the // IOleUndoManager (aka undo stack). _undoManager = (IOleUndoManager)GetService(typeof(SOleUndoManager)); // In order to use the IVsLinkedUndoTransactionManager, it is required that you // advise for IVsLinkedUndoClient notifications. This gives you a callback at // a point when there are intervening undos that are blocking a linked undo. // You are expected to activate your document window that has the intervening undos. if (_undoManager != null) { IVsLinkCapableUndoManager linkCapableUndoMgr = (IVsLinkCapableUndoManager)_undoManager; if (linkCapableUndoMgr != null) { linkCapableUndoMgr.AdviseLinkedUndoClient(this); } } #endregion // hook up our _model = ViewModelCoordinator.GetViewModel(_fileName, _textBuffer); _model.UndoManager = _undoManager; // Set up the build action for this file SetBuildAction(_fileName); // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable, // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on // the object returned by the Content property. _vsDesignerControl = new DesignerControl(_thisPackage, _model, GetService(typeof(STrackSelection)) as ITrackSelection); Content = _vsDesignerControl; RegisterIndependentView(true); IMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as IMenuCommandService; if (null != mcs) { // Now create one object derived from MenuCommnad for each command defined in // the CTC file and add it to the command service. // For each command we have to define its id that is a unique Guid/integer pair, then // create the OleMenuCommand object for this command. The EventHandler object is the // function that will be called when the user will select the command. Then we add the // OleMenuCommand to the menu service. The addCommand helper function does all this for us. AddCommand(mcs, VSConstants.GUID_VSStandardCommandSet97, (int)VSStd97CmdID.ViewCode, new EventHandler(OnViewCode), new EventHandler(OnQueryViewCode)); } InitializeToolbox(); }