Beispiel #1
0
        private TextEditProxy FindOrCreateEditProxy(BaseFrameworkElement textElement, bool active)
        {
            if (this.editProxy != null && this.editProxy.TextSource == textElement)
            {
                return(this.editProxy);
            }
            TextEditProxy textEditProxy = Enumerable.FirstOrDefault <TextEditProxy>((IEnumerable <TextEditProxy>) this.nonActiveEditProxies, (Func <TextEditProxy, bool>)(proxy => proxy.TextSource == textElement));

            if (textEditProxy == null)
            {
                textEditProxy = TextEditProxyFactory.CreateEditProxy(textElement);
                this.AddEditProxyToScene(textEditProxy, active);
                if (active)
                {
                    this.editProxy = textEditProxy;
                }
                else
                {
                    this.nonActiveEditProxies.Add(textEditProxy);
                }
            }
            else if (active)
            {
                this.nonActiveEditProxies.Remove(textEditProxy);
                this.editProxy = textEditProxy;
                textEditProxy.EditingElement.Opacity = 1.0;
                if (textEditProxy.TextSource.IsViewObjectValid)
                {
                    this.SetIsTextEditingProperty(textEditProxy.TextSource, true);
                }
            }
            return(textEditProxy);
        }
Beispiel #2
0
        private SceneElement GetContainingTextElement(DocumentNodePath nodePath)
        {
            if (this.ActiveSceneViewModel == null || this.ActiveSceneViewModel.ActiveEditingContainer == null)
            {
                return((SceneElement)null);
            }
            DocumentNodePath editingContainer = this.ActiveSceneViewModel.GetAncestorInEditingContainer(nodePath, this.ActiveSceneViewModel.ActiveEditingContainer.DocumentNodePath, (DocumentNodePath)null);
            SceneElement     sceneElement     = (SceneElement)null;

            if (editingContainer != null)
            {
                sceneElement = this.ActiveSceneViewModel.GetSceneNode(editingContainer.Node) as SceneElement;
            }
            for (; sceneElement != null; sceneElement = sceneElement.ParentElement)
            {
                if (sceneElement.IsVisuallySelectable || sceneElement == this.ActiveSceneViewModel.ActiveEditingContainer)
                {
                    if (!TextEditProxyFactory.IsEditableElement(sceneElement))
                    {
                        sceneElement = (SceneElement)null;
                        break;
                    }
                    break;
                }
            }
            return(sceneElement);
        }
Beispiel #3
0
 protected override bool OnDragOver(DragEventArgs args)
 {
     base.OnDragOver(args);
     if (!this.IsSuspended)
     {
         BaseFrameworkElement textElementAtPoint = this.GetEditableTextElementAtPoint(args.GetPosition((IInputElement)this.ActiveView.ViewRootContainer));
         if (textElementAtPoint != null)
         {
             if (textElementAtPoint != this.TextSource)
             {
                 bool flag = false;
                 foreach (TextEditProxy textEditProxy in this.nonActiveEditProxies)
                 {
                     if (textEditProxy.TextSource == textElementAtPoint)
                     {
                         flag = true;
                         break;
                     }
                 }
                 if (!flag)
                 {
                     TextEditProxy editProxy = TextEditProxyFactory.CreateEditProxy(textElementAtPoint);
                     this.AddEditProxyToScene(editProxy, true);
                     this.nonActiveEditProxies.Add(editProxy);
                 }
             }
         }
         else
         {
             this.ClearNonActiveEditProxies();
         }
     }
     return(false);
 }
Beispiel #4
0
        private BaseFrameworkElement GetEditableTextElementAtPoint(Point point)
        {
            SceneElement         elementAtPoint   = this.ActiveView.GetElementAtPoint(point, new HitTestModifier(this.GetContainingTextElement), new InvisibleObjectHitTestModifier(SceneView.SmartInvisiblePanelSelect), (ICollection <BaseFrameworkElement>)null);
            BaseFrameworkElement frameworkElement = (BaseFrameworkElement)null;

            if (elementAtPoint != null && TextEditProxyFactory.IsEditableElement(elementAtPoint) && !elementAtPoint.IsLocked)
            {
                frameworkElement = elementAtPoint as BaseFrameworkElement;
            }
            return(frameworkElement);
        }
Beispiel #5
0
        private void EditDifferentElement(BaseFrameworkElement element)
        {
            this.EndTextEdit();
            if (element != null && !TextEditProxyFactory.IsEditableElement((SceneElement)element))
            {
                element = (BaseFrameworkElement)null;
            }
            bool flag1 = false;

            if (element != null && element.IsViewObjectValid)
            {
                SceneElementSelectionSet elementSelectionSet = this.ActiveSceneViewModel.ElementSelectionSet;
                if (elementSelectionSet != null)
                {
                    elementSelectionSet.SetSelection((SceneElement)element);
                }
                flag1 = true;
                this.BeginTextEdit(element);
            }
            TextSelectionSet textSelectionSet = this.ActiveSceneViewModel.TextSelectionSet;
            bool             flag2            = false;

            if (textSelectionSet != null)
            {
                flag2 = this.ActiveSceneViewModel.TextSelectionSet.IsActive;
                int num = flag1 ? true : false;
                textSelectionSet.TextEditProxy = this.editProxy;
                textSelectionSet.IsActive      = flag1;
            }
            if (flag1 != flag2)
            {
                this.ActiveSceneViewModel.RefreshSelection();
            }
            if (flag1)
            {
                return;
            }
            this.ActiveView.ReturnFocus();
        }
Beispiel #6
0
        public static bool IsEditableElement(SceneElement sceneElement, bool textElementOnly)
        {
            bool flag = false;

            if (PlatformTypes.RichTextBox.IsAssignableFrom((ITypeId)sceneElement.Type) || PlatformTypes.TextBox.IsAssignableFrom((ITypeId)sceneElement.Type) || (PlatformTypes.PasswordBox.IsAssignableFrom((ITypeId)sceneElement.Type) || PlatformTypes.TextBlock.IsAssignableFrom((ITypeId)sceneElement.Type)) || (PlatformTypes.FlowDocumentScrollViewer.IsAssignableFrom((ITypeId)sceneElement.Type) || PlatformTypes.AccessText.IsAssignableFrom((ITypeId)sceneElement.Type)))
            {
                flag = true;
            }
            else if (ProjectNeutralTypes.Label.IsAssignableFrom((ITypeId)sceneElement.Type) && TextEditProxyFactory.HasEditableContent(sceneElement, ContentControlElement.ContentProperty))
            {
                flag = true;
            }
            else if (!textElementOnly)
            {
                if (ProjectNeutralTypes.HeaderedContentControl.IsAssignableFrom((ITypeId)sceneElement.Type) && TextEditProxyFactory.HasEditableContent(sceneElement, TextEditProxyFactory.HeaderedContentControlHeaderProperty))
                {
                    flag = true;
                }
                else if (PlatformTypes.ContentControl.IsAssignableFrom((ITypeId)sceneElement.Type) && !PlatformTypes.Window.IsAssignableFrom((ITypeId)sceneElement.Type) && (!PlatformTypes.ScrollViewer.IsAssignableFrom((ITypeId)sceneElement.Type) && TextEditProxyFactory.HasEditableContent(sceneElement, ContentControlElement.ContentProperty)))
                {
                    flag = true;
                }
                else if (ProjectNeutralTypes.HeaderedItemsControl.IsAssignableFrom((ITypeId)sceneElement.Type) && TextEditProxyFactory.HasEditableContent(sceneElement, TextEditProxyFactory.HeaderedItemsControlHeaderProperty))
                {
                    flag = true;
                }
            }
            if (sceneElement.Type.XamlSourcePath != null)
            {
                flag = false;
            }
            return(flag);
        }
Beispiel #7
0
 public static bool IsEditableElement(SceneElement sceneElement)
 {
     return(TextEditProxyFactory.IsEditableElement(sceneElement, false));
 }
Beispiel #8
0
 private void ViewModel_EarlySceneUpdatePhase(object sender, SceneUpdatePhaseEventArgs args)
 {
     if (this.IsSuspended)
     {
         return;
     }
     if (args.IsDirtyViewState(SceneViewModel.ViewStateBits.ElementSelection))
     {
         SceneElementSelectionSet elementSelectionSet = this.ActiveSceneViewModel.ElementSelectionSet;
         BaseFrameworkElement     frameworkElement    = (BaseFrameworkElement)null;
         if (elementSelectionSet != null && elementSelectionSet.PrimarySelection != null && TextEditProxyFactory.IsEditableElement(elementSelectionSet.PrimarySelection))
         {
             frameworkElement = elementSelectionSet.PrimarySelection as BaseFrameworkElement;
         }
         if (this.TextSource != frameworkElement)
         {
             this.PopSelfOrExitEditMode();
             return;
         }
     }
     if (this.editProxy == null)
     {
         return;
     }
     if (args.IsDirtyViewState(SceneViewModel.ViewStateBits.EntireScene))
     {
         foreach (DocumentNodeChange change in args.DocumentChanges.DistinctChanges)
         {
             if ((change.ParentNode == this.TextSource.DocumentNode || change.OldChildNode == this.TextSource.DocumentNode) && !this.editProxy.IsTextChange(change))
             {
                 this.PopSelfOrExitEditMode();
                 return;
             }
         }
     }
     foreach (DocumentNodeChange change in args.DocumentChanges.DistinctChanges)
     {
         if ((change.ParentNode == this.TextSource.DocumentNode || change.OldChildNode == this.TextSource.DocumentNode) && this.editProxy.IsTextChange(change))
         {
             this.editProxy.ApplyPropertyChange(change);
             this.textChangesApplied = true;
         }
     }
     if (!this.editProxy.TextSource.IsViewObjectValid)
     {
         return;
     }
     this.SetIsTextEditingProperty(this.editProxy.TextSource, true);
 }
Beispiel #9
0
 protected override void OnResume()
 {
     if (this.isCreatingText)
     {
         SceneElement primarySelection = this.Tool.ActiveSceneViewModel.ElementSelectionSet.PrimarySelection;
         if ((this.editProxy == null || this.editProxy.TextSource != primarySelection) && (primarySelection != null && TextEditProxyFactory.IsEditableElement(primarySelection)) && this.selectedElementBeforeTextCreation != primarySelection)
         {
             this.EditDifferentElement(primarySelection as BaseFrameworkElement);
             if (this.ActiveSceneViewModel.TextSelectionSet.TextEditProxy != null)
             {
                 this.ActiveSceneViewModel.TextSelectionSet.TextEditProxy.EditingElement.SelectAll();
             }
         }
         else
         {
             this.EditDifferentElement((BaseFrameworkElement)null);
         }
         this.isCreatingText = false;
     }
     base.OnResume();
 }