예제 #1
0
        /// <summary>
        /// 窗体加载事件
        /// </summary>
        /// <param name="sender">发送者</param>
        /// <param name="e">信息</param>
        private void WindowLoad(object sender, RoutedEventArgs e)
        {
            this.handle = new WindowInteropHelper(this).Handle;

            //获取任务栏句柄
            IntPtr taskBarInPtr = WindowApi.FindWindow("Shell_TrayWnd", null);

            this.reBarInPtr = WindowApi.FindWindowEx(taskBarInPtr, (IntPtr)0, "ReBarWindow32", null);
            WindowApi.SetParent(this.handle, this.reBarInPtr);

            this.msTaskSwInPtr = WindowApi.FindWindowEx(this.reBarInPtr, (IntPtr)0, "MSTaskSwWClass", null);

            this.provessor   = new PerformanceCounter("Processor Information", "% Processor Time", "_Total");
            this.memery      = new PerformanceCounter("Memory", "Available MBytes");
            this.totleMemory = this.GetPhisicalMemory();

            this._timer          = new Timer(1000);
            this._timer.Elapsed += new ElapsedEventHandler(TimerElapsedEvent);

            this._monitor = new NetworkMonitor();
            this._monitor.DownloadEvent += new NetworkMonitorEvent(DownloadSpeedEvent);
            this._monitor.UploadEvent   += new NetworkMonitorEvent(UpdateSpeedEvent);

            this._monitor.StartMonitoring();
            this._timer.Start();

            this.RefreshRect();
        }
예제 #2
0
        /// <summary>
        /// 位置刷新
        /// </summary>
        private void RefreshLocation()
        {
            try
            {
                IntPtr taskBarInPtr = WindowApi.FindWindow("Shell_TrayWnd", null);
                var    reBarInPtr   = WindowApi.FindWindowEx(taskBarInPtr, (IntPtr)0, "ReBarWindow32", null);

                if (this.reBarInPtr != reBarInPtr)
                {
                    this.reBarInPtr = WindowApi.SetParent(this.handle, reBarInPtr);
                }
            }
            catch { }
        }