Пример #1
0
 private void CloseDocViewWindow(MicrosoftDataEntityDesignDocView docView)
 {
     Debug.Assert(docView != null, "docView parameter is null");
     if (docView != null)
     {
         var isDirty = 0;
         IsDocDataDirty(out isDirty);
         if (DocViews.Count == 1 &&
             isDirty == 1)
         {
             docView.Frame.CloseFrame((uint)__FRAMECLOSE.FRAMECLOSE_PromptSave);
         }
         else
         {
             docView.Frame.CloseFrame((uint)__FRAMECLOSE.FRAMECLOSE_NoSave);
         }
     }
 }
Пример #2
0
        protected void OnTransactionCommitted(Object sender, TransactionCommitEventArgs e)
        {
            MicrosoftDataEntityDesignDocView dataEntityDesignDocView = null;

            // Need to figure the diagram view where the transaction originates.
            // First we look at transaction context for diagram id information.
            // If this information is not available then we are going to look at the current active window.
            var diagramId = string.Empty;

            if (e.TransactionContext.TryGetValue(EfiTransactionOriginator.TransactionOriginatorDiagramId, out diagramId))
            {
                foreach (var view in DocViews.OfType <MicrosoftDataEntityDesignDocView>())
                {
                    if (view.Diagram.DiagramId == diagramId)
                    {
                        dataEntityDesignDocView = view;
                        break;
                    }
                }
            }
            else
            {
                // look at the current selection
                // Note: must use CurrentDocumentView rather than CurrentWindow, CurrentWindow can be e.g. the MappingDetailsWindow
                IServiceProvider serviceProvider = PackageManager.Package;
                var selectionService             = serviceProvider.GetService(typeof(IMonitorSelectionService)) as IMonitorSelectionService;
                dataEntityDesignDocView = selectionService.CurrentDocumentView as MicrosoftDataEntityDesignDocView;
            }

            // When a new diagram is created, the doc view is not created yet when transaction is committed.
            // In that situation, we just skip delegating the transaction to DSL view model because there is none.
            if (dataEntityDesignDocView != null &&
                dataEntityDesignDocView.IsLoading == false)
            {
                var viewModel = dataEntityDesignDocView.Diagram.ModelElement as EntityDesignerViewModel;
                if (viewModel != null)
                {
                    viewModel.OnTransactionCommited(e);

                    // now set the isDirty flag on Shell's UndoManager so diagram layout changes can
                    // also get persisted; if there isn't one of our context's in the xact, then this
                    // change didn't involve changing any items, just position or size
                    var changeContext = ViewModelChangeContext.GetExistingContext(e.Transaction);
                    if (changeContext == null)
                    {
                        if (IsHandlingDocumentReloaded == false)
                        {
                            SetDocDataDirty(1);
                        }
                    }
                    else
                    {
                        // if we get here, there are changes that originated in the designer surface
                        // so run our validation
                        if (Store != null)
                        {
                            ValidationController.ValidateCustom(Store, "OnTransactionCommited");
                        }
                    }
                }
            }
        }
 private void CloseDocViewWindow(MicrosoftDataEntityDesignDocView docView)
 {
     Debug.Assert(docView != null, "docView parameter is null");
     if (docView != null)
     {
         var isDirty = 0;
         IsDocDataDirty(out isDirty);
         if (DocViews.Count == 1
             && isDirty == 1)
         {
             docView.Frame.CloseFrame((uint)__FRAMECLOSE.FRAMECLOSE_PromptSave);
         }
         else
         {
             docView.Frame.CloseFrame((uint)__FRAMECLOSE.FRAMECLOSE_NoSave);
         }
     }
 }