public ProxyPopup(ProxyViewModel proxy) { InitializeComponent(); FieldServer.Text = proxy.Server; FieldPort.Text = proxy.Port.ToString(); switch (proxy.Type) { case ProxyTypeSocks5 socks: FieldUsername.Text = socks.Username; FieldPassword.Password = socks.Password; TypeSocks.IsChecked = true; break; case ProxyTypeMtproto proto: FieldSecret.Text = proto.Secret; TypeProto.IsChecked = true; break; case ProxyTypeHttp http: FieldUsername.Text = http.Username; FieldPassword.Password = http.Password; FieldTransparent.IsChecked = !http.HttpOnly; TypeHttp.IsChecked = true; break; } }
public async Task <IActionResult> Edit(int id, ProxyEditViewModel pevm) { if (id != pevm.Id) { return(NotFound()); } var proxy = await db.FindProxyByIdAsync(id); if (proxy == null) { return(NotFound()); } if (ModelState.IsValid) { if (!CurrentUser.CanEdit(proxy)) { return(Forbid()); } proxy.IsGlobal = CurrentUser.IsAllowedGlobal && pevm.IsGlobal; proxy.Name = pevm.Name; proxy.Prefix = pevm.Prefix; proxy.Suffix = pevm.Suffix; proxy.Biography = pevm.Biography; if (!await UpdateProxyChannels(proxy, pevm.Channels, pevm.IsGlobal)) { return(Forbid());// TODO: Make this fail gracefully rather than returning HTTP F**k off } await avatarHelper.UpdateAvatar(proxy, pevm.Avatar); db.Update(proxy); await db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } var discord = await discordHelper.LoginBot(); var pvm = new ProxyViewModel(proxy, discord) { IsGlobal = CurrentUser.IsAllowedGlobal && pevm.IsGlobal, Name = pevm.Name, Prefix = pevm.Prefix, Suffix = pevm.Suffix, Biography = pevm.Biography, Avatar = pevm.Avatar, Channels = pevm.Channels, }; return(View(pvm)); }
public ProxySettings(ProxyViewModel viewModel) { _viewModel = viewModel; InitializeComponent(); tbProxy.Text = _viewModel.Proxy; chkAnnonymous.IsChecked = _viewModel.ProxyAnnonymous; tbUsername.Text = _viewModel.ProxyUserName; tbPassword.Password = _viewModel.ProxyPassword; }
public SetAdapterCommand(ProxyViewModel viewModel) { proxyViewModel = viewModel; proxyViewModel.PropertyChanged += (sender, e) => { if (CanExecuteChanged != null) { CanExecuteChanged(sender, e); } }; }
public MainWindowViewModel() { Proxy = new ProxyViewModel(); _multirotorVehicle = new MultirotorVehicleModel(Proxy.Controller); _rc = new RcModel(Proxy.Controller); _camera = new CameraModel(0, Proxy.CameraController); Camera = new CameraViewModel(_camera); Map = new MapViewModel(_multirotorVehicle); Rc = new RcViewModel(_rc); Vehicle = new VehicleViewModel(_multirotorVehicle); }
public ActionResult Proxy([FromBody] ProxyViewModel model) { var urlToProcess = UrlHelpers.ConvertToAbsoluteUrl(model.Url); Logger.Debug() .Message("Proxying custom action url: {url}", urlToProcess) .Write(); var parts = urlToProcess.Split("?".ToCharArray(), 2); var request = WebRequest.Create(parts[0]); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; var postBytes = new ASCIIEncoding().GetBytes(parts[1]); request.ContentLength = postBytes.Length; using (var postStream = request.GetRequestStream()) { postStream.Write(postBytes, 0, postBytes.Length); postStream.Flush(); postStream.Close(); } try { var result = string.Empty; var response = request.GetResponse().GetResponseStream(); if (response != null) { result = new StreamReader(response).ReadToEnd(); } if (model.Level >= PermissionLevel.Modify) { CreateLogs(model.ActionCode, model.Ids, model.ParentEntityId); } return(Content(result)); } catch (Exception ex) { return(JsonMessageResult(MessageResult.Error(ex.Message))); } }
// GET: Proxies/Details/5 public async Task <IActionResult> Details(int?id) { var discord = await discordHelper.LoginBot(); if (id == null) { return(NotFound()); } var proxy = await db.FindProxyByIdAsync(id); if (proxy == null) { return(NotFound()); } var pvm = new ProxyViewModel(proxy, discord); return(View(pvm)); }
public MainWindow() { InitializeComponent(); Loaded += (s, e) => DataContext = new ProxyViewModel(); }
public RelaxedPolicyPage() { InitializeComponent(); DataContext = new ProxyViewModel <RelaxedPolicyViewModel>(ModelManager.Default.GetModel <RelaxedPolicyViewModel>()); }
public ProxyView(ProxyViewModel model) { InitializeComponent(); DataContext = model; }
public MainWindow() { InitializeComponent(); _viewModel = new ProxyViewModel(ListView); DataContext = _viewModel; }
public AdvancedPage() { InitializeComponent(); DataContext = new ProxyViewModel <AdvancedPageViewModel>(ModelManager.Default.GetModel <AdvancedPageViewModel>()); }