public override void EnableEvent(object eventId)
 {
     base.EnableEvent(eventId);
     if (eventId is RichTextViewEvent)
     {
         switch ((RichTextViewEvent)eventId)
         {
         case RichTextViewEvent.NavigateToUrl:
             Widget.AddHandler(Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler(HyperlinkNavigated), true);
             break;
         }
     }
 }
Example #2
0
        private Label GetEditDateControl()
        {
            #region RichTextBox Define

            if (_EditControl == null)
            {
                _EditControl = new Label();
                _EditControl.SetValue(Label.BackgroundProperty, null);
                _EditControl.SetValue(Label.ClipToBoundsProperty, false);
                _EditControl.SetValue(Label.UseLayoutRoundingProperty, true);
                _EditControl.SetValue(Label.PaddingProperty, new Thickness(0));
                _EditControl.SetValue(Label.MarginProperty, new Thickness(0, 5, 0, -1));
                _EditControl.SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased);
                _EditControl.SetValue(Label.RenderTransformOriginProperty, new Point(0.5, 0.5));

                ExRichTextBox temprich = new ExRichTextBox();
                temprich.SetValue(ExRichTextBox.PaddingProperty, new Thickness(0));
                temprich.SetValue(ExRichTextBox.MarginProperty, new Thickness(0));

                temprich.SetValue(ExRichTextBox.BorderThicknessProperty, new Thickness(0));
                temprich.SetValue(ExRichTextBox.BackgroundProperty, null);//new SolidColorBrush(Color.FromRgb(255,0,0))
                temprich.SetValue(ExRichTextBox.BorderBrushProperty, null);

                _EditControl.Content = temprich;
            }
            else if (_EditControl.Parent != null)
            {
                SmallEditText ParentUI = _EditControl.Parent as SmallEditText;
                if (ParentUI != null)
                {
                    ParentUI.RemoveContent(_EditControl);
                }
            }
            #endregion

            AddEditMenu((ExRichTextBox)_EditControl.Content);
            #region InitBinding and Handler

            Binding bind = new Binding("TextRotate");
            bind.Source    = DataContext;
            bind.Mode      = BindingMode.OneWay;
            bind.Converter = new RotateTransConverter();
            _EditControl.SetBinding(Label.RenderTransformProperty, bind);

            bind           = new Binding("vTextVerAligen");
            bind.Source    = DataContext;
            bind.Mode      = BindingMode.TwoWay;
            bind.Converter = new VerticalAlignDataConverter();
            _EditControl.SetBinding(Label.VerticalContentAlignmentProperty, bind);

            ExRichTextBox rich = (ExRichTextBox)_EditControl.Content;

            rich.AddHandler(LostFocusEvent, new RoutedEventHandler(RichControl_LostFocus));

            bind        = new Binding("vFontSize");
            bind.Source = DataContext;
            bind.Mode   = BindingMode.TwoWay;
            bind.NotifyOnTargetUpdated = true;
            rich.SetBinding(ExRichTextBox.SectionFontsizeProperty, bind);

            bind        = new Binding("vFontColor");
            bind.Source = DataContext;
            bind.Mode   = BindingMode.TwoWay;
            bind.NotifyOnTargetUpdated = true;
            rich.SetBinding(ExRichTextBox.SectionFontcolorProperty, bind);

            bind        = new Binding("vFontFamily");
            bind.Source = DataContext;
            bind.Mode   = BindingMode.TwoWay;
            bind.NotifyOnTargetUpdated = true;
            rich.SetBinding(ExRichTextBox.SectionFontFamilyProperty, bind);

            bind        = new Binding("vFontBold");
            bind.Source = DataContext;
            bind.Mode   = BindingMode.TwoWay;
            bind.NotifyOnTargetUpdated = true;
            rich.SetBinding(ExRichTextBox.SectionFontBoldProperty, bind);

            bind        = new Binding("vFontItalic");
            bind.Source = DataContext;
            bind.Mode   = BindingMode.TwoWay;
            bind.NotifyOnTargetUpdated = true;
            rich.SetBinding(ExRichTextBox.SectionFontItalicProperty, bind);

            bind        = new Binding("vFontUnderLine");
            bind.Source = DataContext;
            bind.Mode   = BindingMode.TwoWay;
            bind.NotifyOnTargetUpdated = true;
            rich.SetBinding(ExRichTextBox.SectionFontUnderlineProperty, bind);

            bind        = new Binding("vFontStrickeThrough");
            bind.Source = DataContext;
            bind.Mode   = BindingMode.TwoWay;
            bind.NotifyOnTargetUpdated = true;
            rich.SetBinding(ExRichTextBox.SectionFontStrikeThoughProperty, bind);

            bind        = new Binding("vTextHorAligen");
            bind.Source = DataContext;
            bind.Mode   = BindingMode.TwoWay;
            bind.NotifyOnTargetUpdated = true;
            bind.Converter             = new DocmentAlignDataConverter();
            rich.SetBinding(ExRichTextBox.FontAlignmentProperty, bind);

            bind        = new Binding("vTextBulletStyle");
            bind.Source = DataContext;
            bind.NotifyOnTargetUpdated = true;
            bind.Mode = BindingMode.TwoWay;
            rich.SetBinding(ExRichTextBox.TextBulletStyleProperty, bind);

            bind        = new Binding("vTextContent");
            bind.Source = DataContext;
            bind.NotifyOnTargetUpdated = true;
            bind.Mode = BindingMode.TwoWay;
            rich.SetBinding(ExRichTextBox.TextProperty, bind);

            #endregion

            return(_EditControl);
        }