Esempio n. 1
0
 public static void StartApp(ProfileConfigItem appConfig)
 {
     if (appConfig.displayName.StartsWith("-----") || appConfig.displayName == "startAll")
     {
     }
     else
     {
         try
         {
             ProcessStartInfo pi  = new ProcessStartInfo();
             FileInfo         app = new FileInfo(appConfig.app);
             pi.FileName         = appConfig.app;
             pi.WorkingDirectory = app.Directory.FullName;
             pi.Arguments        = appConfig.parameter;
             if (appConfig.asAdministrator)
             {
                 pi.Verb = "runas";
             }
             Process.Start(pi);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Can't start.", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Esempio n. 2
0
        public static Image GetIconFromProfileConfigItem(ProfileConfigItem configItem, DirectoryInfo iconsFolder)
        {
            Image result = null;

            if (configItem != null && !String.IsNullOrEmpty(configItem.icon) &&
                iconsFolder != null && iconsFolder.Exists)
            {
                FileInfo iconFile = new FileInfo(Path.Combine(iconsFolder.FullName, configItem.icon));
                if (iconFile != null && iconFile.Exists)
                {
                    result = Image.FromFile(Path.Combine(iconsFolder.FullName, configItem.icon));
                }
            }
            else
            {
                result = GetIconFromExeFile(configItem, result);
            }

            if (result == null)
            {
                result = GetDefaultAppIcon(iconsFolder);
            }

            return(result);
        }
Esempio n. 3
0
        void item_Click(object sender, EventArgs e)
        {
            int appKey = (int)((ToolStripItem)sender).Tag;
            ProfileConfigItem appConfig = cacheAppList[appKey];

            Utils.StartApp(appConfig);
        }
Esempio n. 4
0
        private void StartSelectedItems()
        {
            foreach (ListViewItem item in listView1.SelectedItems)
            {
                ProfileConfigItem selectedApp = (ProfileConfigItem)item.Tag;

                if (selectedApp != null && selectedApp.app != null && selectedApp.app != string.Empty)
                {
                    Utils.StartApp(selectedApp);
                }
            }
        }
Esempio n. 5
0
        private static Image GetIconFromExeFile(ProfileConfigItem configItem, Image result)
        {
            try
            {
                result = Icon.ExtractAssociatedIcon(configItem.app).ToBitmap();
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }

            return(result);
        }
Esempio n. 6
0
 public static void GetIconForListView(DirectoryInfo iconsFolder, ProfileConfigItem configItem, ListViewItem item, ImageList iconList)
 {
     if (!String.IsNullOrEmpty(configItem.icon))
     {
         if (!iconList.Images.ContainsKey(configItem.icon))
         {
             FileInfo i1 = new FileInfo(Path.Combine(iconsFolder.FullName, configItem.icon));
             if (i1.Exists)
             {
                 Image icon2 = Image.FromFile(Path.Combine(iconsFolder.FullName, configItem.icon));
                 iconList.Images.Add(configItem.icon, icon2);
             }
             else
             {
                 iconList.Images.Add(configItem.icon, Utils.GetDefaultAppIcon(iconsFolder));
             }
         }
         item.ImageKey = configItem.icon;
     }
     else
     {
         Image result = Icon.ExtractAssociatedIcon(configItem.app).ToBitmap();
         if (result == null)
         {
             if (!iconList.Images.ContainsKey("TRAYAPP_DefaultAppIcon"))
             {
                 iconList.Images.Add("TRAYAPP_DefaultAppIcon", Utils.GetDefaultAppIcon(iconsFolder));
             }
             item.ImageKey = "TRAYAPP_DefaultAppIcon";
         }
         else
         {
             if (!iconList.Images.ContainsKey("TRAYAPP_" + configItem.app))
             {
                 iconList.Images.Add("TRAYAPP_" + configItem.app, result);
             }
             item.ImageKey = "TRAYAPP_" + configItem.app;
         }
     }
 }
Esempio n. 7
0
        private void WpfStarterComboBox1_SelectionChanged(object selectedObject)
        {
            ProfileConfigItem selectedApp = (ProfileConfigItem)selectedObject;

            if (selectedApp != null && selectedApp.app != null && selectedApp.app != string.Empty)
            {
                Utils.StartApp(selectedApp);

                ListViewItem item = new ListViewItem();
                Utils.GetIconForListView(iconsFolder, selectedApp, item, iconList);

                item.Text = selectedApp.displayName;
                item.Tag  = selectedApp;

                ListViewItem oldItem = listView1.FindItemWithText(item.Text);
                if (oldItem != null)
                {
                    listView1.Items.Remove(oldItem);
                }
                listView1.Items.Add(item);

                wpfStarterComboBox1.SetText(" - Starting...");
            }
        }
Esempio n. 8
0
        public Starter()
        {
            InitializeComponent();

            // Design
            this.BackColor         = Color.FromArgb(63, 63, 63);
            panel1.BackColor       = Settings.Default.backColor;
            panelStarter.BackColor = Settings.Default.backColor;

            //pictureBox1.Image = Image.FromFile(Path.Combine(iconsFolder.FullName, "logo.png"));
            iconList.ColorDepth      = ColorDepth.Depth32Bit;
            iconList.ImageSize       = new System.Drawing.Size(32, 32);
            listView1.LargeImageList = iconList;


            ghk = new Hotkeys.GlobalHotkey(Constants.WIN, Keys.Y, this);
            //projectExplorer = new GlobalHotkey(Constants.WIN, Keys.N, this);
            this.Hide();

            configTextList = new List <ProfileConfigItem>();
            int groupCount = 0;

            groups = new List <string>();
            int    menuGroupCount  = 0;
            string menuGroupLetter = string.Empty;

            DAL configDAL = new DAL(Application.StartupPath, Settings.Default.DataFolder);

            foreach (ConfigFile configurationFile in configDAL.allConfigFiles)
            {
                groupCount += 100000;
                List <ProfileConfigItem> configList = configurationFile.GetItems();

                foreach (ProfileConfigItem configItem in configList)
                {
                    // Find Groups
                    if (!groups.Contains(configItem.group))
                    {
                        menuGroupCount++;
                        groups.Add(configItem.group);
                        menuGroupLetter = "ALT + ";
                        listBox1.Items.Add(string.Format("{0}. {1}", string.Format("{0}{1}", menuGroupLetter, menuGroupCount), configItem.group));
                    }
                    // Find Apps
                    if (configItem.app != null && configItem.app != string.Empty)
                    {
                        configTextList.Add(configItem);
                    }
                    // Find Sub Apps
                    foreach (ProfileConfigItem subItem in configItem.subItems)
                    {
                        subItem.group = configItem.group;
                        if (subItem.app != null && subItem.app != string.Empty)
                        {
                            configTextList.Add(subItem);
                        }
                    }
                }
            }


            DirectoryInfo dataFolder;

            dataFolder = new DirectoryInfo(Path.Combine(Settings.Default.DataFolder, @"ProjectExplorer\"));
            string sprintXmlFile  = Path.Combine(dataFolder.FullName, "sprints.xml");
            string todoXmlFile    = Path.Combine(dataFolder.FullName, "todos.xml");
            string projectXmlFile = Path.Combine(dataFolder.FullName, "projects.xml");

            SortableBindingList <Sprint>  sprints  = SortableBindingListHelper.GetBindingListFromXmlFile <Sprint>(sprintXmlFile);
            SortableBindingList <Todo>    todos    = SortableBindingListHelper.GetBindingListFromXmlFile <Todo>(todoXmlFile);
            SortableBindingList <Project> projects = SortableBindingListHelper.GetBindingListFromXmlFile <Project>(projectXmlFile);

            foreach (Project project in projects)
            {
                if (project.FilesFolder != null && project.FilesFolder.Length > 0)
                {
                    ProfileConfigItem item = new ProfileConfigItem();
                    item.app         = "explorer";
                    item.group       = project.Id;
                    item.parameter   = project.FilesFolder;
                    item.displayName = string.Format("1 {0} [Open Files Folderin Explorer]", project.ShortDescription);
                    configTextList.Add(item);
                }

                if (project.SVNRepository != null && project.SVNRepository.Length > 0)
                {
                    ProfileConfigItem item = new ProfileConfigItem();
                    item.app         = @"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe";
                    item.group       = project.Id;
                    item.parameter   = string.Format("/command:repobrowser /path:{0}", project.SVNRepository);
                    item.displayName = string.Format("1 {0} [SVN Open in Repo browser]", project.ShortDescription);

                    configTextList.Add(item);
                }

                if (project.VisualStudioSolution != null && project.VisualStudioSolution.Length > 0)
                {
                    ProfileConfigItem item = new ProfileConfigItem();
                    item.app         = @"C:\Program Files (x86)\Common7\IDE\devenv.exe";
                    item.group       = project.Id;
                    item.parameter   = project.VisualStudioSolution;
                    item.displayName = string.Format("1 {0} [Open in Visual Studio]", project.ShortDescription);

                    configTextList.Add(item);

                    FileInfo          solutionFile = new FileInfo(project.VisualStudioSolution);
                    ProfileConfigItem item2        = new ProfileConfigItem();
                    item2.app         = @"explorer";
                    item2.group       = project.Id;
                    item2.parameter   = solutionFile.DirectoryName;
                    item2.displayName = string.Format("1 {0} Visual Studio Solution Folder", project.ShortDescription);

                    configTextList.Add(item2);

                    if (solutionFile.Exists)
                    {
                        foreach (DirectoryInfo projectDirectory in solutionFile.Directory.GetDirectories())
                        {
                            DirectoryInfo debug = new DirectoryInfo(projectDirectory.FullName + @"\bin\debug");
                            if (debug.Exists)
                            {
                                ProfileConfigItem item3 = new ProfileConfigItem();
                                item3.app         = @"explorer";
                                item3.group       = project.Id;
                                item3.parameter   = debug.FullName;
                                item3.displayName = string.Format("2 Project '{1}' Debug Folder", project.ShortDescription, projectDirectory.Name);

                                configTextList.Add(item3);
                            }
                        }
                    }
                }
            }
            foreach (Sprint sprint in sprints)
            {
            }
            foreach (Todo todo in todos)
            {
                if (todo.FilesFolder != null && todo.FilesFolder.Length > 0)
                {
                    ProfileConfigItem item = new ProfileConfigItem();
                    item.app         = "explorer";
                    item.group       = todo.Id;
                    item.parameter   = todo.FilesFolder;
                    item.displayName = string.Format("1 {0} [Task Files]", todo.ShortDescription);
                    item.icon        = @"_defaulticons\folder.png";

                    configTextList.Add(item);
                }
            }


            wpfStarterComboBox1.Init(configTextList);
            wpfStarterComboBox1.SelectionChanged += WpfStarterComboBox1_SelectionChanged;


            //this.BackColor = BlackTheme.ColorDarkGray;
            this.ForeColor = BlackTheme.ColorText;
            // Apply Black Theme
            //BlackTheme.ApplyTheme(this);
        }
Esempio n. 9
0
        private ToolStripDropDown CreateDropdown(List <string> errors, ref int keyCount, ProfileConfigItem configItem)
        {
            ToolStripDropDown dropDownItem = new ToolStripDropDown();

            dropDownItem.ImageScalingSize = new Size(32, 32);
            dropDownItem.Padding          = new Padding(10, 5, 10, 5);
            dropDownItem.Renderer         = new MyRenderer(new SubMenuColorTable());
            dropDownItem.BackColor        = Settings.Default.subItemBackColor;
            foreach (var subItem in configItem.subItems)
            {
                if (subItem.displayName.StartsWith("-----"))
                {
                    ToolStripMenuItem separator = new ToolStripMenuItem();
                    separator.Text      = "_______________";
                    separator.ForeColor = Settings.Default.borderColor;
                    dropDownItem.Items.Add(separator);
                }
                else if (subItem.displayName == "startAll")
                {
                    dropDownItem.Items.Add(CreateMenuItem(iconsFolder, "Start All", "start.png", configItem.key.ToString(), startAllEventHandler, Settings.Default.subItemBackColor, Settings.Default.subItemForeColor));
                }
                else
                {
                    try
                    {
                        subItem.key = keyCount;
                        cacheAppList.Add(keyCount, subItem);
                        keyCount++;
                    }
                    catch (Exception ex)
                    {
                        errors.Add(string.Format("Wrong item. \r\nKey: '{0}', \r\nGroup: '{1}', \r\nDisplayName: '{2}'\r\n'Error: {3}'\r\n\r\n", subItem.key, subItem.group, subItem.displayName, ex.Message));
                    }
                    ToolStripMenuItem subItemMenuItem = new ToolStripMenuItem();
                    subItemMenuItem.ShowShortcutKeys = false;

                    subItemMenuItem.Text  = " " + subItem.displayName;
                    subItemMenuItem.Image = Utils.GetIconFromProfileConfigItem(subItem, iconsFolder);

                    subItemMenuItem.Tag       = subItem.key;
                    subItemMenuItem.Click    += new EventHandler(item_Click);
                    subItemMenuItem.BackColor = Settings.Default.subItemBackColor;
                    subItemMenuItem.ForeColor = Settings.Default.subItemForeColor;
                    dropDownItem.Items.Add(subItemMenuItem);
                }
            }

            return(dropDownItem);
        }