Ejemplo n.º 1
0
        private ToolStripDropDown CreateProfileCommandMenus(IProfileConfig profile)
        {
            var commandMenus = new ToolStripDropDown
                {
                    LayoutStyle = ToolStripLayoutStyle.Table
                };
            var columnCount = profile.MenusConfig.Menus.Count();
            ((TableLayoutSettings)commandMenus.LayoutSettings).ColumnCount = columnCount;
            var maxRowCount = profile.MenusConfig.Menus.Max(m => m.MenuItems.Count());
            var r = 0;
            var menus = profile.MenusConfig.Menus.ToArray();

            // -- profile name row
            commandMenus.Items.Add(CreateDisabledMenuItem(profile.ProfileName));
            for (var c = 0; c < columnCount - 1; ++c)
            {
                commandMenus.Items.Add(CreateDisabledMenuItem());
            }
            // --

            // -- blank row
            for (var c = 0; c < columnCount; ++c)
            {
                commandMenus.Items.Add(CreateDisabledMenuItem());
            }
            // --

            // -- menu titles
            for (var c = 0; c < columnCount; ++c)
            {
                var m = menus[c];
                commandMenus.Items.Add(CreateDisabledMenuItem(m.Title));
            }
            // --

            // -- menu items
            while (r < maxRowCount)
            {
                for (var c = 0; c < columnCount; ++c)
                {
                    var m = menus[c];
                    var menuItems = m.MenuItems.ToArray();
                    if (r < menuItems.Length)
                    {
                        var cmdConfig = menuItems[r];
                        var cmdItem = CreateCommandItem(profile.PathDirsConfig, profile.WorkingDir, cmdConfig);
                        commandMenus.Items.Add(cmdItem);
                    }
                    else
                    {
                        commandMenus.Items.Add(CreateDisabledMenuItem());
                    }
                }
                ++r;
            }
            // --

            // -- blank row
            for (var c = 0; c < columnCount; ++c)
            {
                commandMenus.Items.Add(CreateDisabledMenuItem());
            }
            // --

            // -- edit profile row
            for (var c = 0; c < columnCount - 1; ++c)
            {
                commandMenus.Items.Add(CreateDisabledMenuItem());
            }
            commandMenus.Items.Add(CreateEditProfileMenuItem(profile));
            // --

            return commandMenus;
        }
Ejemplo n.º 2
0
 private void OnEditProfile(IProfileConfig profile)
 {
     if (!File.Exists(_configData.EditorProgramPath))
         throw new ApplicationException(String.Format(
             "Editor Program Path {0} not found", _configData.EditorProgramPath));
     Process.Start(_configData.EditorProgramPath, "\"" + profile.ProfileFilePath + "\"");
 }
Ejemplo n.º 3
0
 private ToolStripMenuItem CreateEditProfileMenuItem(IProfileConfig profile)
 {
     return new ToolStripMenuItem("Edit Profile...", Images.XmlFile, (s, e) => OnEditProfile(profile));
 }