Exemplo n.º 1
0
        private void AddServerClipboard(object parameter)
        {
            List <V2RayVMess> serverList = V2RayVMess.ImportServers(Clipboard.GetText(TextDataFormat.Text));

            if (serverList.Count > 0)
            {
                AddServer(serverList, out int added, out int updated);

                string notify;
                if (SettingManager.Configuration.IsReplaceOldServer)
                {
                    notify = $"{added} {sr_server_x_added}, {updated} {sr_server_x_updated}";
                }
                else
                {
                    notify = $"{added} {sr_server_x_added}";
                }

                InterfaceCtrl.ShowHomeNotify(notify);
            }
            else
            {
                InterfaceCtrl.ShowHomeNotify(sr_server_not_found);
            }
        }
Exemplo n.º 2
0
        private void AddServerQRCode(object parameter)
        {
            string ssBase64 = parameter as string;

            if (string.IsNullOrWhiteSpace(ssBase64))
            {
                ZXing.Result result = QRCode.DecodeScreen();
                if (result == null || string.IsNullOrWhiteSpace(result.Text))
                {
                    InterfaceCtrl.ShowHomeNotify(sr_server_not_found);
                    InterfaceCtrl.NotifyIcon.ShowMessage(sr_server_not_found);
                    return;
                }

                ssBase64 = result.Text;
            }

            if (V2RayVMess.FromVMessBase64(ssBase64) is V2RayVMess server)
            {
                AddServer(server, out int added, out int updated);

                string notify;
                if (SettingManager.Configuration.IsReplaceOldServer)
                {
                    notify = added > 0 ? $"{added} {sr_server_x_added}" : $"{updated} {sr_server_x_updated}";
                }
                else
                {
                    notify = added > 0 ? $"{added} {sr_server_x_added}" : sr_server_already_exist;
                }

                if (Application.Current.MainWindow.IsActive)
                {
                    InterfaceCtrl.ShowHomeNotify(notify);
                }
                else
                {
                    InterfaceCtrl.NotifyIcon.ShowMessage(notify);
                }
            }
            else
            {
                if (Application.Current.MainWindow.IsActive)
                {
                    InterfaceCtrl.ShowHomeNotify(sr_server_not_found);
                }
                else
                {
                    InterfaceCtrl.NotifyIcon.ShowMessage(sr_server_not_found);
                }
            }
        }
Exemplo n.º 3
0
        private void AddServerFile(object parameter)
        {
            Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog
            {
                InitialDirectory = App.DirectoryApplication,
                DefaultExt       = "txt",
                Filter           = "Text|*.txt",
                AddExtension     = true
            };

            string fileContent = null;

            if (openFileDialog.ShowDialog() == true)
            {
                try
                {
                    fileContent = System.IO.File.ReadAllText(openFileDialog.FileName);
                }
                catch { }
            }
            if (string.IsNullOrWhiteSpace(fileContent))
            {
                return;
            }

            List <V2RayVMess> serverList = V2RayVMess.ImportServers(fileContent);

            if (serverList.Count > 0)
            {
                AddServer(serverList, out int added, out int updated);

                string notify;
                if (SettingManager.Configuration.IsReplaceOldServer)
                {
                    notify = $"{added} {sr_server_x_added}, {updated} {sr_server_x_updated}";
                }
                else
                {
                    notify = $"{added} {sr_server_x_added}";
                }

                InterfaceCtrl.ShowHomeNotify(notify);
            }
            else
            {
                InterfaceCtrl.ShowHomeNotify(sr_server_not_found);
            }
        }
Exemplo n.º 4
0
        private void AddServerCreate(object parameter)
        {
            V2RayVMess server = new V2RayVMess();

            new ServerConfigDialog(server,
                                   (bool resultOK) =>
            {
                if (resultOK)
                {
                    AddServer(server, out int added, out int updated);

                    string notify;
                    if (SettingManager.Configuration.IsReplaceOldServer)
                    {
                        notify = added > 0 ? $"{added} {sr_server_x_added}" : $"{updated} {sr_server_x_updated}";
                    }
                    else
                    {
                        notify = added > 0 ? $"{added} {sr_server_x_added}" : sr_server_already_exist;
                    }

                    InterfaceCtrl.ShowHomeNotify(notify);
                }