Example #1
0
        /// <summary>
        /// returns null when control is not found, control value otherwise
        /// </summary>
        private string GetControlValue(string controlName)
        {
            if (controlName == "Photo")
            {
                return(this.Photo.Tag.ToString());
            }

            Control c = FindControl(this, controlName);

            if (c != null)
            {
                TextBox                tb  = c as TextBox;
                IntAttrControl         iac = c as IntAttrControl;
                StringSelectionControl ssc = c as StringSelectionControl;
                DateValueControl       dvc = c as DateValueControl;
                if (iac != null)
                {
                    return(iac.Value.ToString());
                }
                else if (dvc != null)
                {
                    return(dvc.Value);
                }
                else if (ssc != null)
                {
                    if (controlName == "PBP" && PBPs.ContainsKey(ssc.Value))
                    {
                        return(PBPs[ssc.Value]);
                    }
                    else if (controlName == "Photo" && Photos.ContainsKey(ssc.Value))
                    {
                        return(Photos[ssc.Value]);
                    }
                    else if (controlName == "College" && ssc.Value.IndexOf(',') > -1)
                    {
                        return(string.Concat("\"", ssc.Value, "\""));
                    }
                    return(ssc.Value);
                }
                else if (tb != null)
                {
                    return(tb.Text);
                }
            }
            return(null);
        }
Example #2
0
        private void AddAppearance(string appearance)
        {
            Control c = null;
            IntAttrControl intAttrCtrl = null;
            StringSelectionControl ctrl = null;
            if( "Weight,DOB,YearsPro,JerseyNumber,".IndexOf(appearance+",") > -1)
            {
                switch( appearance)
                {
                    case "JerseyNumber":
                        intAttrCtrl = new IntAttrControl();
                        intAttrCtrl.Name = intAttrCtrl.Text = appearance;
                        intAttrCtrl.Max = 99;
                        intAttrCtrl.ValueChanged += new EventHandler(jersey_ValueChanged);
                        break;
                    case "YearsPro":
                        intAttrCtrl = new IntAttrControl();
                        intAttrCtrl.Name = intAttrCtrl.Text = appearance;
                        intAttrCtrl.Max = 99;
                        break;
                    case "Weight":
                        intAttrCtrl = new IntAttrControl();
                        intAttrCtrl.Name = intAttrCtrl.Text = appearance;
                        intAttrCtrl.Min = 150;
                        intAttrCtrl.Max = intAttrCtrl.Min + 255;
                        intAttrCtrl.ValueChanged += new EventHandler(weight_ValueChanged);

                        break;
                    case "DOB":
                        DateValueControl dvc = new DateValueControl();
                        dvc.Name = dvc.Text = appearance;
                        dvc.ValueChanged += new EventHandler(ValueChanged);
                        c = dvc;
                        break;
                }
            }
            else if( "Hand,BodyType,Skin,Face,MouthPiece,EyeBlack,Dreads,Helmet,Sleeves,Visor,Turtleneck,Height,College,PBP,".IndexOf(appearance+",") > -1) {
                ctrl = new StringSelectionControl();
                ctrl.Name = ctrl.Text = appearance;
                switch (appearance)
                {
                    case "Hand": ctrl.RepresentedValue = typeof(Hand); break;
                    case "BodyType":
                        ctrl.RepresentedValue = typeof(Body);
                        ctrl.ValueChanged += new EventHandler(bodyType_ValueChanged);
                        break;
                    case "Skin":
                        ctrl.RepresentedValue = typeof(Skin);
                        ctrl.ValueChanged += new EventHandler(skin_ValueChanged);
                        break;
                    case "Face": ctrl.RepresentedValue = typeof(Face); break;
                    case "MouthPiece":
                    case "EyeBlack":
                    case "Dreads":  ctrl.RepresentedValue = typeof(YesNo);  break;
                    case "Helmet": ctrl.RepresentedValue = typeof(Helmet); break;
                    case "Sleeves": ctrl.RepresentedValue = typeof(Sleeves); break;
                    case "Visor": ctrl.RepresentedValue = typeof(Visor); break;
                    case "Turtleneck": ctrl.RepresentedValue = typeof(Turtleneck); break;
                    case "Height": //5'6"-7'0"
                        ctrl.SetItems(new string[] {
                            "5'6\"", "5'7\"", "5'8\"", "5'9\"", "5'10\"", "5'11\"",
                            "6'0\"", "6'1\"", "6'2\"", "6'3\"", "6'4\"",  "6'5\"",
                            "6'6\"", "6'7\"", "6'8\"", "6'9\"", "6'10\"", "6'11\"",
                            "7'0\"" });
                        ctrl.ValueChanged += new EventHandler(height_ValueChanged);
                        break;
                    case "College":
                        ctrl.DropDownStyle = ComboBoxStyle.DropDown;
                        ctrl.SetItems(Colleges);
                        break;
                    case "PBP":
                        string[] values = new string[this.ReversePBPs.Count];
                        this.ReversePBPs.Values.CopyTo(values, 0);
                        ctrl.SetItems(values);
                        ctrl.DropDownStyle = ComboBoxStyle.DropDown;
                        break;
                }
            }
            else
            {
                ctrl = new PictureChooser();
                ctrl.Name = ctrl.Text = appearance;
                ctrl.ValueChanged += new EventHandler(PictureChooser_ValueChanged);

                switch(appearance)
                {
                    // need to special case the setting of these items.
                    case "FaceMask": ctrl.RepresentedValue = typeof(FaceMask); break;
                    case "LeftElbow":
                    case "RightElbow": ctrl.RepresentedValue = typeof(Elbow); break;
                    case "LeftGlove":
                    case "RightGlove": ctrl.RepresentedValue = typeof(Glove); break;
                    case "LeftWrist":
                    case "RightWrist": ctrl.RepresentedValue = typeof(Wrist); break;
                    case "LeftShoe":
                    case "RightShoe": ctrl.RepresentedValue = typeof(Shoe); break;
                    case "NeckRoll": ctrl.RepresentedValue = typeof(NeckRoll); break;
                    case "Photo":
                        ctrl.DropDownStyle = ComboBoxStyle.DropDown;
                        ctrl.ValueChanged += new EventHandler(PictureChooser_ValueChanged);
                        string[] vals = new string[this.ReversePhotos.Count];
                        this.ReversePhotos.Values.CopyTo(vals, 0);
                        ctrl.SetItems(vals);
                        break;
                }
            }
            if (intAttrCtrl != null)
            {
                intAttrCtrl.ValueChanged += new EventHandler(ValueChanged);
                c = intAttrCtrl;
            }
            else if (ctrl != null)
            {
                ctrl.ValueChanged += new EventHandler(ValueChanged);
                c = ctrl;
            }

            if (c != null)
            {
                int row = mAppearanceTab.Controls.Count / 5;
                int col = mAppearanceTab.Controls.Count % 5;
                c.Location = new Point(col * c.Width, row * c.Height);
                mAppearanceTab.Controls.Add(c);
            }
        }
Example #3
0
        private bool SetControlValue(Control parentControl, string controlName, string val)
        {
            foreach (Control c in parentControl.Controls)
            {
                if (c.Name == controlName)
                {
                    IntAttrControl         iac = c as IntAttrControl;
                    StringSelectionControl ssc = c as StringSelectionControl;
                    DateValueControl       dvc = c as DateValueControl;

                    if (iac != null)
                    {
                        iac.Value = Int32.Parse(val);
                        return(true);
                    }
                    else if (dvc != null)
                    {
                        dvc.Value = val;
                        return(true);
                    }
                    else if (ssc != null)
                    {
                        if (controlName == "PBP")
                        {
                            if (ReversePBPs.ContainsKey(val))
                            {
                                ssc.Value = ReversePBPs[val];
                                return(true);
                            }
                        }
                        else if (controlName == "Photo")
                        {
                            if (ReversePhotos.ContainsKey(val))
                            {
                                ssc.Value = ReversePhotos[val];
                            }
                            else
                            {
                                ssc.Value = "NoPhoto";
                            }
                            return(true);
                        }
                        else if (controlName == "College")
                        {
                            if (val[0] == '"')
                            {
                                val = val.Replace("\"", "");
                            }
                            ssc.Value = val;
                            return(true);
                        }
                        else
                        {
                            ssc.Value = val;
                            return(true);
                        }
                    }
                    else
                    {
                        c.Text = val;
                        return(true);
                    }
                }
            }
            return(false);
        }
Example #4
0
        private void AddAppearance(string appearance)
        {
            Control                c           = null;
            IntAttrControl         intAttrCtrl = null;
            StringSelectionControl ctrl        = null;

            if ("Weight,DOB,YearsPro,JerseyNumber,".IndexOf(appearance + ",") > -1)
            {
                switch (appearance)
                {
                case "JerseyNumber":
                    intAttrCtrl               = new IntAttrControl();
                    intAttrCtrl.Name          = intAttrCtrl.Text = appearance;
                    intAttrCtrl.Max           = 99;
                    intAttrCtrl.ValueChanged += new EventHandler(jersey_ValueChanged);
                    break;

                case "YearsPro":
                    intAttrCtrl      = new IntAttrControl();
                    intAttrCtrl.Name = intAttrCtrl.Text = appearance;
                    intAttrCtrl.Max  = 99;
                    break;

                case "Weight":
                    intAttrCtrl               = new IntAttrControl();
                    intAttrCtrl.Name          = intAttrCtrl.Text = appearance;
                    intAttrCtrl.Min           = 150;
                    intAttrCtrl.Max           = intAttrCtrl.Min + 255;
                    intAttrCtrl.ValueChanged += new EventHandler(weight_ValueChanged);

                    break;

                case "DOB":
                    DateValueControl dvc = new DateValueControl();
                    dvc.Name          = dvc.Text = appearance;
                    dvc.ValueChanged += new EventHandler(ValueChanged);
                    c = dvc;
                    break;
                }
            }
            else if ("Hand,BodyType,Skin,Face,MouthPiece,EyeBlack,Dreads,Helmet,Sleeves,Visor,Turtleneck,Height,College,PBP,".IndexOf(appearance + ",") > -1)
            {
                ctrl      = new StringSelectionControl();
                ctrl.Name = ctrl.Text = appearance;
                switch (appearance)
                {
                case "Hand": ctrl.RepresentedValue = typeof(Hand); break;

                case "BodyType":
                    ctrl.RepresentedValue = typeof(Body);
                    ctrl.ValueChanged    += new EventHandler(bodyType_ValueChanged);
                    break;

                case "Skin":
                    ctrl.RepresentedValue = typeof(Skin);
                    ctrl.ValueChanged    += new EventHandler(skin_ValueChanged);
                    break;

                case "Face":
                    ctrl.RepresentedValue = typeof(Face);
                    ctrl.ValueChanged    += new EventHandler(face_ValueChanged);
                    break;

                case "MouthPiece":
                case "EyeBlack":
                case "Dreads":  ctrl.RepresentedValue = typeof(YesNo);  break;

                case "Helmet": ctrl.RepresentedValue = typeof(Helmet); break;

                case "Sleeves": ctrl.RepresentedValue = typeof(Sleeves); break;

                case "Visor": ctrl.RepresentedValue = typeof(Visor); break;

                case "Turtleneck": ctrl.RepresentedValue = typeof(Turtleneck); break;

                case "Height":     //5'6"-7'0"
                    ctrl.SetItems(new string[] {
                        "5'6\"", "5'7\"", "5'8\"", "5'9\"", "5'10\"", "5'11\"",
                        "6'0\"", "6'1\"", "6'2\"", "6'3\"", "6'4\"", "6'5\"",
                        "6'6\"", "6'7\"", "6'8\"", "6'9\"", "6'10\"", "6'11\"",
                        "7'0\""
                    });
                    ctrl.ValueChanged += new EventHandler(height_ValueChanged);
                    break;

                case "College":
                    ctrl.DropDownStyle = ComboBoxStyle.DropDown;
                    ctrl.SetItems(Colleges);
                    break;

                case "PBP":
                    string[] values = new string[this.ReversePBPs.Count];
                    this.ReversePBPs.Values.CopyTo(values, 0);
                    ctrl.SetItems(values);
                    ctrl.DropDownStyle = ComboBoxStyle.DropDown;
                    break;
                }
            }
            else
            {
                ctrl               = new PictureChooser();
                ctrl.Name          = ctrl.Text = appearance;
                ctrl.ValueChanged += new EventHandler(PictureChooser_ValueChanged);

                switch (appearance)
                {
                // need to special case the setting of these items.
                case "FaceMask": ctrl.RepresentedValue = typeof(FaceMask); break;

                case "LeftElbow":
                case "RightElbow": ctrl.RepresentedValue = typeof(Elbow); break;

                case "LeftGlove":
                case "RightGlove": ctrl.RepresentedValue = typeof(Glove); break;

                case "LeftWrist":
                case "RightWrist": ctrl.RepresentedValue = typeof(Wrist); break;

                case "LeftShoe":
                case "RightShoe": ctrl.RepresentedValue = typeof(Shoe); break;

                case "NeckRoll": ctrl.RepresentedValue = typeof(NeckRoll); break;

                case "Photo":
                    ctrl.DropDownStyle = ComboBoxStyle.DropDown;
                    ctrl.ValueChanged += new EventHandler(PictureChooser_ValueChanged);
                    string[] vals = new string[this.ReversePhotos.Count];
                    this.ReversePhotos.Values.CopyTo(vals, 0);
                    ctrl.SetItems(vals);
                    break;
                }
            }
            if (intAttrCtrl != null)
            {
                intAttrCtrl.ValueChanged += new EventHandler(ValueChanged);
                c = intAttrCtrl;
            }
            else if (ctrl != null)
            {
                ctrl.ValueChanged += new EventHandler(ValueChanged);
                c = ctrl;
            }

            if (c != null)
            {
                int row = mAppearanceTab.Controls.Count / 5;
                int col = mAppearanceTab.Controls.Count % 5;
                c.Location = new Point(col * c.Width, row * c.Height);
                mAppearanceTab.Controls.Add(c);
            }
        }