FieldBaseControl.cs :  » Persistence-Frameworks » FileHelpers-Library » FileHelpers » WizardApp » 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 » FileHelpers Library 
FileHelpers Library » FileHelpers » WizardApp » FieldBaseControl.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using FileHelpers.RunTime;

namespace FileHelpers.WizardApp{
    public partial class FieldBaseControl : UserControl
    {

        bool mInit = true;

        public FieldBaseControl()
        {
            InitializeComponent();
            this.DoubleBuffered = true;
            cboTrim.SelectedIndex = 0;
            mInit = false;
        }

        bool isFocused = false;

        protected override void OnEnter(EventArgs e)
        {
            base.OnEnter(e);
            isFocused = true;
            this.Invalidate();
        }

        protected override void OnLeave(EventArgs e)
        {
            base.OnLeave(e);
            isFocused = false;
            this.Invalidate();
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);


            LinearGradientBrush lb;
            
            if (isFocused)
//                lb = new LinearGradientBrush(this.ClientRectangle, Color.FromArgb(255, 224, 192), Color.White, LinearGradientMode.Horizontal);
                lb = new LinearGradientBrush(this.ClientRectangle, Color.FromArgb(205, 195, 180), Color.FromArgb(248,248,248), LinearGradientMode.Horizontal);
            else
                lb = new LinearGradientBrush(this.ClientRectangle, Color.FromArgb(235, 225, 215), Color.FromArgb(250,250,250), LinearGradientMode.Horizontal);

            e.Graphics.FillRectangle(lb, this.ClientRectangle);

            e.Graphics.DrawRectangle(Pens.Gray, 0, 0, this.Width - 1, this.Height - 1);
            lb.Dispose();


        }


        private FieldBuilder mFieldInfo;

        public virtual void FieldInfoReload()
        {
            if (mFieldInfo != null)
            {
                txtName.Text = mFieldInfo.FieldName;
                txtName.SelectAll();
                txtType.Text = mFieldInfo.FieldType;
                cboTrim.SelectedItem = mFieldInfo.TrimMode;
            }

        }

        internal FieldBuilder FieldInfo
        {
            get { return mFieldInfo; }
            set 
            {
                 mFieldInfo = value;
                 FieldInfoReload();
            }
        }


        private void txtName_TextChanged(object sender, EventArgs e)
        {
            mFieldInfo.FieldName = txtName.Text;
            OnInfoChanged();
        }

        private void txtType_SelectedIndexChanged(object sender, EventArgs e)
        {
            mFieldInfo.FieldType = txtType.Text;
            OnInfoChanged();
        }

        private void txtType_TextChanged(object sender, EventArgs e)
        {
            mFieldInfo.FieldType = txtType.Text;
            OnInfoChanged();
        }

        private void LabelControlsClick(object sender, EventArgs e)
        {
            this.Focus();
        }

        public event EventHandler InfoChanged;
        public event EventHandler OrderChanged;

        protected void OnInfoChanged()
        {
            if (InfoChanged != null)
                InfoChanged(this, EventArgs.Empty);
        }

        protected void OnOrderChanged()
        {
            if (OrderChanged != null)
                OrderChanged(this, EventArgs.Empty);
        }

        private void lblDelete_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            this.Parent.Controls.Remove(this);
            OnOrderChanged();
        }

        private void lblUp_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            int index = this.Parent.Controls.GetChildIndex(this);
            if (index > 0)
            {
                this.Parent.Controls.SetChildIndex(this, index - 1);
                OnOrderChanged();
            }
        }

        private void lblDown_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            int index = this.Parent.Controls.GetChildIndex(this);
            if (index < this.Parent.Controls.Count - 1)
            {
                this.Parent.Controls.SetChildIndex(this, index + 1);
                OnOrderChanged();
            }
        }

        private void cboTrim_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (mInit == false)
            {
                mFieldInfo.TrimMode = (TrimMode)Enum.Parse(typeof(TrimMode), cboTrim.Text);
                OnInfoChanged();
            }
        }

        private void chkOptional_CheckedChanged(object sender, EventArgs e)
        {
            if (mInit == false)
            {
                mFieldInfo.FieldOptional = chkOptional.Checked;
                OnInfoChanged();
            }
        }



    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.