Beispiel #1
0
        /// <summary>
        /// Gets the task preview image
        /// </summary>
        protected override void GetPreview()
        {
            // if window is minimized, then don't get it's thumbnail
            if (false && !WindowsTaskManager.GetWindowBounds(Handle).IntersectsWith(System.Windows.Forms.Screen.PrimaryScreen.Bounds))
            {
                return;
            }

            // getting the screenshot
            try
            {
                using (Bitmap Shot = WindowsTaskManager.GetWindowBitmap(Handle))
                {
                    // thumbnailing not needed

                    /*using(Bitmap ShotThumb=(Bitmap)ImageHelper.GetAspectThumbnail(Shot, new Size(Global.Configuration.Appearance.IconMagnifiedSize, Global.Configuration.Appearance.IconMagnifiedSize)))
                     * {
                     *      SetBackground(ShotThumb);
                     * }*/
                    SetBackground(Shot);
                }
                Compose();
            }
            catch (Exception) {}
        }
Beispiel #2
0
        /// <summary>
        /// Gets all the running tasks as OrbitItems
        /// </summary>
        /// <param name="device">Direct3D Device to load resources to</param>
        /// <returns>An array of OrbitItems</returns>
        public static OrbitItem[] GetTasks(Device device)
        {
            ExcludedWindow[] ExclusionList = LoadExcludedClassWindows();
            IntPtr[]         TasksList     = WindowsTaskManager.GetWindowHandles(ExclusionList);
            if (TasksList == null)
            {
                return new OrbitItem[] { new EmptyItem(device) }
            }
            ;

            // actually catalog them
            OrbitItem[] ItemRegistry = new OrbitItem[TasksList.Length];

            int a = 0;

            foreach (IntPtr Handle in TasksList)
            {
                ItemRegistry[a] = new TaskItem(device, new WindowInformation(WindowsTaskManager.GetWindowText(Handle), Handle));

                if (ItemRegistry[a] != null)
                {
                    ItemRegistry[a].Parent = "Orbit";
                    ItemRegistry[a].Line   = 0;
                }
                a++;
            }

            return(ItemRegistry);
        }
Beispiel #3
0
 private IntPtr FindFirstWindowLike(ExcludedWindow Window)
 {
     IntPtr[] Windows = WindowsTaskManager.GetWindowHandles();
     foreach (IntPtr Handle in Windows)
     {
         if (WindowsTaskManager.GetWindowClass(Handle) == Window.ClassName &&
             System.IO.Path.GetFileName(WindowsTaskManager.GetExecutableName(Handle)).ToLower() == Window.ProcessName.ToLower())
         {
             return(Handle);
         }
     }
     return(IntPtr.Zero);
 }
Beispiel #4
0
        private void SaveExcludedTasks()
        {
            // copy to array
            ExcludedWindow[] ExcludedTasks = new ExcludedWindow[this.TasksListPanel.Controls.Count];
            int i = 0;

            while (i < ExcludedTasks.Length)
            {
                TaskItemControl tic = (TaskItemControl)this.TasksListPanel.Controls[i];
                ExcludedTasks[i] = new ExcludedWindow(tic.ClassName, tic.ProcessName);
                i++;
            }

            // save
            WindowsTaskManager.SaveExcludedClassWindows(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), @"profiles\" + System.Environment.UserName + @"\ExcludedTasks.xml"), ExcludedTasks);
        }
Beispiel #5
0
        private void LoadExcludedTasks()
        {
            // load the exclusion list
            ExcludedWindow[] ExclusionList = WindowsTaskManager.LoadExcludedClassWindows(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), @"profiles\" + System.Environment.UserName + @"\ExcludedTasks.xml"));

            if (ExclusionList == null)
            {
                return;
            }

            // actually catalog them
            int i = 0;

            foreach (ExcludedWindow window in ExclusionList)
            {
                TaskItemControl tic = new TaskItemControl();

                tic.ProcessName = window.ProcessName;
                tic.ClassName   = window.ClassName;

                // try to find a currently running window that matches this spec
                IntPtr FoundWindow = FindFirstWindowLike(window);
                if (FoundWindow != IntPtr.Zero)
                {
                    tic.WindowTitle = WindowsTaskManager.GetWindowText(FoundWindow);
                    using (Bitmap shot = WindowsTaskManager.GetWindowBitmap(FoundWindow))
                    {
                        tic.WindowScreenshot = ImageHelper.GetAspectThumbnail(shot, new Size(64, 64));
                    }
                }
                else
                {
                    tic.WindowTitle = System.IO.Path.GetFileNameWithoutExtension(window.ProcessName);
                }

                // set this properties
                tic.Width   = this.TasksListPanel.Width;
                tic.Anchor |= AnchorStyles.Right;
                tic.Top     = tic.Height * i;

                // hook up events
                tic.RemoveLinkClicked += new EventHandler(tic_RemoveLinkClicked);

                this.TasksListPanel.Controls.Add(tic);
                i++;
            }
        }
Beispiel #6
0
        /// <summary>
        /// Adds a window class name to the exclusion list
        /// </summary>
        public void IgnoreWindow()
        {
            // create the new excluded window
            ExcludedWindow me = new ExcludedWindow(WindowsTaskManager.GetWindowClass(Handle), System.IO.Path.GetFileName(WindowsTaskManager.GetExecutableName(Handle)));

            //System.Diagnostics.Debug.WriteLine("ignoring "+me.ClassName+" from "+me.ProcessName);

            // load the custom list
            ExcludedWindow[] CustomExcludeList = WindowsTaskManager.LoadExcludedClassWindows(Orbit.Configuration.ConfigurationInfo.LocationsConfig.GetExcludedTasksFilePath());

            if (CustomExcludeList == null)
            {
                ExcludedWindow[] NewExcludedList = new ExcludedWindow[1];
                NewExcludedList[0] = me;
                WindowsTaskManager.SaveExcludedClassWindows(Orbit.Configuration.ConfigurationInfo.LocationsConfig.GetExcludedTasksFilePath(), NewExcludedList);
                return;
            }

            // set our new list
            ExcludedWindow[] ExcludeList = new ExcludedWindow[CustomExcludeList.Length + 1];
            // set our mandatory excluded tasks

            // add our new class
            ExcludeList[0] = me;

            // copy our custom exclusion list
            int i = 0;

            while (i < CustomExcludeList.Length)
            {
                ExcludeList[i + 1] = CustomExcludeList[i];
                i++;
            }

            WindowsTaskManager.SaveExcludedClassWindows(Orbit.Configuration.ConfigurationInfo.LocationsConfig.GetExcludedTasksFilePath(), ExcludeList);
        }
Beispiel #7
0
        private static ExcludedWindow[] LoadExcludedClassWindows()
        {
            // create orbit's own excluded window
            ExcludedWindow me = new ExcludedWindow("WindowsForms10.Window.8.app2", "Orbit.exe");

            // load the list
            ExcludedWindow[] CustomExcludeList = WindowsTaskManager.LoadExcludedClassWindows(Orbit.Configuration.ConfigurationInfo.LocationsConfig.GetExcludedTasksFilePath());

            if (CustomExcludeList == null)
            {
                return new ExcludedWindow[] { me }
            }
            ;

            // set our new list
            ExcludedWindow[] ExcludeList = new ExcludedWindow[CustomExcludeList.Length + 1];
            // set our mandatory excluded tasks

            // excluding all orbit windows
            ExcludeList[0] = me;

            // copy our custom exclusion list
            int i = 0;

            while (i < CustomExcludeList.Length)
            {
                ExcludeList[i + 1] = CustomExcludeList[i];

                i++;
            }

            return(ExcludeList);
        }

        #endregion
    }
Beispiel #8
0
        /// <summary>
        /// Creates a new instance of a Task Item
        /// </summary>
        /// <param name="Device">Direct3D Device to load the resources into</param>
        /// <param name="WindowInformation">Information about the window that this object represents</param>
        public TaskItem(Device Device, Orbit.Utilities.WindowInformation WindowInformation)
        {
            // checking the values
            ValidateDevice(Device);

            // settng the basic properties
            display = Device;

            try
            {
                // initialize common resources
                InitializeResources();

                // initialize needed HQ task preview resources
                InitializePreviewResources();

                // set the context menu flags
                this._MenuFlags = ItemMenuFlags.IgnoreWindow;

                // get information from window
                _WindowName = WindowInformation.Name;
                //base.Name=WindowInformation.Name;
                //base.Description="Running Task";
                this.Handle = WindowInformation.Handle;

                // load icon from window
                try
                {
                    using (Icon ico = WindowsTaskManager.GetWindowIcon(WindowInformation.Handle))
                    {
                        if (ico != null && ico.Width >= 32)                    // we don't want 16x16 icons here (we can get 32x32 icons on the other page for sure)
                        {
                            // got icon for the window
                            using (Bitmap b = ImageHelper.GetBitmapFromIcon(ico))
                            {
                                SetIcon(b);
                                //SetOverlay(b); // overlay not needed anymore. will use standard icon
                            }
                        }
                        else
                        {
                            try
                            {
                                // try to acquire icon from the process module
                                string modulePath = WindowsTaskManager.GetExecutableName(WindowInformation.Handle);
                                // or use the "C:\Windows\System32\more.com" file for dummy icon
                                if (!System.IO.File.Exists(modulePath))
                                {
                                    modulePath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.System), "more.com");
                                }

                                Win32.Shell32.SHFileInfo FileInfo = new Win32.Shell32.SHFileInfo();
                                Win32.Shell32.Shell32API.SHGetFileInfo(modulePath, 0, ref FileInfo, (uint)System.Runtime.InteropServices.Marshal.SizeOf(FileInfo), Win32.Shell32.ShellGetFileInfoFlags.LargeIcon | Win32.Shell32.ShellGetFileInfoFlags.Icon);

                                try
                                {
                                    // getting the handle to the icon from the SHFileInfo structure
                                    using (Icon IconO = Icon.FromHandle(FileInfo.hIcon))
                                    {
                                        // create the biggest possible icon
                                        using (Icon icon = new Icon(IconO, 128, 128))
                                        {
                                            //System.Diagnostics.Debug.WriteLine("Icon size"+icon.Width);
                                            // convert to bitmap
                                            using (Bitmap IconPic = Orbit.Utilities.ImageHelper.GetBitmapFromIcon(icon))
                                            {
                                                // setting it to be the icon
                                                this.SetIcon(IconPic);
                                                //this.SetOverlay(IconPic); // overlay not needed anymore. will use standard icon
                                            }
                                        }
                                    }
                                }
                                catch (Exception) {}
                                // don't forget to destroy the handle to the other icon
                                Win32.User32.User32API.DestroyIcon(FileInfo.hIcon);
                            }
                            catch (Exception)
                            {
                                CannotLoadIcon();
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    System.Diagnostics.Debug.WriteLine("failed to load icon");
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #9
0
 /// <summary>
 /// ALT+TABs to the window represented by this item
 /// </summary>
 public void SwitchTo()
 {
     WindowsTaskManager.SwitchTo(this.Handle);
 }