コード例 #1
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null &&
                context.Instance != null &&
                provider != null)
            {
                edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (edSvc != null)
                {
                    ListBoxControl dbs = new ListBoxControl();
                    dbs.Click += Dbs_Click;

                    try
                    {
                        QDatabaseName dbName = (QDatabaseName)context.Instance.GetType().GetProperty("DatabaseName").GetValue(context.Instance, null);
                        string        sql    = "SELECT NAME FROM sysobjects WHERE xtype = 'V'";
                        QDatabase     db     = QInstance.Environments.GetDatabase(dbName);
                        DataSet       dbSet  = db.ExecuteQuery(sql);
                        dbs.DisplayMember = "NAME";
                        dbs.DataSource    = dbSet.Tables[0];
                        edSvc.DropDownControl(dbs);
                        value = ((DataRowView)dbs.SelectedItem).Row["NAME"];
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }

            return(value);
        }
コード例 #2
0
        private void secondaryVariableDependenceListBoxControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListBoxControl listBoxControl = sender as ListBoxControl;
            int            selectIndex    = listBoxControl.SelectedIndex;
            string         temVariableStr = listBoxControl.SelectedItem as string;

            if (selectIndex >= 0 && listBoxControl.Focused)
            {
                string[] keyArray = Regex.Split(temVariableStr, " --- ", RegexOptions.IgnoreCase);
                if (keyArray.Length == 2)
                {
                    string primaryKey   = keyArray[0];
                    string secondaryKey = keyArray[1];
                    ManualAssignmentPlatformWeightSetMethod manualSet = (ManualAssignmentPlatformWeightSetMethod)this.Strategy.PlatformWeightSetMethod.Value;
                    SerializableDictionary <VariableDependenceRecordKey, VariableDependenceRecord> primaryWeightDict = manualSet.SecondaryItemWeightSetMethod.Value.DependenceRecordDict;
                    VariableDependenceRecord record      = primaryWeightDict[new VariableDependenceRecordKey(primaryKey, secondaryKey)];
                    List <string>            itemStrList = new List <string>(record.ItemDependencDict.Keys);
                    this.secondaryPrimaryVariableListBoxControl.DataSource    = itemStrList;
                    this.secondaryPrimaryVariableListBoxControl.SelectedIndex = -1;
                    this.secondarySecondaryVariablGridControl.DataSource      = null;
                }
                else
                {
                    throw new Exception("key array length error");
                }
            }
        }
コード例 #3
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null &&
                context.Instance != null &&
                provider != null)
            {
                edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (edSvc != null)
                {
                    ListBoxControl dbs = new ListBoxControl();
                    dbs.Click += Dbs_Click;

                    try
                    {
                        QDatabaseName dbName = (QDatabaseName)context.Instance.GetType().GetProperty("DatabaseName").GetValue(context.Instance, null);
                        string        sql    = "select LOV_CODE, LOV_DESC from vw_at_lst_of_val where lov_type='CRITERIA_CATEGORIES' order by lov_desc";
                        QDatabase     db     = QInstance.Environments.GetDatabase(dbName);
                        DataSet       dbSet  = db.ExecuteQuery(sql);
                        dbs.DisplayMember = "LOV_DESC";
                        dbs.DataSource    = dbSet.Tables[0];
                        edSvc.DropDownControl(dbs);
                        value = ((DataRowView)dbs.SelectedItem).Row["LOV_DESC"];
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }

            return(value);
        }
コード例 #4
0
        public void leerDepartamentosListBox(ListBoxControl aRellenar)
        {
            try
            {
                using (cnn = new FbConnection(cadenaConexion))
                {
                    string query = " SELECT * FROM Departamentos";

                    cnn.Open();

                    cmd = new FbCommand(query, cnn);

                    lector = cmd.ExecuteReader();

                    aRellenar.Items.Clear();

                    while (lector.Read())
                    {
                        aRellenar.Items.Add(lector[0].ToString());
                    }
                    lector.Close();
                }
            }
            catch (Exception)
            {
                //falta por terminar
            }
        }
コード例 #5
0
        private void barcode_kayit_aoi_siniflandirma_Load(object sender, EventArgs e)
        {
            string[] States =
            {
                "Alabama",
                "Alaska",
                "Arizona",
                "California",
                "Colorado",
                "Florida",
                "Idaho",
                "Kansas",
                "Michigan",
                "Nevada",
                "Texas",
                "Utah"
            };
            // Initialize and create an instance of the ListBoxControl class
            ListBoxControl listBox = new ListBoxControl();

            // Define the parent control
            listBox.Parent = this;
            // Set the listBox's background color
            listBox.BackColor = Color.FromArgb(254, 246, 212);
            // Dock to all edges and fill the parent container
            listBox.Dock = DockStyle.Fill;
            // Add items
            listBox.Items.AddRange(States);
        }
コード例 #6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adds the specified new style.
        /// </summary>
        /// <param name="newStyle">The new style.</param>
        /// ------------------------------------------------------------------------------------
        public override void Add(BaseStyleInfo newStyle)
        {
            base.Add(newStyle);
            int index = ListBoxControl.FindStringExact(newStyle.Name);

            ListBoxControl.SelectedIndex = index;
        }
コード例 #7
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null &&
                context.Instance != null &&
                provider != null)
            {
                edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (edSvc != null)
                {
                    ListBoxControl dbs = new ListBoxControl();
                    dbs.Click += Dbs_Click;

                    try
                    {
                        QDocumentCR       doc    = (QDocumentCR)((QChangeRequest)context.Instance).GetRoot();
                        List <QPoolField> fields = doc.GetDescendants <QPoolField>();
                        List <String>     tables = fields.Select(cr => cr.TableName).Distinct().ToList();
                        dbs.DataSource = tables;
                        edSvc.DropDownControl(dbs);
                        value = dbs.SelectedItem;
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }

            return(value);
        }
コード例 #8
0
ファイル: ScannerForSerialPort.cs プロジェクト: fflorat/IRAP
        public ScannerForSerialPort(
            ListBoxControl lstBarCodes,
            StationPortInfo portInfo)
        {
            barCodes      = lstBarCodes;
            this.portInfo = portInfo;

            Parity   parity   = (Parity)portInfo.Parity;
            StopBits stopBits = (StopBits)portInfo.StopBits;

            serialPort =
                new SerialPort(
                    portInfo.CommPort,
                    portInfo.BoudRate,
                    parity,
                    portInfo.ByteSize,
                    stopBits);
            serialPort.DataReceived +=
                new SerialDataReceivedEventHandler(OnDataReceived);

            try
            {
                serialPort.Open();
            }
            catch (Exception error)
            {
                serialPortOpenError = error.Message;
            }
        }
コード例 #9
0
        /// <summary>
        /// Add item during refresh.
        /// </summary>
        /// <param name="items"></param>
        protected override void UpdateStyleList(StyleListItem[] items)
        {
            if (m_ignoreListRefresh)
            {
                return;
            }

            string selectedStyle = ListBoxControl.SelectedItem != null?
                                   ListBoxControl.SelectedItem.ToString() : string.Empty;

            ListBoxControl.Items.Clear();
            ListBoxControl.BeginUpdate();
            ListBoxControl.Items.AddRange(items);
            ListBoxControl.EndUpdate();

            SelectedStyleName = selectedStyle;

            // Ensure an item is selected, even if the previous selection is no longer
            // shown.
            if (!String.IsNullOrEmpty(selectedStyle) && ListBoxControl.SelectedItem == null)
            {
                if (ListBoxControl.Items.Count > 0)
                {
                    ListBoxControl.SelectedIndex = 0;
                }
            }
        }
コード例 #10
0
ファイル: frmVaultViewer.cs プロジェクト: GDuggi/DemoTest
        private void listBoxDocuments_DoubleClick(object sender, EventArgs e)
        {
            ListBoxControl listBoxControl = sender as ListBoxControl;
            int            index          = listBoxControl.SelectedIndex;

            if (index != -1)
            {
                string        docFileExt     = docType[index];
                DocViewerType fileViewerType = GetViewerType(docFileExt);

                switch (fileViewerType)
                {
                case DocViewerType.Rtf:
                    PopupViewerRtf(index);
                    break;

                case DocViewerType.Pdf:
                    PopupViewerPdf(index);
                    break;

                case DocViewerType.Tif:
                    PopupViewerTif(index);
                    break;

                default:
                    throw new Exception("Internal Error: " + fileViewerType + " not found");
                }
            }
        }
コード例 #11
0
ファイル: GPGTextList.cs プロジェクト: micheljung/gpgnetfix
 private void InitializeComponent()
 {
     this.listBoxTextLines = new ListBoxControl();
     ((ISupportInitialize) this.listBoxTextLines).BeginInit();
     base.SuspendLayout();
     this.listBoxTextLines.Appearance.BackColor = Color.DimGray;
     this.listBoxTextLines.Appearance.BorderColor = Color.FromArgb(0x80, 0x80, 0xff);
     this.listBoxTextLines.Appearance.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
     this.listBoxTextLines.Appearance.ForeColor = Color.FromArgb(0xff, 0xff, 0x80);
     this.listBoxTextLines.Appearance.Options.UseBackColor = true;
     this.listBoxTextLines.Appearance.Options.UseBorderColor = true;
     this.listBoxTextLines.Appearance.Options.UseFont = true;
     this.listBoxTextLines.Appearance.Options.UseForeColor = true;
     this.listBoxTextLines.Appearance.Options.UseTextOptions = true;
     this.listBoxTextLines.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
     this.listBoxTextLines.BorderStyle = BorderStyles.Simple;
     this.listBoxTextLines.Dock = DockStyle.Fill;
     this.listBoxTextLines.HotTrackItems = true;
     this.listBoxTextLines.ItemHeight = 20;
     this.listBoxTextLines.Location = new Point(0, 0);
     this.listBoxTextLines.Margin = new Padding(0, 0, 0, 0);
     this.listBoxTextLines.Name = "listBoxTextLines";
     this.listBoxTextLines.Size = new Size(0x22d, 0x79);
     this.listBoxTextLines.TabIndex = 0;
     base.AutoScaleDimensions = new SizeF(6f, 13f);
     base.AutoScaleMode = AutoScaleMode.Font;
     this.AutoScroll = true;
     this.BackColor = Color.Black;
     base.Controls.Add(this.listBoxTextLines);
     base.Margin = new Padding(0, 0, 0, 0);
     base.Name = "GPGTextList";
     base.Size = new Size(0x22d, 0x79);
     ((ISupportInitialize) this.listBoxTextLines).EndInit();
     base.ResumeLayout(false);
 }
コード例 #12
0
    private GameStartInfo SelectGame(GameStartInfo[] startInfos)
    {
        var items = new List <string>();

        foreach (var startInfo in startInfos)
        {
            items.Add(string.Format(CultureInfo.CurrentCulture, "{0} {1}", startInfo.Name, startInfo.Version));
        }

        var listBox = new ListBoxControl(this.Interpreter)
        {
            Title  = UserInterface.GameSelectionHeader,
            Width  = GameSelectionListBoxWidth,
            Height = GameSelectionListBoxHeight,
        };

        listBox.SetItems(items.ToArray());

        if (listBox.DoModal())
        {
            return(startInfos[listBox.SelectedItemIndex]);
        }

        return(null);
    }
コード例 #13
0
ファイル: WebListBox.cs プロジェクト: zhangbo27/FastReport
        private string GetListBoxHtml(ListBoxControl control)
        {
            if (control.Items.Count == 0)
            {
                control.FillData();
                ControlFilterRefresh(control);
            }
            string id   = GetControlID(control);
            string html = string.Format("<select style=\"{0}\" name=\"{1}\" size=\"{2}\" onchange=\"{3}\" id=\"{4}\">{5}</select>",
                                                                 // style
                                        GetListBoxStyle(control),
                                                                 // name
                                        control.Name,
                                                                 // size
                                        control.Items.Count.ToString(),
                                                                 // onclick
                                        GetEvent(ONCHANGE, control, DIALOG, $"document.getElementById('{id}').selectedIndex"),
                                                                 // title
                                        id,
                                        GetListBoxItems(control) //control.Text
                                        );

            control.FilterData();
            return(html);
        }
コード例 #14
0
    private void InputTypelessPoll(int key)
    {
        this.State.Variables[Variables.KeyPressed] = (byte)key;
        if (this.State.InputEnabled)
        {
            string[] words = this.ResourceManager.VocabularyResource.GetAllWords();

            var listBox = new ListBoxControl(this.Interpreter)
            {
                Title  = UserInterface.TypelessBox,
                Width  = WordSelectionListBoxWidth,
                Height = WordSelectionListBoxHeight,
            };

            listBox.SetItems(words);

            if (listBox.DoModal())
            {
                string word = words[listBox.SelectedItemIndex];

                foreach (char c in word)
                {
                    this.AddInputCharacter(c);
                }

                this.AddInputCharacter(' ');
            }
        }
    }
コード例 #15
0
        void InitializeComponent()
        {
            tableLayoutPanel1 = new TableLayoutPanel();
            radioButton1      = new RadioButton();
            radioButton2      = new RadioButton();
            radioButton3      = new RadioButton();
            listBoxEx2        = new ListBoxControl <ChartPage>();
            tableLayoutPanel1.SuspendLayout();
            SuspendLayout();

            // tableLayoutPanel1
            tableLayoutPanel1.RowCount = 4;
            tableLayoutPanel1.Dock     = DockStyle.Fill;
            tableLayoutPanel1.RowStyles.Add(new RowStyle());
            tableLayoutPanel1.RowStyles.Add(new RowStyle());
            tableLayoutPanel1.RowStyles.Add(new RowStyle());
            tableLayoutPanel1.RowStyles.Add(new RowStyle());
            tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
            tableLayoutPanel1.Controls.Add(this.radioButton1, 0, 0);
            tableLayoutPanel1.Controls.Add(this.radioButton2, 0, 1);
            tableLayoutPanel1.Controls.Add(this.radioButton3, 0, 2);
            tableLayoutPanel1.Controls.Add(this.listBoxEx2, 0, 3);
            tableLayoutPanel1.TabIndex = 0;

            // radioButton1
            radioButton1.Anchor          = AnchorStyles.Left;
            radioButton1.AutoSize        = true;
            radioButton1.TabIndex        = 1;
            radioButton1.Text            = "All Charts";
            radioButton1.CheckedChanged += radioButton1_CheckedChanged;

            // radioButton2
            radioButton2.Anchor          = AnchorStyles.Left;
            radioButton2.AutoSize        = true;
            radioButton2.TabIndex        = 2;
            radioButton2.Text            = "Current Chart";
            radioButton2.CheckedChanged += radioButton2_CheckedChanged;

            // radioButton3
            radioButton3.Anchor          = AnchorStyles.Left;
            radioButton3.AutoSize        = true;
            radioButton3.TabIndex        = 3;
            radioButton3.Text            = "Select Below:";
            radioButton3.CheckedChanged += radioButton3_CheckedChanged;

            // listBoxEx2
            listBoxEx2.Dock              = DockStyle.Fill;
            listBoxEx2.TabIndex          = 4;
            listBoxEx2.MultiSelect       = true;
            listBoxEx2.ItemHeight        = 28;
            listBoxEx2.SelectionChanged += listBoxEx2_SelectionChanged;

            // ExportDocumentDialog
            ClientSize = new Size(600, 400);
            Controls.Add(this.tableLayoutPanel1);
            Text = "Export Document";
            tableLayoutPanel1.ResumeLayout();
            ResumeLayout();
        }
コード例 #16
0
        public static void writeLog(this ListBoxControl lsbox, string message, int status)
        {
            string space = "...................................." + (status == 1 ? "Done" : status == 2 ? "Faild" : "In Progress");
            string time  = DateTime.Now.ToString("HH:mm:ss");

            lsbox.Items.Insert(0, "[" + time + "] " + message + space);
            lsbox.Refresh();
        }
コード例 #17
0
 /// <summary>
 /// ListBoxControl插入ITEM并选中,【线程安全】
 /// </summary>
 /// <param name="listbox">ListBoxControl</param>
 /// <param name="message">插入内容</param>
 public static void InsertItemWithSelect(this ListBoxControl listbox, string message)
 {
     if (!string.IsNullOrEmpty(message) && listbox != null)
     {
         listbox.Items.Add(message);
         listbox.SelectedIndex = listbox.Items.Count - 1;
     }
 }
コード例 #18
0
        private void secondaryVariableDependenceListBoxControl_DrawItem(object sender, DevExpress.XtraEditors.ListBoxDrawItemEventArgs e)
        {
            ListBoxControl listBox = sender as ListBoxControl;

            if (listBox.Enabled && e.State != (DrawItemState.Focus & DrawItemState.Selected))
            {
                e.Appearance.BackColor = Color.SlateGray;
            }
        }
コード例 #19
0
        private void listBoxControl1_MeasureItem(object sender, MeasureItemEventArgs e)
        {
            ListBoxControl control  = (ListBoxControl)sender;
            string         text     = control.GetItemText(e.Index);
            Size           textSize = TextUtils.GetStringSize(e.Graphics, text, control.Appearance.Font,
                                                              StringFormat.GenericDefault, control.ClientRectangle.Width);

            e.ItemHeight = textSize.Height + 5;
        }
コード例 #20
0
        private void InitSkinNames(ListBoxControl listBox)
        {
            foreach (SkinContainer cnt in SkinManager.Default.Skins)
            {
                listBox.Items.Add(cnt.SkinName);
            }

            listBox.SelectedValue = _lookAndFeel.SkinName;
        }
        /// <summary>
        /// Passa os itens selecionados da Lista atual para um coleção interna
        /// </summary>
        /// <param name="lst">Objeto de ListBoxControl</param>
        private void SelecionaItens(ListBoxControl lst)
        {
            selecionadas = new List <CicloDesenvEstoria>();

            for (int position = 0; position < lst.SelectedItems.Count; position++)
            {
                selecionadas.Add(lst.SelectedItems[position] as CicloDesenvEstoria);
            }
        }
コード例 #22
0
        private void listBoxControl1_DrawItem(object sender, ListBoxDrawItemEventArgs e)
        {
            ListBoxControl control = (ListBoxControl)sender;

            e.Appearance.DrawBackground(e.Cache, e.Bounds);
            TextUtils.DrawString(e.Graphics, control.GetItemText(e.Index), control.Appearance.Font,
                                 control.Appearance.ForeColor, e.Bounds);
            e.Handled = true;
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing && listBox != null)
     {
         listBox.SelectedIndexChanged -= listBox_SelectedIndexChanged;
         listBox = null;
     }
     base.Dispose(disposing);
 }
        private void generalPrimaryVariableListBoxControl_DrawItem(object sender, ListBoxDrawItemEventArgs e)
        {
            ListBoxControl listBox = sender as ListBoxControl;

            if (listBox.Enabled && e.State != (DrawItemState.Focus & DrawItemState.Selected))
            {
                e.Appearance.BackColor = Color.SlateGray;
            }
        }
        static void TextEdit_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            TextEdit       currentTextEdit = sender as TextEdit;
            ListBoxControl currentListBox  = currentTextEdit.Tag as ListBoxControl;

            if (e.KeyValue == 40)
            {
                currentListBox.Focus();
            }
        }
        void listBox_MouseClick(object sender, MouseEventArgs e)
        {
            ListBoxControl listBox = sender as ListBoxControl;
            PivotCustomizationTreeNodeBase treeNode = listBox.SelectedItem as PivotCustomizationTreeNodeBase;

            if (treeNode != null)
            {
                this.Text = treeNode.Field.ToString();
            }
        }
        private void SubscribeEvents(ListBoxControl newValue)
        {
            ListBoxScrollInfo si = GetScrollInfo(newValue);

            if (si != null)
            {
                si.VScroll_Scroll += MyListBoxScrollHelper_VScroll_Scroll;
                si.HScroll_Scroll += MyListBoxScrollHelper_HScroll_Scroll;
            }
        }
コード例 #28
0
ファイル: InventoryGuidelines.cs プロジェクト: shansheng/QDJJ
        /// <summary>
        /// ListBox单击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ListBox_Click(object sender, EventArgs e)
        {
            ListBoxControl tl  = sender as ListBoxControl;
            DataRowView    row = tl.SelectedItem as DataRowView;

            if (row != null)
            {
                string str = CommonData.GetDEBHByQD(row["QINGDBH"].ToString(), this._Clb.ListGallery.LibraryDataSet.Tables["指引内容表"]);
                Filter(str);
            }
        }
        static void TextEdit_Leave(object sender, EventArgs e)
        {
            TextEdit       currentTextEdit = sender as TextEdit;
            ListBoxControl currentListBox  = currentTextEdit.Tag as ListBoxControl;

            currentTextEdit.EditValue = currentListBox.SelectedValue;
            if (TextValueChanged != null)
            {
                TextValueChanged(currentTextEdit, new EventArgs());
            }
        }
 private void OnListBoxChanged(ListBoxControl prevValue, ListBoxControl newValue)
 {
     if (prevValue != null)
     {
         UnSubscribeEvents(prevValue);
     }
     if (newValue != null)
     {
         SubscribeEvents(newValue);
     }
 }
        private void listBoxControl2_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            ListBoxControl listBox  = sender as ListBoxControl;
            Point          newPoint = new Point(e.X, e.Y);

            newPoint = listBox.PointToClient(newPoint);
            int         selectedIndex = listBox.IndexFromPoint(newPoint);
            DataRowView row           = listBoxControl1.SelectedItem as DataRowView;

            (listBox.DataSource as DataTable).Rows.Add(new object[] { row[0], row[1] });
        }
コード例 #32
0
        private void AddToDataToBindingSource(MasterType masterType, BindingSource source, ListBoxControl listBox)
        {
            var universalMasterCreateForm = GlobalUtility.GetFormObject<UniversalMasterCreateForm>(FormConstants.UNIVERASAL_MASTER_CREATE_FORM);
            universalMasterCreateForm.IsNeedClosing = true;
            universalMasterCreateForm.MasterType = masterType;
            universalMasterCreateForm.ShowDialog();

            object obj = universalMasterCreateForm.CreatedItem;
            if (obj != null)
            {
                int index = 0;
                switch (masterType)
                {
                    case MasterType.PRODUCT_COLOR:
                        foreach (ProductColor type in source)
                        {
                            if (type.ColorId.Equals(((ProductColor)obj).ColorId))
                            {
                                listBox.SelectedIndex = index;
                                return;
                            }
                            index++;
                        }
                        break;
                    case MasterType.PRODUCT_SIZE:
                        foreach (ProductSize type in source)
                        {
                            if (type.SizeId.Equals(((ProductSize)obj).SizeId))
                            {
                                listBox.SelectedIndex = index;
                                return;
                            }
                            index++;
                        }
                        break;
                }
                source.Add(obj);
                listBox.SelectedIndex = source.Count - 1;
                Refresh();
            }
        }
コード例 #33
0
ファイル: DataBinder.cs プロジェクト: wuhuayun/JieLi_Cord
 /// <summary>
 /// 显示数据
 /// </summary>
 /// <param name="listBoxControl">ListBoxControl</param>
 /// <param name="dataSource">数据源</param>
 /// <param name="displayMember">显示字段</param>
 public static void BindingListBoxLookupData(ListBoxControl listBoxControl, object dataSource, string displayMember)
 {
     listBoxControl.DisplayMember = displayMember;
     listBoxControl.DataSource = dataSource;
 }
コード例 #34
0
ファイル: LookUp.cs プロジェクト: fizikci/Cinar
        protected override void OnLostFocus(EventArgs e)
        {
            base.OnLostFocus(e);

            Form form = this.FindForm();
            if (form == null)
                return;

            if (lbc != null && !lbc.Focused)
            {
                form.Controls.Remove(lbc);
                lbc = null;
            }
        }
コード例 #35
0
ファイル: LookUp.cs プロジェクト: fizikci/Cinar
        private void showPopup(bool showAll)
        {
            Form form = this.FindForm();
            if (form == null)
                return;

            buildFilterExp(showAll, false);

            IList<BaseEntity> items = null;

            if (GetDataSource != null)
            {
                items = GetDataSource(this.Text);
            }
            else
            {
                Filter.PageNo = 0; Filter.PageSize = 0;
                items = DMT.Provider.Db.ReadList(EntityType, Filter).Cast<BaseEntity>().ToList();
                if (items == null || items.Count == 0)
                {
                    buildFilterExp(showAll, true);
                    Filter.PageSize = 0; Filter.PageNo = 0;
                    items = DMT.Provider.Db.ReadList(EntityType, Filter).Cast<BaseEntity>().ToList();
                }
            }

            if (items.Count == 0)
            {
                if (lbc != null)
                {
                    form.Controls.Remove(lbc);
                    lbc = null;
                }
                return;
            }

            form.SuspendLayout();
            if (lbc == null)
            {
                lbc = new ListBoxControl();
                form.Controls.Add(lbc);
                lbc.KeyUp += (sender, e) =>
                                 {
                                     if (e.KeyCode == Keys.Escape || e.KeyCode == Keys.Enter)
                                     {
                                         if (e.KeyCode == Keys.Enter)
                                             SelectedItem = lbc.SelectedItem;

                                         form.Controls.Remove(lbc);
                                         lbc = null;
                                         this.Focus();
                                     }
                                 };
                lbc.DoubleClick += delegate
                {
                    SelectedItem = lbc.SelectedItem;

                    form.Controls.Remove(lbc);
                    lbc = null;
                    this.Focus();
                };

                lbc.LostFocus += delegate
                {
                    if (lbc.SelectedItem != null)
                        SelectedItem = lbc.SelectedItem;
                    else
                        this.Text = "";

                    form.Controls.Remove(lbc);
                    lbc = null;
                };

                lbc.DrawItem += lbc_DrawItem;
                lbc.BringToFront();
            }

            lbc.Width = this.Width;
            lbc.Location = form.PointToClient(this.PointToScreen(new Point(0, this.Height)));
            if (lbc.Location.Y + lbc.Height > form.Height)
                lbc.Location = new Point(lbc.Location.X, lbc.Location.Y - (lbc.Height + this.Height));

            lbc.DataSource = items;
            lbc.SelectedIndex = -1;

            form.ResumeLayout();
        }
コード例 #36
0
            public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
            {
                if (context == null)
                    throw new System.ArgumentNullException("context");
                if (provider == null)
                    throw new System.ArgumentNullException("provider");

                System.Windows.Forms.Design.IWindowsFormsEditorService iwindowsFormsEditorService = provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)) as System.Windows.Forms.Design.IWindowsFormsEditorService;
                if (iwindowsFormsEditorService != null)
                {
                    ListBoxControl listBoxControl = new ListBoxControl(iwindowsFormsEditorService);
                    listBoxControl.Items.Add("None");
                    foreach(string s1 in enumFields)
                        listBoxControl.Items.Add(s1);

                    string s2 = (string)value;
                    if (System.String.IsNullOrEmpty(s2))
                        listBoxControl.SelectedIndex = 0;
                    else
                        listBoxControl.SelectedIndex = listBoxControl.FindString(s2);
                    iwindowsFormsEditorService.DropDownControl(listBoxControl);
                    
                    string s3 = System.String.Empty;
                    int i = listBoxControl.SelectedIndex;
                    if (i > 0)
                        s3 = listBoxControl.Items[i] as string;
                    return s3;
                }
                return value;
            }