public void CreateConfig(Image groupImage)
        {
            string path = @"config\" + this.Name;

            //string filePath = path + @"\" + this.Name + "Group.exe";
            //
            // Directory and .exe
            //
            System.IO.Directory.CreateDirectory(@path);

            //System.IO.File.Copy(@"config\config.exe", @filePath);
            //
            // XML config
            //
            System.Xml.Serialization.XmlSerializer writer =
                new System.Xml.Serialization.XmlSerializer(typeof(Category));

            using (FileStream file = System.IO.File.Create(@path + @"\ObjectData.xml"))
                writer.Serialize(file, this);
            //
            // Create .ico
            //

            Image img = ImageFunctions.ResizeImage(groupImage, 1024, 1024); // Resize img if too big

            img.Save(path + @"\GroupImage.png");

            using (FileStream fs = new FileStream(path + @"\GroupIcon.ico", FileMode.Create))
                ImageFunctions.IconFromImage(img).Save(fs);  // saving as icon
                                                             //
                                                             // Create .lnk shortcut
                                                             //


            // Through shellLink.cs class, pass through into the function information on how to construct the icon
            // Needed due to needing to set a unique AppUserModelID so the shortcut applications don't stack on the taskbar with the main application
            // Tricks Windows to think they are from different applications even though they are from the same .exe
            ShellLink.InstallShortcut(
                Path.GetFullPath(@System.AppDomain.CurrentDomain.FriendlyName),
                "tjackenpacken.taskbarGroup.menu." + this.Name,
                path + " shortcut",
                Path.GetFullPath(@path),
                Path.GetFullPath(path + @"\GroupIcon.ico"),
                path + "\\" + this.Name + ".lnk",
                this.Name
                );


            // Build the icon cache
            cacheIcons();

            System.IO.File.Move(@path + "\\" + this.Name + ".lnk",
                                Path.GetFullPath(@"Shortcuts\" + Regex.Replace(this.Name, @"(_)+", " ") + ".lnk")); // Move .lnk to correct directory
        }
Exemple #2
0
        public void CreateConfig(Image groupImage)
        {
            string path = Path.Combine(Paths.ConfigPath, this.Name);

            //
            // Directory and .exe
            //
            System.IO.Directory.CreateDirectory(@path);

            //System.IO.File.Copy(@"config\config.exe", @filePath);
            //
            // XML config
            //
            System.Xml.Serialization.XmlSerializer writer =
                new System.Xml.Serialization.XmlSerializer(typeof(Category));

            using (FileStream file = System.IO.File.Create(Path.Combine(@path, "ObjectData.xml")))
            {
                writer.Serialize(file, this);
                file.Close();
            }
            //
            // Create .ico
            //

            Image img = ImageFunctions.ResizeImage(groupImage, 256, 256); // Resize img if too big

            img.Save(Path.Combine(path, "GroupImage.png"));

            if (GetMimeType(groupImage).ToString() == "*.PNG")
            {
                createMultiIcon(groupImage, Path.Combine(path, "GroupIcon.ico"));
            }
            else
            {
                using (FileStream fs = new FileStream(Path.Combine(path, "GroupIcon.ico"), FileMode.Create))
                {
                    ImageFunctions.IconFromImage(img).Save(fs);
                    fs.Close();
                }
            }


            // Through shellLink.cs class, pass through into the function information on how to construct the icon
            // Needed due to needing to set a unique AppUserModelID so the shortcut applications don't stack on the taskbar with the main application
            // Tricks Windows to think they are from different applications even though they are from the same .exe
            ShellLink.InstallShortcut(
                Paths.exeString,
                "tjackenpacken.taskbarGroup.menu." + this.Name,
                path + " shortcut",
                path,
                Path.Combine(path, "GroupIcon.ico"),
                Path.Combine(path, this.Name + ".lnk"),
                this.Name
                );


            // Build the icon cache
            cacheIcons();

            System.IO.File.Move(Path.Combine(path, this.Name + ".lnk"),
                                Path.Combine(Paths.ShortcutsPath, Regex.Replace(this.Name, @"(_)+", " ") + ".lnk")); // Move .lnk to correct directory
        }
Exemple #3
0
        public void CreateConfig(Image groupImage)
        {
            try
            {
                //string filePath = path + @"\" + this.Name + "Group.exe";
                //
                // Directory and .exe
                //
                path = Path.Combine(Paths.ConfigPath, this.Name);
                System.IO.Directory.CreateDirectory(@path);

                //System.IO.File.Copy(@"config\config.exe", @filePath);


                writeXML();

                //
                // Create .ico
                //

                Image img = ImageFunctions.ResizeImage(groupImage, 256, 256); // Resize img if too big
                img.Save(Path.Combine(path, "GroupImage.png"));

                if (GetMimeType(groupImage).ToString() == "*.PNG")
                {
                    createMultiIcon(groupImage, Path.Combine(path, "GroupIcon.ico"));
                }
                else
                {
                    using (FileStream fs = new FileStream(Path.Combine(path, "GroupIcon.ico"), FileMode.Create))
                    {
                        ImageFunctions.IconFromImage(img).Save(fs);
                        fs.Close();
                    }
                }


                // Through shellLink.cs class, pass through into the function information on how to construct the icon
                // Needed due to needing to set a unique AppUserModelID so the shortcut applications don't stack on the taskbar with the main application
                // Tricks Windows to think they are from different applications even though they are from the same .exe
                ShellLink.InstallShortcut(
                    Paths.BackgroundApplication,
                    "tjackenpacken.taskbarGroup.menu." + this.Name,
                    path + " shortcut",
                    path,
                    Path.Combine(path, "GroupIcon.ico"),
                    Path.Combine(path, this.Name + ".lnk"),
                    this.Name
                    );


                // Build the icon cache
                cacheIcons();

                System.IO.File.Move(Path.Combine(path, this.Name + ".lnk"),
                                    Path.Combine(Paths.ShortcutsPath, Regex.Replace(this.Name, @"(_)+", " ") + ".lnk")); // Move .lnk to correct directory
            }
            catch { }
            finally
            {
                Process[] pname = Process.GetProcessesByName(Path.GetFileNameWithoutExtension("Taskbar Groups Background"));
                if (pname.Length != 0)
                {
                    pname[0].Kill();
                }


                Process backgroundProcess = new Process();
                backgroundProcess.StartInfo.FileName = Paths.BackgroundApplication;
                backgroundProcess.Start();


                Process p = new Process();
                p.StartInfo.FileName  = Paths.BackgroundApplication;
                p.StartInfo.Arguments = this.Name + " setGroupContextMenu";
                p.Start();
            }
        }