/// <summary> /// Creates a new view digram for the pattern model. /// </summary> /// <param name="patternModel">The pattern model</param> /// <param name="docData">The document window data</param> /// <returns></returns> public static Guid CreateNewViewDiagram(PatternModelSchema patternModel, ModelingDocData docData) { Guard.NotNull(() => patternModel, patternModel); Guard.NotNull(() => docData, docData); // Create a new diagram file var docView = docData.DocViews.FirstOrDefault() as SingleDiagramDocView; PatternModelSchemaDiagram diagram = null; patternModel.Store.TransactionManager.DoWithinTransaction(() => { diagram = PatternModelSerializationHelper.CreatePatternModelSchemaDiagram( new SerializationResult(), patternModel.Store.DefaultPartition, patternModel.Store.GetRootElement(), string.Empty); }); if (diagram != null) { SetCurrentDiagram(docView, diagram, patternModel.Pattern); FixUpDiagram(patternModel, patternModel.Pattern, diagram.Id.ToString(), PresentationViewsSubject.GetPresentation(patternModel.Pattern).OfType<ShapeElement>()); return diagram.Id; } return Guid.Empty; }
/// <summary> /// Creates a new view digram for the pattern model. /// </summary> /// <param name="patternModel">The pattern model</param> /// <param name="docData">The document window data</param> /// <returns></returns> public static Guid CreateNewViewDiagram(PatternModelSchema patternModel, ModelingDocData docData) { Guard.NotNull(() => patternModel, patternModel); Guard.NotNull(() => docData, docData); // Create a new diagram file var docView = docData.DocViews.FirstOrDefault() as SingleDiagramDocView; PatternModelSchemaDiagram diagram = null; patternModel.Store.TransactionManager.DoWithinTransaction(() => { diagram = PatternModelSerializationHelper.CreatePatternModelSchemaDiagram( new SerializationResult(), patternModel.Store.DefaultPartition, patternModel.Store.GetRootElement(), string.Empty); }); if (diagram != null) { SetCurrentDiagram(docView, diagram, patternModel.Pattern); FixUpDiagram(patternModel, patternModel.Pattern, diagram.Id.ToString(), PresentationViewsSubject.GetPresentation(patternModel.Pattern).OfType <ShapeElement>()); return(diagram.Id); } return(Guid.Empty); }
public static void ValidateFromElement( ModelingDocData docData, ICollection currentSelection, Func <Object, ModelElement> validationTargetProvider) { ThrowOnInvalidController(docData); HashSet <ModelElement> elementList = new HashSet <ModelElement>(); FullDepthElementWalker elementWalker = new FullDepthElementWalker( new ModelElementVisitor(elementList), new EmbeddingReferenceVisitorFilter(), false); foreach (object selectedObject in currentSelection) { // Build list of elements embedded beneath the selected root. ModelElement element = validationTargetProvider(selectedObject); if (element != null && !elementList.Contains(element)) { elementWalker.DoTraverse(element); } } // Clear the previous messages IValidationControllerAccesor accesor = docData as IValidationControllerAccesor; accesor.Controller.ClearMessages(); if (elementList.Count > 0) { accesor.Controller.Validate(elementList, ValidationCategories.Menu); } elementList.Clear(); }
protected override void OnDocumentWindowChanged(ModelingDocView oldView, ModelingDocView newView) { base.OnDocumentWindowChanged(oldView, newView); ModelingDocData data1 = (oldView != null) ? oldView.DocData : null; if ((data1 != null) && data1 is ActiveWriterDocData) { oldView.SelectionChanged -= new EventHandler(this.OnDocumentSelectionChanged); Model model = (Model)data1.RootElement; model.ModelPropertyAdded -= new ModelPropertyAddedHandler(this.OnModelPropertyAdded); model.ModelPropertyDeleted -= new ModelPropertyDeletedHandler(this.OnModelPropertyDeleted); model.ModelPropertyChanged -= new ModelPropertyChangedHandler(this.OnModelPropertyChanged); } ModelingDocData data2 = (newView != null) ? newView.DocData : null; if ((data2 != null) && data2 is ActiveWriterDocData) { newView.SelectionChanged += new EventHandler(this.OnDocumentSelectionChanged); Model model = (Model)data2.RootElement; model.ModelPropertyAdded += new ModelPropertyAddedHandler(this.OnModelPropertyAdded); model.ModelPropertyDeleted += new ModelPropertyDeletedHandler(this.OnModelPropertyDeleted); model.ModelPropertyChanged += new ModelPropertyChangedHandler(this.OnModelPropertyChanged); } OnDocumentSelectionChanged(data2, EventArgs.Empty); }
protected override ModelingDocView CreateDocView(ModelingDocData docData, string physicalView, out string editorCaption) { // Set EditorCaption to be null here because we do not want EditorFactory to update the value. // We will manually set the EditorCaption when the View is loaded (see code in MicrosoftDataEntityDesignDocView.cs). editorCaption = null; return(new MicrosoftDataEntityDesignDocView(docData, ServiceProvider, physicalView)); }
public ModelingDocDataObserver(ModelingDocData docData) { Guard.ArgumentNotNull(docData, "docData"); this.docData = docData; this.docData.DocumentLoaded += OnDocumentLoaded; this.docData.DocumentClosed += OnDocumentClosed; }
// Dispose(bool disposing) executes in two distinct scenarios. // If disposing equals true, the method has been called directly // or indirectly by a user's code. Managed and unmanaged resources // can be disposed. // If disposing equals false, the method has been called by the // runtime from inside the finalizer and you should not reference // other objects. Only unmanaged resources can be disposed. protected virtual void Dispose(bool disposing) { // Check to see if Dispose has already been called. if (!this.disposed) { // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { if (this.docData != null) { this.docData.DocumentLoaded -= OnDocumentLoaded; this.docData.DocumentClosed -= OnDocumentClosed; this.docData = null; } } // Release unmanaged resources. If disposing is false, // only the following code is executed. // Note that this is not thread safe. // Another thread could start disposing the object // after the managed resources are disposed, // but before the disposed flag is set to true. // If thread safety is necessary, it must be // implemented by the client. } disposed = true; }
/// <summary> /// Provides a first chance to tell the shell that this window is capable of handling certain commands. Implements IOleCommandTarget.QueryStatus /// </summary> protected int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, MSOLE.OLECMD[] prgCmds, IntPtr pCmdText) { int hr = VSConstants.S_OK; bool handled = true; // Only handle commands from the Office 97 Command Set (aka VSStandardCommandSet97). if (pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97) { // There typically is only one command passed in to this array - in any case, we only care // about the first command. MSOLE.OLECMD cmd = prgCmds[0]; switch ((VSConstants.VSStd97CmdID)cmd.cmdID) { case VSConstants.VSStd97CmdID.Delete: // Always support this command, disabling it if necessary per the control. cmd.cmdf = (uint)(MSOLE.OLECMDF.OLECMDF_SUPPORTED | (myEditor.CanDelete ? MSOLE.OLECMDF.OLECMDF_ENABLED : 0)); prgCmds[0] = cmd; break; case VSConstants.VSStd97CmdID.EditLabel: // Support this command regardless of the current state of the inline editor. // If we do not do this, then an F2 keypress with an editor already open will // report the command as disabled and we would need to use IVsUIShell.UpdateCommandUI // whenever an editor closed to reenable the command. cmd.cmdf = (int)(MSOLE.OLECMDF.OLECMDF_SUPPORTED | MSOLE.OLECMDF.OLECMDF_ENABLED); prgCmds[0] = cmd; break; default: // Inform the shell that we don't support any other commands. handled = false; hr = (int)MSOLE.Constants.OLECMDERR_E_NOTSUPPORTED; break; } } else { // Inform the shell that we don't recognize this command group. handled = false; hr = (int)MSOLE.Constants.OLECMDERR_E_UNKNOWNGROUP; } if (!handled) { Debug.Assert(ErrorHandler.Failed(hr)); ModelingDocData docData = CurrentDocument; Microsoft.VisualStudio.Modeling.Shell.UndoManager undoManager; MSOLE.IOleCommandTarget forwardTo; if ((docData != null && null != (undoManager = docData.UndoManager) && null != (forwardTo = undoManager.VSUndoManager as MSOLE.IOleCommandTarget)) || null != (forwardTo = GetService(typeof(MSOLE.IOleCommandTarget)) as MSOLE.IOleCommandTarget)) { // If the command wasn't handled already, forward it to the undo manager. hr = forwardTo.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); } } return(hr); }
/// <summary> /// Display the diagram order dialog with the specified diagram order and update /// the diagram order as specified by the user. /// </summary> /// <param name="serviceProvider">A <see cref="IServiceProvider"/> used to parent the dialog</param> /// <param name="docData">The owning <see cref="ModelingDocData"/> of the diagrams being reordered</param> /// <param name="diagrams">A list of <see cref="Diagram"/> elements to reorder</param> /// <param name="selectedDiagram">A <see cref="Diagram"/> to select when the dialog is initially displayed.</param> /// <param name="images">The diagram images to display. Images are keyed off the Guid of the diagram type (format "N")</param> public static void ShowDialog(IServiceProvider serviceProvider, ModelingDocData docData, IList <Diagram> diagrams, Diagram selectedDiagram, ImageList images) { DiagramOrderDialog orderDialog = new DiagramOrderDialog(diagrams, selectedDiagram, images); if (orderDialog.ShowDialog(Utility.GetDialogOwnerWindow(serviceProvider)) == DialogResult.OK) { DiagramDisplay.UpdateDiagramDisplayOrder(docData.Store, orderDialog.myDiagramOrder); } }
private static void ThrowOnInvalidController(ModelingDocData docData) { if (docData == null || docData.Store == null || !typeof(IValidationControllerAccesor).IsAssignableFrom(docData.GetType())) { throw new InvalidOperationException(Properties.Resources.InvalidValidationController); } }
/// <summary> /// Provides a first chance to handle any command that MSOLE.IOleCommandTarget.QueryStatus /// informed the shell to pass to this window. Implements IOleCommandTarget.Exec /// </summary> protected int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { int hr = 0; bool handled = true; // Only handle commands from the Office 97 Command Set (aka VSStandardCommandSet97). if (pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97) { // Default to a not-supported status. hr = (int)MSOLE.Constants.OLECMDERR_E_NOTSUPPORTED; MSOLE.IOleCommandTarget forwardTo = myTextBox as MSOLE.IOleCommandTarget; if (forwardTo != null) { hr = forwardTo.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut); // We enabled the command, so we say we handled it regardless of the further conditions if (hr != (int)MSOLE.Constants.OLECMDERR_E_NOTSUPPORTED && hr != (int)MSOLE.Constants.OLECMDERR_E_UNKNOWNGROUP) { hr = VSConstants.S_OK; } else { handled = false; } } else { // If the command is from our command set, but not explicitly handled, inform the shell // that we didn't handle the command. handled = false; hr = (int)MSOLE.Constants.OLECMDERR_E_NOTSUPPORTED; } } // The command is from an unknown group. else { handled = false; hr = (int)MSOLE.Constants.OLECMDERR_E_UNKNOWNGROUP; } if (!handled) { Debug.Assert(ErrorHandler.Failed(hr)); ModelingDocData docData = CurrentDocument; Microsoft.VisualStudio.Modeling.Shell.UndoManager undoManager; MSOLE.IOleCommandTarget forwardTo; if ((docData != null && null != (undoManager = docData.UndoManager) && null != (forwardTo = undoManager.VSUndoManager as MSOLE.IOleCommandTarget)) || null != (forwardTo = GetService(typeof(MSOLE.IOleCommandTarget)) as MSOLE.IOleCommandTarget)) { // If the command wasn't handled already, give the undo manager a chance to handle the command. hr = forwardTo.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut); } } return(hr); }
public void OnMenuValidate(object sender, EventArgs e, ModelingDocData docData) { try { MenuValidation.ValidateFromElement(docData, this.CurrentSelection, o => { return(DomainModelHelper.GetModelElement(o)); }); } catch (Exception error) { Logger.Write(error); } }
public void OnMenuValidateModel <T>(object sender, EventArgs e, ModelingDocData docData) where T : ModelElement { try { MenuValidation.ValidateFromModel <T>(docData); } catch (Exception error) { Logger.Write(error); } }
/// <summary> /// Execute the command /// </summary> public void Exec() { Guid logicalViewGuid = new Guid(LogicalViewID.ProjectSpecificEditor); ModelElementLocator locator = new ModelElementLocator((IServiceProvider)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(Microsoft.VisualStudio.OLE.Interop.IObjectWithSite))); ModelingDocView view = locator.FindDocView(logicalViewGuid, this._diagram); ModelingDocData docdata = view.DocData as ModelingDocData; if (docdata != null && docdata.FileName != null) { // Guid du DataLayerEditorFactory Guid guid1 = new Guid("56AF6F2B-EF94-4297-9857-8653A0AE02D8"); ServiceLocator.Instance.IDEHelper.OpenModelsDiagram(docdata.FileName, guid1); } }
/// <summary> /// Provides a first chance to tell the shell that this window is capable /// of handling certain commands. Implements IOleCommandTarget.QueryStatus /// </summary> protected int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, MSOLE.OLECMD[] prgCmds, IntPtr pCmdText) { int hr = VSConstants.S_OK; bool handled = true; if (pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97) // Only handle commands from the Office 97 // Command Set (aka VSStandardCommandSet97). { MSOLE.IOleCommandTarget forwardTo = myTextBox as MSOLE.IOleCommandTarget; if (forwardTo != null) { hr = forwardTo.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); handled = hr != (int)MSOLE.Constants.OLECMDERR_E_NOTSUPPORTED && hr != (int)MSOLE.Constants.OLECMDERR_E_UNKNOWNGROUP; } else { // Inform the shell that we don't support any other commands. hr = (int)MSOLE.Constants.OLECMDERR_E_NOTSUPPORTED; handled = false; } } else { // Inform the shell that we don't recognize this command group. handled = false; hr = (int)MSOLE.Constants.OLECMDERR_E_UNKNOWNGROUP; } if (!handled) { Debug.Assert(ErrorHandler.Failed(hr)); ModelingDocData docData = CurrentDocument; Microsoft.VisualStudio.Modeling.Shell.UndoManager undoManager; MSOLE.IOleCommandTarget forwardTo; if ((docData != null && null != (undoManager = docData.UndoManager) && null != (forwardTo = undoManager.VSUndoManager as MSOLE.IOleCommandTarget)) || null != (forwardTo = GetService(typeof(MSOLE.IOleCommandTarget)) as MSOLE.IOleCommandTarget)) { // If the command wasn't handled already, forward it to the undo manager. hr = forwardTo.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); } else { hr = (int)MSOLE.Constants.MSOCMDERR_E_NOTSUPPORTED; } } return(hr); }
/// <summary> /// Ouverture du diagramme dédié /// </summary> /// <param name="e">The diagram point event arguments.</param> public override void OnDoubleClick(DiagramPointEventArgs e) { base.OnDoubleClick(e); // TODO dans un helper Guid logicalViewGuid = new Guid(LogicalViewID.ProjectSpecificEditor); ModelElementLocator locator = new ModelElementLocator( (IServiceProvider)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(IObjectWithSite))); ModelingDocView view = locator.FindDocView(logicalViewGuid, Diagram); ModelingDocData docdata = view.DocData; if (docdata != null) { OpenDiagram(docdata.FileName); } }
public void SetupObjects(nHydrate.Dsl.nHydrateModel model, DiagramDocView diagram, ModelingDocData docView) { _model = model; _diagram = diagram; _docData = docView; _modelElements.Clear(); //Add Entities foreach (var item in _model.Entities.OrderBy(x => x.Name)) { _modelElements.Add(item); } //Add Views foreach (var item in _model.Views.OrderBy(x => x.Name)) { _modelElements.Add(item); } this.DisplayObjects(); }
public static void ValidateFromModel <T>(ModelingDocData docData) where T : ModelElement { ThrowOnInvalidController(docData); HashSet <ModelElement> elementList = new HashSet <ModelElement>(); FullDepthElementWalker elementWalker = new FullDepthElementWalker( new ModelElementVisitor(elementList), new EmbeddingReferenceVisitorFilter(), false); T model = DomainModelHelper.GetElement <T>(docData.Store); if (model != null) { elementWalker.DoTraverse(model); } // Clear the previous messages IValidationControllerAccesor accesor = docData as IValidationControllerAccesor; accesor.Controller.ClearMessages(); if (elementList.Count > 0) { accesor.Controller.Validate(elementList, ValidationCategories.Menu); } elementList.Clear(); }
/// <summary> /// Document we are tracking selection on is closing, ensure we clean everything up. /// </summary> private void OnDocumentClosing(object sender, EventArgs args) { Debug.Assert(_currentDocData != null, "null docData in DocumentClosing event"); if (_currentDocData != null) { try { // clear tree data, causes event handlers to be removed from our branches. if (_treeProvider != null) { _treeProvider.Root = null; } // clear cached selection _currentSelection = null; _currentBrowseObject = null; // disable column event handlers Debug.Assert(_currentDocData.Store != null, "unable to remove column event handlers"); if (_currentDocData.Store != null) { _treeControl.RemoveColumnEventHandlers(); } // NOTE: It's important to cast here, otherwise a wrong overload would be called // and selection container would not be cleared leading to strange problems - e.g. // properties window might call refresh on disposed store etc. DoSelectionChanged((object)null); } finally { // Unsubscribe from document closing event _currentDocData.DocumentClosing -= OnDocumentClosing; _currentDocData = null; } } }
/// <summary> /// Creates a new view in the current pattern. /// </summary> public static IViewSchema CreateNewViewDiagram(this IPatternModelSchema patternModel, ModelingDocData docData, string name) { Guard.NotNull(() => patternModel, patternModel); Guard.NotNull(() => docData, docData); Guard.NotNull(() => name, name); // Create a new diagram var diagramId = PatternModelDocHelper.CreateNewViewDiagram(patternModel as PatternModelSchema, docData); // Create a new view IViewSchema view = null; if (diagramId != Guid.Empty) { view = patternModel.Pattern.CreateViewSchema(vw => { ((INamedElementSchema)vw).Name = name; vw.DiagramId = diagramId.ToString(); }); } return(view); }
protected override void OnDocumentWindowChanged(ModelingDocView oldView, ModelingDocView newView) { if (newView == null && oldView != null) { //The model is being unloaded var m = oldView.DocData.RootElement as nHydrate.Dsl.nHydrateModel; if (m == null) return; _loadedModels.Remove(m.Id); oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.nHydrateModel)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ModelChanged)); #region Entity oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Entity)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Entity)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Entity)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #region Field oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Field)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Field)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Field)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #endregion #region View oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.View)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.View)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.View)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #region Field oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.ViewField)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.ViewField)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.ViewField)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #endregion #region Stored Procedure oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedure)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedure)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedure)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #region Field oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureField)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureField)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureField)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #region Parameter oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureParameter)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureParameter)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureParameter)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #endregion #region Function oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Function)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Function)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Function)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #region Field oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionField)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionField)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionField)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #region Parameter oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionParameter)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionParameter)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionParameter)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #endregion return; } //When the old view is null this is the first time. Only load the first time if (newView == null) return; //Reload model if necessary _model = newView.DocData.RootElement as nHydrate.Dsl.nHydrateModel; if (_model == null) return; _diagram = ((Microsoft.VisualStudio.Modeling.Shell.SingleDiagramDocView)newView).CurrentDesigner.DocView; _docView = newView.DocData; //This model is already hooked if (!_loadedModels.Contains(_model.Id)) { _loadedModels.Add(_model.Id); newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.nHydrateModel)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ModelChanged)); #region Entity newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Entity)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Entity)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Entity)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #region Field newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Field)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Field)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Field)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #endregion #region View newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.View)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.View)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.View)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #region Field newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.ViewField)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.ViewField)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.ViewField)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #endregion #region Stored Procedure newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedure)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedure)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedure)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #region Field newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureField)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureField)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureField)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #region Parameter newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureParameter)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureParameter)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureParameter)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #endregion #region Function newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Function)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Function)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Function)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #region Field newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionField)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionField)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionField)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #region Parameter newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionParameter)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionParameter)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionParameter)), new EventHandler<Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #endregion } _findControl.SetupObjects(_model, _diagram, _docView); base.OnDocumentWindowChanged(oldView, newView); }
protected override ModelingDocView CreateDocView(ModelingDocData docData, string physicalView, out string editorCaption) { // Set EditorCaption to be null here because we do not want EditorFactory to update the value. // We will manually set the EditorCaption when the View is loaded (see code in MicrosoftDataEntityDesignDocView.cs). editorCaption = null; return new MicrosoftDataEntityDesignDocView(docData, ServiceProvider, physicalView); }
/// <summary> /// Standard DocView constructor, called by the editor factory /// </summary> /// <param name="docData">DocData</param> /// <param name="serviceProvider">IServiceProvider</param> public ORMDesignerDocView(ModelingDocData docData, IServiceProvider serviceProvider) : base(docData, serviceProvider) { myCtorServiceProvider = serviceProvider; }
public void SetupObjects(nHydrate.Dsl.nHydrateModel model, DiagramDocView diagram, ModelingDocData docView) { _model = model; _diagram = diagram; _docData = docView; _modelElements.Clear(); //Add Entities foreach (var item in _model.Entities.OrderBy(x => x.Name)) { _modelElements.Add(item); } //if ((_model.DiagramVisibility & Dsl.VisibilityTypeConstants.View) == Dsl.VisibilityTypeConstants.View) { //Add Views foreach (var item in _model.Views.OrderBy(x => x.Name)) { _modelElements.Add(item); } } //if ((_model.DiagramVisibility & Dsl.VisibilityTypeConstants.StoredProcedure) == Dsl.VisibilityTypeConstants.StoredProcedure) { //Add StoredProcedures foreach (var item in _model.StoredProcedures.OrderBy(x => x.Name)) { _modelElements.Add(item); } } //if ((_model.DiagramVisibility & Dsl.VisibilityTypeConstants.Function) == Dsl.VisibilityTypeConstants.Function) { //Add Functions foreach (var item in _model.Functions.OrderBy(x => x.Name)) { _modelElements.Add(item); } } DisplayObjects(); }
/// <summary> /// Creates a new view in the current pattern. /// </summary> public static IViewSchema CreateNewViewDiagram(this IPatternModelSchema patternModel, ModelingDocData docData, string name) { Guard.NotNull(() => patternModel, patternModel); Guard.NotNull(() => docData, docData); Guard.NotNull(() => name, name); // Create a new diagram var diagramId = PatternModelDocHelper.CreateNewViewDiagram(patternModel as PatternModelSchema, docData); // Create a new view IViewSchema view = null; if (diagramId != Guid.Empty) { view = patternModel.Pattern.CreateViewSchema(vw => { ((INamedElementSchema)vw).Name = name; vw.DiagramId = diagramId.ToString(); }); } return view; }
/// <summary> /// Initializes a new instance of <see cref="MultiDiagramDocView"/>. /// </summary> /// <remarks> /// For parameter descriptions, see <see cref="DiagramDocView(ModelingDocData,IServiceProvider)"/>. /// </remarks> protected MultiDiagramDocView(ModelingDocData docData, IServiceProvider serviceProvider) : base(docData, serviceProvider) { myDiagramRefCounts = new Dictionary <Diagram, int>(); }
protected override void OnDocumentWindowChanged(ModelingDocView oldView, ModelingDocView newView) { if (newView == null && oldView != null) { //The model is being unloaded var m = oldView.DocData.RootElement as nHydrate.Dsl.nHydrateModel; if (m == null) { return; } _loadedModels.Remove(m.Id); oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.nHydrateModel)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ModelChanged)); #region Entity oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Entity)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Entity)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Entity)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #region Field oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Field)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Field)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Field)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #endregion #region View oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.View)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.View)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.View)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #region Field oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.ViewField)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.ViewField)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.ViewField)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #endregion #region Stored Procedure oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedure)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedure)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedure)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #region Field oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureField)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureField)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureField)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #region Parameter oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureParameter)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureParameter)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureParameter)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #endregion #region Function oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Function)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Function)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Function)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #region Field oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionField)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionField)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionField)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #region Parameter oldView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionParameter)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); oldView.DocData.Store.EventManagerDirectory.ElementAdded.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionParameter)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); oldView.DocData.Store.EventManagerDirectory.ElementDeleted.Remove( oldView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionParameter)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #endregion return; } //When the old view is null this is the first time. Only load the first time if (newView == null) { return; } //Reload model if necessary _model = newView.DocData.RootElement as nHydrate.Dsl.nHydrateModel; if (_model == null) { return; } _diagram = ((Microsoft.VisualStudio.Modeling.Shell.SingleDiagramDocView)newView).CurrentDesigner.DocView; _docView = newView.DocData; //This model is already hooked if (!_loadedModels.Contains(_model.Id)) { _loadedModels.Add(_model.Id); newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.nHydrateModel)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ModelChanged)); #region Entity newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Entity)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Entity)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Entity)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #region Field newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Field)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Field)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Field)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #endregion #region View newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.View)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.View)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.View)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #region Field newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.ViewField)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.ViewField)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.ViewField)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #endregion #region Stored Procedure newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedure)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedure)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedure)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #region Field newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureField)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureField)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureField)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #region Parameter newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureParameter)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureParameter)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.StoredProcedureParameter)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #endregion #region Function newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Function)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Function)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.Function)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #region Field newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionField)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionField)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionField)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #region Parameter newView.DocData.Store.EventManagerDirectory.ElementPropertyChanged.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionParameter)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ElementChanged)); newView.DocData.Store.EventManagerDirectory.ElementAdded.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionParameter)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(ElementAddHandler)); newView.DocData.Store.EventManagerDirectory.ElementDeleted.Add( newView.DocData.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrate.Dsl.FunctionParameter)), new EventHandler <Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs>(ElementDeleteHandler)); #endregion #endregion } _findControl.SetupObjects(_model, _diagram, _docView); base.OnDocumentWindowChanged(oldView, newView); }
/// <summary> /// Fired when the current document changes. /// </summary> /// <param name="oldView">Previous DocData</param> /// <param name="newView">Current DocData</param> protected override void OnDocumentWindowChanged(ModelingDocView oldView, ModelingDocView newView) { var newModelingData = newView != null ? newView.DocData : null; if (newModelingData != null && IsDocumentSupported(newModelingData)) { var store = newModelingData.Store; if (store != null) { if (_currentDocData != null) { // if we're switching stores, make sure we clear the tree. Prevents store disposed exceptions if // the currentDocData.Store is disposed before we switch back to it. if (newModelingData.Store != _currentDocData.Store) { // clear tree data, causes event handlers to be removed from our branches. if (_treeProvider != null) { _treeProvider.Root = null; } // clear cached selection _currentSelection = null; _currentBrowseObject = null; } // disable column event handlers _treeControl.RemoveColumnEventHandlers(); // unsubscribe from document closing event _currentDocData.DocumentClosing -= OnDocumentClosing; } // enable column event handlers _treeControl.AddColumnEventHandlers(); // subscribe to document closing event newModelingData.DocumentClosing += OnDocumentClosing; // cache the doc data, so we can unsubscribe properly. We cannot // unsubscribe using oldView.DocData, because we may get an OnDocumentWindowChanged(oldModelingData, null) // just prior to a document close. In that case, we'd unsubscribe too early, and not clean up properly // in OnDocumentClosed. Instead we wait until either we get a new supported document, or the old one closes. _currentDocData = newModelingData; } } else { // it's possible that the oldView is not some docData we support, in that case, don't do anything var oldModelingData = oldView != null ? oldView.DocData : null; if (oldModelingData != null && IsDocumentSupported(oldModelingData)) { // Null or unsupported view, clear our selection context. Note that we leave the tree populated // here so that in the common case of switching back and forth between designer and code, we // don't lose selection/expansion state in the tree. We also clear/save the selection context, // because we don't want to push anything to the property browser while the watermark is showing. _currentBrowseObject = PrimarySelection; SetSelectedComponents(new object[] { }); if (_containerControl != null) { _containerControl.WatermarkVisible = true; } } } }
/// <summary> /// Creates an <see cref="ORMDesignerDocView"/>. See <see cref="ModelingEditorFactory.CreateDocView"/>. /// </summary> /// <param name="docData">The document, created by <see cref="CreateDocData"/>.</param> /// <param name="physicalView">The name of the view to created.</param> /// <param name="editorCaption">The editor caption.</param> /// <returns>A new instance of <see cref="ORMDesignerDocView"/>.</returns> protected override ModelingDocView CreateDocView(ModelingDocData docData, string physicalView, out string editorCaption) { editorCaption = null; return new ORMDesignerDocView(docData, this.ServiceProvider); }
public PatternModelDocView(ModelingDocData docData, IServiceProvider serviceProvider, string physicalView) : base(docData, serviceProvider) { this.physicalView = physicalView; }
public MicrosoftDataEntityDesignDocView(ModelingDocData docData, IServiceProvider serviceProvider, string diagramId) : base(docData, serviceProvider) { _diagramId = diagramId; }
/// <summary> /// Provides a first chance to tell the shell that this window is capable of handling certain commands. Implements IOleCommandTarget.QueryStatus /// </summary> protected int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, MSOLE.OLECMD[] prgCmds, IntPtr pCmdText) { int hr = VSConstants.S_OK; bool handled = true; // Only handle commands from the Office 97 Command Set (aka VSStandardCommandSet97). if (pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97) { // There typically is only one command passed in to this array - in any case, we only care // about the first command. MSOLE.OLECMD cmd = prgCmds[0]; MSOLE.OLECMDF flags = 0; ReadingRichTextBox activeRichTextEditor = myActiveInlineEditor as ReadingRichTextBox; switch ((VSConstants.VSStd97CmdID)cmd.cmdID) { case VSConstants.VSStd97CmdID.Cut: if (activeRichTextEditor != null) { flags = (myRichTextSelected && !myRichTextProtected) ? MSOLE.OLECMDF.OLECMDF_SUPPORTED | MSOLE.OLECMDF.OLECMDF_ENABLED : MSOLE.OLECMDF.OLECMDF_SUPPORTED; } break; case VSConstants.VSStd97CmdID.Copy: if (activeRichTextEditor != null) { flags = myRichTextSelected ? MSOLE.OLECMDF.OLECMDF_SUPPORTED | MSOLE.OLECMDF.OLECMDF_ENABLED : MSOLE.OLECMDF.OLECMDF_SUPPORTED; } break; case VSConstants.VSStd97CmdID.Paste: if (activeRichTextEditor != null) { flags = (!myRichTextProtected && (Clipboard.ContainsText(TextDataFormat.Text) || Clipboard.ContainsText(TextDataFormat.UnicodeText))) ? MSOLE.OLECMDF.OLECMDF_SUPPORTED | MSOLE.OLECMDF.OLECMDF_ENABLED : MSOLE.OLECMDF.OLECMDF_SUPPORTED; } break; case VSConstants.VSStd97CmdID.SelectAll: if (activeRichTextEditor != null) { flags = MSOLE.OLECMDF.OLECMDF_SUPPORTED | MSOLE.OLECMDF.OLECMDF_ENABLED; } break; case VSConstants.VSStd97CmdID.Redo: case VSConstants.VSStd97CmdID.MultiLevelRedo: case VSConstants.VSStd97CmdID.MultiLevelUndo: if (activeRichTextEditor != null) { flags = MSOLE.OLECMDF.OLECMDF_SUPPORTED; } break; case VSConstants.VSStd97CmdID.Undo: if (activeRichTextEditor != null) { flags = activeRichTextEditor.CanUndo ? MSOLE.OLECMDF.OLECMDF_SUPPORTED | MSOLE.OLECMDF.OLECMDF_ENABLED : MSOLE.OLECMDF.OLECMDF_SUPPORTED; } break; case VSConstants.VSStd97CmdID.Delete: // Inform the shell that we should have a chance to handle the delete command. if (!this.myForm.ReadingEditor.EditingFactType.IsEmpty) { flags = MSOLE.OLECMDF.OLECMDF_SUPPORTED | MSOLE.OLECMDF.OLECMDF_ENABLED; } break; case VSConstants.VSStd97CmdID.EditLabel: // Support this command regardless of the current state of the inline editor. // If we do not do this, then an F2 keypress with an editor already open will // report the command as disabled and we would need to use IVsUIShell.UpdateCommandUI // whenever an editor closed to reenable the command. flags = MSOLE.OLECMDF.OLECMDF_SUPPORTED | MSOLE.OLECMDF.OLECMDF_ENABLED; break; } if (flags == 0) { // Inform the shell that we don't support the command. handled = false; hr = (int)MSOLE.Constants.OLECMDERR_E_NOTSUPPORTED; } else { cmd.cmdf = (uint)flags; prgCmds[0] = cmd; } } else { // Inform the shell that we don't recognize this command group. handled = false; hr = (int)MSOLE.Constants.OLECMDERR_E_UNKNOWNGROUP; } if (!handled) { Debug.Assert(ErrorHandler.Failed(hr)); ModelingDocData docData = CurrentDocument; Microsoft.VisualStudio.Modeling.Shell.UndoManager undoManager; MSOLE.IOleCommandTarget forwardTo; if ((docData != null && null != (undoManager = docData.UndoManager) && null != (forwardTo = undoManager.VSUndoManager as MSOLE.IOleCommandTarget)) || null != (forwardTo = GetService(typeof(MSOLE.IOleCommandTarget)) as MSOLE.IOleCommandTarget)) { // If the command wasn't handled already, forward it to the undo manager. hr = forwardTo.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); } } return(hr); }
/// <summary> /// Provides a first chance to handle any command that MSOLE.IOleCommandTarget.QueryStatus /// informed the shell to pass to this window. Implements IOleCommandTarget.Exec /// </summary> protected int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { int hr = 0; bool handled = true; // Only handle commands from the Office 97 Command Set (aka VSStandardCommandSet97). if (pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97) { ReadingsViewForm form = myForm; ReadingEditor editor = form.ReadingEditor; ReadingRichTextBox activeRichTextEditor = myActiveInlineEditor as ReadingRichTextBox; // Default to a not-supported status. switch ((VSConstants.VSStd97CmdID)nCmdID) { case VSConstants.VSStd97CmdID.Cut: if (activeRichTextEditor != null) { activeRichTextEditor.Cut(); hr = VSConstants.S_OK; } else { goto default; } break; case VSConstants.VSStd97CmdID.Copy: if (activeRichTextEditor != null) { activeRichTextEditor.Copy(); hr = VSConstants.S_OK; } else { goto default; } break; case VSConstants.VSStd97CmdID.Paste: if (activeRichTextEditor != null) { activeRichTextEditor.Paste(); hr = VSConstants.S_OK; } else { goto default; } break; case VSConstants.VSStd97CmdID.SelectAll: if (activeRichTextEditor != null) { activeRichTextEditor.SelectAll(); hr = VSConstants.S_OK; } else { goto default; } break; case VSConstants.VSStd97CmdID.Undo: if (activeRichTextEditor != null) { activeRichTextEditor.Undo(); hr = VSConstants.S_OK; } else { goto default; } break; case VSConstants.VSStd97CmdID.Delete: // If we aren't in label edit (in which case the commands should be passed down to the // VirtualTreeView control), handle the delete command and set the hresult to a handled status. if (!editor.EditingFactType.IsEmpty) { if (!editor.InLabelEdit) { if (editor.IsReadingPaneActive && editor.CurrentReading != null) { editor.OnMenuDeleteSelectedReading(); } } else { Control editControl = editor.LabelEditControl; if (editControl != null) { HandleRef editHandle = new HandleRef(editControl, editControl.Handle); // WM_KEYDOWN == 0x100 SendMessage(editHandle, 0x100, (int)Keys.Delete, 1); // WM_KEYUP == 0x101 SendMessage(editHandle, 0x101, (int)Keys.Delete, 0x40000001); } } // We enabled the command, so we say we handled it regardless of the further conditions hr = VSConstants.S_OK; } else { goto default; } break; case VSConstants.VSStd97CmdID.EditLabel: // If we aren't in label edit (in which case the commands should be passed down to the // VirtualTreeView control), handle the edit command and set the hresult to a handled status. if (!editor.EditingFactType.IsEmpty) { if (!editor.InLabelEdit) { if (editor.IsReadingPaneActive) { editor.EditSelection(); } } else { Control editControl = editor.LabelEditControl; if (editControl != null) { HandleRef editHandle = new HandleRef(editControl, editControl.Handle); // WM_KEYDOWN == 0x100 SendMessage(editHandle, 0x100, (int)Keys.F2, 1); // WM_KEYUP == 0x101 SendMessage(editHandle, 0x101, (int)Keys.F2, 0x40000001); } } } // We enabled the command, so we say we handled it regardless of the further conditions hr = VSConstants.S_OK; break; default: // If the command is from our command set, but not explicitly handled, inform the shell // that we didn't handle the command. handled = false; hr = (int)MSOLE.Constants.OLECMDERR_E_NOTSUPPORTED; break; } } // The command is from an unknown group. else { handled = false; hr = (int)MSOLE.Constants.OLECMDERR_E_UNKNOWNGROUP; } if (!handled) { Debug.Assert(ErrorHandler.Failed(hr)); ModelingDocData docData = CurrentDocument; Microsoft.VisualStudio.Modeling.Shell.UndoManager undoManager; MSOLE.IOleCommandTarget forwardTo; if ((docData != null && null != (undoManager = docData.UndoManager) && null != (forwardTo = undoManager.VSUndoManager as MSOLE.IOleCommandTarget)) || null != (forwardTo = GetService(typeof(MSOLE.IOleCommandTarget)) as MSOLE.IOleCommandTarget)) { // If the command wasn't handled already, give the undo manager a chance to handle the command. hr = forwardTo.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut); } } return(hr); }
/// <summary> /// Creates an <see cref="ORMDesignerDocView"/>. See <see cref="ModelingEditorFactory.CreateDocView"/>. /// </summary> /// <param name="docData">The document, created by <see cref="CreateDocData"/>.</param> /// <param name="physicalView">The name of the view to created.</param> /// <param name="editorCaption">The editor caption.</param> /// <returns>A new instance of <see cref="ORMDesignerDocView"/>.</returns> protected override ModelingDocView CreateDocView(ModelingDocData docData, string physicalView, out string editorCaption) { editorCaption = null; return(new ORMDesignerDocView(docData, this.ServiceProvider)); }
public void SetupObjects(nHydrate.Dsl.nHydrateModel model, DiagramDocView diagram, ModelingDocData docView) { _model = model; _diagram = diagram; _docView = docView; }
/// <summary> /// Initializes a new instance of <see cref="MultiDiagramDocView"/>. /// </summary> /// <remarks> /// For parameter descriptions, see <see cref="DiagramDocView(ModelingDocData,IServiceProvider)"/>. /// </remarks> protected MultiDiagramDocView(ModelingDocData docData, IServiceProvider serviceProvider) : base(docData, serviceProvider) { myDiagramRefCounts = new Dictionary<Diagram, int>(); }
/// <summary> /// Display the diagram order dialog with the specified diagram order and update /// the diagram order as specified by the user. /// </summary> /// <param name="serviceProvider">A <see cref="IServiceProvider"/> used to parent the dialog</param> /// <param name="docData">The owning <see cref="ModelingDocData"/> of the diagrams being reordered</param> /// <param name="diagrams">A list of <see cref="Diagram"/> elements to reorder</param> /// <param name="images">The diagram images to display. Images are keyed off the Guid of the diagram type (format "N")</param> public static void ShowDialog(IServiceProvider serviceProvider, ModelingDocData docData, IList<Diagram> diagrams, ImageList images) { DiagramOrderDialog orderDialog = new DiagramOrderDialog(diagrams, images); if (orderDialog.ShowDialog(Utility.GetDialogOwnerWindow(serviceProvider)) == DialogResult.OK) { DiagramDisplay.UpdateDiagramDisplayOrder(docData.Store, orderDialog.myDiagramOrder); } }
/// <summary> /// Provides a first chance to handle any command that MSOLE.IOleCommandTarget.QueryStatus /// informed the shell to pass to this window. Implements IOleCommandTarget.Exec /// </summary> protected int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { int hr = VSConstants.S_OK; bool handled = true; // Only handle commands from the Office 97 Command Set (aka VSStandardCommandSet97). if (pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97) { SamplePopulationEditor samplePopulationEditor; // Default to a not-supported status. switch ((VSConstants.VSStd97CmdID)nCmdID) { case VSConstants.VSStd97CmdID.Delete: if ((samplePopulationEditor = myEditor) != null) { Control editControl = samplePopulationEditor.LabelEditControl; if (editControl != null) { IntPtr editHandle = editControl.Handle; // WM_KEYDOWN == 0x100 SendMessage(editHandle, 0x100, (int)Keys.Delete, 1); // WM_KEYUP == 0x101 SendMessage(editHandle, 0x101, (int)Keys.Delete, 0x40000001); } else { samplePopulationEditor.DeleteSelectedCell(); } } // We enabled the command, so we say we handled it regardless of the further conditions break; case VSConstants.VSStd97CmdID.EditLabel: if ((samplePopulationEditor = myEditor) != null && (samplePopulationEditor.SelectedEntityType != null || samplePopulationEditor.SelectedFactType != null || samplePopulationEditor.SelectedValueType != null)) { if (!samplePopulationEditor.FullRowSelect && !samplePopulationEditor.InLabelEdit) { samplePopulationEditor.BeginEditSamplePopulationInstance(); } else { Control editControl = samplePopulationEditor.LabelEditControl; if (editControl != null) { IntPtr editHandle = editControl.Handle; // WM_KEYDOWN == 0x100 SendMessage(editHandle, 0x100, (int)Keys.F2, 1); // WM_KEYUP == 0x101 SendMessage(editHandle, 0x101, (int)Keys.F2, 0x40000001); } } } // We enabled the command, so we say we handled it irrespective of the other conditions. // See commands in QueryStatus regarding the enabled state of this command. hr = VSConstants.S_OK; break; default: // If the command is from our command set, but not explicitly handled, inform the shell // that we didn't handle the command. handled = false; hr = (int)MSOLE.Constants.OLECMDERR_E_NOTSUPPORTED; break; } } // The command is from an unknown group. else { handled = false; hr = (int)MSOLE.Constants.OLECMDERR_E_UNKNOWNGROUP; } if (!handled) { Debug.Assert(ErrorHandler.Failed(hr)); ModelingDocData docData = CurrentDocument; Microsoft.VisualStudio.Modeling.Shell.UndoManager undoManager; MSOLE.IOleCommandTarget forwardTo; if ((docData != null && null != (undoManager = docData.UndoManager) && null != (forwardTo = undoManager.VSUndoManager as MSOLE.IOleCommandTarget)) || null != (forwardTo = GetService(typeof(MSOLE.IOleCommandTarget)) as MSOLE.IOleCommandTarget)) { // If the command wasn't handled already, give the undo manager a chance to handle the command. hr = forwardTo.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut); } } return(hr); }