Esempio n. 1
0
 public TileBrushEditor(BrushEditor brushEditor, ITypeId brushType, SceneNodeProperty basisProperty)
     : base(brushEditor, basisProperty)
 {
     if (PlatformTypes.VisualBrush.Equals((object)brushType))
     {
         this.brushCategory = BrushCategory.Visual;
     }
     else if (PlatformTypes.ImageBrush.Equals((object)brushType))
     {
         this.brushCategory = BrushCategory.Image;
     }
     else if (PlatformTypes.DrawingBrush.Equals((object)brushType))
     {
         this.brushCategory = BrushCategory.Drawing;
     }
     else if (PlatformTypes.VideoBrush.Equals((object)brushType))
     {
         this.brushCategory = BrushCategory.Video;
     }
     else if (PlatformTypes.WebBrowserBrush.Equals((object)brushType))
     {
         this.brushCategory = BrushCategory.Html;
     }
     this.editorTemplate            = new DataTemplate();
     this.editorTemplate.VisualTree = new FrameworkElementFactory(typeof(TileBrushEditorControl));
     this.stretchProperty           = this.RegisterProperty(TileBrushNode.StretchProperty, new PropertyChangedEventHandler(this.OnStretchChanged));
     this.tileModeProperty          = this.RegisterProperty(TileBrushNode.TileModeProperty, new PropertyChangedEventHandler(this.OnTileModeChanged));
     this.imageSourceProperty       = this.RegisterProperty(ImageBrushNode.ImageSourceProperty, new PropertyChangedEventHandler(this.OnImageSourceChanged));
     this.opacityProperty           = this.RegisterProperty(BrushNode.OpacityProperty, new PropertyChangedEventHandler(this.OnOpacityChanged));
     this.AdvancedProperties.Add((PropertyEntry)this.opacityProperty);
     this.relativeTransformProperty = this.RegisterProperty(BrushNode.RelativeTransformProperty, new PropertyChangedEventHandler(this.OnRelativeTransformChanged));
     this.AdvancedProperties.Add((PropertyEntry)this.relativeTransformProperty);
     this.IsSilverlight = !basisProperty.SceneNodeObjectSet.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf);
 }
Esempio n. 2
0
        public GradientBrushEditor(BrushEditor brushEditor, ITypeId brushType, SceneNodeProperty basisProperty)
            : base(brushEditor, basisProperty)
        {
            IPlatformMetadata platformMetadata = basisProperty.SceneNodeObjectSet.DocumentContext.TypeResolver.PlatformMetadata;

            if (PlatformTypes.LinearGradientBrush.Equals((object)brushType))
            {
                this.brushCategory = BrushCategory.LinearGradient;
            }
            else if (PlatformTypes.RadialGradientBrush.Equals((object)brushType))
            {
                this.brushCategory = BrushCategory.RadialGradient;
            }
            this.editorTemplate            = new DataTemplate();
            this.editorTemplate.VisualTree = new FrameworkElementFactory(typeof(GradientBrushEditorControl));
            this.gradientStopsProperty     = this.RegisterProperty(GradientBrushNode.GradientStopsProperty, (PropertyChangedEventHandler)null);
            this.gradientStopsProperty.PropertyReferenceChanged += new Microsoft.Expression.DesignSurface.Documents.PropertyReferenceChangedEventHandler(this.OnGradientStopsChange);
            basisProperty.SceneNodeObjectSet.DesignerContext.GradientToolSelectionService.PropertyChanged += new PropertyChangedEventHandler(this.OnGradientStopSelectionChange);
            this.gradientStops           = new ObservableCollection <GradientStopEditor>();
            this.gradientStopsView       = (ListCollectionView)CollectionViewSource.GetDefaultView((object)this.gradientStops);
            this.sortedGradientStopsView = new ListCollectionView((IList)this.gradientStops);
            this.sortedGradientStopsView.SortDescriptions.Add(new SortDescription("Offset", ListSortDirection.Ascending));
            this.sortedGradientStopsView.SortDescriptions.Add(new SortDescription("PropertyIndex", ListSortDirection.Ascending));
            this.gradientStops.CollectionChanged  += new NotifyCollectionChangedEventHandler(this.OnGradientStopsChanged);
            this.gradientStopsView.CurrentChanged += new EventHandler(this.OnCurrentStopChanged);
            this.RebuildAdvancedProperties();
            this.RebuildModel(-1);
        }
Esempio n. 3
0
        private void ChangeBrushType(BrushCategory brushCategory)
        {
            if (this.editingProperty == null || this.IsEditingCategory(brushCategory))
            {
                return;
            }
            ITypeId type = (ITypeId)this.editingProperty.ComputedValueTypeId;
            bool    flag = false;

            if (type != null && this.editingProperty.IsResource && (type.Equals((object)brushCategory.Type) || PlatformTypes.GradientBrush.IsAssignableFrom(type) && brushCategory.DefaultBrush is GradientBrush || PlatformTypes.TileBrush.IsAssignableFrom(type) && brushCategory.DefaultBrush is TileBrush))
            {
                flag = true;
            }
            if (this.brushSubtypeEditor != null)
            {
                BrushCategory.SetLastUsed(this.brushSubtypeEditor.Category, this.editingProperty.GetValue());
            }
            if (flag)
            {
                this.editingProperty.DoSetLocalValue();
            }
            else
            {
                this.editingProperty.SetValue(BrushCategory.GetLastUsed(this.editingProperty.SceneNodeObjectSet.DesignerContext, this.editingProperty.SceneNodeObjectSet.DocumentContext, brushCategory));
            }
            this.editingProperty.Recache();
            this.Rebuild();
        }
Esempio n. 4
0
 private bool IsEditingCategory(BrushCategory brushCategory)
 {
     if (this.brushSubtypeEditor != null && this.brushSubtypeEditor.Category == brushCategory)
     {
         return(!this.editingResource);
     }
     return(false);
 }
Esempio n. 5
0
 public static void SetLastUsed(BrushCategory brushCategory, object brush)
 {
     BrushCategory.LastUsedBrush[brushCategory].SetBrush(brush);
     if (brushCategory == BrushCategory.LinearGradient || brushCategory == BrushCategory.RadialGradient)
     {
         BrushCategory.LastUsedBrush[BrushCategory.Gradient].SetBrush(brush);
     }
     else
     {
         if (brushCategory != BrushCategory.Drawing && brushCategory != BrushCategory.Visual && (brushCategory != BrushCategory.Image && brushCategory != BrushCategory.Video))
         {
             return;
         }
         BrushCategory.LastUsedBrush[BrushCategory.Tile].SetBrush(brush);
     }
 }
Esempio n. 6
0
        private void UpdateBrushEditorFromDataContext()
        {
            Microsoft.Windows.Design.PropertyEditing.PropertyValue propertyValue = this.DataContext as Microsoft.Windows.Design.PropertyEditing.PropertyValue;
            SceneNodeProperty sceneNodeProperty = (SceneNodeProperty)null;

            if (propertyValue != null)
            {
                sceneNodeProperty = (SceneNodeProperty)propertyValue.ParentProperty;
            }
            if (sceneNodeProperty == this.editingProperty)
            {
                return;
            }
            BrushCategory.ResetLastUsedBrushes();
            this.ResetEditingProperty();
            this.editingProperty = sceneNodeProperty;
            if (this.editingProperty != null)
            {
                this.editingProperty.PropertyReferenceChanged += new Microsoft.Expression.DesignSurface.Documents.PropertyReferenceChangedEventHandler(this.OnBrushChanged);
            }
            this.OnPropertyChanged("EditingProperty");
            this.Rebuild();
        }
Esempio n. 7
0
 private void Rebuild()
 {
     if (this.editingProperty == null)
     {
         this.BrushSubtypeEditor = (BrushSubtypeEditor)null;
     }
     else
     {
         if (!this.editingProperty.Associated)
         {
             return;
         }
         this.oldNichedState  = this.editingProperty.IsMixedValue;
         this.editingResource = false;
         bool flag = this.brushSubtypeEditor is BrushEditor.NullBrushEditor;
         if (this.editingProperty.IsResource)
         {
             this.editingResource = true;
             this.editingProperty.SceneNodeObjectSet.InvalidateLocalResourcesCache();
             this.BrushSubtypeEditor = (BrushSubtypeEditor)null;
             this.Dispatcher.BeginInvoke(DispatcherPriority.Background, (Delegate)(o =>
             {
                 if (this.editingProperty != null && this.ResourceList.IsLoaded && this.Parent != null)
                 {
                     this.ResourceList.ApplyTemplate();
                     ItemsControl itemsControl = (ItemsControl)this.ResourceList.Template.FindName("ResourcesControl", (FrameworkElement)this.ResourceList);
                     itemsControl.ApplyTemplate();
                     ItemsPresenter itemsPresenter = (ItemsPresenter)itemsControl.Template.FindName("ResourcesItemsPresenter", (FrameworkElement)itemsControl);
                     itemsPresenter.ApplyTemplate();
                     WorkaroundVirtualizingStackPanel virtualizingStackPanel = (WorkaroundVirtualizingStackPanel)itemsControl.ItemsPanel.FindName("VirtualizingStackPanel", (FrameworkElement)itemsPresenter);
                     int index = -1;
                     if (this.editingProperty.SelectedLocalResourceModel != null)
                     {
                         this.editingProperty.SelectedLocalResourceModel.Parent.IsExpanded = true;
                         index = itemsControl.Items.IndexOf((object)this.editingProperty.SelectedLocalResourceModel);
                     }
                     else if (this.editingProperty.SelectedSystemResourceModel != null)
                     {
                         this.editingProperty.SelectedSystemResourceModel.Parent.IsExpanded = true;
                         index = itemsControl.Items.IndexOf((object)this.editingProperty.SelectedSystemResourceModel);
                     }
                     if (index >= 0)
                     {
                         virtualizingStackPanel.BringIndexIntoViewWorkaround(index);
                     }
                 }
                 return((object)null);
             }), (object)null);
         }
         else if (this.editingProperty.IsMixedValue)
         {
             this.BrushSubtypeEditor = (BrushSubtypeEditor)null;
         }
         else
         {
             ITypeId typeId = (ITypeId)this.editingProperty.ComputedValueTypeId;
             if (typeId != null)
             {
                 if (typeId.Equals((object)PlatformTypes.SolidColorBrush) && !(this.BrushSubtypeEditor is SolidColorBrushEditor))
                 {
                     this.BrushSubtypeEditor = (BrushSubtypeEditor) new SolidColorBrushEditor(this, this.editingProperty);
                 }
                 else if (PlatformTypes.GradientBrush.IsAssignableFrom(typeId))
                 {
                     if (this.BrushSubtypeEditor == null || !typeId.Equals((object)this.BrushSubtypeEditor.Category.Type))
                     {
                         this.BrushSubtypeEditor = (BrushSubtypeEditor) new GradientBrushEditor(this, typeId, this.editingProperty);
                     }
                 }
                 else if (PlatformTypes.TileBrush.IsAssignableFrom(typeId) && (this.BrushSubtypeEditor == null || !typeId.Equals((object)this.BrushSubtypeEditor.Category.Type)))
                 {
                     this.BrushSubtypeEditor = (BrushSubtypeEditor) new TileBrushEditor(this, typeId, this.editingProperty);
                 }
                 if (this.BrushSubtypeEditor != null)
                 {
                     BrushCategory.SetLastUsed(this.BrushSubtypeEditor.Category, this.editingProperty.GetValue());
                 }
             }
             else
             {
                 this.BrushSubtypeEditor = (BrushSubtypeEditor) new BrushEditor.NullBrushEditor();
             }
         }
         if (!(this.brushSubtypeEditor is BrushEditor.NullBrushEditor) && flag)
         {
             this.Dispatcher.BeginInvoke(DispatcherPriority.Background, (Delegate)(o =>
             {
                 this.BringIntoView();
                 return((object)null);
             }), (object)null);
         }
         this.OnEditingTypeChange();
     }
 }
Esempio n. 8
0
        public static object GetLastUsed(DesignerContext designerContext, IDocumentContext documentContext, BrushCategory brushCategory)
        {
            object obj = (object)null;

            BrushCategory.LastBrushEntry lastBrushEntry = (BrushCategory.LastBrushEntry)null;
            BrushCategory.LastUsedBrush.TryGetValue(brushCategory, out lastBrushEntry);
            if (lastBrushEntry != null)
            {
                obj = lastBrushEntry.GetBrush(designerContext, documentContext);
            }
            return(obj);
        }
Esempio n. 9
0
 static BrushCategory()
 {
     BrushCategory.ResetLastUsedBrushes();
 }