public TraktDialogViewModel(ITraktService traktService) { _traktService = traktService; CloseCommand = new RelayCommand(() => { CloseAction.Invoke(); }); InitializeAsyncCommand = new RelayCommand(async() => { try { IsLoading = true; IsLoggedIn = await _traktService.IsLoggedIn(); TraktOAuthUrl = !IsLoggedIn ? _traktService.GetAuthorizationUrl() : string.Empty; } catch (Exception ex) { Logger.Error(ex); } finally { IsLoading = false; } }); }
protected override void PostConstruct() { base.PostConstruct(); if (PauseWhenVisible) { Node.GetTree().Paused = true; } else { _initialActiveState = PlayerControl.Active; PlayerControl.Active = false; } Input.SetMouseMode(Input.MouseMode.Visible); CloseAction.Iter(action => { Node.OnUnhandledInput() .Where(e => e.IsActionPressed(action) && !e.IsEcho()) .Do(_ => Node.GetTree().SetInputAsHandled()) .TakeUntil(Disposed.Where(identity)) .Subscribe(_ => Resume(), this); }); }
/// <summary> /// Starts the instance of the <see cref="kOS.Screen.ListPickerDialog"/> class. /// Because Monobehaviour doesn't like setting up things in the constructor, you call this /// after the constructor: /// </summary> /// <param name="leftX">position of upper left x coord</param> /// <param name="topY">position of upper left y coord</param> /// <param name="minWidth">force Unity to render the window at least this wide.</param>"> /// <param name="title">Title text.</param> /// <param name="current">Current string value.</param> /// <param name="choices">Choices.</param> /// <param name="callWhenChanged">Your Callback invoked when a new pick has been made.</param> /// <param name="callWhenClosed">Your Callback invoked when the user closes the dialog box.</param> public void Summon( float leftX, float topY, float minWidth, string title, string subTitle, string current, IEnumerable <string> choices, ChangeAction callWhenChanged, CloseAction callWhenClosed) { this.choices = new List <string>(choices); this.current = current; this.title = title; this.subTitle = subTitle; this.callWhenChanged = callWhenChanged; this.callWhenClosed = callWhenClosed; MakeStyles(); outerWindowRect.x = leftX; outerWindowRect.y = topY; this.minWidth = minWidth; running = true; // For calculating the rectangle size, what's the biggest string we'll need to fit? longestString = (subTitle != null && subTitle.Length > title.Length) ? subTitle : title; foreach (string str in choices) { if (str.Length > longestString.Length) { longestString = str; } } }
private void OKExecute(object obj) { bool allMappingsValid = true; bool isValid; var mappings = GetMappings(out isValid); allMappingsValid &= isValid; if (mappings != null) { foreach (var m in mappings) { var mappingsValid = m.PhaidraAttribute.ValidateMappings(m); if (!mappingsValid) { Logger.LogW($"Mappings of Attribute {m.PhaidraAttribute.Name} invalid"); } allMappingsValid &= mappingsValid; } } if (allMappingsValid) { DialogResult = true; CloseAction?.Invoke(); } else { DebugCommand.Execute(null); } }
private void Cancel(object obj) { if (CloseAction != null) { CloseAction.Invoke(); } }
/// <summary> /// Adiciona os arquivos gerados nos projetos de Portal e Model /// </summary> /// <param name="createdFiles"></param> private void AddGenerateFilesToProject(Dictionary <String, TypeFile> createdFiles) { createdFiles.Where(file => file.Value == TypeFile.Model).ToList().ForEach(file => { AddFile(file.Key, Project.BuildActions.Compile, modelProject); }); createdFiles.Where(file => file.Value == TypeFile.Portal).ToList().ForEach(file => { if (file.Key.Contains("cshtml")) { AddFile(file.Key, Project.BuildActions.Resource, portalProject); } else { AddFile(file.Key, Project.BuildActions.Compile, portalProject); } }); createdFiles.Where(file => file.Value == TypeFile.PortalBusiness).ToList().ForEach(file => { AddFile(file.Key, Project.BuildActions.Compile, portalBusinessProject); }); createdFiles.Where(file => file.Value == TypeFile.WebDriverPages).ToList().ForEach(file => { AddFile(file.Key, Project.BuildActions.Compile, webPagesProject); }); modelProject.Save(); portalProject.Save(); portalBusinessProject.Save(); webPagesProject.Save(); CloseAction.Invoke(); }
//登录 public void Confirm() { try { if (Check()) { ReadClientConfig(); if (CheckLogin()) { ListmenuItem = GetItems(listCheckUesrInfo[0].menuitem); listCheckUesrInfo[0].menuitem = ListmenuItem.ToArray <MenuItem>(); MainWindow mw = new MainWindow(); mw.ui = listCheckUesrInfo[0]; //mw.Show(); Common.CommonData.GetInstance().ListCheckUesrInfo = listCheckUesrInfo[0]; CloseAction.Invoke(); } } } catch (Exception ex) { lg.LogWrite(Logger.LogLevel.Debug, "", ex.ToString()); MessageBox.Show("网络异常,请联系管理员!"); return; } }
protected void HandleWrites(SocketState ss) { ArrayList socks = ss.WriteSocks; for (int i = 0; i < socks.Count; i++) { Socket s = (Socket)socks[i]; CreationState cs = ss.TakeCreationState(s); if (cs != null) { cs.HandleWritability(s); } else { //Let's try to flush the buffer: try { ss.FlushSocket(s); } catch { /* * We should close this edge */ TcpEdge tcpe = ss.GetEdge(s); TEL.RequestClose(tcpe); //Go ahead and forget about this socket. CloseAction ca = new CloseAction(tcpe, null); ca.Start(ss); } } } }
//获取用户权限职责 private void GetUserDspInfo() { //加密 Encryption4Net.Encryption encryption = new Encryption4Net.Encryption(); string inputPsw = encryption.EnCode(ui.UserPwd); ui.UserPwd = inputPsw; encryption = null; listCheckUesrInfo = LoginClient.Current.CheckUserInfo(ui); if (listCheckUesrInfo.Count == 0) { MessageBox.Show("用户名或密码不存在!"); } else { ListmenuItem = GetItems(listCheckUesrInfo[0].menuitem); listCheckUesrInfo[0].menuitem = ListmenuItem.ToArray <MenuItem>(); MainWindow mw = new MainWindow(); mw.ui = listCheckUesrInfo[0]; mw.Show(); CloseAction.Invoke(); } }
public FloatingActionButton() { SizeRequest = 40; AllowTap = true; GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => { if (TapAction != null) { TapAction.Dispatch(); return; } if (IsOpened) { IsOpened = false; CloseAction.Dispatch(); } else { IsOpened = true; OpenAction.Dispatch(); } }, () => AllowTap) }); }
/* * Update the SocketState.TAA and check to see if any Edges need * to be closed. */ public override void Start(SocketState ss) { ss.TAA = TAA; ArrayList bad_edges = new ArrayList(); foreach (Socket s in ss.AllSockets) { TcpEdge e = ss.GetEdge(s); if (e != null) { if (TAA.Authorize(e.RemoteTA) == TAAuthorizer.Decision.Deny) { //We can't close now, that would invalidate the AllSockets //iterator bad_edges.Add(e); } } } foreach (TcpEdge e in bad_edges) { EL.RequestClose(e); CloseAction ca = new CloseAction(e, null); ca.Start(ss); } }
/** * Called when the socket is writable */ public void HandleWritability(Socket s) { try { if (s.Connected) { TcpEdgeListener.SetSocketOpts(s); TcpEdge e = new TcpEdge(TEL, false, s); Result.Value = e; //Handle closes in the select thread: CloseAction ca = new CloseAction(e, TEL.ActionQueue); e.CloseEvent += ca.CloseHandler; //Set the edge TEL.ActionQueue.Enqueue(this); } else { //This did not work out, close the socket and release the resources: HandleError(s); } } catch (Exception) { //This did not work out, close the socket and release the resources: //Console.WriteLine("Exception: {0}", x); HandleError(s); } }
// ========================================= // ViewModel Commands Collection Handler. // ========================================= private void InvokeRequestClose(RequestCloseEventArgs e) { if ((bool)e.ViewModelOutputData) { DialogResult = true; } CloseAction?.Invoke(); }
public int hookClose(CloseAction act) { int Key = (closes.Keys.ToArray().Length > 0) ? closes.Keys.Last() : 0; Key++; closes.Add(Key, act); return(Key); }
/// <summary> /// Click event handler for the Save button. Validates the form, requests a save and closes the form. /// </summary> private void Save(object sender, RoutedEventArgs e) { if (!this.FormCount.GetBindingExpression(TextBox.TextProperty).HasValidationError) { this.ClosedWith = CloseAction.Save; this.Close(); } }
public async Task ValidateOAuthCode(string code) { IsLoading = true; await _traktService.AuthorizeAsync(code); IsLoading = false; CloseAction.Invoke(); }
private void ExecButtonTwo() { if (OnButtonTwoAction != null) { OnButtonTwoAction.Invoke(); } CloseAction.Invoke(); }
private void OnCancel() { model.ReloadSettings(); MainWindow win = (MainWindow)Application.Current.MainWindow; win.Show(); // triggers the Close Action of the settings window . CloseAction?.Invoke(); }
public void Close(CloseAction action) { if (!this.isOpened) { throw new InvalidOperationException("Can't close an unopened window."); } this.ClosePropertiesDialog(action); this.isOpened = false; }
private void Button_OnClicked(object sender, EventArgs e) { if (Result.SelectedItem == null) { return; } FinalResult = Result.SelectedItem.ToString(); CloseAction?.Invoke(); }
protected override Validation <string, TObj> CreateService(TDel node, ILoggerFactory loggerFactory) { var service = from playerControl in PlayerControl .ToValidation("Failed to find the player control.") select CreateService( CloseAction.TrimToOption(), playerControl, node, loggerFactory); return(service.Bind(identity)); }
/// <exception cref="Exception">A delegate callback throws an exception.</exception> public ManagePluginSourceViewModel(IManagePluginSourceModel updateManager, IEventAggregator aggregator, IAsyncWorker asyncWorker) : base("PluginSource") { VerifyArgument.IsNotNull("asyncWorker", asyncWorker); VerifyArgument.IsNotNull("updateManager", updateManager); VerifyArgument.IsNotNull("aggregator", aggregator); _updateManager = updateManager; DllChooser = new DLLChooser(updateManager); HeaderText = Resources.Languages.Core.PluginSourceNewHeaderLabel; Header = Resources.Languages.Core.PluginSourceNewHeaderLabel; OkCommand = new DelegateCommand(o => Save(), o => CanSave()); FileSystemAssemblyName = string.Empty; ConfigFilePath = string.Empty; GACAssemblyName = string.Empty; ChooseFileSystemDLLCommand = new DelegateCommand(o => { var dll = DllChooser.GetFileSystemDLL(); if (dll != null) { FileSystemAssemblyName = dll.FullName; } }); ChooseGACDLLCommand = new DelegateCommand(o => { var dll = DllChooser.GetGacDLL(); if (dll != null) { GACAssemblyName = dll.FullName; } }); ChooseConfigFileCommand = new DelegateCommand(o => { var fileChooser = CustomContainer.GetInstancePerRequestType <IFileChooserView>(); fileChooser.ShowView(false); var vm = fileChooser.DataContext as FileChooser; if (vm != null && vm.Result == MessageBoxResult.OK) { var selectedFiles = vm.GetAttachments(); if (selectedFiles != null && selectedFiles.Count > 0) { ConfigFilePath = selectedFiles[0]; } } }); CancelCommand = new DelegateCommand(o => CloseAction.Invoke()); _warewolfserverName = updateManager.ServerName; }
public override void PostClose() { if (ConfirmButtonLabel != null) { if (confirmed) { CloseAction?.Invoke(); } } else { CloseAction?.Invoke(); } }
public async Task Login() { _loginViewModel = new LoginViewModel(); LoginWindow loginWindow = new LoginWindow(_loginViewModel); _loginViewModel.CloseAction = () => { loginWindow.Close(); }; await loginWindow.ShowDialog(_parentWindow); if (!_loginViewModel.DialogResult) { CloseAction?.Invoke(); } }
private void ClosePropertiesDialog(CloseAction action) { switch (action) { case CloseAction.OK: okButton.Click(); break; case CloseAction.Cancel: cancelButton.Click(); break; } Globals.WaitForTimeout(); }
protected override void OnClosing(CancelEventArgs e) { if (!CloseAction.HasFlag(FormCloseAction.Close)) { e.Cancel = true; if (CloseAction.HasFlag(FormCloseAction.Hide)) { Hide(); } if (CloseAction.HasFlag(FormCloseAction.Minimize)) { WindowState = FormWindowState.Minimized; } } }
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { if (rbTerminate.IsChecked == true) { Result = CloseAction.Terminate; } else if (rbSystray.IsChecked == true) { Result = CloseAction.Systray; } else { Result = CloseAction.Consolidate; } }
private void RedirectToMainWindow(string token) { MainWindow mainWindow = new MainWindow(token); mainWindow.Show(); try { CloseAction.Invoke(); } catch (NullReferenceException) { log.Debug("When created LoginWindowVM CloseAction wasn't bound"); throw; } }
private async void Reject() { try { App app = App.GetApp(); var accessToken = app.AccessToken; await app.GetService <SummonRequestService>() .Reject(Request.Id, accessToken.Id); CloseAction?.Invoke(); } catch (Exception e) { log.Error("Failed to reject request", e); } }
public TraktDialogViewModel() { _traktService = new TraktService(); CloseCommand = new RelayCommand(() => { CloseAction.Invoke(); }); InitializeAsyncCommand = new RelayCommand(async() => { IsLoading = true; IsLoggedIn = await _traktService.IsLoggedIn(); IsLoading = false; TraktOAuthUrl = !IsLoggedIn ? _traktService.GetAuthorizationUrl() : string.Empty; }); }
public static string GetName(CloseAction type) { string result = String.Empty; switch (type) { case CloseAction.Hide: result = "hide"; break; case CloseAction.HideRefresh: result = "hide_refresh"; break; case CloseAction.HidePostBack: result = "hide_postback"; break; } return result; }
protected void HandleWrites(SocketState ss) { ArrayList socks = ss.WriteSocks; for(int i = 0; i < socks.Count; i++) { Socket s = (Socket)socks[i]; CreationState cs = ss.TakeCreationState( s ); if( cs != null ) { cs.HandleWritability(s); } else { //Let's try to flush the buffer: try { ss.FlushSocket(s); } catch { /* * We should close this edge */ TcpEdge tcpe = ss.GetEdge(s); TEL.RequestClose(tcpe); //Go ahead and forget about this socket. CloseAction ca = new CloseAction(tcpe, null); ca.Start(ss); } } } }
/* * Update the SocketState.TAA and check to see if any Edges need * to be closed. */ public override void Start(SocketState ss) { ss.TAA = TAA; ArrayList bad_edges = new ArrayList(); foreach(Socket s in ss.AllSockets) { TcpEdge e = ss.GetEdge(s); if( e != null ) { if( TAA.Authorize( e.RemoteTA ) == TAAuthorizer.Decision.Deny ) { //We can't close now, that would invalidate the AllSockets //iterator bad_edges.Add(e); } } } foreach(TcpEdge e in bad_edges) { EL.RequestClose(e); CloseAction ca = new CloseAction(e, null); ca.Start(ss); } }
/** * Called when the socket is writable */ public void HandleWritability(Socket s) { try { if( s.Connected ) { TcpEdgeListener.SetSocketOpts(s); TcpEdge e = new TcpEdge(TEL, false, s); Result.Value = e; //Handle closes in the select thread: CloseAction ca = new CloseAction(e, TEL.ActionQueue); e.CloseEvent += ca.CloseHandler; //Set the edge TEL.ActionQueue.Enqueue(this); } else { //This did not work out, close the socket and release the resources: HandleError(s); } } catch(Exception) { //This did not work out, close the socket and release the resources: //Console.WriteLine("Exception: {0}", x); HandleError(s); } }
protected void HandleReads(SocketState ss) { ArrayList readsocks = ss.ReadSocks; Socket listen_sock = ss.ListenSock; for(int i = 0; i < readsocks.Count; i++) { Socket s = (Socket)readsocks[i]; //See if this is a new socket if( s == listen_sock ) { TcpEdge e = null; Socket new_s = null; try { new_s = listen_sock.Accept(); IPEndPoint rep = (IPEndPoint)new_s.RemoteEndPoint; new_s.LingerState = new LingerOption (true, 0); TransportAddress rta = TransportAddressFactory.CreateInstance(TransportAddress.TAType.Tcp, rep); if( ss.TAA.Authorize(rta) == TAAuthorizer.Decision.Deny ) { //No thank you Dr. Evil Console.Error.WriteLine("Denying: {0}", rta); new_s.Close(); } else { //This edge looks clean TcpEdgeListener.SetSocketOpts(s); e = new TcpEdge(TEL, true, new_s); ss.AddEdge(e); //Handle closes in the select thread: CloseAction ca = new CloseAction(e, TEL.ActionQueue); e.CloseEvent += ca.CloseHandler; TEL.SendEdgeEvent(e); } } catch(Exception) { //Looks like this Accept has failed. Do nothing //Console.Error.WriteLine("New incoming edge ({0}) failed: {1}", new_s, sx); //Make sure the edge is closed if( e != null ) { TEL.RequestClose(e); //Go ahead and forget about this socket. CloseAction ca = new CloseAction(e, null); ca.Start(ss); } else if( new_s != null) { //This should not be able to throw an exception: new_s.Close(); } } } else { ReceiveState rs = ss.GetReceiveState(s); if( rs != null && !rs.Receive() ) { TEL.RequestClose(rs.Edge); //Go ahead and forget about this socket. CloseAction ca = new CloseAction(rs.Edge, null); ca.Start(ss); } } } }
public void CloseTab(int index, CloseAction action) { this.Call("closeTab", index, action.ToString().ToLowerInvariant()); }
public void CloseTab(AbstractContainer tab, CloseAction action) { this.Call("closeTab", JRawValue.From(tab.ClientID), action.ToString().ToLowerInvariant()); }
public void CloseTab(string id, CloseAction action) { this.Call("closeTab", JRawValue.From(id), action.ToString().ToLowerInvariant()); }