示例#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);
        }
示例#2
0
        private object OnDragDropDelayed(object arg)
        {
            this.isDropping = false;
            TextEditProxy textEditProxy = (TextEditProxy)arg;

            if (textEditProxy != null)
            {
                using (SceneEditTransaction editTransaction = this.Tool.ActiveSceneViewModel.CreateEditTransaction(StringTable.UndoUnitDragDropText))
                {
                    if (this.editProxy != null)
                    {
                        this.ActiveSceneViewModel.ElementSelectionSet.SetSelection((SceneElement)this.editProxy.TextSource);
                        TextSelectionSet textSelectionSet = this.ActiveSceneViewModel.TextSelectionSet;
                        textSelectionSet.TextEditProxy = this.editProxy;
                        textSelectionSet.IsActive      = true;
                    }
                    textEditProxy.Serialize();
                    textEditProxy.UpdateDocumentModel();
                    this.RemoveEditProxyFromScene(textEditProxy);
                    this.CommitCurrentEdit();
                    editTransaction.Commit();
                    if (this.editProxy != null)
                    {
                        if (this.editProxy.TextSource.IsViewObjectValid)
                        {
                            this.SetIsTextEditingProperty(this.editProxy.TextSource, true);
                        }
                    }
                }
            }
            return((object)null);
        }
示例#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);
 }
示例#4
0
        protected override bool OnDrop(DragEventArgs args)
        {
            BaseFrameworkElement textElementAtPoint = this.GetEditableTextElementAtPoint(args.GetPosition((IInputElement)this.ActiveView.ViewRootContainer));

            if (textElementAtPoint != null)
            {
                if (textElementAtPoint != this.TextSource)
                {
                    this.CommitCurrentEdit();
                    if (this.editProxy != null)
                    {
                        this.UnregisterEditingHandlers(this.editProxy);
                    }
                    this.isDropping = true;
                    Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Send, (Delegate) new DispatcherOperationCallback(this.OnDragDropDelayed), (object)this.editProxy);
                }
                TextEditProxy editingProxy = (TextEditProxy)null;
                foreach (TextEditProxy textEditProxy in this.nonActiveEditProxies)
                {
                    if (textEditProxy.TextSource == textElementAtPoint)
                    {
                        editingProxy = textEditProxy;
                    }
                }
                if (editingProxy != null)
                {
                    this.nonActiveEditProxies.Remove(editingProxy);
                    this.RegisterEditingHandlers(editingProxy);
                    this.editProxy = editingProxy;
                }
            }
            return(false);
        }
示例#5
0
 private void UnregisterEditingHandlers(TextEditProxy editingProxy)
 {
     editingProxy.EditingElement.PreviewTextInput         -= new TextCompositionEventHandler(this.editingTextBox_PreviewTextInput);
     editingProxy.EditingElement.TextChanged              -= new TextChangedEventHandler(this.editingTextBox_TextChanged);
     editingProxy.EditingElement.SelectionChanged         -= new RoutedEventHandler(this.editingTextBox_SelectionChanged);
     editingProxy.EditingElement.LostFocus                -= new RoutedEventHandler(this.editingTextBox_LostFocus);
     editingProxy.EditingElement.PreviewLostKeyboardFocus -= new KeyboardFocusChangedEventHandler(this.editingTextBox_PreviewLostKeyboardFocus);
 }
示例#6
0
 private void AddEditProxyToScene(TextEditProxy textEditProxy, bool visible)
 {
     if (visible && textEditProxy.TextSource.IsViewObjectValid)
     {
         this.SetIsTextEditingProperty(textEditProxy.TextSource, true);
     }
     textEditProxy.EditingElement.GotKeyboardFocus += new KeyboardFocusChangedEventHandler(this.editingTextBox_GotKeyboardFocus);
     textEditProxy.AddToScene(visible);
 }
示例#7
0
 private void RemoveEditProxyFromScene(TextEditProxy textEditProxy)
 {
     textEditProxy.RemoveFromScene();
     textEditProxy.EditingElement.GotKeyboardFocus -= new KeyboardFocusChangedEventHandler(this.editingTextBox_GotKeyboardFocus);
     if (textEditProxy.TextSource.DocumentNode.DocumentRoot == null || !textEditProxy.TextSource.IsViewObjectValid)
     {
         return;
     }
     this.SetIsTextEditingProperty(textEditProxy.TextSource, false);
 }
示例#8
0
        private void editingTextBox_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
        {
            TextEditProxy textEditProxy = (TextEditProxy)((IViewTextBoxBase)sender).TextEditProxyObject;

            if (textEditProxy == this.editProxy)
            {
                return;
            }
            this.EditDifferentElement(textEditProxy.TextSource);
        }
示例#9
0
 private void EndTextEdit()
 {
     if (this.editProxy == null)
     {
         return;
     }
     this.ActiveSceneViewModel.TextSelectionSet.Clear();
     this.CommitCurrentEdit();
     this.UnregisterEditingHandlers(this.editProxy);
     this.RemoveEditProxyFromScene(this.editProxy);
     this.editProxy = (TextEditProxy)null;
 }
示例#10
0
        public static TextEditProxy CreateEditProxy(BaseFrameworkElement textElement)
        {
            TextEditProxy textEditProxy = (TextEditProxy)null;

            if (PlatformTypes.RichTextBox.IsAssignableFrom((ITypeId)textElement.Type))
            {
                textEditProxy = !textElement.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf) ? (TextEditProxy) new SilverlightRichTextBoxEditProxy(textElement) : (TextEditProxy) new FlowDocumentEditProxy(textElement);
            }
            else if (PlatformTypes.TextBox.IsAssignableFrom((ITypeId)textElement.Type))
            {
                textEditProxy = (TextEditProxy) new TextBoxEditProxy(textElement);
            }
            else if (ProjectNeutralTypes.HeaderedContentControl.IsAssignableFrom((ITypeId)textElement.Type))
            {
                textEditProxy = (TextEditProxy) new ContentEditProxy(textElement, TextEditProxyFactory.HeaderedContentControlHeaderProperty);
            }
            else if (PlatformTypes.ContentControl.IsAssignableFrom((ITypeId)textElement.Type))
            {
                textEditProxy = (TextEditProxy) new ContentEditProxy(textElement, ContentControlElement.ContentProperty);
            }
            else if (ProjectNeutralTypes.HeaderedItemsControl.IsAssignableFrom((ITypeId)textElement.Type))
            {
                textEditProxy = (TextEditProxy) new ContentEditProxy(textElement, TextEditProxyFactory.HeaderedItemsControlHeaderProperty);
            }
            else if (PlatformTypes.PasswordBox.IsAssignableFrom((ITypeId)textElement.Type))
            {
                textEditProxy = (TextEditProxy) new ContentEditProxy(textElement, TextEditProxyFactory.PasswordBoxPasswordProperty);
            }
            else if (PlatformTypes.TextBlock.IsAssignableFrom((ITypeId)textElement.Type))
            {
                textEditProxy = (TextEditProxy) new TextBlockEditProxy(textElement);
            }
            else if (PlatformTypes.FlowDocumentScrollViewer.IsAssignableFrom((ITypeId)textElement.Type))
            {
                textEditProxy = (TextEditProxy) new FlowDocumentScrollViewerEditProxy(textElement);
            }
            else if (PlatformTypes.AccessText.IsAssignableFrom((ITypeId)textElement.Type))
            {
                textEditProxy = (TextEditProxy) new AccessTextEditProxy(textElement);
            }
            return(textEditProxy);
        }