Click here to Skip to main content
15,883,749 members
Articles / Desktop Programming / WPF

Stacked Geometry Brush Factory

Rate me:
Please Sign up or sign in to vote.
4.95/5 (68 votes)
16 Jul 2010CPOL13 min read 79.4K   2.6K   103  
A geometric visual brush producer with plug-in architecture and customized XAML.
using System.Windows;
using System.Collections.ObjectModel;
using StackedGeometry;
using System.Reflection;
using System.IO;

namespace StackedGeometryDesigner
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private ObservableCollection<IGeometrySource> geometrySources = new ObservableCollection<IGeometrySource>();
        private ObservableCollection<IEffectFactory> effectFactories = new ObservableCollection<IEffectFactory>();

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Height = 540;

       

            geometrySources.Clear();
            effectFactories.Clear();

            AttributeReflector ar = new AttributeReflector();
         
            
            ar.ReflectionItems.Add(new AttributeReflectionItem
                                       {
                AssemblyAttribute = typeof(ContainsGeometrySourcesAttribute),
                ClassAttribute = typeof(GeometrySourceAttribute),
                List = geometrySources
            });

            ar.ReflectionItems.Add(new AttributeReflectionItem
                                       {
                AssemblyAttribute = typeof(ContainsEffectFactoriesAttribute),
                ClassAttribute = typeof(EffectFactoryAttribute),
                List = effectFactories
            });
            string currentAssemblyDirectoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            ar.Reflect(currentAssemblyDirectoryName, SearchOption.AllDirectories);

            foreach (IGeometrySource gs in geometrySources)
            {
                gs.DesignMode = true;
            }
            foreach (IEffectFactory ef in effectFactories)
            {
                ef.DesignMode = true;
            }
            cmbGeometry.ItemsSource = geometrySources;
            cmbEffectFactory.ItemsSource = effectFactories;
            cmbGeometry.SelectedIndex = 0;
            cmbEffectFactory.SelectedIndex = 0;



            XamlDocumenter doc = (XamlDocumenter)FindResource("StackedDocumenter");
            doc.XamlRun = xamlRun;
            doc.Enabled = false;
        }

        private void DisplayTabs_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            XamlDocumenter doc = (XamlDocumenter)FindResource("StackedDocumenter");
            if (DisplayTabs.SelectedIndex ==0)
            {
                doc.Enabled = false;
            }else
            {
                doc.Enabled = true;
            }

        }

      
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
Written software for what seems like forever. I'm currenly infatuated with WPF. Hopefully my affections are returned.

Comments and Discussions