Click here to Skip to main content
15,886,840 members
Articles / Desktop Programming / WPF

The Time Machine

Rate me:
Please Sign up or sign in to vote.
4.91/5 (13 votes)
9 May 2012CPOL6 min read 34.1K   1.2K   32  
Long time strategy of software design and development
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Windows.Forms;

using System.Drawing;


using CategoryTheory;
using DiagramUI;
using DiagramUI.Labels;
using BasicEngineeringUIFactory;
using Database.UI.Forms;
using Database.UI.Labels;
using Diagram.UI.Factory;
using Diagram.UI.Interfaces.Labels;
using Diagram.UI.Interfaces;


namespace Database.UI.Factory
{
    public class DatabaseFactory : EmptyUIFactory
    {

        #region Fields

 
        public static readonly ButtonWrapper[] ObjectButtons = 
        {
                 new ButtonWrapper(typeof(DataSetService.StatementWrapper),
                    "", "ODBC Table", ResourceImage.Query, 
                    DatabaseFactory.Object, true, false),
                 new ButtonWrapper(typeof(DataTableSelection.DataSetSelection),
                    "", "Table selection", ResourceImage.DataTableSelection.ToBitmap(), 
                    DatabaseFactory.Object, true, false),
                 new ButtonWrapper(typeof(DataTableSelection.DataSetIterator),
                    "", "Data set iterator", ResourceImage.DataTableIterator.ToBitmap(), 
                    DatabaseFactory.Object, true, false),
                 new ButtonWrapper(typeof(DataTableSelection.DataTableSeries),
                    "", "Data table series", ResourceImage.SeriesData.ToBitmap(), 
                    DatabaseFactory.Object, true, false),
                 new ButtonWrapper(typeof(DataSetService.SavedDataProvider),
                    "", "Saved data set", ResourceImage.DataSave.ToBitmap(), 
                    DatabaseFactory.Object, true, false)
               /*  new ButtonWrapper(typeof(DataSetWeb.StatementWrapperWeb),
                    "", "Web service data", ResourceImage.DataWeb.ToBitmap(), 
                    DatabaseFactory.Object, true, false),*/
         };

        public static readonly Dictionary<Type, Image> TypeImage =
            ButtonWrapper.CreateImageDictionary(ObjectButtons);

        public static readonly ButtonWrapper[] ArrowButtons = 
        {
                 new ButtonWrapper(typeof(DataSetService.DataSetArrow),
                    "", "Link between table provider and table consumer", 
                    ResourceImage.DataTableSelectionLink.ToBitmap(), 
                    DatabaseFactory.Object, true, true),
        };


        /// <summary>
        /// Singleton
        /// </summary>
        public static DatabaseFactory Object = new DatabaseFactory();



        #endregion

        #region Ctor

        private DatabaseFactory()
        {
            Dictionary<Type, Image> d = DataPerformerUI.Labels.NamedlSeriesLabel.ImageDictionary;
            Dictionary<Type, Image> dic = ButtonWrapper.CreateImageDictionary(ObjectButtons);
            foreach (Type type in dic.Keys)
            {
                if (!d.ContainsKey(type))
                {
                    d[type] = dic[type];
                }
            }
            Dictionary<Type, Icon> ico = DataPerformerUI.Labels.NamedlSeriesLabel.IconDictionary;
            ico[typeof(DataTableSelection.DataTableSeries)] = ResourceImage.SeriesData;
 
        }

        #endregion

        #region IUIFactory Members

 
 

        public override object CreateForm(INamedComponent comp)
        {
            if (comp is IObjectLabel)
            {
                IObjectLabel lab = comp as IObjectLabel;
                // The object of component
                ICategoryObject obj = lab.Object;
   /*             if (obj is DataSetService.StatementWrapper)
                {
                    return new FormStatementWrapper(lab);
                }
                if (obj is DataSetService.SavedDataProvider)
                {
                    return new FormSavedData(lab);
                }*/
            }
            return null;
        }


        public override IObjectLabelUI CreateObjectLabel(IPaletteButton button)
        {
            return CreateObjectLabel(button.ReflectionType, button.Kind, button.ButtonImage as System.Drawing.Image);
        }




        public override IObjectLabelUI CreateLabel(ICategoryObject obj)
        {
            Type t = obj.GetType();
            return CreateObjectLabel(t, "", null);
        }

  
        #endregion

        #region Private Members

        private IObjectLabelUI CreateObjectLabel(Type t, string kind, System.Drawing.Image image)
        {
            if (t == null)
            {
                return null;
            }
            if (t.GetInterface(typeof(DataPerformer.Interfaces.INamedCoordinates).FullName) != null)
            {
                return DataPerformerUI.Labels.NamedlSeriesLabel.Create(t);
            }
            {
                //return UserControlLabel.CreateLabel(new Labels.SeriesTableLabel(), image, false);
            }
            if (t.Equals(typeof(DataSetService.StatementWrapper)))
            {
                return UserControlLabel.CreateLabel(new Labels.QueryLabel(), image, false);
            }
            if (t.Equals(typeof(DataSetService.SavedDataProvider)))
            {
                return UserControlLabel.CreateLabel(new Labels.SavedDataLabel(), image, false);
            }
            return null;
        }


        #endregion
    }
}

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
Architect
Russian Federation Russian Federation
Ph. D. Petr Ivankov worked as scientific researcher at Russian Mission Control Centre since 1978 up to 2000. Now he is engaged by Aviation training simulators http://dinamika-avia.com/ . His additional interests are:

1) Noncommutative geometry

http://front.math.ucdavis.edu/author/P.Ivankov

2) Literary work (Russian only)

http://zhurnal.lib.ru/editors/3/3d_m/

3) Scientific articles
http://arxiv.org/find/all/1/au:+Ivankov_Petr/0/1/0/all/0/1

Comments and Discussions