internal Data.AnnotationStyle GetAnnotationStyle(Data.NewAnnotationType type)
 {
     if (_annotationStyles == null)
     {
         _annotationStyles = new Data.AnnotationStyle();
         _annotationStyles.PropertyChanged += (o, e) =>
         {
             OnPropertyChanged("AnnotationStyle");
         };
     }
     return(_annotationStyles);
 }
Example #2
0
        private void GetAnnotationEditorData(AnnotationBase anno)
        {
            var editStyle = (ContentEditor as AnnotationEditor).EditingAnnotationStyle;

            ChartStyle contentStyle = null;

            if (anno is Shape)
            {
                contentStyle = (anno as Shape).ContentStyle;
            }
            if (anno is Text)
            {
                contentStyle = anno.Style;
                Data.AnnotationStyle style = ViewModel.ViewModel.Instance.GetAnnotationStyle(Data.NewAnnotationType.Text);
                if (style != null && contentStyle != null)
                {
                    contentStyle.FontFamily = new FontFamily(style.FontFamily);
                    contentStyle.FontSize   = contentStyle.FontSize == 0 ? style.FontSize : contentStyle.FontSize;
                }
            }

            if (editStyle != null && anno != null)
            {
                editStyle.Stroke = anno.Style == null || anno.Style.Stroke == null ? Colors.Black : (anno.Style.Stroke as SolidColorBrush).Color;
                editStyle.Fill   = anno.Style == null || anno.Style.Fill == null ? Colors.Black : (anno.Style.Fill as SolidColorBrush).Color;
            }
            if (contentStyle != null)
            {
                if (anno is Text)
                {
                    editStyle.Foreground = contentStyle == null || contentStyle.Stroke == null?
                                           ViewModel.ViewModel.Instance.GetAnnotationStyle(Data.NewAnnotationType.Text).Foreground : (contentStyle.Stroke as SolidColorBrush).Color;
                }
                else
                {
                    editStyle.Foreground = contentStyle == null || contentStyle.Stroke == null ?
                                           Colors.Black : (contentStyle.Stroke as SolidColorBrush).Color;
                }

                editStyle.FontFamily = contentStyle.FontFamily.Source.ToString();
                editStyle.FontSize   = contentStyle.FontSize;
                editStyle.FontWeight = contentStyle.FontWeight;
            }
        }
Example #3
0
        private void SetAnnotationEditorData(AnnotationBase anno, Data.AnnotationStyle style)
        {
            if (anno is Text)
            {
                if (anno.Style == null)
                {
                    anno.Style = new ChartStyle();
                }

                anno.Style.Fill   = new SolidColorBrush(style.Fill);
                anno.Style.Stroke = new SolidColorBrush(style.Stroke);

                anno.Style.FontFamily = new FontFamily(style.FontFamily);
                anno.Style.FontWeight = style.FontWeight;
                anno.Style.Stroke     = new SolidColorBrush(style.Foreground);
                anno.Style.FontSize   = style.FontSize;
            }
            else if (anno is Shape)
            {
                var shape = anno as Shape;

                if (shape.Style == null)
                {
                    shape.Style = new ChartStyle();
                }

                shape.Style.Fill   = new SolidColorBrush(style.Fill);
                shape.Style.Stroke = new SolidColorBrush(style.Stroke);

                if (shape.ContentStyle == null)
                {
                    shape.ContentStyle = new ChartStyle();
                }
                shape.ContentStyle.FontFamily = new FontFamily(style.FontFamily);
                shape.ContentStyle.FontWeight = style.FontWeight;
                shape.ContentStyle.Stroke     = new SolidColorBrush(style.Foreground);
                shape.ContentStyle.FontSize   = style.FontSize;
            }
        }