/// <summary>
 /// Initialize an AppBarHandler for a specific window
 /// </summary>
 /// <param name="winHandle">Handler of the window to hook into</param>
 public AppBarHandler(IntPtr winHandle)
 {
     edgeHandler           = null;
     appbar                = new AppBar(winHandle);
     AppBarIsActive        = false;
     UsePrimaryMonitorOnly = false;
 }
        /// <summary>
        /// Activate the AppBar at the given location on the screen
        /// </summary>
        /// <param name="newLocat">Location of the AppBar</param>
        /// <returns>True if AppBar was successfully created</returns>
        public bool ActivateAppBar(ScreenEdge newLocat)
        {
            DeactivateAppBar();

            Func <IEdgeHandler> edgeHandlerFact;

            if (EdgeHandlerFactory.TryGetValue(newLocat, out edgeHandlerFact))
            {
                edgeHandler = edgeHandlerFact();
            }
            else
            {
                return(false);
            }

            var winBounds = Windows.GetRectangle(appbar.hWnd);

            AppBarDimension = edgeHandler.GetCurrentDimension(winBounds);

            appbar = new AppBar(appbar.hWnd);
            if (!appbar.CreateNew())
            {
                return(false);
            }
            CheckDockSize(AppBarDimension);
            SizeToNewValues();

            SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged;

            AppBarIsActive = true;
            return(true);
        }
예제 #3
0
 public Piece(char symbol, int speedRow, int speedCol, IEdgeHandler edgeHandler)
 {
     _edgeHandler = edgeHandler;
     _symbol      = symbol;
     SpeedRow     = speedRow;
     SpeedCol     = speedCol;
 }
        /// <summary>
        /// Deactivate the AppBar if it is currently active
        /// </summary>
        public void DeactivateAppBar()
        {
            if (AppBarIsActive)
            {
                SystemEvents.DisplaySettingsChanged -= SystemEvents_DisplaySettingsChanged;

                AppBarIsActive = false;
                appbar.Remove();
                edgeHandler = null;
            }
        }