======================================== .NET Framework 3.0 Custom Control ======================================== Follow steps 1a or 1b and then 2 to use this custom control in a XAML file. Step 1a) Using this custom control in a XAML file that exists in the current project. Add this XmlNamespace attribute to the root element of the markup file where it is to be used: xmlns:MyNamespace="clr-namespace:CloseableTabItemDemo" Step 1b) Using this custom control in a XAML file that exists in a different project. Add this XmlNamespace attribute to the root element of the markup file where it is to be used: xmlns:MyNamespace="clr-namespace:CloseableTabItemDemo;assembly=CloseableTabItemDemo" You will also need to add a project reference from the project where the XAML file lives to this project and Rebuild to avoid compilation errors: Right click on the target project in the Solution Explorer and "Add Reference"->"Projects"->[Browse to and select this project] Step 2) Go ahead and use your control in the XAML file. Note that Intellisense in the XML editor does not currently work on custom controls and its child elements.
Наследование: System.Windows.Controls.TabItem
 private void CreateMenu_Click(object sender, RoutedEventArgs e)
 {
     var tabItem = new CloseableTabItem();
     tabItem.Header = "hello";
     MainTabControl.Items.Add(tabItem);
     tabItem.IsSelected = true;
 }
Пример #2
0
        public void AddTabModule(TabGenre tabG)
        {
            CloseableTabItem closeableTabItem = new CloseableTabItem();
            TabItem regularTabItem = new TabItem();
            closeableTabItem.Header = regularTabItem.Header = "swag";
            closeableTabItem.HorizontalAlignment = regularTabItem.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            closeableTabItem.VerticalAlignment = regularTabItem.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;

            switch (tabG)
            {
                case TabGenre.StartPage:
                    regularTabItem.Header = "Start Page";
                    regularTabItem.Content = new StartPage();
                    break;
            }

            if (closeableTabItem.Header != "swag")
            {
                foreach (TabItem tabb in homeTabControl.Items)
                    if (tabb.Header == closeableTabItem.Header)
                    {
                        homeTabControl.SelectedItem = tabb;
                        return;
                    }

                homeTabControl.Items.Add(closeableTabItem);
                homeTabControl.SelectedItem = closeableTabItem;
            }
            if (regularTabItem.Header != "swag")
            {
                foreach (TabItem tabb in homeTabControl.Items)
                    if (tabb.Header == regularTabItem.Header)
                    {
                        homeTabControl.SelectedItem = tabb;
                        return;
                    }

                homeTabControl.Items.Add(regularTabItem);
                homeTabControl.SelectedItem = regularTabItem;
            }
        }
Пример #3
0
        public void novaPagina(UserControl janela, String cabecalho)
        {
            Boolean achou = false;

            CloseableTabItem tabItem = new CloseableTabItem();
            tabItem.Header = cabecalho;
            tabItem.Content = janela;

            foreach (TabItem tab in CadastrosBasePrincipal.TabPrincipal.Items)
            {
                if (tab.Header == tabItem.Header)
                {
                    achou = true;
                    tab.Focus();
                }
            }

            if (!achou)
            {
                CadastrosBasePrincipal.TabPrincipal.Items.Add(tabItem);
                tabItem.Focus();
            }
        }
Пример #4
0
        public void AddTabModule(TabGenre tabG)
        {
            var tab = new CloseableTabItem
                          {
                              HorizontalAlignment = HorizontalAlignment.Stretch,
                              VerticalAlignment = VerticalAlignment.Stretch
                          };

            switch(tabG)
            {
                case TabGenre.StartPage:
                    tab.Header = new ContentControl
                    {
                        Content = "Start Page",
                        ContextMenu = BaseContextMenu
                    };
                    tab.Content = new StartPage();
                    break;
                case TabGenre.Welcome:
                    tab.Header = new ContentControl
                    {
                        Content = "Welcome",
                        ContextMenu = BaseContextMenu
                    };
                    tab.Content = new WelcomePage();
                    break;
                case TabGenre.Settings:
                    tab.Header = new ContentControl
                    {
                        Content = "Settings",
                        ContextMenu = BaseContextMenu
                    };
                    tab.Content = new SettingsPage();
                    break;
                case TabGenre.NetworkPoking:
                    tab.Header = new ContentControl
                    {
                        Content = "Network Poking",
                        ContextMenu = BaseContextMenu
                    };
                    tab.Content = new NetworkGrouping();
                    break;
                case TabGenre.PluginGenerator:
                    tab.Header = new ContentControl
                    {
                        Content = "Plugin Generator",
                        ContextMenu = BaseContextMenu
                    };
                    tab.Content = new HaloPluginGenerator();
                    break;
                case TabGenre.PluginConverter:
                    tab.Header = new ContentControl
                    {
                        Content = "Plugin Converter",
                        ContextMenu = BaseContextMenu
                    };
                    tab.Content = new HaloPluginConverter();
                    break;

                case TabGenre.MemoryManager:
                    tab.Header = new ContentControl
                    {
                        Content = "Memory Manager",
                        ContextMenu = BaseContextMenu
                    };
                    tab.Content = new MemoryManager();
                    break;
                case TabGenre.VoxelConverter:
                    tab.Header = new ContentControl
                    {
                        Content = "Voxel Converter",
                        ContextMenu = BaseContextMenu
                    };
                    tab.Content = new VoxelConverter();
                    break;
            }

            foreach (var tabb in homeTabControl.Items.Cast<TabItem>().Where(tabb => ((ContentControl)tabb.Header).Content == ((ContentControl)tab.Header).Content))
            {
                homeTabControl.SelectedItem = tabb;
                return;
            }

            homeTabControl.Items.Add(tab);
            homeTabControl.SelectedItem = tab;
        }
Пример #5
0
        /// <summary>
        /// Add a new XBox Screenshot Editor Container
        /// </summary>
        /// <param name="tempImageLocation">Path to the temporary location of the image</param>
        public void AddScrenTabModule(string tempImageLocation)
        {
            var newImageTab = new CloseableTabItem
                                  {
                                      Tag = tempImageLocation,
                                      Header = new ContentControl
                                                   {
                                                       Content = "Screenshot",
                                                       ContextMenu = BaseContextMenu
                                                   }
                                  };
            newImageTab.Content = new HaloScreenshot(tempImageLocation, newImageTab);

            homeTabControl.Items.Add(newImageTab);
            homeTabControl.SelectedItem = newImageTab;
        }
Пример #6
0
        /// <summary>
        /// Add a new Patch Control
        /// </summary>
        /// <param name="patchLocation">Path to the Patch file</param>
        public void AddPatchTabModule(string patchLocation = null)
        {
            var newInfooTab = new CloseableTabItem
                                  {
                                      Tag = patchLocation,
                                      Header = new ContentControl
                                                   {
                                                       Content = "Patcher",
                                                       ContextMenu = FilesystemContextMenu
                                                   },
                                      Content = patchLocation == null ? new PatchControl() : new PatchControl(patchLocation)
                                  };

            homeTabControl.Items.Add(newInfooTab);
            homeTabControl.SelectedItem = newInfooTab;
        }
Пример #7
0
        /// <summary>
        /// Add a new MapInfo Editor Container
        /// </summary>
        /// <param name="infooLocation">Path to the MapInfo file</param>
        public void AddInfooTabModule(string infooLocation)
        {
            // Check the map image isn't already open
            foreach (var tab in homeTabControl.Items.Cast<TabItem>().Where(tab => infooLocation == (string)tab.Tag))
            {
                // Show Message Telling user map image is already open
                MetroMessageBox.Show("Map Info Already Open!", "The selected Blam Engine File is already open in Assembly. Let us take you there now.");
                homeTabControl.SelectedItem = tab;
                return;
            }

            var newInfooTab = new CloseableTabItem
                                  {
                                      Tag = infooLocation,
                                      Header = new ContentControl
                                      {
                                          Content = "",
                                          ContextMenu = FilesystemContextMenu
                                      }
                                  };
            //newInfooTab.ToolTip = infooLocation;
            newInfooTab.Content = new HaloInfo(infooLocation, newInfooTab);

            homeTabControl.Items.Add(newInfooTab);
            homeTabControl.SelectedItem = newInfooTab;
        }
Пример #8
0
        /// <summary>
        /// Add a new Blam Cache Editor Container
        /// </summary>
        /// <param name="cacheLocation">Path to the Blam Cache File</param>
        public void AddCacheTabModule(string cacheLocation)
        {
            // Check the map isn't already open
            foreach (var tab in homeTabControl.Items.Cast<TabItem>().Where(tab => cacheLocation == (string)tab.Tag))
            {
                homeTabControl.SelectedItem = tab;
                return;
            }

            var newCacheTab = new CloseableTabItem
                                  {
                                      Tag = cacheLocation,
                                      Header = new ContentControl
                                                   {
                                                       Content = "",
                                                       ContextMenu = FilesystemContextMenu
                                                   }
                                  };
            newCacheTab.Content = new HaloMap(cacheLocation, newCacheTab, Settings.halomapTagSort);

            homeTabControl.Items.Add(newCacheTab);
            homeTabControl.SelectedItem = newCacheTab;
        }
Пример #9
0
        private void LocaleButtonClick(object sender, RoutedEventArgs e)
        {
            FrameworkElement element = (FrameworkElement)sender;
            LanguageEntry language = (LanguageEntry)element.DataContext;
            string tabName = language.Name + " Locales";
            if (IsTagOpen(tabName))
            {
                SelectTabFromTitle(tabName);
            }
            else
            {
                CloseableTabItem tab = new CloseableTabItem();
                tab.Header = tabName;
                tab.Content = new Components.Editors.LocaleEditor(_cacheFile, _mapManager, language.Index);

                contentTabs.Items.Add(tab);
                contentTabs.SelectedItem = tab;
            }
        }
Пример #10
0
        public void AddTabModule(TabGenre tabG)
        {
            var tab = new CloseableTabItem
                          {
                              HorizontalAlignment = HorizontalAlignment.Stretch,
                              VerticalAlignment = VerticalAlignment.Stretch
                          };

            switch(tabG)
            {
                case TabGenre.StartPage:
                    tab.Header = "Start Page";
                    tab.Content = new StartPage();
                    break;
                case TabGenre.Welcome:
                    tab.Header = "Welcome";
                    tab.Content = new WelcomePage();
                    break;
                case TabGenre.Settings:
                    tab.Header = "Settings Page";
                    tab.Content = new SettingsPage();
                    break;
                case TabGenre.NetworkPoking:
                    tab.Header = "Network Poking";
                    tab.Content = new NetworkGrouping();
                    break;
                case TabGenre.PluginGenerator:
                    tab.Header = "Plugin Generator";
                    tab.Content = new HaloPluginGenerator();
                    break;
                case TabGenre.Patches:
                    tab.Header = "Patch Control";
                    tab.Content = new PatchControl();
                    break;
                case TabGenre.MemoryManager:
                    tab.Header = "Memory Manager";
                    tab.Content = new MemoryManager();
                    break;
            }

            foreach (var tabb in homeTabControl.Items.Cast<TabItem>().Where(tabb => tabb.Header == tab.Header))
            {
                homeTabControl.SelectedItem = tabb;
                return;
            }

            homeTabControl.Items.Add(tab);
            homeTabControl.SelectedItem = tab;
        }
Пример #11
0
        private void ScriptButtonClick(object sender, RoutedEventArgs e)
        {
            FrameworkElement elem = e.Source as FrameworkElement;
            IScriptFile script = elem.DataContext as IScriptFile;

            var tabName = script.Name;
            if (IsTagOpen(tabName))
            {
                SelectTabFromTitle(tabName);
            }
            else
            {
                var tab = new CloseableTabItem
                              {
                                  Header = new ContentControl
                                  {
                                      Content = tabName,
                                      ContextMenu = BaseContextMenu
                                  },
                                  Content = new Components.Editors.ScriptEditor(script, _mapManager, _buildInfo.ScriptDefinitionsFilename)
                              };

                contentTabs.Items.Add(tab);
                contentTabs.SelectedItem = tab;
            }
        }
Пример #12
0
        /// <summary>
        /// Add a new BLF Editor Container
        /// </summary>
        /// <param name="imageLocation">Path to the BLF file</param>
        public void AddImageTabModule(string imageLocation)
        {
            // Check the map image isn't already open
            foreach (var tab in homeTabControl.Items.Cast<TabItem>().Where(tab => imageLocation == (string)tab.Tag))
            {
                // Show Message Telling user map image is already open
                MetroMessageBox.Show("Map Image Already Open!", "The selected Blam Engine File is already open in Assembly. Let us take you there now.");
                homeTabControl.SelectedItem = tab;
                return;
            }

            var newImageTab = new CloseableTabItem
                                  {
                                      Tag = imageLocation,
                                      Header = ""
                                  };
            newImageTab.Content = new HaloImage(imageLocation, newImageTab);

            homeTabControl.Items.Add(newImageTab);
            homeTabControl.SelectedItem = newImageTab;
        }
Пример #13
0
        public void AddFilm()
        {
            var ofd = new System.Windows.Forms.OpenFileDialog
                          {

                          };
            if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;

            var fileInfo = new FileInfo(ofd.FileName);
            var closeableTabItem = new CloseableTabItem
                                       {
                                           Header = fileInfo.Name,
                                           HorizontalAlignment = HorizontalAlignment.Stretch,
                                           VerticalAlignment = VerticalAlignment.Stretch,
                                           Content = new FilmEditor(ofd.FileName)
                                       };

            if ((string) closeableTabItem.Header == "swag") return;

            foreach (var tabb in homeTabControl.Items.Cast<TabItem>().Where(tabb => tabb.Header == closeableTabItem.Header))
            {
                homeTabControl.SelectedItem = tabb;
                return;
            }
            homeTabControl.Items.Add(closeableTabItem);
            homeTabControl.SelectedItem = closeableTabItem;
        }
Пример #14
0
        private void ScriptButtonClick(object sender, RoutedEventArgs e)
        {
            string tabName = _cacheFile.Info.InternalName.Replace("_", "__") + ".hsc";
            if (IsTagOpen(tabName))
            {
                SelectTabFromTitle(tabName);
            }
            else
            {
                CloseableTabItem tab = new CloseableTabItem();
                tab.Header = tabName;
                tab.Content = new Components.Editors.ScriptEditor(_cacheFile, _buildInfo.ScriptDefinitionsFilename);

                contentTabs.Items.Add(tab);
                contentTabs.SelectedItem = tab;
            }
        }
Пример #15
0
        private void LocaleButtonClick(object sender, RoutedEventArgs e)
        {
            var element = (FrameworkElement) sender;
            var language = (LanguageEntry) element.DataContext;
            string tabName = language.Name + " Strings";
            if (IsTagOpen(tabName))
            {
                SelectTabFromTitle(tabName);
            }
            else
            {
                var tab = new CloseableTabItem
                {
                    Header = new ContentControl
                    {
                        Content = tabName,
                        ContextMenu = BaseContextMenu
                    },
                    Content = new LocaleEditor(language.Language, _cacheFile, _mapManager, _stringIdTrie, _buildInfo.LocaleSymbols)
                };

                contentTabs.Items.Add(tab);
                contentTabs.SelectedItem = tab;
            }
        }
Пример #16
0
        private void ScriptButtonClick(object sender, RoutedEventArgs e)
        {
            var tabName = _cacheFile.InternalName.Replace("_", "__") + ".hsc";
            if (IsTagOpen(tabName))
            {
                SelectTabFromTitle(tabName);
            }
            else
            {
                var tab = new CloseableTabItem
                              {
                                  Header = new ContentControl
                                  {
                                      Content = tabName,
                                      ContextMenu = BaseContextMenu
                                  },
                                  Content = new Components.Editors.ScriptEditor(_cacheFile, _buildInfo.ScriptDefinitionsFilename)
                              };

                contentTabs.Items.Add(tab);
                contentTabs.SelectedItem = tab;
            }
        }
Пример #17
0
        private void ScriptButtonClick(object sender, RoutedEventArgs e)
        {
            var elem = e.Source as FrameworkElement;
            if (elem == null) return;
            var script = elem.DataContext as IScriptFile;
            if (script == null) return;

            string tabName = script.Name;
            if (IsTagOpen(tabName))
            {
                SelectTabFromTitle(tabName);
            }
            else
            {
                var tab = new CloseableTabItem
                {
                    Header = new ContentControl
                    {
                        Content = tabName,
                        ContextMenu = BaseContextMenu
                    },
                    Content = new ScriptEditor(_buildInfo, script, _mapManager)
                };

                contentTabs.Items.Add(tab);
                contentTabs.SelectedItem = tab;
            }
        }
Пример #18
0
        private void btnEditorsString_Click(object sender, RoutedEventArgs e)
        {
            if (IsTagOpen("StringID Viewer"))
                SelectTabFromTitle("StringID Viewer");
            else
            {
                CloseableTabItem tab = new CloseableTabItem();
                tab.Header = "StringID Viewer";
                tab.Content = new Components.Editors.StringEditor(_cacheFile);

                contentTabs.Items.Add(tab);
                contentTabs.SelectedItem = tab;
            }
        }