public TournamentXPSettings GetSettings()
        {
            //var config = new MapperConfiguration(cfg => cfg.CreateMap<TournamentXPSettingsModLib, TournamentXPSettings>());
            //var mapper = new Mapper(config);
            //TournamentXPSettings dto = mapper.Map<TournamentXPSettings>(Instance);
            TournamentXPSettings dto = new TournamentXPSettings();

            PropertyInfo[] propertiesML = typeof(TournamentXPSettingsModLib).GetProperties();
            foreach (PropertyInfo pTXP in typeof(TournamentXPSettings).GetProperties())
            {
                foreach (PropertyInfo pML in propertiesML)
                {
                    try
                    {
                        if (pTXP.Name == pML.Name && pML.Name != "Instance")
                        {
                            pTXP.SetValue(dto, pML.GetValue(TournamentXPSettingsModLib.Instance));
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        ErrorLog.Log("Error in assigning ModLib property to TXPSettings: " + pTXP.Name + "\n" + ex.ToStringFull());
                    }
                }
            }
            return(dto);
        }
        public TournamentXPSettings GetSettings()
        {
            var config = new MapperConfiguration(cfg => cfg.CreateMap <TournamentXPSettingsModLib, TournamentXPSettings>());
            var mapper = new Mapper(config);
            TournamentXPSettings dto = mapper.Map <TournamentXPSettings>(Instance);

            return(dto);
        }
Exemple #3
0
        public TournamentXPSettings GetSettings()
        {
            //var config = new MapperConfiguration(cfg => cfg.CreateMap<TournamentXPSettingsModLib, TournamentXPSettings>());
            //var mapper = new Mapper(config);
            //TournamentXPSettings dto = mapper.Map<TournamentXPSettings>(Instance);
            TournamentXPSettings dto = new TournamentXPSettings();

            PropertyInfo[] propertiesML  = typeof(TournamentXPSettingsModLib).GetProperties();
            PropertyInfo[] propertiesTXP = typeof(TournamentXPSettings).GetProperties();

            foreach (PropertyInfo pTXP in propertiesTXP)
            {
                foreach (PropertyInfo pML in propertiesML)
                {
                    if (pTXP.Name == pML.Name)
                    {
                        pTXP.SetValue(dto, pML.GetValue(TournamentXPSettingsModLib.Instance));
                        break;
                    }
                }
            }
            return(dto);
        }
Exemple #4
0
 public static void SetSettings(TournamentXPSettings settings)
 {
     _instance = settings;
 }
        public void SetProperty(SettingPropertyAttribute attr, PropertyInfo pInfo, TournamentXPSettings settings)
        {
            _pInfo    = pInfo;
            _settings = settings;


            string text = attr.DisplayName;

            if (text.Trim().StartsWith("{"))
            {
                var id = LocalizedTextManager.GetStringId(text);
                text = LocalizedTextManager.GetTranslatedText(languageId, id);
            }
            lblName.Text = text;
            if (!string.IsNullOrWhiteSpace(attr.HintText))
            {
                string text2 = attr.HintText;
                if (text2.Trim().StartsWith("{"))
                {
                    var id = LocalizedTextManager.GetStringId(text2);
                    text2 = LocalizedTextManager.GetTranslatedText(languageId, id);
                }
                ToolTip tt = new ToolTip();
                tt.IsBalloon = true;
                tt.SetToolTip(lblName, text2);
            }

            checkBox1.Visible  = false;
            textBox1.Visible   = false;
            textBox1.TextAlign = HorizontalAlignment.Right;
            trackBar1.Visible  = false;
            trackBar2.Visible  = false;

            switch (pInfo.PropertyType.Name)
            {
            case "Boolean":
                checkBox1.Visible = true;
                checkBox1.Checked = (bool)pInfo.GetValue(settings);
                break;

            case "Int32":
            case "Int64":
            case "Integer":
                textBox1.Visible  = true;
                textBox1.Text     = ((int)pInfo.GetValue(settings)).ToString();
                trackBar1.Visible = true;
                trackBar1.Minimum = (int)attr.MinValue;
                trackBar1.Maximum = (int)attr.MaxValue;
                trackBar1.Value   = ((int)pInfo.GetValue(settings));
                break;

            case "Single":
                textBox1.Visible  = true;
                textBox1.Text     = ((float)pInfo.GetValue(settings)).ToString();
                trackBar2.Visible = true;
                trackBar2.Minimum = attr.MinValue;
                trackBar2.Maximum = attr.MaxValue;
                trackBar2.Value   = ((float)pInfo.GetValue(settings));
                break;

            default:
                break;
            }
        }