示例#1
0
        public void BackupOptions()
        {
            if (!IsOptionsSaved())
            {
                MessageBox.Show(I18N.SaveChangeFirst);
                return;
            }

            var serverString = string.Empty;

            foreach (var server in Services.Servers.Instance.GetAllServersOrderByIndex())
            {
                // insert a space in the front for regex matching
                serverString += @" "
                                + VgcApis.Models.Datas.Enums.LinkTypes.v2cfg.ToString()
                                + @"://"
                                + Misc.Utils.Base64Encode(server.GetConfiger().GetConfig())
                                + Environment.NewLine;
            }

            var data = new Dictionary <string, string> {
                { BAK_IMPORT, JsonConvert.SerializeObject(setting.GetGlobalImportItems()) },
                { BAK_SUBSCRIPTION, JsonConvert.SerializeObject(setting.GetSubscriptionItems()) },
                { BAK_SERVERS, serverString },
                { BAK_PLUGINS, setting.AllPluginsSetting },
            };

            VgcApis.Misc.UI.SaveToFile(
                VgcApis.Models.Consts.Files.TxtExt,
                JsonConvert.SerializeObject(data));
        }
示例#2
0
文件: Import.cs 项目: ghotm/V2RayGCon
        public override void Update(JObject config)
        {
            content = I18N.AnalysingImport;

            var plainText = config.ToString();

            if (cboxGlobalImport.Checked)
            {
                var configWithGlobalImports =
                    Misc.Utils.ImportItemList2JObject(
                        setting.GetGlobalImportItems(), false, true, false);

                Misc.Utils.MergeJson(ref configWithGlobalImports, config);
                plainText = configWithGlobalImports.ToString();
            }

            VgcApis.Misc.Utils.RunInBackground(() =>
            {
                string result = ParseConfig(plainText);
                setting.LazyGC();

                VgcApis.Misc.UI.RunInUiThread(editor, () =>
                {
                    content = result;
                });
            });
        }
示例#3
0
文件: Import.cs 项目: ghotm/V2RayGCon
        void InitPanel()
        {
            var importUrlItemList = setting.GetGlobalImportItems();

            this.oldOptions = JsonConvert.SerializeObject(importUrlItemList);

            if (importUrlItemList.Count <= 0)
            {
                importUrlItemList.Add(new Models.Datas.ImportItem());
            }

            foreach (var item in importUrlItemList)
            {
                this.flyPanel.Controls.Add(new Views.UserControls.ImportUI(item, UpdatePanelItemsIndex));
            }

            UpdatePanelItemsIndex();
        }