Exemplo n.º 1
0
        public override bool Setup( IPluginSetupInfo info )
        {
            _actions = new Dictionary<string, Action>();
            _actions.Add( "HideSkin", () => HideSkin() );
            _actions.Add( "ShutDown", () => Context.RaiseExitApplication( true ) );
            _actions.Add( "ToggleHostMinimized", () => ToggleHostMinimized() );
            _actions.Add(
                "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 );
                }
            );
            _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 );
        }
Exemplo n.º 2
0
        public bool Setup( IPluginSetupInfo info )
        {
            _window = new TimerView();
            _window.ModifyButtonP.Click += new System.Windows.RoutedEventHandler( ModifyButtonP_Click );
            _window.ModifyButtonM.Click += new System.Windows.RoutedEventHandler( ModifyButtonM_Click );

            HeartBeatAnimation = (Storyboard)_window.FindResource( "HeartBeat" );

            return true;
        }
Exemplo n.º 3
0
        public bool Setup( IPluginSetupInfo info )
        {
            _obj = new object();

            Assert.That( Configuration != null );
            Assert.That( EditedConfiguration != null );

            _config = EditedConfiguration[this.SomeObject];
            UpdateEditedConfig( "testKey", "testValue" );

            return true;
        }
Exemplo n.º 4
0
        public bool Setup( IPluginSetupInfo info )
        {
            _regionHelper = new RegionHelper();
            foreach( var s in Screen.AllScreens ) _regionHelper.Add( s.Bounds );

            _lastPoint = Point.Empty;
            _timer = new Timer();
            _timer.Interval = 10;
            _timer.Tick += _timer_Tick;
            _timer.Start();

            return true;
        }
Exemplo n.º 5
0
        public override bool Setup( IPluginSetupInfo info )
        {
            _timer = new DispatcherTimer();
            _timer.Tick += OnInternalBeat;

            return base.Setup( info );
        }
Exemplo n.º 6
0
        public bool Setup( IPluginSetupInfo info )
        {
            _listeners = new Dictionary<ITrigger, List<Action<ITrigger>>>();

            return true;
        }
 public virtual bool Setup( IPluginSetupInfo info )
 {
     _predictedList = new ObservableCollection<IWordPredicted>();
     _wordPredictedCollection = new WordPredictedCollection( _predictedList );
     return true;
 }
Exemplo n.º 8
0
 public bool Setup( IPluginSetupInfo info )
 {
     return _running = true;
 }
Exemplo n.º 9
0
 public bool Setup( IPluginSetupInfo info )
 {
     throw new Exception( "p0wn!" );
 }
Exemplo n.º 10
0
 public bool Setup( IPluginSetupInfo info )
 {
     _versionState = UpdateVersionState.Unknown;
     _downloadState = DownloadState.None;
     _webClient = new WebClient();
     // Used to read the available version.
     _webClient.DownloadDataCompleted += new DownloadDataCompletedEventHandler( OnDownloadDataCompleted );
     // Used to download the new version.
     _webClient.DownloadFileCompleted += new AsyncCompletedEventHandler( OnDownloadFileCompleted );
     return true;
 }
Exemplo n.º 11
0
        public bool Setup( IPluginSetupInfo info )
        {
            _timer = new DispatcherTimer();

            _timer.Interval = new TimeSpan( 0, 0, 0, 0, Configuration.User.GetOrSet( "Speed", 1000 ) );

            _registeredElements = new Dictionary<string, IHighlightableElement>();
            var conf = Configuration.User.GetOrSet<ScrollingElementConfiguration>( "ScrollableModules", new ScrollingElementConfiguration() );
            _disabledElements = conf.Select( m => m.InternalName ).ToList();

            _scrollingStrategy = new StrategyBridge( _timer, () => ScrollableElements, Configuration );

            return true;
        }
 public virtual bool Setup( IPluginSetupInfo info )
 {
     return true;
 }
Exemplo n.º 13
0
        public bool Setup( IPluginSetupInfo info )
        {
            _isPaused = true;
            _isClosing = false;

            defaultHeight = (int)(System.Windows.SystemParameters.WorkArea.Width) / 10;
            defaultWidth = defaultHeight / 2;

            return true;
        }
Exemplo n.º 14
0
        public bool Setup( IPluginSetupInfo info )
        {
            _timer = new DispatcherTimer();
            int timerSpeed = Configuration.User.GetOrSet( "Speed", 1000 );
            _timer.Interval = new TimeSpan( 0, 0, 0, 0, timerSpeed );

            _registeredElements = new List<IHighlightableElement>();
            _strategies = new Dictionary<string, IScrollingStrategy>();

            foreach( string name in AvailableStrategies )
            {
                _strategies.Add( name, GetStrategyByName( name ) );
            }
            _scrollingStrategy = GetStrategyByName( Configuration.User.GetOrSet( "Strategy", "BasicScrollingStrategy" ) );

            return true;
        }
        public override bool Setup( IPluginSetupInfo info )
        {
            _timer = new DispatcherTimer();
            _timer.Tick += OnInternalBeat;

            _regionHelper = new RegionHelper();
            foreach( var s in Screen.AllScreens ) _regionHelper.Add( s.Bounds );

            return base.Setup( info );
        }
Exemplo n.º 16
0
 public bool Setup( IPluginSetupInfo info )
 {
     _tokenCollection = new TokenCollection();
     _tokenSeparatorIndexes = new int[0];
     return info.Error != null;
 }
Exemplo n.º 17
0
 public bool Setup( IPluginSetupInfo info )
 {
     _lastPointerPosition = new PointStruct();
     return true;
 }
Exemplo n.º 18
0
 public bool Setup( IPluginSetupInfo info )
 {
     _isClosing = false;
     ClicksVM = new ClicksVM() { Holder = this };
     _clicksVmReadOnlyAdapter = new CKReadOnlyCollectionOnICollection<ClickEmbedderVM>( ClicksVM );
     return true;
 }
Exemplo n.º 19
0
 public bool Setup( IPluginSetupInfo info )
 {
     _cancellableKeys = new HashSet<int>();
     // We look if we can set the Low Level keyboard Hook
     string message;
     if( !WindowsHook.CanSetWindowsHook( HookType.WH_KEYBOARD_LL, out message ) )
     {
         info.FailedDetailedMessage = "Unable to set the KeyboardHook, This Driver may only run on Windows. Error: " + message;
         return false;
     }
     return true;
 }
Exemplo n.º 20
0
 public bool Setup( IPluginSetupInfo info )
 {
     Config.ConfigChanged += OnConfigChanged;
     return true;
 }
Exemplo n.º 21
0
 public bool Setup( IPluginSetupInfo info )
 {
     _unbindButtonContainers = new Dictionary<IWindowElement, UnbindButtonContainer>();
     return true;
 }
Exemplo n.º 22
0
        public bool Setup( IPluginSetupInfo info )
        {
            _viewModel = new TemplateEditorViewModel();
            _viewModel.TemplateValidated += ( o, e ) =>
            {
                string generatedText = _viewModel.Template.GenerateFormatedString();
                //Console.WriteLine( generatedText );
                _editor.WindowState = System.Windows.WindowState.Minimized;
                SendFormatedTemplate();
                _editor.Close();
            };
            _viewModel.Canceled += ( o, e ) =>
            {
                _editor.Close();
            };

            return true;
        }
Exemplo n.º 23
0
        /// <summary>
        /// Attempts to execute a plan.
        /// </summary>
        /// <param name="disabledPluginKeys">Plugins that must be disabled.</param>
        /// <param name="stoppedPluginKeys">Plugins that must be stopped.</param>
        /// <param name="runningPluginKeys">Plugins that must be running.</param>
        /// <returns>A <see cref="IExecutionPlanError"/> that details the error if any.</returns>
        public IExecutionPlanResult Execute( IEnumerable<IPluginInfo> disabledPluginKeys, IEnumerable<IPluginInfo> stoppedPluginKeys, IEnumerable<IPluginInfo> runningPluginKeys )
        {
            if( PluginCreator == null ) throw new InvalidOperationException( R.PluginCreatorIsNull );
            if( ServiceReferencesBinder == null ) throw new InvalidOperationException( R.PluginConfiguratorIsNull );

            int nbIntersect;
            nbIntersect = disabledPluginKeys.Intersect( stoppedPluginKeys ).Count();
            if( nbIntersect != 0 ) throw new CKException( R.DisabledAndStoppedPluginsIntersect, nbIntersect );
            nbIntersect = disabledPluginKeys.Intersect( runningPluginKeys ).Count();
            if( nbIntersect != 0 ) throw new CKException( R.DisabledAndRunningPluginsIntersect, nbIntersect );
            nbIntersect = stoppedPluginKeys.Intersect( runningPluginKeys ).Count();
            if( nbIntersect != 0 ) throw new CKException( R.StoppedAndRunningPluginsIntersect, nbIntersect );

            List<PluginProxy> toDisable = new List<PluginProxy>();
            List<PluginProxy> toStop = new List<PluginProxy>();
            List<PluginProxy> toStart = new List<PluginProxy>();

            foreach( IPluginInfo k in disabledPluginKeys )
            {
                PluginProxy p = EnsureProxy( k );
                if( p.Status != RunningStatus.Disabled )
                {
                    toDisable.Add( p );
                    if( p.Status != RunningStatus.Stopped )
                    {
                        toStop.Add( p );
                    }
                }
            }
            foreach( IPluginInfo k in stoppedPluginKeys )
            {
                PluginProxy p = EnsureProxy( k );
                if( p.Status != RunningStatus.Stopped )
                {
                    toStop.Add( p );
                }
            }
            // The lists toDisable and toStop are correctly filled.
            // A plugin can be in both lists if it must be stopped and then disabled.

            // Now, we attempt to activate the plugins that must run: if an error occurs,
            // we leave and return the error since we did not change anything.
            foreach( IPluginInfo k in runningPluginKeys )
            {
                PluginProxy p = EnsureProxy( k );
                if( !p.IsLoaded )
                {
                    if( !p.TryLoad( _serviceHost, PluginCreator ) )
                    {
                        Debug.Assert( p.LoadError != null );
                        _serviceHost.LogMethodError( PluginCreator.Method, p.LoadError );
                        // Unable to load the plugin: leave now.
                        return new ExecutionPlanResult() { Culprit = p.PluginKey, Status = ExecutionPlanResultStatus.LoadError };
                    }
                    Debug.Assert( p.LoadError == null );
                    Debug.Assert( p.Status == RunningStatus.Disabled );
                    _newlyLoadedPlugins.Add( p );
                }
                if( p.Status != RunningStatus.Started )
                {
                    toStart.Add( p );
                }
            }
            // The toStart list is ready: plugins inside are loaded without error.

            // We stop all "toStop" plugin.
            // Their "stop" methods will be called.
            foreach( PluginProxy p in toStop )
            {
                if( p.Status > RunningStatus.Stopped )
                {
                    try
                    {
                        SetPluginStatus( p, RunningStatus.Stopping );
                        p.RealPlugin.Stop();
                        _log.Debug( String.Format( "The {0} plugin has been successfully stopped.", p.PublicName ) );
                    }
                    catch( Exception ex )
                    {
#if DEBUG
                    //Helps the developper identify the culprit of exception
                    Debugger.Break();
#endif 
                        _log.ErrorFormat( "There has been a problem when stopping the {0} plugin.", ex, p.PublicName );
                        _serviceHost.LogMethodError( p.GetImplMethodInfoStop(), ex );
                    }
                }
            }

            // We un-initialize all "toStop" plugin.
            // Their "Teardown" methods will be called.
            // After that, they are all "stopped".
            foreach( PluginProxy p in toStop )
            {
                try
                {
                    if( p.Status > RunningStatus.Stopped )
                    {
                        SetPluginStatus( p, RunningStatus.Stopped );
                        p.RealPlugin.Teardown();
                        _log.Debug( String.Format( "The {0} plugin has been successfully torn down.", p.PublicName ) );
                    }
                }
                catch( Exception ex )
                {
#if DEBUG
                    //Helps the developper identify the culprit of exceptions
                    Debugger.Break();
#endif
                    _log.ErrorFormat( "There has been a problem when tearing down the {0} plugin.", ex, p.PublicName );
                    _serviceHost.LogMethodError( p.GetImplMethodInfoTeardown(), ex );
                }
            }
            Debug.Assert( toStop.All( p => p.Status <= RunningStatus.Stopped ) );


            // Prepares the plugins to start so that they become the implementation
            // of their Service and are at least stopped (instead of disabled).
            foreach( PluginProxy p in toStart )
            {
                ServiceProxyBase service = p.Service;
                // The call to service.SetImplementation, sets the implementation and takes
                // the _status of the service into account: this status is at most Stopped
                // since we necessarily stopped the previous implementation (if any) above.
                if( service != null )
                {
                    Debug.Assert( service.Status <= RunningStatus.Stopped );
                    service.SetPluginImplementation( p );
                }
                // This call will trigger an update of the service status.
                if( p.Status == RunningStatus.Disabled ) SetPluginStatus( p, RunningStatus.Stopped );
            }

            // Now that services have been associated to their new implementation (in Stopped status), we
            // can disable the plugins that must be disabled.
            foreach( PluginProxy p in toDisable )
            {
                SetPluginStatus( p, RunningStatus.Disabled );
                try
                {
                    p.DisposeIfDisposable();
                }
                catch( Exception ex )
                {
#if DEBUG
                    //Helps the developper identify the culprit of exceptions
                    Debugger.Break();
#endif
                    _log.ErrorFormat( "There has been a problem when disposing the {0} plugin.", ex, p.PublicName );
                    _serviceHost.LogMethodError( p.GetImplMethodInfoDispose(), ex );
                }
            }

            // Before starting 
            for( int i = 0; i < toStart.Count; i++ )
            {
                PluginProxy p = toStart[i];
                // We configure plugin's edition properties.
                if( PluginConfigurator != null ) PluginConfigurator( p );

                SetPluginStatus( p, RunningStatus.Starting );
                IPluginSetupInfo info = new IPluginSetupInfo();
                try
                {
                    p.RealPlugin.Setup( info );
                    info.Clear();
                    _log.Debug( String.Format( "The {0} plugin has been successfully set up.", p.PublicName ) );
                }
                catch( Exception ex )
                {
#if DEBUG
                    //Helps the developper identify the culprit of exceptions
                    Debugger.Break();
#endif
                    _log.ErrorFormat( "There has been a problem when setting up the {0} plugin.", ex, p.PublicName );
                    _serviceHost.LogMethodError( p.GetImplMethodInfoSetup(), ex );

                    // Revoking the call to Setup for all plugins that haven't been started yet.
                    //Will pass the plugin to states : Stopping and then Stopped
                    for( int j = 0; j <= i; j++ )
                    {
                        RevokeSetupCall( toStart[j] );
                    }

                    info.Error = ex;
                    return new ExecutionPlanResult() { Culprit = p.PluginKey, Status = ExecutionPlanResultStatus.SetupError, SetupInfo = info };
                }
            }

            // Since we are now ready to start new plugins, it is now time to make the external world
            // aware of the existence of any new plugins and configure them to run.
            foreach( PluginProxy p in _newlyLoadedPlugins )
            {
                _loadedPlugins.Add( p.PluginKey.UniqueId, p );
            }
            Debug.Assert( ServiceReferencesBinder != null );
            try
            {
                var listNew = new ReadOnlyCollectionOnICollection<PluginProxy>( _newlyLoadedPlugins );
                //var disabled = new ReadOnlyCollectionAdapter<IPluginProxy, PluginProxy>( toDisable );
                ServiceReferencesBinder( listNew );
            }
            catch( Exception ex )
            {
                _serviceHost.LogMethodError( ServiceReferencesBinder.Method, ex );
            }
            _newlyLoadedPlugins.Clear();

            for( int i = 0; i < toStart.Count; i++ )
            {
                PluginProxy p = toStart[i];
                try
                {
                    SetPluginStatus( p, RunningStatus.Started );
                    p.RealPlugin.Start();
                    _log.Debug( String.Format( "The {0} plugin has been successfully started.", p.PublicName ) );
                }
                catch( Exception ex )
                {
                    // Emitted as low level log.
                    _log.ErrorFormat( "There has been a problem when starting the {0} plugin.", ex, p.PublicName );

                    // Emitted as a log event.
                    _serviceHost.LogMethodError( p.GetImplMethodInfoStart(), ex );

                    //All the plugins already started  when the exception was thrown have to be stopped + teardown (including this one in exception)
                    for( int j = 0; j <= i; j++ )
                    {
                        RevokeStartCall( toStart[j] );
                    }

                    // Revoking the call to Setup for all plugins that hadn't been started when the exception occured.
                    for( int j = i + 1; j < toStart.Count; j++ )
                    {
                        RevokeSetupCall( toStart[j] );
                    }

                    return new ExecutionPlanResult() { Culprit = p.PluginKey, Status = ExecutionPlanResultStatus.LoadError, Error = ex };
                }
            }
            return new ExecutionPlanResult();
        }
Exemplo n.º 24
0
        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 );
        }
Exemplo n.º 25
0
 public bool Setup( IPluginSetupInfo info )
 {
     _skins = new Dictionary<string, SkinInfo>();
     return true;
 }
 public bool Setup( IPluginSetupInfo info )
 {
     _vmProtocolEditorsProvider = new VMProtocolEditorsProvider();
     return true;
 }
Exemplo n.º 27
0
 public bool Setup( IPluginSetupInfo info )
 {
     throw new NotImplementedException();
 }
Exemplo n.º 28
0
 public bool Setup( IPluginSetupInfo info )
 {
     Assert.That( Configuration != null );
     Assert.That( ServiceWrapped == null );
     return true;
 }
 public bool Setup( IPluginSetupInfo info )
 {
     return true;
 }
Exemplo n.º 30
0
        public bool Setup( IPluginSetupInfo info )
        {
            Root = this;
            Parent = this;
            ChildNodes = new System.Collections.ObjectModel.ObservableCollection<NodeViewModel>();
            _screens = new List<Screen>();

            return true;
        }