예제 #1
0
        public Form1( )
        {
            Logger = new DebugLogger( "Form1" );
            //foreach(var proc in Process.GetProcesses())
            //{
            //    var pname = proc.ProcessName;
            //    if(pname.Contains("Browser"))
            //    {
            //        Trace.WriteLine( pname );
            //        proc.Kill( );
            //    }
            //}
            _TileSetting = TileSetting.Load( SettingPath );

            WindowManager = new TileWindowManager( UIHeight );
            WindowManager.OnTagChange += ( s , e ) => Invalidate( );
            try
            {
                InitializeComponent( );

                ClientTitleList = new List<ListBox>( )
                {
                    listBox1,
                    listBox2,
                    listBox3,
                    listBox4,
                    listBox5,
                    listBox6,
                    listBox7,
                    listBox8,
                    listBox9,
                    listBox10,
                    listBox11,
                    listBox12,
                };

                for ( int i = 1 ; i < 10; i++ )
                {
                    Keys d0 = ( Keys )( ( int )Keys.D0 + i );
                    AddIndexHotKey( i , d0 );


                }
                AddIndexHotKey( 10 , Keys.D0 );
                AddIndexHotKey( 11 , Keys.OemMinus );
                // HHKBの^キー
                AddIndexHotKey( 12 , Keys.OemQuotes);

                HotkeyList.Add( new HotKey( Handle , ToggleHotID , Keys.H , Keys.Control ) );
                HotkeyList.Add( new HotKey( Handle , SortMaster , Keys.M , Keys.Control | Keys.Alt ) );
                HotkeyList.Add( new HotKey( Handle , QuitHotID , Keys.Q , Keys.Control | Keys.Alt ) );

                SetUp( );
                WindowManager.ActiveClient = WindowManager.TryGetMaster( );
                UpdateGeom( );
                ThreadWindowHandles.RegisterShellHookWindow( Handle );
                ShellHookID = ThreadWindowHandles.RegisterWindowMessage( "SHELLHOOK" );
                FormClosing += Form1_FormClosing;
                Bounds = ScreenGeom.Rect;
                Height = UIHeight;

                UpdateTimer = new Timer( );
                UpdateTimer.Interval = 10;
                UpdateTimer.Tick += T_Tick;
                UpdateTimer.Start( );
                Paint += Form1_Paint;
                // 狭いスクリーンだとquitがなくなることがある
                var widestScr = Screen.AllScreens.OrderBy( s => s.WorkingArea.Width ).Last( );
                Location = widestScr.Bounds.Location;
                WindowManager.BelongScreen = Screen.FromHandle( Handle );
                WindowManager.Tile( );
            }
            catch ( Exception ex )
            {
                MessageBox.Show( ex.ToString( ) );
                CleanUp( );
            }
        }
예제 #2
0
        private void T_Tick( object sender , EventArgs e )
        {
            DebugLogger.Update( );
            var wnd = Win32dll.WindowFromPoint( MousePosition.X , MousePosition.Y );
            if(MousePosition.Y > UIHeight)
            {
                Opacity = 0.7f;
            }
            else
            {
                Opacity = 1.0f;
            }

            uint procID = 0;
            var now = DateTime.Now;
            //label2.Text = wnd.ToString( );
            label2.Text = now.ToString(" yyyy/MM/dd (ddd)" );
            label1.Text = now.ToString( "HH:mm" );
            //label1.Text = SelectedClientList( ).Aggregate( "" , ( acc , c ) => acc + "\n" + c.Title );
#if USEWINAPI
            //IntPtr procPtr = IntPtr.Zero;
            //uint procID2 = User32Methods.GetWindowThreadProcessId( wnd , procPtr );
#endif
            Win32dll.GetWindowThreadProcessId( wnd , out procID );
            //wnd = Win32dll.OpenProcess( Win32dll.ProcessAccessFlags.QueryInformation | Win32dll.ProcessAccessFlags.VMRead | Win32dll.ProcessAccessFlags.Terminate , false , procID );
            //label3.Text = SelectedTag;
            //var size = User32Methods.GetWindowTextLength( wnd );
            //if ( size > 0 )
            //{
            //    var len = size + 1;
            //    var sb = new StringBuilder( len );

            //    label1.Text = Win32dll.QueryFullProcessImageName( wnd , false );
            //}
            UpdateClient( );

            if ( WindowManager.IsDirty )
            {
#if MultiScreen
                foreach ( var screen in ScreenList )
                {
                    foreach ( var tagMan in screen.TagList )
#else
                foreach ( var tagMan in WindowManager.ScreenList[ 0 ].TagList )
#endif
                {
                    UpdateTitle( tagMan );
                }
#if MultiScreen
                }
#endif
                Invalidate( );
                WindowManager.IsDirty = false;
            }

            CalcSlaveSizeFromMaster( );

            UpdateSlaveSize( );
#if SCREENCHANGE
            var movedClientList = WindowManager.ScreenList.SelectMany(screen=> screen.MovedClients( WindowManager.SelectedTag ));
            UpdateClientScreen( movedClientList );

            foreach ( var screen in WindowManager.ScreenList )
            {
                screen.UpdateScreen( WindowManager.SelectedTag );
            }
#endif
        }