Exemplo n.º 1
0
        //public DropDownTreeCardsController(ChooserEditor editor, IDropDownControl ctl)
        //    : base(editor, ctl)
        //{
        //    ddController = new CardGridChooserController<TS, TD, CS, CD>(ctl.Grid);
        //    ddController.Reload(null);
        //    ddController.DatValueChanged += new DatEventDelegate(ddController_DatValueChanged);
        //    ddController.DatValueSelected += new DatEventDelegate(ddController_DatValueSelected);
        //    ddController.ListReloaded += new EventHandler<EventArgs<TD>>(ddController_ListReloaded);
        //}

        public DropDownTreeCardsController(ChooserEditor editor, IDropDownControl ctl, bool reload)
            : base(editor, ctl, reload)
        {
            ddController = new CardGridChooserController <TS, TD, CS, CD>(ctl.Grid);
            ddController.Reload(null);
            ddController.DatValueChanged  += new DatEventDelegate(ddController_DatValueChanged);
            ddController.DatValueSelected += new DatEventDelegate(ddController_DatValueSelected);
            ddController.ListReloaded     += new EventHandler <EventArgs <TD> >(ddController_ListReloaded);
        }
Exemplo n.º 2
0
        void Editor_PrevValue(object sender, EventArgs e)
        {
            ChooserEditor editor = sender as ChooserEditor;

            if (editor != null && set != null)
            {
                int index = set.IndexOf(editor.Value) - 1;
                if (index >= 0 && index < set.Count)
                {
                    editor.Value = set[index] as CD;
                }
            }
        }
Exemplo n.º 3
0
        public DropDownController(ChooserEditor editor, IDropDownControl ctl, CS bset, bool reload)
            : base(editor, bset, reload)
        {
            ddControl = ctl;
            ddForm    = new DropDownFormBase(this, ddControl);
            ddControl.Grid.DataSource = set;
            ddControl.RowEntered     += new EventHandler <EventArgs <int> >(ddControl_RowEntered);
            ddControl.RowSelected    += new EventHandler <EventArgs <int> >(ddControl_RowSelected);
            ddControl.DropDownClosed += new EventHandler(ddControl_DropDownClosed);

            Editor = editor;
            Editor.ValueDropDown += Editor_ValueDropDown;
            //Editor.ValueChanged += new EventHandler(Editor_ValueChanged);
        }
Exemplo n.º 4
0
        protected virtual void OnValueChanged(object sender, EventArgs e)
        {
            ChooserEditor editor = sender as ChooserEditor;

            if (editor != null && editor.Value != null)
            {
                if (!(editor.Value is CD))
                {
                    string ex = string.Format("ѕопытка записи в поле {0} с типом {1} значени¤ '{2}' c типом {3}"
                                              , editor.Name
                                              , typeof(CD)
                                              , editor.Value
                                              , editor.Value.GetType()
                                              );

                    throw new Exception(ex);
                }
            }
        }
Exemplo n.º 5
0
        void Editor_TextChanged(object sender, EventArgs e)
        {
            ChooserEditor editor = sender as ChooserEditor;

            if (editor != null)
            {
                if (BaseDat.ToString(editor.Value, editor.Format) == editor.Text)
                {
                    return;
                }

                if (editor.AutoCompleteMode != AutoCompleteMode.None)
                {
                    int index = editor.AutoCompleteCustomSource.IndexOf(editor.Text);
                    if (index >= 0)
                    {
                        CD dat = set[index] as CD;
                        editor.Value = dat;
                    }
                }
                else
                {
                    string text = editor.Text.ToLower();

                    for (int i = 0; i < set.Count; i++)
                    {
                        CD     dat  = set[i] as CD;
                        string sdat = dat.ToString(editor.Format, null);
                        if (dat != null && sdat.ToLower().StartsWith(text))
                        {
                            editor.Value           = dat;
                            editor.SelectionStart  = text.Length;
                            editor.SelectionLength = sdat.Length - text.Length;
                            return;
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// —оздаетс¤ новый контроллер и прив¤зываетс¤ к заданному ChooserEditor.
        /// Set-класс используетс¤ без загрузки! Ќадо загрузить заранее!
        /// </summary>
        /// <param name="editor"></param>
        /// <param name="setclass"></param>
        public ChooserController(ChooserEditor editor, CS setclass, bool reload)
        {
            editor.ReadOnly      = false;
            editor.ValueChanged += new EventHandler(editor_ValueChanged);
            editor.TextChanged  += new EventHandler(Editor_TextChanged);

            if (setclass == null)
            {
                set = new CS();
                if (reload)
                {
                    set.Load();
                }
            }
            else
            {
                set = setclass;
            }

            if (set.Count > 0)
            {
                CD d = set[0] as CD;
                if (d != null && d is IDat)
                {
                    Dictionary <int, string> dict = new Dictionary <int, string>(set.Count);
                    foreach (CD dat in set)
                    {
                        dict.Add(((IDat)dat).ID, BaseDat.ToString(dat, editor.Format));
                    }

                    set.Sort(delegate(CD dat1, CD dat2)
                    {
                        return(string.Compare(dict[((IDat)dat1).ID], dict[((IDat)dat2).ID]));
                    });
                }
                else
                {
                    set.Sort(delegate(CD dat1, CD dat2)
                    {
                        return(string.Compare(BaseDat.ToString(dat1, editor.Format), BaseDat.ToString(dat2, editor.Format)));
                    });
                }
            }
            if (editor.AutoCompleteMode != AutoCompleteMode.None)
            {
                editor.AutoCompleteSource       = AutoCompleteSource.CustomSource;
                editor.AutoCompleteCustomSource = new AutoCompleteStringCollection();

                List <string> ls = set.ConvertType <string>(delegate(CD dat)
                {
                    return(BaseDat.ToString(dat, editor.Format));
                });
                editor.AutoCompleteCustomSource.AddRange(ls.ToArray());
            }
            else
            {
                editor.PrevValue += new EventHandler(Editor_PrevValue);
                editor.NextValue += new EventHandler(Editor_NextValue);
            }
            editor.Value = null;
        }
Exemplo n.º 7
0
 public ChooserController(ChooserEditor editor, CS setclass)
     : this(editor, setclass, true)
 {
 }
Exemplo n.º 8
0
 /// <summary>
 /// —оздаетс¤ новый контроллер и прив¤зываетс¤ к заданному ChooserEditor.
 /// Set-класс загружаетс¤ полностью.
 /// </summary>
 /// <param name="editor"></param>
 public ChooserController(ChooserEditor editor)
     : this(editor, null)
 {
 }
Exemplo n.º 9
0
 public DropDownTreeCardsController(ChooserEditor editor, bool reload)
     : this(editor, new DropDownGridStatus(), reload)
 {
 }
Exemplo n.º 10
0
 public DropDownTreeCardsController(ChooserEditor editor)
     : this(editor, new DropDownGridStatus(), true)
 {
 }
Exemplo n.º 11
0
 public DropDownController(ChooserEditor editor, IDropDownControl ctl, CS bset)
     : this(editor, ctl, bset, true)
 {
 }
Exemplo n.º 12
0
 public DropDownController(ChooserEditor editor, IDropDownControl ctl, bool reload)
     : this(editor, ctl, null, reload)
 {
 }
Exemplo n.º 13
0
        /// <summary>
        /// Конструктор с заданным IDropDownControl - выпадающим контролом
        /// </summary>
        /// <param name="editor"></param>
        /// <param name="ctl"></param>
        //public DropDownController(ChooserEditor editor, IDropDownControl ctl)
        //    : base(editor)
        //{
        //    ddControl = ctl;
        //    ddForm = new DropDownFormBase(this, ddControl);
        //    ddControl.Grid.DataSource = set;
        //    ddControl.RowEntered += new EventHandler<EventArgs<int>>(ddControl_RowEntered);
        //    ddControl.RowSelected += new EventHandler<EventArgs<int>>(ddControl_RowSelected);
        //    ddControl.DropDownClosed += new EventHandler(ddControl_DropDownClosed);

        //    Editor = editor;
        //    Editor.ValueDropDown += Editor_ValueDropDown;
        //    //Editor.ValueChanged += new EventHandler(Editor_ValueChanged);
        //}

        public DropDownController(ChooserEditor editor, IDropDownControl ctl)
            : this(editor, ctl, null)
        {
        }
Exemplo n.º 14
0
 public DropDownController(ChooserEditor editor, CS bset)
     : this(editor, new DropDownGrid(), bset)
 {
 }
Exemplo n.º 15
0
 /// <summary>
 /// Конструктор со стандартным выпадающим DropDownGrid
 /// </summary>
 /// <param name="editor"></param>
 public DropDownController(ChooserEditor editor)
     : this(editor, new DropDownGrid())
 {
 }