示例#1
0
        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 );
            }
        }