Пример #1
0
        public void Export2ServerConfig(int index, Config config)
        {
            //int index = GetLvSelectedIndex();
            if (index < 0)
            {
                return;
            }
            if (config.vmess[index].configType != (int)EConfigType.Vmess &&
                config.vmess[index].configType != (int)EConfigType.VLESS)
            {
                UI.Show(UIRes.I18N("NonVmessService"));
                return;
            }

            SaveFileDialog fileDialog = new SaveFileDialog
            {
                Filter           = "Config|*.json",
                FilterIndex      = 2,
                RestoreDirectory = true
            };

            if (fileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string fileName = fileDialog.FileName;

            if (Utils.IsNullOrEmpty(fileName))
            {
                return;
            }
            Config configCopy = Utils.DeepCopy(config);

            configCopy.index = index;
            if (V2rayConfigHandler.Export2ServerConfig(configCopy, fileName, out string msg) != 0)
            {
                UI.Show(msg);
            }
            else
            {
                UI.ShowWarning(string.Format(UIRes.I18N("SaveServerConfigurationIn"), fileName));
            }
        }
Пример #2
0
        public void Export2ServerConfig(VmessItem item, Config config)
        {
            if (item == null)
            {
                return;
            }
            if (item.configType != EConfigType.Vmess &&
                item.configType != EConfigType.VLESS)
            {
                UI.Show(ResUI.NonVmessService);
                return;
            }

            SaveFileDialog fileDialog = new SaveFileDialog
            {
                Filter           = "Config|*.json",
                FilterIndex      = 2,
                RestoreDirectory = true
            };

            if (fileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string fileName = fileDialog.FileName;

            if (Utils.IsNullOrEmpty(fileName))
            {
                return;
            }
            //Config configCopy = Utils.DeepCopy(config);
            //configCopy.index = index;
            if (V2rayConfigHandler.Export2ServerConfig(item, fileName, out string msg) != 0)
            {
                UI.Show(msg);
            }
            else
            {
                UI.ShowWarning(string.Format(ResUI.SaveServerConfigurationIn, fileName));
            }
        }