Beispiel #1
0
 public ShellManagerWin32()
 {
     form              = new SystemProcessHookForm();
     form.WindowEvent += (s, e) => {
         CoreLib.Log((string)e);
     };
 }
Beispiel #2
0
 public override void BringToFront()
 {
     CoreLib.Log("BringToFront");
     //Interop.BringWindowToTop(hwnd);
     Interop.ShowWindow(hwnd, Interop.SW_SHOW);
     if (Interop.IsIconic(hwnd))
     {
         Interop.ShowWindow(hwnd, Interop.SW_RESTORE);
     }
     Interop.SetForegroundWindow(hwnd);
 }
Beispiel #3
0
        public static void Main(string[] args)
        {
            Application.Init();



            //var dwin = new DesktopWindow();
            //dwin.Show();

            /*GLib.ExceptionManager.UnhandledException += (e) => {
             *      e.ExitApplication = false;
             *      CoreLib.Log(e.ExceptionObject.ToString());
             * };*/

            try {
                var logwin = new LogWindow();
                logwin.Show();
                CoreLib.Log("log started");


                AppConfig.Load("../config/config.xml");

                //Gtk.Settings.Default.ThemeName = "Dorian-3.16";
                var shellMan = ShellManager.Create();
                shellMan.UpdateWindows();

                var idx = new TLauncherIndex();
                idx.AddLocations();
                idx.Rebuild();

                foreach (var panConfig in AppConfig.Panels)
                {
                    var pwin = new TPanel(panConfig);
                    pwin.Setup();
                    pwin.Show();
                }
            } catch (Exception ex) {
                CoreLib.MessageBox(ex.ToString());
            }

            Application.Run();
        }
Beispiel #4
0
        private void createButton(TWindow wnd)
        {
            CoreLib.Log(wnd.hwnd.ToString());

            var but = new TWindowButton(wnd);

            var img = wnd.GetIcon(new Size(22, 22));

            if (img != null)
            {
                but.Image = img;
                img.Show();
            }

            but.Label = wnd.GetName();
            buttonTable.Add(but);

            buthash2.Add(wnd, but);

            //but.Clicked += (s, e) => {
            //wnd.BringToFront();
            //};
        }
Beispiel #5
0
        public static void ResolveShortcut(string filename, out string name, out string command, out string args, out string description, out string iconLocation, out int iconIndex)
        {
            ShellLink link = new ShellLink();

            ((IPersistFile)link).Load(filename, STGM_READ);
            // TODO: if I can get hold of the hwnd call resolve first. This handles moved and renamed files.
            //((IShellLinkW)link).Resolve(IntPtr.Zero, SLR_FLAGS.SLR_ANY_MATCH);

            StringBuilder    sb   = new StringBuilder(MAX_PATH);
            WIN32_FIND_DATAW data = new WIN32_FIND_DATAW();

            ((IShellLinkW)link).GetPath(sb, sb.Capacity, out data, SLGP_FLAGS.SLGP_RAWPATH);
            command = sb.ToString();

            sb = new StringBuilder(MAX_PATH);             //MAX_PATH?
            ((IShellLinkW)link).GetArguments(sb, sb.Capacity);
            args = sb.ToString();

            description = "";
            try {
                sb = new StringBuilder(MAX_PATH);                 //MAX_PATH?
                ((IShellLinkW)link).GetDescription(sb, sb.Capacity);
                description = sb.ToString();
            } catch (COMException ex) {
            }

            sb = new StringBuilder(MAX_PATH);             //MAX_PATH?
            var hresult = ((IShellLinkW)link).GetIconLocation(sb, sb.Capacity, out iconIndex);

            iconLocation = sb.ToString();
            if (hresult != 0)
            {
                CoreLib.Log("GetIconLocation result: " + hresult);
            }

            name = GetLocalizedName.GetName(filename);
        }
Beispiel #6
0
        public WindowListPlugin(TPanel panel, PluginConfig cfg)
            : base(panel, cfg)
        {
            buttonTable = new PanelButtonTable(Orientation.Horizontal);
            //box.HeightRequest = panel.height;
            Update();

            ShellManager.Current.WindowActivated += (wnd) => {
                var bt = GetButton(wnd);
                if (bt != null)
                {
                    CoreLib.Log("act");
                    Application.Invoke((s, e) => {
                        foreach (var b in buthash2.Values)
                        {
                            b.Active = bt == b;
                        }
                    });
                    //bt.Toggle();
                }
            };
            ShellManager.Current.WindowDestroyed += (wnd) => {
                var bt = GetButton(wnd);
                if (bt != null)
                {
                    buthash2.Remove(wnd);
                    buttonTable.Remove(bt);
                    bt.Dispose();
                }
            };
            ShellManager.Current.WindowCreated += (wnd) => {
                if (wnd.ShowInTaskbar())
                {
                    createButton(wnd);
                }
            };
        }
Beispiel #7
0
 public void Log()
 {
     CoreLib.Log("HWND: " + hwnd.ToString() + ", Name: " + GetName());
 }
Beispiel #8
0
        public static TLauncherEntry CreateFromFileLnk(string path)
        {
            var entry = new TLauncherEntry();

            string name, command, args, description, iconLocation;
            int    iconIndex;

            ResolveShortcut(path, out name, out command, out args, out description, out iconLocation, out iconIndex);

            command = Environment.ExpandEnvironmentVariables(command);

            if (!File.Exists(command))
            {
                var newCommand = command.Replace("\\Program Files (x86)", "\\Program Files").Replace("\\system32", "\\Sysnative");
                if (File.Exists(newCommand))
                {
                    command = newCommand;
                }
                else
                {
                    CoreLib.Log("COMMAND NOT FOUND: '" + command + "'");
                }
            }

            if (string.IsNullOrEmpty(iconLocation))
            {
                iconLocation = command;
                iconIndex    = 0;
            }

            //if (name == "Steam") {
            //	AppLib.log("########################################################" + iconLocation);
            //}

            iconLocation = Environment.ExpandEnvironmentVariables(iconLocation);

            if (!File.Exists(iconLocation))
            {
                //AppLib.log("COMMAND NOT FOUND: " + command);
                iconLocation = iconLocation.Replace("\\Program Files (x86)", "\\Program Files").Replace("\\system32", "\\Sysnative");
            }

            if (File.Exists(iconLocation))
            {
                //var ext = new TsudaKageyu.IconExtractor(iconLocation);
                //var ico = ext.GetIcon(iconIndex);

                IntPtr p1 = new IntPtr();
                IntPtr p2 = new IntPtr();
                Interop.ExtractIconEx(iconLocation, iconIndex, ref p1, ref p2, 1);

                System.Drawing.Icon ico;
                if (p1 != IntPtr.Zero)
                {
                    ico = System.Drawing.Icon.FromHandle(p1);
                }
                else
                {
                    ico = System.Drawing.Icon.FromHandle(p2);
                }

                var ms = new MemoryStream();
                ico.ToBitmap().Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                entry.IconStored = ms.ToArray();
            }
            else
            {
                CoreLib.Log("ICON LOCATION NOT FOUND: " + iconLocation);
            }

            if (path.Contains("ANNO"))
            {
                var s = "";
            }

            entry.Name        = name;
            entry.CommandPath = Path.GetDirectoryName(command);
            entry.CommandFile = Path.GetFileName(command);
            entry.CommandArgs = args;
            entry.Description = description;

            SetCategory(entry);

            return(entry);
        }