Example #1
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();
                    }
                }
            }
        }
Example #2
0
 public static Control Find(this System.Windows.Forms.Control.ControlCollection ctrls, string name)
 {
     return(ctrls.Find <Control>(name));
 }
Example #3
0
        public bool GatherDataFromGUI(System.Windows.Forms.Control.ControlCollection Controls, int currentcycle)
        {
            bool   res = true;
            string str = "";

            try
            {
                Crown          = Controls.Find("txtNum1", true)[0].Text;
                ThirdEye       = Controls.Find("txtNum2", true)[0].Text;
                Throught       = Controls.Find("txtNum3", true)[0].Text;
                Heart          = Controls.Find("txtNum4", true)[0].Text;
                Sun            = Controls.Find("txtNum5", true)[0].Text;
                SexAndCreation = Controls.Find("txtNum6", true)[0].Text;
                Base           = Controls.Find("txtNum7", true)[0].Text;
                PrivateNameNum = Controls.Find("txtPName_Num", true)[0].Text;
                Astro          = Controls.Find("txtAstroName", true)[0].Text;

                #region Balance
                str = Controls.Find("txtInfo1", true)[0].Text.Split(Environment.NewLine.ToCharArray()[0])[1];
                if (BLL.AppSettings.Instance.ProgramLanguage == BLL.AppSettings.Language.English)
                {
                    if (str == Enums.EnumProvider.Instance.GetBalanceEnumFromDescription(Enums.EnumProvider.Balance._מאוזן_.ToString()))
                    {
                        MapBalanceStatus = Enums.EnumProvider.Balance._מאוזן_;
                    }
                    if (str == Enums.EnumProvider.Instance.GetBalanceEnumFromDescription(Enums.EnumProvider.Balance._לא_מאוזן_.ToString()))
                    {
                        MapBalanceStatus = Enums.EnumProvider.Balance._לא_מאוזן_;
                    }
                    if (str == Enums.EnumProvider.Instance.GetBalanceEnumFromDescription(Enums.EnumProvider.Balance._מאוזן_חלקית_.ToString()))
                    {
                        MapBalanceStatus = Enums.EnumProvider.Balance._מאוזן_חלקית_;
                    }
                }
                if (BLL.AppSettings.Instance.ProgramLanguage == BLL.AppSettings.Language.English)
                {
                    if (str == "מאוזן")
                    {
                        MapBalanceStatus = Enums.EnumProvider.Balance._מאוזן_;
                    }
                    if (str == "לא מאוזן")
                    {
                        MapBalanceStatus = Enums.EnumProvider.Balance._לא_מאוזן_;
                    }
                    if (str == "חצי מאוזן")
                    {
                        MapBalanceStatus = Enums.EnumProvider.Balance._מאוזן_חלקית_;
                    }
                }
                #endregion Balance

                if (bool.TryParse(Controls.Find("txtMapStrong", true)[0].Text, out isMapStrong))
                {
                }
                else
                {
                }

                LC_chlng1 = Controls.Find("txt1_4", true)[0].Text;
                LC_chlng2 = Controls.Find("txt2_4", true)[0].Text;
                LC_chlng3 = Controls.Find("txt3_4", true)[0].Text;
                LC_chlng4 = Controls.Find("txt4_4", true)[0].Text;

                LC_cycle1 = Controls.Find("txt1_2", true)[0].Text;
                LC_cycle2 = Controls.Find("txt2_2", true)[0].Text;
                LC_cycle3 = Controls.Find("txt3_2", true)[0].Text;
                LC_cycle4 = Controls.Find("txt4_2", true)[0].Text;

                LC_climx1 = Controls.Find("txt1_3", true)[0].Text;
                LC_climx2 = Controls.Find("txt2_3", true)[0].Text;
                LC_climx3 = Controls.Find("txt3_3", true)[0].Text;
                LC_climx4 = Controls.Find("txt4_3", true)[0].Text;

                LC_Climax   = Controls.Find("txt" + currentcycle.ToString() + "_3", true)[0].Text;
                LC_Chalange = Controls.Find("txt" + currentcycle.ToString() + "_4", true)[0].Text;
                LC_cycle    = Controls.Find("txt" + currentcycle.ToString() + "_2", true)[0].Text;



                mrkBssnss  = Convert.ToDouble(Controls.Find("txtFinalBusinessMark", true)[0].Text);
                stryBssnss = Controls.Find("txtBusinessStory", true)[0].Text;

                mrkMarr  = Convert.ToDouble(Controls.Find("txtMrrgMark", true)[0].Text);
                stryMarr = Controls.Find("txtMrrgStory", true)[0].Text;

                mrkLearn  = Convert.ToDouble(Controls.Find("txtLeanSccss", true)[0].Text);
                stryLearn = Controls.Find("txtLearnStory", true)[0].Text;

                mrkADHD  = Convert.ToDouble(Controls.Find("txtAtt", true)[0].Text);
                stryADHD = Controls.Find("txtAttStory", true)[0].Text;

                mrkHealth  = Convert.ToDouble(Controls.Find("txtHealthValue", true)[0].Text);
                stryHealth = Controls.Find("txtHealthStory", true)[0].Text;
            }
            catch //(Exception exp)
            {
                res = false;
            }
            return(res);
        }
Example #4
0
        /// <summary>
        /// 控件赋值或取值
        /// </summary>
        /// <param name="controlName">控件命名规则前缀</param>
        /// <param name="type">反射类型</param>
        /// <param name="classModel">反射类型实例</param>
        /// <param name="flag">0:赋值,1:取值</param>
        /// <param name="collection">控件集合</param>
        public static object Control_Reflection(Type type, object classModel, System.Windows.Forms.Control.ControlCollection collection, string controlName = "txt_|cbo_", int flag = 0)
        {
            object model = new object();

            if (classModel != null)
            {
                Control[]      c          = new Control[] { };
                PropertyInfo[] properties = type.GetProperties();
                for (int i = 0; i < properties.Length; i++)
                {
                    string       propertyID = properties[i].Name;
                    PropertyInfo pinfo      = type.GetProperty(propertyID);
                    string[]     cName      = controlName.Split('|');

                    for (int k = 0; k < cName.Length; k++)
                    {
                        string ControlName = cName[k] + propertyID.ToLower();
                        c = collection.Find(ControlName, true);
                        if (c.Length > 0)
                        {
                            break;
                        }
                    }
                    object obj   = pinfo.GetValue(classModel, null) == null ? "" : pinfo.GetValue(classModel, null);
                    string Value = obj == null ? "" : obj.ToString();

                    if (c.Length > 0)
                    {
                        Type t = c[0].GetType();
                        switch (t.Name)
                        {
                        case "TextBox":
                            if (flag == 0)
                            {
                                (c[0] as TextBox).Text = Value;
                            }
                            else
                            {
                                pinfo.SetValue(classModel, (c[0] as TextBox).Text, null);
                            }
                            break;

                        case "TXTextBoxEX":
                            if (flag == 0)
                            {
                                (c[0] as TXTextBoxEX).Text = Value;
                            }
                            else
                            {
                                pinfo.SetValue(classModel, (c[0] as TXTextBoxEX).Text, null);
                            }
                            break;

                        case "MaskedTextBox":
                            if (flag == 0)
                            {
                                (c[0] as NumberTextBoxEX).Text = Value;
                            }
                            else
                            {
                                pinfo.SetValue(classModel, (c[0] as NumberTextBoxEX).Text, null);
                            }
                            break;

                        case "NumberTextBoxEX":
                            if (flag == 0)
                            {
                                (c[0] as NumberTextBoxEX).Text = Value;
                            }
                            else
                            {
                                object controlValue = (c[0] as NumberTextBoxEX).Text;
                                switch (pinfo.PropertyType.Name)
                                {
                                case "String": controlValue = controlValue.ToString(); break;

                                case "Int32": controlValue = (controlValue == null || controlValue.ToString() == "") ? 0 : Convert.ToInt32(controlValue); break;

                                case "Double": controlValue = controlValue == null || controlValue.ToString() == "" ? 0.00 : Convert.ToDouble(controlValue); break;

                                case "Nullable`1": controlValue = controlValue == null || controlValue.ToString() == "" ? 0.00 : Convert.ToDouble(controlValue); break;
                                }
                                pinfo.SetValue(classModel, controlValue, null);
                            }
                            break;

                        case "NumberTextBox":
                            if (flag == 0)
                            {
                                (c[0] as NumberTextBox).Text = Value;
                            }
                            else
                            {
                                object controlValue = (c[0] as NumberTextBox).Text;
                                switch (pinfo.PropertyType.Name)
                                {
                                case "String": controlValue = controlValue.ToString(); break;

                                case "Int32": controlValue = (controlValue == null || controlValue.ToString() == "") ? 0 : Convert.ToInt32(controlValue); break;

                                case "Double": controlValue = controlValue == null || controlValue.ToString() == "" ? 0.00 : Convert.ToDouble(controlValue); break;

                                case "Nullable`1": controlValue = controlValue == null || controlValue.ToString() == "" ? 0.00 : Convert.ToDouble(controlValue); break;
                                }
                                pinfo.SetValue(classModel, controlValue, null);
                            }
                            break;

                        case "NumberTextBox1":
                            if (flag == 0)
                            {
                                (c[0] as NumberTextBox1).Text = Value;
                            }
                            else
                            {
                                object controlValue = (c[0] as NumberTextBox1).Text;
                                switch (pinfo.PropertyType.Name)
                                {
                                case "String": controlValue = controlValue.ToString(); break;

                                case "Int32": controlValue = (controlValue == null || controlValue.ToString() == "") ? 0 : Convert.ToInt32(controlValue); break;

                                case "Double": controlValue = controlValue == null || controlValue.ToString() == "" ? 0.00 : Convert.ToDouble(controlValue); break;

                                case "Nullable`1": controlValue = controlValue == null || controlValue.ToString() == "" ? 0.00 : Convert.ToDouble(controlValue); break;
                                }
                                pinfo.SetValue(classModel, controlValue, null);
                            }
                            break;

                        case "ComboBox":
                            if (flag == 0)
                            {
                                (c[0] as ComboBox).SelectedValue = Value;
                            }
                            else
                            {
                                pinfo.SetValue(classModel, (c[0] as ComboBox).SelectedValue == null ? "" : (c[0] as ComboBox).SelectedValue.ToString(), null);
                            }
                            break;

                        case "ComboBoxEx":
                            if (flag == 0)
                            {
                                (c[0] as ComboBoxEx).SelectedValue = Value;
                            }
                            else
                            {
                                pinfo.SetValue(classModel, (c[0] as ComboBoxEx).SelectedValue == null ? "" : (c[0] as ComboBoxEx).SelectedValue.ToString(), null);
                            }
                            break;

                        case "TXComboxEX":
                            if (flag == 0)
                            {
                                (c[0] as TXComboxEX).SelectedValue = Value;
                            }
                            else
                            {
                                pinfo.SetValue(classModel, (c[0] as TXComboxEX).SelectedValue == null ? "" : (c[0] as TXComboxEX).SelectedValue.ToString(), null);
                            }
                            break;

                        case "DateTimePicker":
                            if (flag == 0)
                            {
                                (c[0] as DateTimePicker).Text = Value;
                            }
                            else
                            {
                                pinfo.SetValue(classModel, (c[0] as DateTimePicker).Text, null);
                            }
                            break;

                        case "DateTimeEx":
                            if (flag == 0)
                            {
                                (c[0] as DateTimeEx).TextEx = Value;
                            }
                            else
                            {
                                pinfo.SetValue(classModel, (c[0] as DateTimeEx).TextEx, null);
                            }
                            break;
                        }
                    }
                    model = classModel;
                }
            }
            return(model);
        }
Example #5
0
        public void UpdateControls(System.Windows.Forms.Control.ControlCollection ctrlCollection, string formName)
        {
            // Set the row filter based on the Form's name and the lang...
            _appResources.DefaultView.RowFilter = "sys_lang_id=" + _lang.ToString() + " AND form_name='" + formName + "'";
// If this is the client window - change the title bar...
//if (ctrlCollection.Owner.GetType() == typeof(GRINGlobal.Client.CuratorTool.GRINGlobalClientCuratorTool))
//if (ctrlCollection.Owner.GetType().FullName == "GRINGlobal.Client.CuratorTool.GRINGlobalClientCuratorTool")
            {
                //this.Text = "GRIN-Global  v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
                DataRow[] title = _appResources.DefaultView.ToTable().Select("app_resource_name='Text'");
                if (title != null &&
                    title.Length > 0)
                {
                    if (title[0].Table.Columns.Contains("display_member"))
                    {
                        if (title[0]["display_member"].ToString().Contains("{0}"))
                        {
                            ctrlCollection.Owner.Text = string.Format(title[0]["display_member"].ToString(), System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString());
                        }
                        else
                        {
                            ctrlCollection.Owner.Text = title[0]["display_member"].ToString() + " v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
                        }
                    }
                    else if (!ctrlCollection.Owner.Text.Contains(System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString()))
                    {
                        ctrlCollection.Owner.Text += " v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
                    }
                }
                else
                {
                    if (!ctrlCollection.Owner.Text.Contains(System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString()))
                    {
                        ctrlCollection.Owner.Text = "GRIN-Global  v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
                    }
                }
            }

            // Iterate through the Form's controls...
            foreach (DataRowView drv in _appResources.DefaultView)
            {
                System.Windows.Forms.Control[] ctrlArray = ctrlCollection.Find(drv["app_resource_name"].ToString(), true);
                if (ctrlArray != null && ctrlArray.Length > 0)
                {
                    foreach (System.Windows.Forms.Control ctrl in ctrlArray)
                    {
                        ctrl.Text = drv["display_member"].ToString();
                    }
                }
            }

            // Iterate through the Form's toolstrips...
            foreach (System.Windows.Forms.Control ctrl in ctrlCollection)
            {
                if (ctrl is System.Windows.Forms.ToolStrip)
                {
                    System.Windows.Forms.ToolStrip ts = (System.Windows.Forms.ToolStrip)ctrl;
                    foreach (DataRowView drv in _appResources.DefaultView)
                    {
                        System.Windows.Forms.ToolStripItem[] tsiArray = ts.Items.Find(drv["app_resource_name"].ToString(), true);
                        if (tsiArray != null && tsiArray.Length > 0)
                        {
                            foreach (System.Windows.Forms.ToolStripItem tsi in tsiArray)
                            {
                                tsi.Text = drv["display_member"].ToString();
                            }
                        }
                    }
                }
            }
        }