예제 #1
0
 private static void AttachEventHandlers(TextBoxBase textBox, UndoManager manager)
 {
     if (textBox != null && manager != null)
     {
         textBox.AddHandler(CommandManager.PreviewExecutedEvent, new ExecutedRoutedEventHandler(manager.ExecutedHandler), true); // we need to see all events to subvert the built-in undo/redo tracking in the text boxes
         textBox.TextChanged += new TextChangedEventHandler(manager.TextChangedHandler);
     }
 }
예제 #2
0
        /// <summary>
        /// Registers this object to receive notifications of changes to the content.
        /// </summary>
        /// <param name="dependencyObject">The target element that will register for state change events.</param>
        public override void Register(DependencyObject dependencyObject)
        {
            // The Undo/Redo strategy involves handling global operations that are common to all controls and specific operations
            // that are particular to a family of controls.  This registers handlers for this family of controls that will add the
            // proper actions to the Undo/Redo stacks.
            TextBoxBase textBox = dependencyObject as TextBoxBase;

            textBox.AddHandler(TextBoxBase.TextChangedEvent, new TextChangedEventHandler(TextChangedHandler), true);
        }
예제 #3
0
        public override void Instantiate()
        {
            base.Instantiate();
            this.CopyProperty(RichTextBoxElement.VerticalScrollBarVisibilityProperty);
            this.CopyProperty(RichTextBoxElement.HorizontalScrollBarVisibilityProperty);
            this.CopyProperty(ControlElement.ForegroundProperty);
            this.CopyProperty(ControlElement.BackgroundProperty);
            this.CopyProperty(ControlElement.BorderThicknessProperty);
            this.CopyProperty(RichTextBoxElement.TextAlignmentProperty);
            this.CopyProperty(RichTextBoxElement.CaretBrushProperty);
            if (this.EditingElement.Platform.Metadata.ResolveProperty(TextBlockElement.BackgroundProperty) != null)
            {
                this.CopyProperty(ControlElement.BackgroundProperty);
            }
            if (this.TextSource.IsSet(RichTextBoxElement.BlocksProperty) == PropertyState.Set)
            {
                this.TextSource.DocumentNodePath.GetPathInContainer(((DocumentCompositeNode)this.TextSource.DocumentNode).Properties[RichTextBoxElement.BlocksProperty]);
                IDocumentContext documentContext = this.TextSource.ViewModel.Document.DocumentContext;
                this.RichTextBox.Document.Blocks.Clear();
                this.inlineUIElementStandIns  = new List <Microsoft.Expression.DesignModel.DocumentModel.DocumentNode>();
                this.inlineUIElementOriginals = new List <Microsoft.Expression.DesignModel.DocumentModel.DocumentNode>();
                this.standInImageSource       = (RenderTargetBitmap)null;
                foreach (SceneNode sceneNode in (IEnumerable <SceneNode>) this.TextSource.GetCollectionForProperty(RichTextBoxElement.BlocksProperty))
                {
                    Microsoft.Expression.DesignModel.DocumentModel.DocumentNode documentNode = this.TextSource.ViewModel.DefaultView.ConvertToWpfValueAsDocumentNode((object)this.PreProcessDocumentNodeForEditProxy(sceneNode.DocumentNode));
                    Block block = (Block)this.TextSource.ViewModel.DefaultView.ConvertToWpfValue((object)documentNode);
                    this.PostProcessInstanceForEditProxy((DependencyObject)block);
                    this.UpdateUIChildrenInstances((DocumentCompositeNode)documentNode, (TextElement)block);
                    this.RichTextBox.Document.Blocks.Add((IViewBlock)this.ProxyPlatform.ViewObjectFactory.Instantiate((object)block));
                }
            }
            if (this.ForceLoadOnInstantiate)
            {
                this.EditingElement.UpdateLayout();
                this.AdjustSpacing();
            }
            else
            {
                this.RichTextBox.Loaded += new RoutedEventHandler(this.RichTextBox_Loaded);
            }
            if (!this.TextSource.ViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.SupportsTabInTextControl))
            {
                return;
            }
            TextBoxBase textBoxBase = this.RichTextBox.PlatformSpecificObject as TextBoxBase;

            if (textBoxBase == null)
            {
                return;
            }
            textBoxBase.AddHandler(CommandManager.PreviewCanExecuteEvent, (Delegate) new CanExecuteRoutedEventHandler(SilverlightRichTextBoxEditProxy.CanExecute));
        }