示例#1
0
        private void selectWindowMenuItem_SubmenuOpened(object sender, RoutedEventArgs e)
        {
            ItemCollection items = selectWindowMenuItem.Items;

            items.Clear();
            ApplicationWindow[] windows = ApplicationWindow.GetApplicationWindows().Where(window => !window.IsIdentical(this)).ToArray();
            for (int index = 0; index < windows.Length; index++)
            {
                ApplicationWindow window     = windows[index];
                Process           process    = Process.GetProcessById(window.ProcessId);
                MenuItem          windowItem = new MenuItem()
                {
                    Header = window.Text,
                    Icon   = new Image()
                    {
                        Source = window.GetIcon(IconSize.Small),
                        Width  = 16,
                        Height = 16,
                    },
                };
                windowItem.Click += (eventSender, eventArgs) => CaptureWindow(window);
                items.Add(windowItem);
            }
            if (items.Count == 0)
            {
                object[] extension = (object[])this.FindResource("noSelectionItem");
                foreach (var item in extension)
                {
                    items.Add(item);
                }
            }
        }
示例#2
0
        private void selectWindowsToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            ToolStripItemCollection items = addWindowsToolStripMenuItem.DropDownItems;

            items.Clear();
            foreach (ApplicationWindow window in ApplicationWindow.GetApplicationWindows())
            {
                if (window.Handle == this.Handle)
                {
                    continue;
                }

                Process process = Process.GetProcessById(window.ProcessId);
                IntPtr  handle  = window.Handle;
                string  title   = window.Text;
                Icon    icon    = window.Icon;

                ToolStripMenuItem windowItem = new ToolStripMenuItem(title);
                windowItem.Click += (eventSender, eventArgs) => CaptureWindow(handle);
                if (icon != null)
                {
                    windowItem.Image = icon.ToBitmap();
                }
                items.Add(windowItem);
            }
            if (items.Count == 0)
            {
                items.Add(NoSelectionItem);
            }
        }
示例#3
0
        private void windowObserver_DoWork(object sender, DoWorkEventArgs e)
        {
            Size sourceSize = DesktopWindowManager.QueryThumbnailSourceSize(thumbnail);

            while (ApplicationWindow.GetApplicationWindows().Any(window => window.Handle == windowHandle))
            {
                Size size = DesktopWindowManager.QueryThumbnailSourceSize(thumbnail);
                if (!sourceSize.Equals(size))
                {
                    sourceSize = size;
                    OnSourceSizeChanged(EventArgs.Empty);
                }
            }
        }