PDGridTitle.cs :  » Persistence-Frameworks » csopf » csopf » UI » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Persistence Frameworks » csopf 
csopf » csopf » UI » PDGridTitle.cs
/*
    C# Object Persistent Framework.
    Copyright (C) 2004  Yoon-Kit Yong

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    Yoon Kit:  yoonkit@users.sourceforge.net (yoonkit@yahoo.com)
*/

using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.Xml.Serialization;
//using System.Web.UI;


//using System.Drawing.Design;


using csopf.Core;

namespace csopf.UI{
    /// <summary>
    /// Sets the Table Titles for the
    ///   PropertyName
    ///   ColumnTitle
    ///   Size and Relative Size
    ///   Clickable
    /// 041003  yky  Created
    ///                 Property, Title, Size, Clickable.
    /// 041130  yky  Added PDGridTitleConverter for its TypeConverter.                
    /// </summary>
    //[ToolboxData("<{0}:PDGridTitle runat=server></{0}:PDGridTitle>")]
    [TypeConverter(typeof(PDGridTitleConverter))]
    //[Serializable()]
    public class PDGridTitle//: Control 
    {
        private string fProperty;
        public string Property
        {
            get { return fProperty; }
            set { fProperty = value; }
        }

        private string fTitle;
        public string Title
        {
            get { return fTitle; }
            set { fTitle = value; }
        }

        private int fSize;
        public int Size
        {
            get { return fSize; }
            set { fSize = value; }
        }

        private bool fClickable = false;
        public bool Clickable
        {
            get { return fClickable; }
            set { fClickable = value; }
        }

        public int RelativeSize;
        public MetaInfo Info;

        public PDGridTitle(): this( "Property", "Title" ) 
        {}

        public PDGridTitle( string pProperty ): this( pProperty, pProperty )
        {}

        public PDGridTitle( string pProperty, string pTitle ): this (pProperty, pTitle, 10)
        {}

        public PDGridTitle( string pProperty, string pTitle, int pSize ): this (pProperty, pTitle, pSize, false )
        {}

        public PDGridTitle( string pProperty, string pTitle, int pSize, bool pClickable )
        {
            Property = pProperty;
            Title = pTitle;
            Size = pSize;
            Info = null;
            Clickable = pClickable;
        }
    }

    /// <summary>
    /// Class to convert the PDGridTitle object to and
    /// from something editable via the Designer.
    /// 041130  yky  Created
    ///                 Unfortunately the Title property is an ArrayList.
    ///                 Not entirely sure on how to set this thing to editable.
    ///                 Ref: 'Designer Intergration for ASP.NET Custom Controls' by Fritz Onion (DevelopMentor)
    /// </summary>
    public class PDGridTitleConverter: ExpandableObjectConverter // TypeConverter
    {
        public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
        {
            if (sourceType == typeof(string))
                return true;
            else
                return base.CanConvertFrom (context, sourceType);
        }

        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
        {
            if ( (destinationType == typeof(InstanceDescriptor)) ||
                (destinationType == typeof(string)) )
                return true;
            return base.CanConvertTo (context, destinationType);
        }

        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            string vVal = value as string;
            if (vVal != null)
            {
                string[] vArr = vVal.Split(',');
                return new PDGridTitle( vArr[0], vArr[1], Convert.ToInt32(vArr[2]), Convert.ToBoolean( vArr[3] ) );
            }
            else
                return base.ConvertFrom (context, culture, value);
        }

        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            PDGridTitle vTitle = value as PDGridTitle;
            if (destinationType == typeof(string))
            {
                return string.Format("{0},{1},{2},{3}", 
                    vTitle.Property, vTitle.Title, 
                    vTitle.Size, vTitle.Clickable );
            } 
            else if (destinationType == typeof(InstanceDescriptor))
            {
                Type[] vParam = new Type[] { typeof(string), typeof(string), typeof(int), typeof(bool) };
                object[] vVal = new object[] { vTitle.Property, vTitle.Title, vTitle.Size, vTitle.Clickable };
                return new InstanceDescriptor( typeof(PDGridTitle).GetConstructor( vParam ), vVal );
            }
            return base.ConvertTo (context, culture, value, destinationType);
        }
    }
    /*   // 041201  yky  Not sure why this doesnt work.  
    //[Serializable()]
    public class PDGridTitleList: ArrayList
    {
        new public PDGridTitle this[ int index ]
        {
            get { return base[ index ] as PDGridTitle; }
            set { base[index] = value; }
        }
    }              */
    // 041201  yky  fobbed off wwWebTabControlList   
    public class PDGridTitleList : CollectionBase 
    {
        public PDGridTitle this[int index]
        {   get { return (PDGridTitle) this.List[index]; }
            set { this.List[index] = value; }
        }

        public bool HasTitle( string pTitle )
        {
            foreach( PDGridTitle vTitle in List )
               if (vTitle.Title == pTitle) return true;
            return false;
        }

        public void Add(PDGridTitle pItem) 
        {   this.List.Add(pItem); }

        public void Insert(int index, PDGridTitle pItem) 
        { this.List.Insert(index,pItem); }
    
        public void Remove(PDGridTitle pItem) 
        { List.Remove(pItem); }

        public bool Contains(PDGridTitle pItem) 
        { return this.List.Contains(pItem); }

        public int IndexOf(PDGridTitle pItem) 
        { return List.IndexOf(pItem); } 

        public void CopyTo(PDGridTitle[] array, int index) 
        { List.CopyTo(array, index); } 
    }    
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.