예제 #1
2
파일: UIInvokeUtil.cs 프로젝트: yienit/KST
 /// <summary>
 /// Invoke方式设置ComboBox控件的SelectedIndex属性
 /// </summary>
 public static void InvokeComboxBoxSelectedIndex(ComboBox combox, int index)
 {
     if (combox.InvokeRequired)
     {
         combox.Invoke(new MethodInvoker(delegate() { InvokeComboxBoxSelectedIndex(combox, index); }));
     }
     else
     {
         combox.SelectedIndex = index;
     }
 }
예제 #2
1
        public static void RemoveItemAt(ComboBox combobox, int index)
        {
            MethodInvoker miRemoveItem = delegate
            {
                combobox.Items.RemoveAt(index);
            };

            if (combobox.InvokeRequired)
            {
                combobox.Invoke(miRemoveItem);
            }
            else
            {
                miRemoveItem();
            }
        }
예제 #3
1
        public static void AddItem(ComboBox combobox, object item)
        {
            MethodInvoker miAddItem = delegate
            {
                combobox.Items.Add(item);
            };

            if (combobox.InvokeRequired)
            {
                combobox.Invoke(miAddItem);
            }
            else
            {
                miAddItem();
            }
        }
        private void InitComboboxes()
        {
            WorkAsync(new WorkAsyncInfo
            {
                Message = "Retrieving the entities...",
                Work    = (w, e) =>
                {
                    var result = Helper.GetEntyNames(Service).OrderBy(_ => _.Value).ToList();

                    cmbEntity.Invoke((MethodInvoker) delegate
                    {
                        cmbEntity.ValueMember   = "Key";
                        cmbEntity.DisplayMember = "Value";
                        cmbEntity.DataSource    = result;
                    });
                },
                ProgressChanged = e =>
                {
                },
                PostWorkCallBack = e =>
                {
                },
                AsyncArgument = null,
                IsCancelable  = false,
                MessageWidth  = 340,
                MessageHeight = 150
            });
        }//InitComboboxes
        }//BtnLoad_Click

        private void CmbEntity_SelectedIndexChanged(object sender, EventArgs args)
        {
            WorkAsync(new WorkAsyncInfo
            {
                Message = "Retrieving the attributes...",
                Work    = (w, e) =>
                {
                    cmbEntity.Invoke((MethodInvoker) delegate
                    {
                        selectedEntityLogicalName = (string)cmbEntity.SelectedValue;
                    });

                    var result = Helper.GetOptionSetsForEntity(Service, selectedEntityLogicalName).OrderBy(_ => _.Value).ToList();

                    cmbOptionSet.Invoke((MethodInvoker) delegate
                    {
                        cmbOptionSet.ValueMember   = "Key";
                        cmbOptionSet.DisplayMember = "Value";
                        cmbOptionSet.DataSource    = result;
                    });
                },
                ProgressChanged = e =>
                {
                },
                PostWorkCallBack = e =>
                {
                },
                AsyncArgument = null,
                IsCancelable  = false,
                MessageWidth  = 340,
                MessageHeight = 150
            });
        }
예제 #6
0
        private void FillHostListThreadFunc()
        {
            Invoke(new MethodInvoker(SetStartingCursor));

            try {
                System.Data.DataTable sources = PgSqlProviderFactory.Instance.CreateDataSourceEnumerator().GetDataSources();

                foreach (System.Data.DataRow hostInfo in sources.Rows)
                {
                    if (cbHost != null && !cbHost.IsDisposed && !cbHost.Disposing)
                    {
                        cbHost.Invoke(new AddHostItemDelegate(AddHostItem), new object[] { hostInfo["ServerName"].ToString() });
                    }
                }
            }
            catch {
            }
            finally {
                try {
                    Invoke(new MethodInvoker(SetDefaultCursor));
                }
                catch {
                }
            }
        }
예제 #7
0
 public void AddComboItem(System.Windows.Forms.ComboBox p_oCombo, string p_strValue)
 {
     if (p_oCombo.InvokeRequired)
     {
         AddComboItemCallback d = new AddComboItemCallback(AddComboItem);
         p_oCombo.Invoke(
             d,
             new object[] { p_oCombo, p_strValue });
     }
     else
     {
         p_oCombo.Items.Add(p_strValue);
     }
 }
예제 #8
0
        public static void ClearItems(ComboBox combobox)
        {
            MethodInvoker miClearItems = delegate
            {
                combobox.Items.Clear();
            };

            if (combobox.InvokeRequired)
            {
                combobox.Invoke(miClearItems);
            }
            else
            {
                miClearItems();
            }
        }
예제 #9
0
        public static void InsertItem(ComboBox combobox, int index, object item)
        {
            MethodInvoker miInsertItem = delegate
            {
                combobox.Items.Insert(index, item);
            };

            if (combobox.InvokeRequired)
            {
                combobox.Invoke(miInsertItem);
            }
            else
            {
                miInsertItem();
            }
        }
예제 #10
0
        public static object GetItem(ComboBox combobox, int index)
        {
            object item = null;

            MethodInvoker miRemoveItem = delegate
            {
                item = combobox.Items[index];
            };

            if (combobox.InvokeRequired)
            {
                combobox.Invoke(miRemoveItem);
            }
            else
            {
                miRemoveItem();
            }

            return item;
        }
예제 #11
0
        public static object GetSelectedItem(ComboBox combobox)
        {
            object selectedItem = null;

            MethodInvoker miClearItems = delegate
            {
                selectedItem = combobox.SelectedItem;
            };

            if (combobox.InvokeRequired)
            {
                combobox.Invoke(miClearItems);
            }
            else
            {
                miClearItems();
            }

            return selectedItem;
        }
예제 #12
0
 public void ExecuteComboItemsMethodWithParam(System.Windows.Forms.ComboBox p_oCombo, string p_strMethodName, object[] p_oParam)
 {
     if (p_oCombo.InvokeRequired)
     {
         ExecuteComboItemsMethodWithParamCallback d = new ExecuteComboItemsMethodWithParamCallback(ExecuteComboItemsMethodWithParam);
         p_oCombo.Invoke(d, new object[] { p_oCombo, p_strMethodName, p_oParam });
     }
     else
     {
         Type t = p_oCombo.Items.GetType();
         System.Reflection.MethodInfo[] methods = t.GetMethods();
         foreach (System.Reflection.MethodInfo m in methods)
         {
             if (m.Name.Trim().ToUpper() == p_strMethodName.Trim().ToUpper())
             {
                 m.Invoke(p_oCombo.Items, p_oParam);
                 break;
             }
         }
     }
 }
예제 #13
0
        public object GetComboItem(System.Windows.Forms.ComboBox p_oCombo, int p_intItem, bool p_bCallback)
        {
            if (p_bCallback == false)
            {
                m_oReturnValue = null;
            }

            if (p_oCombo.InvokeRequired)
            {
                GetComboItemCallback d = new GetComboItemCallback(GetComboItem);
                p_oCombo.Invoke(d, new object[] { p_oCombo, p_intItem, true });
            }
            else
            {
                m_oReturnValue = p_oCombo.Items[p_intItem];
            }
            if (m_oReturnValue == null && p_bCallback == false)
            {
                m_oReturnValue = "";
            }
            return(m_oReturnValue);
        }
예제 #14
0
        public static string GetText(ComboBox combobox)
        {
            string text = string.Empty;

            MethodInvoker miGetText = delegate
            {
                text = combobox.Text;
            };

            if (combobox.InvokeRequired)
            {
                combobox.Invoke(miGetText);
            }
            else
            {
                miGetText();
            }

            return text;
        }
예제 #15
0
 private string readComboBox(ComboBox box)
 {
     return (string)box.Invoke(new ReadComboDelegate(readComboHelper), new object[] { box });
 }
예제 #16
0
파일: Form1.cs 프로젝트: Duke-Jones/ED-IBE
        public void AddComboboxLine(ComboBox Destination, String newText, Int32 position=0, Int32 maxLength=10)
        {
            if(Destination.InvokeRequired)
                Destination.Invoke(new del_AddComboboxLine(AddComboboxLine), Destination, newText, position, maxLength);
            else
            {
                Destination.Items.Insert(position, newText);

                Destination.SelectedIndex = 0;

                while (Destination.Items.Count > maxLength)
                    Destination.Items.RemoveAt(Destination.Items.Count-1);
            }
        }
예제 #17
0
 public void SetTofFitFunctionComboState(bool state)
 {
     tofFitFunctionCombo.Invoke(new ComboStateDelegate(TofFitComboHelper), state);
 }
예제 #18
0
 public void SetSpectrumFitFunctionComboState(bool state)
 {
     spectrumFitFunctionCombo.Invoke(new ComboStateDelegate(SpectrumFitComboHelper), state);
 }
예제 #19
0
        void UpdateClassComboBox(bool need_fill_members)
        {
            // Still needed ?

            /*if (currentCompilationUnit == null) {
             *  currentCompilationUnit = (ICompilationUnit)ParserService.GetParseInformation(Path.GetFullPath(textAreaControl.FileName)).MostRecentCompilationUnit;
             * }*/

            autoselect = false;
            Hashtable ns_list = new Hashtable();

            try
            {
                //if (currentCompilationUnit != null)
                //// Alex: when changing between files in different compilation units whole process must be restarted
                //// happens usually when files are opened from different project(s)
                for (int i = 0; i < classComboBox.Items.Count; i++)
                {
                    if (((ComboBoxItem)classComboBox.Items[i]).IsInside(textAreaControl.ActiveTextAreaControl.Caret.Line, textAreaControl.ActiveTextAreaControl.Caret.Column))
                    {
                        bool innerClassContainsCaret = false;
                        if (((ComboBoxItem)classComboBox.Items[i]).Item == null || ((ComboBoxItem)classComboBox.Items[i]).Item.si.kind == SymbolKind.Namespace)
                        {
                            ns_list[(ComboBoxItem)classComboBox.Items[i]] = i;
                            continue;
                        }

                        /*for (int j = i + 1; j < classComboBox.Items.Count;j++) {
                         *  if (((ComboBoxItem)classComboBox.Items[j]).IsInside(textAreaControl.ActiveTextAreaControl.Caret.Line)) {
                         *      if (((ComboBoxItem)classComboBox.Items[j]).Item.si.kind == SymbolKind.Namespace)
                         *      {
                         *          ns_list[classComboBox.Items[j]] = j;
                         *          continue;
                         *      }
                         *      innerClassContainsCaret = true;
                         *      break;
                         *  }
                         * }*/
                        if (!innerClassContainsCaret)
                        {
                            if ((int)classComboBox.Invoke(new Invoke_del_with_ret(GetSelectedClassInternal)) != i)
                            {
                                //classComboBox.SelectedIndex = i;
                                classComboBox.Invoke(new Invoke_param_del(SetSelectedClassItemInternal), i);
                                if (need_fill_members)
                                {
                                    FillMembersComboBox();
                                }
                            }
                            if (!classComboBoxSelectedMember)
                            {
                                classComboBox.Invoke(new Invoke_del(Invoke_Refresh));
                            }
                            classComboBoxSelectedMember = true;

                            return;
                        }
                    }
                }
                foreach (ComboBoxItem cbi in ns_list.Keys)
                {
                    if (cbi.Item is ImplementationUnitScope && cbi.IsInside(textAreaControl.ActiveTextAreaControl.Caret.Line, textAreaControl.ActiveTextAreaControl.Caret.Column))
                    {
                        //classComboBox.SelectedIndex = (int)ns_list[cbi];
                        classComboBox.Invoke(new Invoke_param_del(SetSelectedClassItemInternal), ns_list[cbi]);
                        if (need_fill_members)
                        {
                            FillMembersComboBox();
                        }
                        classComboBox.Invoke(new Invoke_del(Invoke_Refresh));
                        classComboBoxSelectedMember = true;
                        return;
                    }
                    else
                    {
                        //classComboBox.SelectedIndex = (int)ns_list[cbi];
                        classComboBox.Invoke(new Invoke_param_del(SetSelectedClassItemInternal), ns_list[cbi]);
                        classComboBoxSelectedMember = true;
                    }
                }
                if (need_fill_members)
                {
                    FillMembersComboBox();
                }
                classComboBox.Invoke(new Invoke_del(Invoke_Refresh));
                return;

                if (classComboBoxSelectedMember)
                {
                    classComboBox.Invoke(new Invoke_del(Invoke_Refresh));
                    classComboBoxSelectedMember = false;
                }
            }
            finally
            {
                autoselect = true;
            }
            //				classComboBox.SelectedIndex = -1;
        }
예제 #20
0
 void UpdateMembersComboBox()
 {
     membersComboBox.Invoke(new Invoke_del(Member_Invoke_Refresh));
     autoselect = false;
     try
     {
         if (currentCompilationUnit != null)
         {
             for (int i = 0; i < membersComboBox.Items.Count; ++i)
             {
                 if (((ComboBoxItem)membersComboBox.Items[i]).IsInside(textAreaControl.ActiveTextAreaControl.Caret.Line, textAreaControl.ActiveTextAreaControl.Caret.Column))
                 {
                     if ((int)membersComboBox.Invoke(new Invoke_del_with_ret(GetSelectedMemberInternal)) != i)
                     {
                         membersComboBox.Invoke(new Invoke_param_del(SetSelectedMemberItemInternal), i);
                     }
                     if (!membersComboBoxSelectedMember)
                     {
                         membersComboBox.Invoke(new Invoke_del(Member_Invoke_Refresh));
                     }
                     membersComboBoxSelectedMember = true;
                     return;
                 }
             }
         }
         membersComboBox.Invoke(new Invoke_param_del(SetSelectedMemberItemInternal), -1);
         if (membersComboBoxSelectedMember)
         {
             membersComboBox.Invoke(new Invoke_del(Member_Invoke_Refresh));
             membersComboBoxSelectedMember = false;
         }
     }
     catch (Exception e)
     {
     }
     finally {
         autoselect = true;
     }
 }
예제 #21
0
        void UpdateClassComboBox(bool need_fill_members)
        {
            // Still needed ?

            /*if (currentCompilationUnit == null) {
             *  currentCompilationUnit = (ICompilationUnit)ParserService.GetParseInformation(Path.GetFullPath(textAreaControl.FileName)).MostRecentCompilationUnit;
             * }*/

            autoselect = false;
            Dictionary <ComboBoxItem, int> ns_list = new Dictionary <ComboBoxItem, int>();

            try
            {
                for (int i = 0; i < classComboBox.Items.Count; i++)
                {
                    if (((ComboBoxItem)classComboBox.Items[i]).IsInside(textAreaControl.ActiveTextAreaControl.Caret.Line, textAreaControl.ActiveTextAreaControl.Caret.Column))
                    {
                        bool innerClassContainsCaret = false;
                        if (((ComboBoxItem)classComboBox.Items[i]).Item == null || ((ComboBoxItem)classComboBox.Items[i]).Item.SymbolInfo.kind == SymbolKind.Namespace)
                        {
                            ns_list[(ComboBoxItem)classComboBox.Items[i]] = i;
                            continue;
                        }
                        if (!innerClassContainsCaret)
                        {
                            if ((int)classComboBox.Invoke(new Invoke_del_with_ret(GetSelectedClassInternal)) != i)
                            {
                                //classComboBox.SelectedIndex = i;
                                classComboBox.Invoke(new Invoke_param_del(SetSelectedClassItemInternal), i);
                                if (need_fill_members)
                                {
                                    FillMembersComboBox();
                                }
                            }
                            if (!classComboBoxSelectedMember)
                            {
                                classComboBox.Invoke(new Invoke_del(Invoke_Refresh));
                            }
                            classComboBoxSelectedMember = true;

                            return;
                        }
                    }
                }
                foreach (ComboBoxItem cbi in ns_list.Keys)
                {
                    if (cbi.Item is ImplementationUnitScope && cbi.IsInside(textAreaControl.ActiveTextAreaControl.Caret.Line, textAreaControl.ActiveTextAreaControl.Caret.Column))
                    {
                        //classComboBox.SelectedIndex = (int)ns_list[cbi];
                        classComboBox.Invoke(new Invoke_param_del(SetSelectedClassItemInternal), ns_list[cbi]);
                        if (need_fill_members)
                        {
                            FillMembersComboBox();
                        }
                        classComboBox.Invoke(new Invoke_del(Invoke_Refresh));
                        classComboBoxSelectedMember = true;
                        return;
                    }
                    else
                    {
                        //classComboBox.SelectedIndex = (int)ns_list[cbi];
                        classComboBox.Invoke(new Invoke_param_del(SetSelectedClassItemInternal), ns_list[cbi]);
                        classComboBoxSelectedMember = true;
                    }
                }
                if (need_fill_members)
                {
                    FillMembersComboBox();
                }
                classComboBox.Invoke(new Invoke_del(Invoke_Refresh));
                return;
            }
            finally
            {
                autoselect = true;
            }
            //				classComboBox.SelectedIndex = -1;
        }
예제 #22
0
 private void updateComboBox(ComboBox cmb, string value, bool add)
 {
     if (cmb.InvokeRequired) { cmb.Invoke(new cmbDelegate(updateComboBox), new object[] { cmb, value, add }); } else {
         if (add) { cmb.Items.Add(value); } else { cmb.Items.Clear(); }
     }
 }
예제 #23
0
        private int GetSelectedIndexOfComboBox(ComboBox comboBox)
        {
            if (comboBox.InvokeRequired)
                return (int)comboBox.Invoke(new Func<int>(() => GetSelectedIndexOfComboBox(comboBox)));

            return comboBox.SelectedIndex;
        }
예제 #24
0
 private string getDropDownListValue(ComboBox ddlName, String columnName)
 {
     #region Variable
     var result = "";
     #endregion
     #region Procedure
     try
     {
         if (ddlName.InvokeRequired)
         {
             ddlName.Invoke(new MethodInvoker(delegate
             {
                 try
                 {
                     var drv = (DataRowView)ddlName.SelectedItem;
                     var dr = drv.Row;
                     try
                     {
                         result = dr[columnName].ToString();
                     }
                     catch (Exception)
                     {
                         result = dr[0].ToString();
                     }
                 }
                 catch (Exception)
                 {
                     result = "";
                 }
             }));
         }
         else
         {
             try
             {
                 var drv = (DataRowView)ddlName.SelectedItem;
                 var dr = drv.Row;
                 try
                 {
                     result = dr[columnName].ToString();
                 }
                 catch (Exception)
                 {
                     result = dr[0].ToString();
                 }
             }
             catch (Exception)
             {
                 result = "";
             }
         }
     }
     catch (Exception) { }
     #endregion
     return result;
 }
 private void setComboBox(ComboBox control, int index)
 {
     if (control.InvokeRequired)
     {
         control.Invoke(new MethodInvoker(delegate
         {
             control.SelectedIndex = index;
         }));
     }
     else
     {
         control.SelectedIndex = index;
     }
 }
예제 #26
0
파일: ciudades.cs 프로젝트: moisesiq/aupaga
 private object GetSelectedValue(ComboBox cbo)
 {
     object obj = null;
     if (cbo.InvokeRequired)
     {
         obj = cbo.Invoke((MyDelegate)delegate() { return obj = cbo.SelectedValue; });
         return obj;
     }
     else
     {
         return obj = cbo.SelectedValue;
     }
 }
예제 #27
0
 private void setCbxText(ComboBox cbx, string text)
 {
     if (cbx.InvokeRequired)
     {
         cbx.Invoke(new void__ComboBox_string(setCbxText), cbx, text);
     }
     else
     {
         cbx.Text = text;
     }
 }
예제 #28
0
 /// <summary>
 ///     combox数据绑定
 /// </summary>
 /// <param name="comboBox"></param>
 /// <param name="data"></param>
 private void ComboxBind(ComboBox comboBox, object data)
 {
     if (comboBox.InvokeRequired)
         comboBox.Invoke(new EventsHandlerComboxBind(ComboxBind), comboBox, data);
     else
     {
         var bs = new BindingSource { DataSource = data };
         comboBox.DataSource = bs;
         comboBox.DisplayMember = "Key";
         comboBox.ValueMember = "Value";
         comboBox.SelectedIndex = -1;
     }
 }