Esempio n. 1
0
        public override void Refresh(ObservableCollection <DataObject> objects)
        {
            using (var manager = new RefreshManager <WindowDataObject>(objects))
            {
                foreach (int hwnd in NativeWindowFunctions.EnumWindows())
                {
                    string           internalID = hwnd.ToString("X4");
                    WindowDataObject wdo;

                    if (manager.Contains(internalID, out wdo))
                    {
                        if (!wdo.Refresh(hwnd))
                        {
                            objects.Remove(wdo);
                        }
                    }
                    else
                    {
                        wdo = new WindowDataObject(hwnd);
                        if (!string.IsNullOrEmpty(wdo.Title))
                        {
                            objects.Add(wdo);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 public override void OnControlRestart(object sender, RoutedEventArgs e)
 {
     foreach (WindowDataObject wdo in MainListView.SelectedItems)
     {
         NativeWindowFunctions.BringWindowToTop(wdo.Handle);
         wdo.Refresh(wdo.Handle);
     }
 }
Esempio n. 3
0
 private void OnShowWindow(int state)
 {
     foreach (WindowDataObject wdo in MainListView.SelectedItems)
     {
         NativeWindowFunctions.ShowWindow(wdo.Handle, state);
         wdo.Refresh(wdo.Handle);
     }
 }
Esempio n. 4
0
        public bool Refresh(int hwnd)
        {
            bool WindowTimedOut = false;

            string title = NativeWindowFunctions.GetTitle(hwnd, out WindowTimedOut);

            if (string.IsNullOrEmpty(title))
            {
                return(false);
            }

            if (SetStringProperty("Title", title))
            {
                ToolTipCaption = title;
                NotifyPropertyChanged("ToolTipCaption");
            }

            if (SetStringProperty("Class", NativeWindowFunctions.GetClassName(hwnd)))
            {
                ToolTip = Class;
                NotifyPropertyChanged("ToolTip");
            }

            WS_STYLE style = NativeWindowFunctions.GetWindowStyle(hwnd);

            SetStringProperty("Style", style);
            SetStringProperty("ExStyle", NativeWindowFunctions.GetWindowExStyle(hwnd));
            SetStringProperty("ID", NativeWindowFunctions.GetWindowID(hwnd));

            RECT r = new RECT();

            NativeWindowFunctions.GetWindowRect(Handle, ref r);

            SetStringProperty("Size", string.Format("({0}, {1})", r.Width, r.Height));
            SetStringProperty("Position", string.Format("({0}, {1})", r.Top, r.Left));

            int pID, tID;

            NativeWindowFunctions.GetWindowThreadProcessId(hwnd, out pID, out tID);
            SetStringProperty("ProcessID", pID);
            SetStringProperty("ThreadID", tID);

            bool isDisabled = false;
            bool isRunning  = false;

            if ((r.Width == r.Height) && (r.Width == 0))
            {
                isDisabled = true;
            }
            if ((style & WS_STYLE.VISIBLE) == 0)
            {
                isDisabled = true;
            }
            if (!WindowTimedOut)
            {
                isRunning = true;
            }
            SetRunning(isRunning);
            SetDisabled(isDisabled);
            return(true);
        }