public void Teardown() { if( _mouseIndicatorWindow != null ) { _mouseIndicatorWindow.Close(); _editorWindow.Close(); } if( _autoClickWindow != null ) { if( _autoClickWindow.IsVisible ) _autoClickWindow.Close(); } _editorWindow = null; _mouseIndicatorWindow = null; _autoClickWindow = null; }
public void Start() { _autoClickWindow = new AutoClickWindow() { DataContext = this }; _autoClickWindow.Closing += OnWindowClosing; if( !Config.User.Contains( "AutoClickWindowPlacement" ) ) SetDefaultWindowPosition( defaultWidth, defaultHeight ); else _autoClickWindow.Width = _autoClickWindow.Height = 0; _mouseIndicatorWindow = new MouseDecoratorWindow { DataContext = this }; _editorWindow = new AutoClickEditorWindow { DataContext = this }; Config.ConfigChanged += new EventHandler<ConfigChangedEventArgs>( OnConfigChanged ); ConfigureMouseWatcher(); RegisterEvents(); Config.User.GetOrSet<bool>( "ShowMouseIndicatorOption", true ); _mouseIndicatorWindow.Show(); _autoClickWindow.Show(); //Executed only at first launch, has to be done once the window is shown, otherwise, it will save a "hidden" state for the window if( !Config.User.Contains( "AutoClickWindowPlacement" ) ) Config.User.Set( "AutoClickWindowPlacement", CKWindowTools.GetPlacement( _autoClickWindow.Hwnd ) ); CKWindowTools.SetPlacement( _autoClickWindow.Hwnd, (WINDOWPLACEMENT)Config.User["AutoClickWindowPlacement"] ); //Re-positions the window in the screen if it is not in it. Which may happen if the autoclick is saved as being on a secondary screen. if( !ScreenHelper.IsInScreen( new System.Drawing.Point( (int)_autoClickWindow.Left, (int)_autoClickWindow.Top ) ) && !ScreenHelper.IsInScreen( new System.Drawing.Point( (int)(_autoClickWindow.Left + _autoClickWindow.ActualWidth), (int)_autoClickWindow.Top ) ) ) { SetDefaultWindowPosition( defaultWidth, defaultHeight ); } OnPause( this, EventArgs.Empty ); InitializeWindowManager(); InitializeTopMost(); }