private async void ShareExecute(ProxyViewModel proxy) { var response = await ProtoService.SendAsync(new GetProxyLink(proxy.Id)); if (response is Text text && Uri.TryCreate(text.TextValue, UriKind.Absolute, out Uri uri)) { await SharePopup.GetForCurrentView().ShowAsync(uri, Strings.Resources.Proxy); } }
private async void CopyLinkExecute(ProxyViewModel proxy) { var response = await ProtoService.SendAsync(new GetProxyLink(proxy.Id)); if (response is Text text && Uri.TryCreate(text.TextValue, UriKind.Absolute, out Uri uri)) { var dataPackage = new Windows.ApplicationModel.DataTransfer.DataPackage(); dataPackage.SetText(text.TextValue); ClipboardEx.TrySetContent(dataPackage); await MessagePopup.ShowAsync(Strings.Resources.LinkCopied, Strings.Resources.UseProxyTelegram, Strings.Resources.OK); } }
private async void RemoveExecute(ProxyViewModel proxy) { var confirm = await MessagePopup.ShowAsync(Strings.Resources.DeleteProxy, Strings.Resources.AppName, Strings.Resources.OK, Strings.Resources.Cancel); if (confirm != ContentDialogResult.Primary) { return; } var response = await ProtoService.SendAsync(new RemoveProxy(proxy.Id)); if (response is Ok) { Items.Remove(proxy); } Handle(CacheService.GetConnectionState(), CacheService.Options.EnabledProxyId); }
private async void AddExecute() { var dialog = new ProxyPopup(); var confirm = await dialog.ShowQueuedAsync(); if (confirm != ContentDialogResult.Primary) { return; } var response = await ProtoService.SendAsync(new AddProxy(dialog.Server, dialog.Port, false, dialog.Type)); if (response is Proxy proxy) { var connection = new ProxyViewModel(proxy); Items.Add(connection); await UpdateAsync(connection); } }
private async void EditExecute(ConnectionViewModel connection) { var dialog = new ProxyPopup(connection as ProxyViewModel); var confirm = await dialog.ShowQueuedAsync(); if (confirm != ContentDialogResult.Primary) { return; } var response = await ProtoService.SendAsync(new EditProxy(connection.Id, dialog.Server, dialog.Port, false, dialog.Type)); if (response is Proxy proxy) { var index = Items.IndexOf(connection); Items.Remove(connection); var edited = new ProxyViewModel(proxy); Items.Insert(index, edited); await UpdateAsync(edited); } Handle(CacheService.GetConnectionState(), CacheService.Options.EnabledProxyId); }