Esempio n. 1
0
 /// <summary>
 /// Clears and displose a collection of controls
 /// </summary>
 /// <param name="collection"></param>
 public static void ClearAndDispose(this System.Windows.Forms.Control.ControlCollection collection)
 {
     while (collection.Count > 0)
     {
         collection[0].Dispose();
     }
 }
Esempio n. 2
0
 public static void SetEnabled(this System.Windows.Forms.Control.ControlCollection ctrls, bool value)
 {
     foreach (Control ctrl in ctrls)
     {
         ctrl.Enabled = value;
     }
 }
Esempio n. 3
0
        private void InitializeAlbumsPreviewLocation()
        {
            System.Windows.Forms.Control.ControlCollection data = ContentPanel.Controls;
            if (data.Count != 0)
            {
                int ContentPanelWidth  = ContentPanel.Size.Width;
                int ContentPanelHeight = ContentPanel.Size.Height;

                int CountAlbumsInARow = ContentPanelWidth / 240;
                //if (CountAlbumsInARow > data.Count) CountAlbumsInARow = data.Count;
                if (CountAlbumsInARow != 0)
                {
                    int SpaceBetween  = ((ContentPanelWidth - (CountAlbumsInARow * 240)) / CountAlbumsInARow) - 2;
                    int currentWidth  = SpaceBetween / 2;
                    int currentHeight = 5;
                    int rowCounter    = 1;
                    for (int i = 0; i < data.Count; i++)
                    {
                        if (rowCounter > CountAlbumsInARow)
                        {
                            currentWidth   = SpaceBetween / 2;
                            currentHeight += (10 + data[0].Size.Height);
                            rowCounter     = 1;
                        }
                        data[i].Location = new Point(currentWidth, currentHeight);
                        data[i].Show();
                        currentWidth = (currentWidth + (SpaceBetween + data[i].Size.Width));
                        rowCounter++;
                    }
                }
            }
        }
Esempio n. 4
0
        public void UpdateControls(System.Windows.Forms.Control.ControlCollection ctrlCollection)
        {
            // If this is the client window - change the title bar...
            if (ctrlCollection.Owner.GetType() == typeof(GRINGlobal.Client.CuratorTool.GRINGlobalClientCuratorTool))
            {
                //this.Text = "GRIN-Global  v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
                DataRow[] title = _appSettings.Select("app_resource_name='GRINGlobalClient'");
                if (title != null && title.Length > 0)
                {
                    ctrlCollection.Owner.Text = title[0]["display_member"] + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
                }
                else
                {
                    ctrlCollection.Owner.Text = "GRIN-Global  v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
                }
            }

            // Iterate through the Forms controls...
            foreach (DataRow dr in _appSettings.Rows)
            {
                System.Windows.Forms.Control[] ctrlArray = ctrlCollection.Find(dr["app_resource_name"].ToString(), true);
                if (ctrlArray != null && ctrlArray.Length > 0)
                {
                    foreach (System.Windows.Forms.Control ctrl in ctrlArray)
                    {
                        ctrl.Text = dr["display_member"].ToString();
                    }
                }
            }
        }
 void ITranslator.Translate(System.Windows.Forms.Control.ControlCollection controls, string sourceCultureName, string targetCultureName)
 {
     if (this.translator != null)
     {
         this.translator.Translate(controls, sourceCultureName, targetCultureName);
     }
 }
 void ITranslator.Restoration(System.Windows.Forms.Control.ControlCollection controls)
 {
     if (this.translator != null)
     {
         this.translator.Translate(controls);
     }
 }
 void ITranslator.Translate(System.Windows.Forms.Control.ControlCollection controls, CultureInfo sourceCultureInfo, CultureInfo targetCultureInfo)
 {
     if (this.translator != null)
     {
         this.translator.Translate(controls, sourceCultureInfo, targetCultureInfo);
     }
 }
Esempio n. 8
0
        public void OrganizeFilters(System.Windows.Forms.Control.ControlCollection controles, string ListaFiltros)
        {
            foreach (Control control in controles)
            {
                control.Visible = false;
            }

            int LocationY  = 5;
            int separacion = 22;

            ArrayList arrFiltros = systemframework.Util.Parse(ListaFiltros);

            foreach (string filtro in arrFiltros)
            {
                foreach (System.Windows.Forms.Control control in controles)
                {
                    if (control.Tag.Equals(filtro))
                    {
                        control.Visible  = true;
                        control.Location = new System.Drawing.Point(control.Location.X, LocationY);
                    }
                }
                LocationY = LocationY + separacion;
            }
            _height = LocationY;
        }
Esempio n. 9
0
 /// <summary>
 /// Registers the controls.
 /// </summary>
 /// <param name="controls">The controls.</param>
 /// <remarks>Documented by Dev02, 2008-05-08</remarks>
 public void RegisterControls(System.Windows.Forms.Control.ControlCollection controls)
 {
     foreach (Control control in controls)
     {
         RegisterControl(control);
     }
 }
Esempio n. 10
0
        /// <summary>
        /// Control value is get
        /// </summary>
        /// <param name="coll">Control collection</param>
        /// <returns>Control value</returns>
        public static Property[] Get(System.Windows.Forms.Control.ControlCollection coll)
        {
            var dic = GetTypeList();
            var ret = new List <Property>();

            /// Control scanning
            foreach (Control ctrl in coll)
            {
                /// Child control recurisve call
                if (ctrl.Controls.Count > 0)
                {
                    var c_ctrl = Get(ctrl.Controls);
                    ret.AddRange(c_ctrl);
                }
                /// know control, value is get
                if (dic.ContainsKey(ctrl.GetType()))
                {
                    ret.Add(new Property()
                    {
                        Name = ctrl.Name, Value = dic[ctrl.GetType()].GetValue(ctrl)
                    });
                }
            }
            return(ret.ToArray());
        }
Esempio n. 11
0
 public static void SetAllControlsFontSize(
     System.Windows.Forms.Control.ControlCollection ctrls,
     int amount = 0, bool amountInPercent = true)
 {
     if (amount == 0)
     {
         return;
     }
     foreach (Control ctrl in ctrls)
     {
         // recursive
         if (ctrl.Controls != null)
         {
             SetAllControlsFontSize(ctrl.Controls,
                                    amount, amountInPercent);
         }
         if (ctrl != null)
         {
             var   oldSize = ctrl.Font.Size;
             float newSize =
                 (amountInPercent) ? oldSize + oldSize * (amount / 100) : oldSize + amount;
             if (newSize < 4)
             {
                 newSize = 4;              // don't allow less than 4
             }
             var fontFamilyName = ctrl.Font.FontFamily.Name;
             ctrl.Font = new Font(fontFamilyName, newSize);
         }
         ;
     }
     ;
 }
Esempio n. 12
0
        public static bool hasValidationErrors(System.Windows.Forms.Control.ControlCollection controls)
        {
            bool hasError = false;

            // Now we need to loop through the controls and deterime if any of them have errors
            foreach (Control control in controls)
            {
                // check the control and see what it returns
                bool validControl = IsValid(control);
                // If it's not valid then set the flag and keep going.  We want to get through all
                // the validators so they will display on the screen if errorProviders were used.
                if (!validControl)
                {
                    hasError = true;
                }
                // If its a container control then it may have children that need to be checked
                if (control.HasChildren)
                {
                    if (hasValidationErrors(control.Controls))
                    {
                        hasError = true;
                    }
                }
            }
            return(hasError);
        }
        /// <summary>
        /// 检查所有的输入项
        /// </summary>
        /// <param name="p_Controls"></param>
        public void CheckAllControls(System.Windows.Forms.Control.ControlCollection p_Controls)
        {
            foreach (System.Windows.Forms.Control ctl in p_Controls)
            {
                FlowLayoutPanel flpan = ctl as FlowLayoutPanel;
                if (flpan != null)
                {
                    CheckAllControls(flpan.Controls);
                    continue;
                }
                GroupBox grp = ctl as GroupBox;
                if (grp != null)
                {
                    CheckAllControls(grp.Controls);
                    continue;
                }

                Panel pan = ctl as Panel;
                if (pan != null)
                {
                    CheckAllControls(pan.Controls);
                    continue;
                }
                TabControl tabcontrol = ctl as TabControl;
                if (tabcontrol != null)
                {
                    CheckAllControls(tabcontrol.Controls);
                    continue;
                }
                TabPage tabpage = ctl as TabPage;
                if (tabpage != null)
                {
                    CheckAllControls(tabpage.Controls);
                    continue;
                }
                TableLayoutPanel tlpan = ctl as TableLayoutPanel;
                if (tlpan != null)
                {
                    CheckAllControls(tlpan.Controls);
                    continue;
                }
                UserControl uc = ctl as UserControl;
                if (uc != null)
                {
                    CheckAllControls(uc.Controls);
                    continue;
                }
                //转换特殊字符
                TextBox txtbox = ctl as TextBox;
                if (txtbox != null)
                {
                    //txtbox.
                    string temp = StringUtils.repalceSepStr(txtbox.Text.ToString());
                    if (!temp.Equals(txtbox.Text.ToString()))
                    {
                        txtbox.Text = StringUtils.repalceSepStr(txtbox.Text.ToString());
                    }
                }
            }
        }
Esempio n. 14
0
 public static void FillControls(Dictionary <string, string> collection, System.Windows.Forms.Control.ControlCollection controls)
 {
     foreach (Control control in controls.Cast <Control>().Where(y => y.Tag != null).OrderBy(y => y.TabIndex))
     {
         FillControl(collection, control);
     }
 }
Esempio n. 15
0
        /// <summary>
        /// 增加窗体控件、并且绑定数据
        /// </summary>
        /// <param name="dg1"></param>
        public void Adddli(System.Windows.Forms.Control.ControlCollection cont, List <reportRow> dg1)
        {
            //int x;
            //int y;
            foreach (reportRow d1 in dg1)
            {
                switch (d1.Lx)
                {
                case "com":
                    ComboBox com = new ComboBox();


                    break;

                case "ch":


                    break;

                default:


                    break;
                }
            }
        }
Esempio n. 16
0
        protected bool GetControlsChanged(System.Windows.Forms.Control.ControlCollection controls)
        {
            bool Result = false;

            // Ver si algo cambió
            foreach (System.Windows.Forms.Control ctl in controls)
            {
                if (ctl == null)
                {
                    //Nada
                }
                else if (ctl is IEditableControl)
                {
                    if (((IEditableControl)ctl).Changed)
                    {
                        Result = true;
                        break;
                    }
                }
                else if (ctl.Controls.Count > 0)
                {
                    if (GetControlsChanged(ctl.Controls))
                    {
                        Result = true;
                        break;
                    }
                }
            }
            return(Result);
        }
Esempio n. 17
0
        /// <summary>
        /// Control value is set
        /// </summary>
        /// <param name="coll">Control collection</param>
        /// <param name="val">Configuration file of a value</param>
        public static void Set(System.Windows.Forms.Control.ControlCollection coll, Property[] val)
        {
            var dic = GetTypeList();
            var ret = new List <Property>();

            /// Control scanning
            foreach (Control ctrl in coll)
            {
                /// Child control recursive call
                if (ctrl.Controls.Count > 0)
                {
                    Set(ctrl.Controls, val);
                }
                /// know control, value is set
                else
                {
                    if (dic.ContainsKey(ctrl.GetType()))
                    {
                        var currentValue = val.Where(p => p.Name == ctrl.Name);
                        if (currentValue.Any())
                        {
                            dic[ctrl.GetType()].SetValue(ctrl, currentValue.First().Value);
                        }
                    }
                }
            }
        }
Esempio n. 18
0
 void Button1Click(object sender, EventArgs e)
 {
     System.Windows.Forms.Control.ControlCollection cc = this.panel2.Controls as System.Windows.Forms.Control.ControlCollection;
     if (this.button1.Text != "完成")
     {
         if (((INextButton)cc[order]).OnNextButton())
         {
             cc[order].Visible = false;
             ((INextButton)cc[order + 1]).DownNextButton();
             cc[order + 1].Visible = true;
             order++;
             if (cc.Count == order + 1)
             {
                 this.button1.Text = "完成";
             }
         }
         if (order > 0)
         {
             this.button2.Visible = true;
         }
         else
         {
             this.button2.Visible = false;
         }
     }
     else
     {
         ((INextButton)cc[order]).OnNextButton();
         this.Close();
     }
 }
Esempio n. 19
0
        /// <summary>
        /// 从控件集合的每个元素及其子元素中寻找所有的智能数据控件并返回智能控件列表
        /// </summary>
        /// <param name="controls">控件集合,如页面容器对象</param>
        /// <returns>智能控件列表</returns>
        public static List <IDataControl> GetIBControls(System.Windows.Forms.Control.ControlCollection controls)
        {
            List <IDataControl> IBControls = new List <IDataControl>();

            findIBControls(IBControls, controls);
            return(IBControls);
        }
Esempio n. 20
0
        /// <summary>
        /// 获取选择和删除查询的SQL语句
        /// </summary>
        /// <param name="Controls">要收集的控件集合</param>
        /// <returns> ArrayList 中的成员为 IBCommand 对象,包含具体的CRUD SQL</returns>
        public static List <IBCommand> GetSelectAndDeleteCommand(System.Windows.Forms.Control.ControlCollection Controls)
        {
            List <IDataControl> IBControls = new List <IDataControl>();

            findIBControls(IBControls, Controls);
            return(GetSelectAndDeleteCommand(IBControls));
        }
Esempio n. 21
0
        /// <summary>
        /// 自动更新窗体数据,要求控件数据绑定到映射的表和字段
        /// </summary>
        /// <param name="Controls">控件集合</param>
        /// <returns></returns>
        public List <IBCommand> AutoUpdateIBFormData(System.Windows.Forms.Control.ControlCollection Controls)
        {
            List <IBCommand> ibCommandList = GetIBFormData(Controls, this.DAO);

            AutoUpdateIBFormDataInner(ibCommandList);
            return(ibCommandList);
        }
Esempio n. 22
0
        private void InitUI()
        {
            toolbarButtonBackgroundColor = Color.Transparent;
            this.u_panelGeneral          = new PanelGeneral(this.m_generalDictionary, this.m_searchDictionary, this.m_genericInputMethods, this.u_applyButton);
            this.AddPreferencePane(u_panelGeneral, "General");
            PanelPhonetic panelPhonetic = new PanelPhonetic(this.m_traditionalPhoneticDictionary, this.m_smartPhoneticDictionary, this.u_applyButton);

            this.AddPreferencePane(panelPhonetic, "Phonetic");
            PanelCangjie panelCangjie = new PanelCangjie(this.m_cangjieDictionary, this.u_applyButton);

            this.AddPreferencePane(panelCangjie, "Cangjie");
            PanelSimplex panelSimplex = new PanelSimplex(this.m_simplexDictionary, this.u_applyButton);

            this.AddPreferencePane(panelSimplex, "Simplex");
            if (this.m_hasGenericInputMethods == false)
            {
                this.u_toolbarGeneric.Visible = false;
                this.u_toolbar.Controls.Remove(this.u_toolbarGeneric);
                this.u_settingsPanel.Left = 43;
                this.u_toolbar.Width      = this.u_toolbar.Width - 56;
                this.Width = this.Width - 56;
            }
            else
            {
                this.u_panelGeneric = new PanelGeneric(m_venderIdentifer, m_genericInputMethods, u_applyButton);
                this.AddPreferencePane(u_panelGeneric, "Generic");
            }
            PanelMisc panelMisc = new PanelMisc(m_generalDictionary, u_applyButton);

            this.AddPreferencePane(panelMisc, "Misc");
            PanelPhrases panelPhrases = new PanelPhrases();

            this.AddPreferencePane(panelPhrases, "Phrases");
            PanelUpdate panelUpdate = new PanelUpdate(m_generalDictionary, u_applyButton);

            this.AddPreferencePane(panelUpdate, "Update");

            BIAboutPanel.c_icon = global::TakaoPreference.Properties.Resources.yahoo;
            this.u_panelAbout   = new BIAboutPanel(this);
            this.AddPreferencePane(u_panelAbout, "About");
            this.u_toolbarGeneral.Checked   = true;
            this.u_toolbarGeneral.BackColor = toolbarButtonBackgroundColor;
            this.u_applyButton.Enabled      = false;

            System.Windows.Forms.Control.ControlCollection c = this.u_settingsPanel.Controls;
            int i = 0;

            foreach (Control item in c)
            {
                if (i == 0)
                {
                    item.Visible = true;
                }
                else
                {
                    item.Visible = false;
                }
                i++;
            }
        }
Esempio n. 23
0
        /// <summary>
        ///  Clears the entries in a form. This currently includes textboxes, comboboxes, list boxes and datagrid
        /// views.
        /// </summary>
        /// <param name="targetCollection">The form to be cleared</param>
        public void clearControls(System.Windows.Forms.Control.ControlCollection targetCollection)
        {
            foreach (Control myControl in targetCollection)
            {
                string controlType = myControl.GetType().ToString();
                switch (controlType)
                {
                case "System.Windows.Forms.TextBox":
                    myControl.Text = "";
                    break;

                case "System.Windows.Forms.ComboBox":
                    myControl.Text = null;
                    break;

                case "System.Windows.Forms.DataGridView":
                    DataGridView myView = (DataGridView)myControl;
                    myView.DataSource = null;
                    myView.Rows.Clear();
                    break;

                case "System.Windows.Forms.ListBox":
                    ListBox myList = (ListBox)myControl;
                    myList.SelectedIndex = -1;
                    break;

                default:

                    break;
                }
            }
        }
Esempio n. 24
0
        private static void LoadControls(string name, System.Windows.Forms.Control.ControlCollection controls)
        {
            if (controls == null)
            {
                return;
            }

            for (int i = 0; i < controls.Count; i++)
            {
                string find = String.Format("{0}::{1}", name, controls[i].Name);
                string str  = m_Controls[find] as string;
                if (str != null)
                {
                    controls[i].Text = str;
                }

                if (controls[i] is ListView)
                {
                    foreach (ColumnHeader ch in ((ListView)controls[i]).Columns)
                    {
                        find = String.Format("{0}::{1}::{2}", name, controls[i].Name, ch.Index);
                        str  = m_Controls[find] as string;
                        if (str != null)
                        {
                            ch.Text = str;
                        }
                    }
                }

                LoadControls(name, controls[i].Controls);
            }
        }
Esempio n. 25
0
        private void BindUpdatePreview(System.Windows.Forms.Control.ControlCollection controls)
        {
            controls.Cast <Control>().ForEach(x => { if (x.HasChildren)
                                                     {
                                                         BindUpdatePreview(x.Controls);
                                                     }
                                              });

            foreach (Control ctl in controls)
            {
                if (ctl is NumericUpDown)
                {
                    ((NumericUpDown)ctl).ValueChanged += (sender, e) => UpdateUI();
                }
                else if (ctl is TrackBar)
                {
                    ((TrackBar)ctl).ValueChanged += (sender, e) => UpdateUI();
                }
                else if (ctl is TextBox && ctl != txtCommandLinePreview)
                {
                    ((TextBox)ctl).TextChanged += (sender, e) => UpdateUI();
                }
                else if (ctl is ComboBox)
                {
                    ((ComboBox)ctl).SelectedIndexChanged += (sender, e) => UpdateUI();
                }
            }
        }
        internal void ProcessMappingRemoval(FieldMapping currentFieldMappingControl, System.Windows.Forms.Control.ControlCollection parentContainer, FieldMappingEventArgs e)
        {
            try
            {
                //Add back any selected mappings to the relevant master collection, and remove them as well

                foreach (Control c in parentContainer)
                {
                    if (c.GetType() == typeof(FieldMapping))
                    {
                        FieldMapping fm = (FieldMapping)c;
                        if (fm != currentFieldMappingControl)
                        {
                            if (e.OCMField != null)
                            {
                                fm.AddOCMField(e.OCMField);
                            }
                            if (e.BCMField != null)
                            {
                                fm.AddBCMField(e.BCMField);
                            }
                        }
                    }
                }

                parentContainer.Remove(currentFieldMappingControl);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
 void ITranslator.Restoration(System.Windows.Forms.Control.ControlCollection controls)
 {
     foreach (System.Windows.Forms.Control control in controls)
     {
         ((ITranslator)this).Restoration(control);
     }
 }
 void ITranslator.Translate(System.Windows.Forms.Control.ControlCollection controls, string sourceCultureName, string targetCultureName)
 {
     foreach (System.Windows.Forms.Control control in controls)
     {
         ((ITranslator)this).Translate(control, sourceCultureName, targetCultureName);
     }
 }
 void ITranslator.Translate(System.Windows.Forms.Control.ControlCollection controls, System.Globalization.CultureInfo sourceCultureInfo, System.Globalization.CultureInfo targetCultureInfo)
 {
     foreach (System.Windows.Forms.Control control in controls)
     {
         ((ITranslator)this).Translate(control, sourceCultureInfo, targetCultureInfo);
     }
 }
Esempio n. 30
0
        // hàm clear các textbox, checkbox, combobox
        public void ClearGroup(System.Windows.Forms.Control.ControlCollection controls)
        {
            foreach (Control c in controls)
            {
                Type cControls = c.GetType();
                switch (cControls.Name)
                {
                case "TextBox":
                    ((TextBox)c).Text = string.Empty;
                    break;

                case "CheckBox":
                    ((CheckBox)c).Checked = false;
                    break;

                case "ComboBox":
                    ((ComboBox)c).SelectedIndex = -1;
                    break;

                case "RichTextBox":
                    ((RichTextBox)c).Text = string.Empty;
                    break;

                default:
                    break;
                }
                if (c.Controls != null)
                {
                    ClearGroup(c.Controls);
                }
            }
        }
        /// <summary>
        /// This function is called from the designer in order to evaluate when and
        /// when not to display any new properties.
        ///
        /// </summary>
        /// <returns>void</returns>
        public bool CanExtend(System.Object AnObject)
        {
            bool ReturnValue = false;

            // If the System.Object is derived from System.Windows.Forms.UserControl then we have to deal with it
            if (AnObject is System.Windows.Forms.UserControl)
            {
                this.ExtenderHost = (System.Windows.Forms.UserControl)AnObject;
                this.UExtenderControlCollection = new System.Windows.Forms.Control.ControlCollection(this.UExtenderHost);
                this.UExtenderControlCollection = this.UExtenderHost.Controls;

                // Check whether we need to extend these
                foreach (System.Windows.Forms.Control mControl in this.UExtenderControlCollection)
                {
                    if ((mControl is System.Windows.Forms.TextBox) || (mControl is TTxtPartnerKeyTextBox)
                        || (mControl is System.Windows.Forms.TextBox))
                    {
                        ReturnValue = true;
                    }
                }
            }

            return ReturnValue;
        }
        /// <summary>
        /// This procedure ensures that all textboxes in the form have the MaxLength
        /// property set to the value given from the database.
        ///
        /// </summary>
        /// <returns>void</returns>
        public void RetrieveTextboxes(System.Object AnObject)
        {
            // If the System.Object is derived from System.Windows.Forms.UserControl then we have to deal with it
            if (AnObject is System.Windows.Forms.UserControl)
            {
                // Get the host System.Object
                this.ExtenderHost = (System.Windows.Forms.UserControl)AnObject;

                // TLogging.Log('Host: ' + this.ExtenderHost.Name, [TLoggingType.ToLogfile]);
                this.RegisterExtenderProvider(this.ExtenderHost);

                // Messagebox.Show(this.CheckForExtenderProvider(this.ExtenderHost).ToString);
                try
                {
                    this.UExtenderControlCollection = new System.Windows.Forms.Control.ControlCollection(this.UExtenderHost);
                    this.UExtenderControlCollection = this.UExtenderHost.Controls;
                }
                catch (Exception)
                {
                    MessageBox.Show("Error happened!!!");
                }

                // Check whether we find any TextBoxes in this collection then we have to add
                // these to this.UTextBoxCollection
                foreach (System.Windows.Forms.Control mControl in this.UExtenderControlCollection)
                {
                    GetTextBox(mControl);
                }

                // Here the DataSources and the maximum length of the text of the TextBoxes is retrieved
                this.ImposeMaxLength();
            }
        }