internal VMZoneSimple( VMContextSimple ctx, IZone zone ) : base(ctx) { _zone = zone; _keys = new CKObservableSortedArrayKeyList<VMKeySimple, int>( k => k.Index ); foreach( IKey key in _zone.Keys ) { VMKeySimple k = Context.Obtain( key ); Keys.Add( k ); } }
internal VMKeyboardSimple( VMContextSimple ctx, IKeyboard kb ) : base(ctx) { _zones = new ObservableCollection<VMZoneSimple>(); _keys = new ObservableCollection<VMKeySimple>(); _keyboard = kb; RegisterEvents(); foreach( IZone zone in _keyboard.Zones ) { Zones.Add( Context.Obtain( zone ) ); foreach( IKey key in zone.Keys ) { _keys.Add( Context.Obtain( key ) ); } } SafeUpdateW(); SafeUpdateH(); SafeUpdateInsideBorderColor(); UpdateBackgroundPath(); }
public void Stop() { if( _isStarted ) { UnInitializeHighlighter(); Context.ServiceContainer.Remove( typeof( IPluginConfigAccessor ) ); UnregisterEvents(); _forceClose = true; //Setting the config is done after closing the window because modifying a value in the Config ///Triggers a Caliburn Micro OnNotifyPropertyChanged, which calls an Invoke on the main UI Thread. //generating random locks. //Once the LayoutManager is ready, we won't need this anymore. WINDOWPLACEMENT placement = new WINDOWPLACEMENT(); _skinDispatcher.Invoke( (Action)( () => { placement = CKWindowTools.GetPlacement( _skinWindow.Hwnd ); _skinWindow.Close(); } ) ); Config.User.Set( PlacementString, placement ); if( _miniView != null ) { _skinDispatcher.BeginInvoke( (Action)( () => { _miniView.Close(); _miniView = null; } ), null ); _viewHidden = false; } if( _miniViewVm != null ) _miniViewVm.Dispose(); _ctxVm.Dispose(); _ctxVm = null; _isStarted = false; } }
public void Start() { if( HelpService.Status.IsStartingOrStarted ) HelpService.Service.RegisterHelpContent( PluginId, typeof( SimpleSkin ).Assembly.GetManifestResourceStream( "SimpleSkin.Res.helpcontent.zip" ) ); if( KeyboardContext.Status == InternalRunningStatus.Started && KeyboardContext.Service.Keyboards.Count > 0 ) { _noFocusWindowManager = new CKNoFocusWindowManager(); _skinDispatcher = _noFocusWindowManager.NoFocusWindowThreadDispatcher; _ctxVm = new VMContextSimple( Context, KeyboardContext.Service.Keyboards.Context, Config, _skinDispatcher ); _isStarted = true; _skinWindow = _noFocusWindowManager.CreateNoFocusWindow<SkinWindow>( (Func<SkinWindow>)( () => { return new SkinWindow() { DataContext = _ctxVm }; } ) ); WINDOWPLACEMENT defaultPlacement = new WINDOWPLACEMENT(); _skinDispatcher.Invoke( (System.Action)( () => { InitializeWindowLayout(); _skinWindow.Show(); defaultPlacement = CKWindowTools.GetPlacement( _skinWindow.Hwnd ); } ), null ); //Sets on the Config must always be done on the main UI thread WINDOWPLACEMENT actualPlacement = (WINDOWPLACEMENT)Config.User.GetOrSet<WINDOWPLACEMENT>( PlacementString, defaultPlacement ); //Placing the skin at the same location as the last launch. _skinDispatcher.Invoke( (System.Action)( () => { CKWindowTools.SetPlacement( _skinWindow.Hwnd, actualPlacement ); } ), null ); SendStringService.Service.SendKeyboardKey( NativeMethods.KeyboardKeys.S ); InitializeHighligther(); UpdateAutoHideConfig(); RegisterEvents(); } else { _isStarted = false; Application.Current.Dispatcher.BeginInvoke( (Action)( () => { Notification.ShowNotification( PluginId.UniqueId, "Aucun clavier n'est disponible", "Aucun clavier n'est disponible dans le contexte actuel, veuillez choisir un contexte contenant au moins un clavier.", 1000, NotificationTypes.Error ); } ), null ); } }
internal VMKeySimple( VMContextSimple ctx, IKey k ) : base(ctx) { _actionsOnPropertiesChanged = new Dictionary<string, ActionSequence>(); _key = k; ResetCommands(); RegisterEvents(); SafeUpdateBackground(); SafeUpdateDescription(); SafeUpdateDownLabel(); SafeUpdateFontSize(); SafeUpdateFontStyle(); SafeUpdateFontWeight(); SafeUpdateHeight(); SafeUpdateHighlightBackground(); SafeUpdateHoverBackground(); SafeUpdateImage(); SafeUpdateIndex(); SafeUpdateIsEnabled(); SafeUpdateIsFallback(); SafeUpdateLetterColor(); SafeUpdateOpacity(); SafeUpdatePressedBackground(); SafeUpdateShowImage(); SafeUpdateShowLabel(); SafeUpdateUpLabel(); SafeUpdateVisible(); SafeUpdateWidth(); SafeUpdateX(); SafeUpdateY(); }