コード例 #1
0
        private bool?ShowReferencesFoundDialog(ReferencesFoundModel model)
        {
            bool?nullable1 = new bool?(true);
            bool?nullable2 = new ReferencesFoundDialog(model).ShowDialog();

            if (nullable2.GetValueOrDefault(false) && model.SelectedUpdateMethod != ReferencesFoundModel.UpdateMethod.DontFix)
            {
                nullable2 = new AsyncProcessDialog(model.FixReferencesAsync(), this.DesignerContext.ExpressionInformationService).ShowDialog();
            }
            return(nullable2);
        }
コード例 #2
0
        private void InteractiveRenameResource()
        {
            if (this.DocumentNode == null || this.DocumentNode.DocumentRoot == null || this.DocumentNode.DocumentRoot.DocumentContext == null)
            {
                return;
            }
            string key = this.currentName;

            this.currentName = (string)null;
            if (key == null || key.Equals(this.resource.Name))
            {
                this.OnKeyChanged();
            }
            else
            {
                SceneViewModel viewModel = this.Container.ViewModel;
                if (new ResourceSite(viewModel.Document.DocumentContext, this.Container.ResourcesCollection).FindResource((IDocumentRootResolver)null, key, (ICollection <DocumentCompositeNode>)null, (ICollection <IDocumentRoot>)null) != null)
                {
                    viewModel.DesignerContext.MessageDisplayService.ShowError(StringTable.CreateResourceKeyStringIssueDirectConflict);
                    this.OnKeyChanged();
                }
                else
                {
                    List <SceneNode>     list  = new List <SceneNode>();
                    ReferencesFoundModel model = (ReferencesFoundModel)null;
                    viewModel.FindInternalResourceReferences(this.resource.ResourceNode, (ICollection <SceneNode>)list);
                    ITypeId             type = (ITypeId)viewModel.RootNode.Type;
                    bool                flag = PlatformTypes.ResourceDictionary.IsAssignableFrom(type) || PlatformTypes.Application.IsAssignableFrom(type);
                    DictionaryEntryNode dictionaryEntryNode = (DictionaryEntryNode)viewModel.GetSceneNode((DocumentNode)this.resource.ResourceNode);
                    if (list.Count > 0 || flag)
                    {
                        model = new ReferencesFoundModel((SceneNode)dictionaryEntryNode, (ICollection <SceneNode>)list, ReferencesFoundModel.UseScenario.RenameResource);
                        bool valueOrDefault = new AsyncProcessDialog((AsyncProcess) new SerialAsyncProcess((IAsyncMechanism) new CurrentDispatcherAsyncMechanism(DispatcherPriority.Background), new AsyncProcess[2]
                        {
                            (AsyncProcess) new ExternalOpenSceneResourceReferenceAnalyzer(model),
                            (AsyncProcess) new ExternalClosedSceneResourceReferenceAnalyzer(model)
                        }), this.DesignerContext.ExpressionInformationService).ShowDialog().GetValueOrDefault(false);
                        if (valueOrDefault && model.ReferenceNames.Count > 0)
                        {
                            valueOrDefault = new ReferencesFoundDialog(model).ShowDialog().GetValueOrDefault(false);
                        }
                        if (!valueOrDefault)
                        {
                            this.OnKeyChanged();
                            return;
                        }
                    }
                    using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.UndoUnitRenameResource))
                    {
                        if (model != null && model.SelectedUpdateMethod != ReferencesFoundModel.UpdateMethod.DontFix && model.ReferenceNames.Count > 0)
                        {
                            model.NewKey = (object)key;
                            new AsyncProcessDialog(model.FixReferencesAsync(), this.DesignerContext.ExpressionInformationService).ShowDialog();
                        }
                        dictionaryEntryNode.Key = (object)key;
                        editTransaction.Commit();
                    }
                    this.OnKeyChanged();
                }
            }
        }