Пример #1
0
        private void ChangeColorFromColorPicker(Control colorPicker, EventArgs e)
        {
            if (colorPicker is SolidColorPicker)
            {
                SolidColorPicker solidColorPicker = (SolidColorPicker)colorPicker;
                Color            newColor         = solidColorPicker.SelectedColor;
                GeoColor         newGeoColor      = GeoColor2MediaColorConverter.ConvertBack(newColor);

                hatchColorPicker.SyncBaseColor(DrawingColorToMediaColorConverter.ConvertBack(newColor));
                gradientPicker.SyncBaseColor(DrawingColorToMediaColorConverter.ConvertBack(newColor));

                SelectedBrush = new GeoSolidBrush(newGeoColor);
            }
            else if (colorPicker is HatchPicker)
            {
                HatchPicker hatchPicker = (HatchPicker)colorPicker;
                System.Drawing.Drawing2D.HatchStyle drawingHatchStyle = hatchPicker.SelectedHatchStyle;
                GeoHatchStyle geoHatchStyle = GeoHatchStyle2DrawingHatchStyle.ConvertBack(drawingHatchStyle);

                //solidColorPicker.SyncBaseColor(hatchPicker.ForegroundColor);
                gradientPicker.SyncBaseColor(hatchPicker.ForegroundColor);

                SelectedBrush = new GeoHatchBrush(geoHatchStyle, GeoColor2DrawingColorConverter.ConvertBack(hatchPicker.ForegroundColor)
                                                  , GeoColor2DrawingColorConverter.ConvertBack(hatchColorPicker.BackgroundColor));
            }
            else if (colorPicker is TexturePicker)
            {
                PropertyChangedEventArgs args          = (PropertyChangedEventArgs)e;
                TexturePicker            texturePicker = (TexturePicker)colorPicker;
                if (args.PropertyName == "SelectedBrush")
                {
                    ImageBrush mediaBrush = texturePicker.SelectedBrush as ImageBrush;
                    if (mediaBrush != null)
                    {
                        BitmapImage imageSource = (BitmapImage)mediaBrush.ImageSource;
                        if (imageSource != null)
                        {
                            SelectedBrush = new GeoTextureBrush(new GeoImage(imageSource.UriSource.LocalPath));
                        }
                    }
                }
            }
            else if (colorPicker is DrawingLinearGradientBrushPicker)
            {
                DrawingLinearGradientBrushPicker linearPicker = (DrawingLinearGradientBrushPicker)colorPicker;
                LinearGradientBrushEntity        brushEntity  = linearPicker.SelectedBrush;

                solidColorPicker.SyncBaseColor(brushEntity.StartColor);
                hatchColorPicker.SyncBaseColor(brushEntity.StartColor);

                SelectedBrush = new GeoLinearGradientBrush(GeoColor2DrawingColorConverter.ConvertBack(brushEntity.StartColor),
                                                           GeoColor2DrawingColorConverter.ConvertBack(brushEntity.EndColor),
                                                           brushEntity.Angle);
            }
        }
Пример #2
0
 internal void SyncBaseColor(System.Drawing.Color color)
 {
     stopColorChangedEvent = true;
     SelectedColor         = DrawingColorToMediaColorConverter.Convert(color);
     stopColorChangedEvent = false;
 }
Пример #3
0
 public static Color ConvertBack(System.Windows.Media.SolidColorBrush mediaBrush)
 {
     return(DrawingColorToMediaColorConverter.ConvertBack(mediaBrush.Color));
 }