Esempio n. 1
0
        private static void OnDeserialize(Config value)
        {

        }
Esempio n. 2
0
        private void Init()
        {
            var skins = new Dictionary <string, string> {
                ["默认皮肤"] = ""
            };

            skins = Utils.GetMatchedFiles(SKINS_PATH, "*.ssk", skins);
            var skinSet = new BindingSource {
                DataSource = skins
            };

            skinSetBox.DataSource    = skinSet;
            skinSetBox.DisplayMember = "Key";
            skinSetBox.ValueMember   = "Value";
            _autoSizeFormControlUtil = new AutoSizeFormControlUtil(this);
            _autoSizeFormControlUtil.RefreshControlsInfo(this.Controls[0]);
            FormBorderStyle = FormBorderStyle.FixedDialog;
            instance        = this;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
            if (!Utils.IsUnixPlatform())
            {
                foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
                {
                    var registry = asm.GetType("Microsoft.Win32.Registry");
                    if (registry == null)
                    {
                        continue;
                    }
                    var getValue = registry.GetMethod("GetValue", new Type[] { typeof(string), typeof(string), typeof(object) });
                    if (getValue != null)
                    {
                        var exePath = getValue.Invoke(null, new object[] { REG_PATH, "ExePath", string.Empty }) as string;
                        if (string.IsNullOrEmpty(exePath) || !File.Exists(exePath))
                        {
                            var setValue = registry.GetMethod("SetValue", new Type[] { typeof(string), typeof(string), typeof(object) });
                            if (setValue != null)
                            {
                                setValue.Invoke(null, new object[] { REG_PATH, "ExePath", Path.Combine(Application.StartupPath, "DearUnityModManager.exe") });
                                setValue.Invoke(null, new object[] { REG_PATH, "Path", Application.StartupPath });
                            }
                        }
                    }
                    break;
                }
            }
            var rbWidth = 0;

            for (var i = (InstallType)0; i < InstallType.Count; i++)
            {
                var rb = new RadioButton
                {
                    Name     = i.ToString(),
                    Text     = i == InstallType.DoorstopProxy ? $"{i.ToString()}(推荐)" : i.ToString(),
                    AutoSize = true,
                    Location = new Point(rbWidth + 8, 50),
                    Margin   = new Padding(0)
                };
                rb.Click += installType_Click;
                installTypeGroup.Controls.Add(rb);
                rbWidth += rb.Width + 12;
            }
            version             = typeof(UnityModManager).Assembly.GetName().Version;
            currentVersion.Text = version.ToString();
            config = Config.Load();
            param  = Param.Load();
            skinSetBox.SelectedIndex = param.LastSelectedSkin;
            if (config?.GameInfo != null && config.GameInfo.Length > 0)
            {
                config.GameInfo = config.GameInfo.OrderBy(x => x.GameName).ToArray();
                gameList.Items.AddRange(config.GameInfo);

                GameInfo selected = null;
                if (!string.IsNullOrEmpty(param.LastSelectedGame))
                {
                    selected = config.GameInfo.FirstOrDefault(x => x.Name == param.LastSelectedGame);
                }
                selected = selected ?? config.GameInfo.First();
                gameList.SelectedItem = selected;
                selectedGameParams    = param.GetGameParam(selected);
            }
            else
            {
                InactiveForm();
                Log.Print($"解析配置文件“{Config.filename}”失败!");
                return;
            }
            CheckLastVersion();
        }