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); }
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); }
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(); }
public static bool IsEditableElement(SceneElement sceneElement) { return(TextEditProxyFactory.IsEditableElement(sceneElement, false)); }
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); }
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(); }