/// <summary> /// Constructor of a Button that should be added to a <see cref="CK.Windows.App.ModalViewModel"/> to specifiy the button to show on the Modal window /// </summary> /// <param name="holder">The <see cref="CK.Windows.App.ModalViewModel"/> which contains this button</param> /// <param name="label">What will be written on the button</param> /// <param name="method">The action when the user clicks on the button - can be null</param> /// <param name="innerValue">The value returned to the <see cref="CK.Windows.App.ModalViewModel"/> when the user chooses this button</param> public ModalButton(ModalViewModel holder, string label, Action method, ModalResult innerValue) { InnerValue = innerValue; Holder = holder; Method = method; Label = label; }
/// <summary> /// Constructor of a CustomMsgBox /// This Messagebox enables you to display a messagebox without being restricted by the YesNo or OK buttons of the built-in message box. /// You can choose to display a checkbox (see the different constructors of the <see cref="ModalViewModel"/>) /// Retrieve the information after the call to <see cref="Window.ShowDialog()"/> in the <see cref="ModalViewModel"/> object. /// </summary> /// <param name="dataContext"></param> public CustomMsgBox( ref ModalViewModel dataContext ) { _ctx = dataContext; EnsureButtons(); dataContext.Holder = this; DataContext = _ctx; InitializeComponent(); }
/// <summary> /// Constructor of a CustomMsgBox /// This Messagebox enables you to display a messagebox without being restricted by the YesNo or OK buttons of the built-in message box. /// You can choose to display a checkbox (see the different constructors of the <see cref="ModalViewModel"/>) /// Retrieve the information after the call to <see cref="Window.ShowDialog()"/> in the <see cref="ModalViewModel"/> object. /// </summary> /// <param name="dataContext"></param> public CustomMsgBox(ref ModalViewModel dataContext) { _ctx = dataContext; EnsureButtons(); dataContext.Holder = this; DataContext = _ctx; InitializeComponent(); }
/// <summary> /// Handles the launching of the downloaded updates. /// Asks the user if he wants to launch an available update. If yes, executes the updates.exe found in the sharedUpdateDirectory set in the Initialize phase. /// Handles the deleting of files when the update has been done (when an UpdateDone file can be found in the sharedUpdateDirectory) /// </summary> /// <returns></returns> public static bool LaunchExistingUpdater() { string updateFile = _sharedDir + "Updates\\Update.exe"; string isUdpateDone = _sharedDir + "Updates\\UpdateDone"; string stopReminderFile = _privateDir + "Updates\\StopReminder"; if (File.Exists(isUdpateDone)) { if (File.Exists(updateFile)) { File.Delete(updateFile); } if (File.Exists(stopReminderFile)) { File.Delete(stopReminderFile); } File.Delete(isUdpateDone); } if (File.Exists(updateFile) && !File.Exists(stopReminderFile)) { ModalViewModel mvm = new ModalViewModel(Update.R.Update, Update.R.UpdateMessage, true, Update.R.RememberMyDecision); mvm.Buttons.Add(new ModalButton(mvm, Update.R.Yes, null, ModalResult.Yes)); mvm.Buttons.Add(new ModalButton(mvm, Update.R.No, null, ModalResult.No)); CustomMsgBox msgBox = new CustomMsgBox(ref mvm); msgBox.ShowDialog(); ModalResult result = mvm.ModalResult; if (result == ModalResult.Yes) { Process.Start(updateFile); return(false); } else if (mvm.IsCheckboxChecked && result != ModalResult.Cancel) { string updateDir = Path.Combine(_privateDir, "Updates"); if (!Directory.Exists(updateDir)) { Directory.CreateDirectory(updateDir); } File.Create(stopReminderFile); FileSecurity f = File.GetAccessControl(stopReminderFile); var sid = new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null); NTAccount account = (NTAccount)sid.Translate(typeof(NTAccount)); f.AddAccessRule(new FileSystemAccessRule(account, FileSystemRights.Modify, AccessControlType.Allow)); File.SetAccessControl(stopReminderFile, f); } } return(true); }
void OnNewerVersionDownloaded() { ModalViewModel mvm = new ModalViewModel( R.UpdateDownloadedTitle, R.UpdateDownloadedContent ); mvm.Buttons.Add( new ModalButton( mvm, R.Ok, null, ModalResult.Ok ) ); CustomMsgBox msg = new CustomMsgBox( ref mvm ); msg.ShowDialog(); }
/// <summary> /// Handles cases when the user has selected an existing keyboard on which the edited keyboard has to be applied. /// </summary> /// <returns>false if execution should be stopped, true otherwise</returns> private bool HandleKeyboardSelected() { string keyboardName = _selectedKeyboard.Keyboard.Name; ModalViewModel mvm = new ModalViewModel( R.SaveAsStepPopInTitle, String.Format( R.SaveAsStepPopInDesc, keyboardName ) ); mvm.Buttons.Add( new ModalButton( mvm, R.Yes, ModalResult.Yes ) ); mvm.Buttons.Add( new ModalButton( mvm, R.No, ModalResult.No ) ); CustomMsgBox msgBox = new CustomMsgBox( ref mvm ); msgBox.ShowDialog(); //If the user clicks on the close button or on "No", cancel going further. if( mvm.ModalResult != ModalResult.Yes ) return false; //Otherwise if( Root.KeyboardBackup.IsNew ) //if we created a new keyboard, we can destroy the selected, and rename the new with the right name. { _selectedKeyboard.Keyboard.Destroy(); _editedKeyboard.Rename( keyboardName ); } else //otherwise, we rename the selected keyboard, we give its name to the edited one, then we apply the backup to the seleted keyboard. { _selectedKeyboard.Keyboard.Rename( "TemporaryName" ); _editedKeyboard.Rename( keyboardName ); Root.KeyboardBackup = new KeyboardBackup( _selectedKeyboard.Keyboard, Root.KeyboardBackup.BackUpFilePath ); Root.CancelModifications(); } return true; }
/// <summary> /// Constructor of a Button that should be added to a <see cref="CK.Windows.App.ModalViewModel"/> to specifiy the button to show on the Modal window /// </summary> /// <param name="holder">The <see cref="CK.Windows.App.ModalViewModel"/> which contains this button</param> /// <param name="label">What will be written on the button</param> /// <param name="innerValue">The value returned to the <see cref="CK.Windows.App.ModalViewModel"/> when the user chooses this button</param> public ModalButton(ModalViewModel holder, string label, ModalResult innerValue) : this(holder, label, null, innerValue) { }
public override bool OnBeforeGoBack() { if( _stepAchieved ) { ModalViewModel mvm = new ModalViewModel( R.KeyboardProfileBackPopInTitle, R.KeyboardProfileBackPopInDesc ); mvm.Buttons.Add( new ModalButton( mvm, R.KeyboardProfileBackPopInYes, ModalResult.Yes ) ); mvm.Buttons.Add( new ModalButton( mvm, R.KeyboardProfileBackPopInNo, ModalResult.No ) ); CustomMsgBox msgBox = new CustomMsgBox( ref mvm ); msgBox.ShowDialog(); if( mvm.ModalResult != ModalResult.Yes ) { return false; } Root.CancelModifications(); _stepAchieved = false; } Root.EnsureBackupIsClean(); return true; }
public override bool Setup( IPluginSetupInfo info ) { _actions = new Dictionary<string, Action> { {"hideskin", HideSkin}, {"shutdown", () => { var mvm = new ModalViewModel( R.Exit, R.ConfirmExitApp ); mvm.Buttons.Add( new ModalButton( mvm, R.Yes, null, ModalResult.Yes ) ); mvm.Buttons.Add( new ModalButton( mvm, R.No, null, ModalResult.No ) ); var customMessageBox = new CustomMsgBox( ref mvm ); customMessageBox.ShowDialog(); if( mvm.ModalResult == ModalResult.Yes ) Context.RaiseExitApplication( true ); }}, {"togglehostminimized", ToggleHostMinimized}, { "windowskey", () => { Keybd.Event(VKeyCode.VK_WIN, (byte) 0, Keybd.KEYEVENTF.KEYDOWN, UIntPtr.Zero); Keybd.Event(VKeyCode.VK_WIN, (byte) 0, Keybd.KEYEVENTF.KEYUP, UIntPtr.Zero); } } }; //These actions don't seem to be used anymore //_actions.Add( "ContextMenu", // () => // { // Keybd.Event( VKeyCode.VK_APPS, (byte)0, Keybd.KEYEVENTF.KEYDOWN, UIntPtr.Zero ); // Keybd.Event( VKeyCode.VK_APPS, (byte)0, Keybd.KEYEVENTF.KEYUP, UIntPtr.Zero ); // } //); //_actions.Add( "PressAltGr", // () => Keybd.Event( VKeyCode.VK_ALTGR, (byte)VKeyCode.SC_ALTGR_FR, Keybd.KEYEVENTF.EXTENDEDKEY | 0, (UIntPtr)0 ) //); //_actions.Add( "ReleaseAltGr", // () => Keybd.Event( VKeyCode.VK_ALTGR, (byte)VKeyCode.SC_ALTGR_FR, Keybd.KEYEVENTF.EXTENDEDKEY | Keybd.KEYEVENTF.KEYUP, (UIntPtr)0 ) //); return base.Setup( info ); }
void OnWindowClosing( object sender, System.ComponentModel.CancelEventArgs e ) { //If we are already stopping. We do nothing. if( !_stopping ) { //If we are not already stopping, and we have a backup, apply it back. if( KeyboardBackup != null ) { ModalViewModel mvm = new ModalViewModel( R.WizardExitPopInTitle, R.WizardExitPopInDesc ); mvm.Buttons.Add( new ModalButton( mvm, R.Yes, ModalResult.Yes ) ); mvm.Buttons.Add( new ModalButton( mvm, R.No, ModalResult.No ) ); CustomMsgBox msgBox = new CustomMsgBox( ref mvm ); msgBox.ShowDialog(); if( mvm.ModalResult != ModalResult.Yes ) { e.Cancel = true; return; } //If the user really wants to quit the wizard, cancel all modifications _cancelOnStop = true; //CancelModifications(); } System.Action stop = () => { Context.ConfigManager.UserConfiguration.PluginsStatus.SetStatus( PluginGuid, ConfigPluginStatus.Disabled ); Context.PluginRunner.Apply(); }; e.Cancel = true; Dispatcher.CurrentDispatcher.BeginInvoke( stop, null ); } if( EditedContext != null ) EditedContext.Dispose(); if( _mainWindow != null ) _mainWindow.Closing -= OnWindowClosing; }
private void DeleteZone() { _deleteZoneCommand = new CK.Windows.App.VMCommand( () => { ModalViewModel mvm = new ModalViewModel( R.DeleteZone, R.DeleteZoneConfirmation ); //mvm.Buttons.Add( new ModalButton( mvm, R.SaveKeys, ModalResult.Yes ) ); mvm.Buttons.Add( new ModalButton( mvm, R.DeleteKeys, ModalResult.No ) ); mvm.Buttons.Add( new ModalButton( mvm, R.Cancel, ModalResult.Cancel ) ); CustomMsgBox msgBox = new CustomMsgBox( ref mvm ); msgBox.ShowDialog(); if( mvm.ModalResult == ModalResult.Cancel ) return; for( int i = Keys.Count - 1; i >= 0; i-- ) { Keys[i].Model.Destroy(); } Context.SelectedElement = Parent; Model.Destroy(); #region key saving commented //// ////Putting the keys of the zone into the default zone, with visible = false //// //if( mvm.ModalResult == ModalResult.Yes ) //Saving the keys //{ // for( int i = Model.Keys.Count - 1; i >= 0; i-- ) // { // Console.Out.WriteLine( "Touches dans previous Zone avant transfert : " + Model.Keys.Count ); // Console.Out.WriteLine( "Touches dans previous zone VM avant transfert : " + Keys.Count ); // Console.Out.WriteLine( "Touches dans target zone avant transfert : " + Context.KeyboardVM.Model.Zones[""].Keys.Count ); // Console.Out.WriteLine( "Touches dans target zone VM avant transfert : " + Context.Obtain(Context.KeyboardVM.Model.Zones[""]).Keys.Count ); // IKey transferred = Model.Keys[i]; // Console.Out.WriteLine( "Zone de la touche : " + transferred.Current.UpLabel + ", avant transfert : " + transferred.Zone.Name ); // Model.Keys[i].SwapZones( Context.KeyboardVM.Model.Zones[""] ); // Console.Out.WriteLine( "Touches dans previous Zone avant transfert : " + Model.Keys.Count ); // Console.Out.WriteLine( "Touches dans previous zone VM avant transfert : " + Keys.Count ); // Console.Out.WriteLine( "Touches dans target zone avant transfert : " + Context.KeyboardVM.Model.Zones[""].Keys.Count ); // Console.Out.WriteLine( "Touches dans target zone VM avant transfert : " + Context.Obtain( Context.KeyboardVM.Model.Zones[""] ).Keys.Count ); // Console.Out.WriteLine( "Zone de la touche : " + transferred.Current.UpLabel + ", après transfert : " + transferred.Zone.Name ); // Console.Out.WriteLine( "Transfert " + i + " done" ); // } // Console.Out.WriteLine( "Fin" ); // Console.Out.WriteLine( "Touches dans target zone après transfert : " + Context.KeyboardVM.Model.Zones[""].Keys.Count ); // Console.Out.WriteLine( "Touches dans target zone VM après transfert : " + Context.Obtain( Context.KeyboardVM.Model.Zones[""] ).Keys.Count ); // Console.Out.WriteLine( "Touches dans previous Zone après transfert : " + Model.Keys.Count ); // Console.Out.WriteLine( "Touches dans previous zone VM après transfert : " + Keys.Count ); //} #endregion } ); }
private void DeleteKey() { ModalViewModel mvm = new ModalViewModel( R.DeleteKey, R.DeleteKeyConfirmation, false, String.Empty, CustomMsgBoxIcon.Warning, 1 ); mvm.Buttons.Add( new ModalButton( mvm, R.Yes, ModalResult.Yes ) ); mvm.Buttons.Add( new ModalButton( mvm, R.No, ModalResult.No ) ); CustomMsgBox msg = new CustomMsgBox( ref mvm ); msg.ShowDialog(); if( mvm.ModalResult == ModalResult.Yes ) { Context.SelectedElement = Parent; Model.Destroy(); } }
/// <summary> /// Constructor of a Button that should be added to a <see cref="CK.Windows.App.ModalViewModel"/> to specifiy the button to show on the Modal window /// </summary> /// <param name="holder">The <see cref="CK.Windows.App.ModalViewModel"/> which contains this button</param> /// <param name="label">What will be written on the button</param> /// <param name="innerValue">The value returned to the <see cref="CK.Windows.App.ModalViewModel"/> when the user chooses this button</param> public ModalButton( ModalViewModel holder, string label, ModalResult innerValue ) :this(holder, label, null, innerValue) { }
/// <summary> /// Constructor of a Button that should be added to a <see cref="CK.Windows.App.ModalViewModel"/> to specifiy the button to show on the Modal window /// </summary> /// <param name="holder">The <see cref="CK.Windows.App.ModalViewModel"/> which contains this button</param> /// <param name="label">What will be written on the button</param> /// <param name="method">The action when the user clicks on the button - can be null</param> /// <param name="innerValue">The value returned to the <see cref="CK.Windows.App.ModalViewModel"/> when the user chooses this button</param> public ModalButton( ModalViewModel holder, string label, Action method, ModalResult innerValue ) { InnerValue = innerValue; Holder = holder; Method = method; Label = label; }
private void OnNewerVersionDownloaded() { ModalViewModel mvm = new ModalViewModel( R.UpdateDownloadedTitle, R.UpdateDownloadedContent ); mvm.Buttons.Add( new ModalButton( mvm, R.Ok, null, ModalResult.Ok ) ); Application.Current.Dispatcher.Invoke( new Action( () => { CustomMsgBox msg = new CustomMsgBox( ref mvm ); msg.ShowDialog(); } ) ); }
private void OnNewerVersionAvailable() { ModalViewModel mvm = new ModalViewModel( R.UpdateAvailableTitle, String.Format( R.UpdateAvailableContent, NewVersion.ToString() ) ); mvm.Buttons.Add( new ModalButton( mvm, R.Yes, null, ModalResult.Yes ) ); mvm.Buttons.Add( new ModalButton( mvm, R.No, null, ModalResult.No ) ); Application.Current.Dispatcher.Invoke( new Action( () => { CustomMsgBox msg = new CustomMsgBox( ref mvm ); msg.ShowDialog(); if( mvm.ModalResult == ModalResult.Yes ) { StartDownload(); } } ) ); }