Ejemplo n.º 1
0
        public void PlaceView(ViewResult viewResult)
        {
            if (viewResult.ViewTarget == MoviesViewTargets.AdvancedSearch)
            {
                ModalViewPlacer.PlaceView(viewResult);
            }
            else
            {
                var exists = false;
                var title = GetTitleFromViewModel(viewResult.View.DataContext);
                foreach (TabItem tabItem in MainTabControl.Items)
                {
                    if (tabItem.Header.ToString() == title)
                    {
                        exists = true;
                        break;
                    }
                }

                if (!exists)
                {
                    var newTabItem = new TabItem() { Header = title, Content = viewResult.View };
                    MainTabControl.Items.Add(newTabItem);

                    newTabItem.Focus();
                }
            }
        }
Ejemplo n.º 2
0
        public void AddTab(Uri URL)
        {
            TabItem myTab = new TabItem();
            UserControlWebBrowserWindow myWebBrowserWindow = new UserControlWebBrowserWindow(myTab);

            myWebBrowserWindow.WebBrowser.Navigate(URL);

            myTab.Content = myWebBrowserWindow;
            myTab.Header = "Untitled";
            tabControlMain.Items.Add(myTab);
            myTab.Focus();
        }
Ejemplo n.º 3
0
 public TabItem AddFrame(Page _window)
 {
     TabItem tabitem = new TabItem();
     tabitem.Header = "Tab: " + _window.GetType().Name;
     Frame tabFrame = new Frame();
     _window.GetType();
     tabitem.Tag = _window.GetType().Name;
     tabFrame.Content = _window;
     tabitem.Content = tabFrame;
     TabControl.Items.Add(tabitem);
     tabitem.Focus();
     return tabitem;
 }
        private void AddNewTab()
        {
            if (MainTabControl.Items.Count > 99)
            {
                MessageBox.Show("You open many tabs. Please close unnecessary.");
                return;
            }

            TabItem newTab = new TabItem();
            newTab.Header = GetTabItemName(MainTabControl);
            newTab.Content = new RegexTesterPage();
            MainTabControl.Items.Add(newTab);
            Dispatcher.BeginInvoke(new Action(() => { newTab.Focus(); }));
        }
Ejemplo n.º 5
0
        bool checkSetting(bool result, TextBox textBox, string message, TabItem tab = null)
        {
            if (!result) {
                MessageBox.Show(message, resources["Connect"] as string, MessageBoxButton.OK, MessageBoxImage.Warning);
                if (tab != null) tab.Focus();
                new Action(() => {
                    Dispatcher.BeginInvoke(new Action(() => {
                        textBox.SelectAll();
                        textBox.Focus();
                    }));
                }).BeginInvoke(null, null);
            }

            return result;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// This is the method that responds to the KeyDown event.
        /// </summary>
        /// <param name="e">
        /// A <see cref="T:System.Windows.Input.KeyEventArgs" /> that contains
        /// the event data.
        /// </param>
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);
            if (e.Handled)
            {
                return;
            }

            // Some keys (e.g. Left/Right) need to be translated in RightToLeft mode
            Key invariantKey = InteractionHelper.GetLogicalKey(FlowDirection, e.Key);

            TabItem nextTabItem = null;

            int direction  = 0;
            int startIndex = TabControlParent.Items.IndexOf(this);

            switch (invariantKey)
            {
            case Key.Right:
            case Key.Down:
                direction = 1;
                break;

            case Key.Left:
            case Key.Up:
                direction = -1;
                break;

            default:
                return;
            }

            nextTabItem = TabControlParent.FindNextTabItem(startIndex, direction);

            if (nextTabItem != null && nextTabItem != TabControlParent.SelectedItem)
            {
                e.Handled = true;
                TabControlParent.SelectedItem = nextTabItem;
                nextTabItem.Focus();
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// This is the method that responds to the KeyDown event.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);
            if (e.Handled)
            {
                return;
            }

            TabItem nextTabItem = null;

            int direction  = 0;
            int startIndex = TabControlParent.Items.IndexOf(this);

            switch (e.Key)
            {
            case Key.Right:
            case Key.Up:
                direction = 1;
                break;

            case Key.Left:
            case Key.Down:
                direction = -1;
                break;

            default:
                return;
            }

            nextTabItem = TabControlParent.FindNextTabItem(startIndex, direction);

            if (nextTabItem != null && nextTabItem != TabControlParent.SelectedItem)
            {
                e.Handled = true;
                TabControlParent.SelectedItem = nextTabItem;
                nextTabItem.Focus();
            }
        }
Ejemplo n.º 8
0
        private void HandleShowView(ShowViewMessage args)
        {
            var viewFactory = ComponentContainer.Container.Resolve<IViewFactory>();
            var viewResult = viewFactory.Build(args.ViewTarget, args.LoadArgs);

            var exists = false;
            foreach (TabItem tabItem in _MainTabControl.Items)
            {
                if (tabItem.Header.ToString() == viewResult.Title)
                {
                    exists = true;
                    break;
                }
            }

            if (!exists)
            {
                var newTabItem = new TabItem() { Header = viewResult.Title, Content = viewResult.View };
                _MainTabControl.Items.Add(newTabItem);

                newTabItem.Focus();
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// This is the method that responds to the KeyDown event.
        /// </summary>
        /// <param name="e">Data used by the event.</param>
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);
            if (e.Handled)
            {
                return;
            }
            TabItem nextTabItem = null;

            int direction  = 0;
            int startIndex = -1;

            switch (e.Key)
            {
            case Key.Home:
                direction  = 1;
                startIndex = -1;
                break;

            case Key.End:
                direction  = -1;
                startIndex = Items.Count;
                break;

            default:
                return;
            }

            nextTabItem = FindNextTabItem(startIndex, direction);

            if (nextTabItem != null && nextTabItem != SelectedItem)
            {
                e.Handled    = true;
                SelectedItem = nextTabItem;
                nextTabItem.Focus();
            }
        }
Ejemplo n.º 10
0
        private void DisplayMessage(string message)
        {
            var fkColor = cfg.GetSolidBrush("gui.sql.result.message.Foreground", Colors.White);
            var bkColor = cfg.GetSolidBrush("gui.sql.result.message.Background", Colors.Black);

            var tab = new TabItem
            {
                Header = "Messages",
                Content = new TextBox
                {
                    Text = message,
                    Foreground = fkColor,
                    Background = bkColor,
                    IsReadOnly = true,
                    TextWrapping = TextWrapping.Wrap,
                    AcceptsReturn = true
                }
            };

            tabControl.Items.Add(tab);
            tab.Focus();
        }
Ejemplo n.º 11
0
        private void Plus_click(object sender, System.Windows.RoutedEventArgs e)
        {
            WebBrowser wb = new WebBrowser();
            wb.Source = new Uri(homepage);
            wb.LoadCompleted += new LoadCompletedEventHandler(Browser_loadCompleted);

            TabItem tab = new TabItem();
            tab.Content = wb;
            tabControl.Items.Add(tab);
            tab.Focus();

            ongletControl oc = new ongletControl();
            oc.TabUI = tabControl;
            oc.TabIndex = tabControl.Items.Count -1;
            uniformGrid.Children.Add(oc);
        }
Ejemplo n.º 12
0
        private void ItemsListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            {
                if (ItemsListBox.SelectedItem != null)
                {
                    TabItem ti = new TabItem();
                    var found = loti.FindIndex(x => x.Header == ItemsListBox.SelectedItem.ToString());
                    if (found < 0)
                    {
                        loti.Add(ti);
                        ti.Header = ItemsListBox.SelectedItem.ToString();

                        ScrollViewer sV = new ScrollViewer();
                        sV.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;

                        ContextMenu cM = new ContextMenu();
                        MenuItem mI = new MenuItem();
                        mI.Name = "CloseTab";
                        mI.Header = "Close";
                        var er = new RoutedEventArgs();
                        mI.Click += new RoutedEventHandler(ContextMenuClickEventHandler);
                        cM.Items.Add(mI);
                        ti.ContextMenu = cM;
                        Room.Items.Add(ti);
                        ti.Focus();

                    }
                    else
                    {
                        loti[found].Focus();
                    }
                }
            }
        }
Ejemplo n.º 13
0
        private void OpenDatabase(string journalFile)
        {
            try {
                var db = new DBController(journalFile, _factories);

                var tab = new TabItem();
                tab.Header = System.IO.Path.GetDirectoryName(journalFile).Split('\\').Last();

                var ctxMenu = new ContextMenu();
                var menuItem = new MenuItem();
                menuItem.Header = "Close " + tab.Header;
                menuItem.Click += new RoutedEventHandler((object sender, RoutedEventArgs e) => {
                    ((DataViewControl)tab.Content).Close();
                    tabControl.Items.Remove(tab);
                });
                ctxMenu.Items.Add(menuItem);
                tab.ContextMenu = ctxMenu;

                var control = new DataViewControl { DBController = db };
                tab.Content = control;
                tabControl.Items.Add(tab);
                tab.Focus();
            } catch (Exception ex) {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
        }
Ejemplo n.º 14
0
        private void item_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var definition = ((sender as TreeViewItem).Tag as ExpressionDefinition);

            var instanceVM = new ExpressionInstanceVM(definition);
            var control = new ExpressionControl {DataContext = instanceVM};
            var item = new TabItem
            {
                Tag = definition.Name,
                Header = definition.Name,
                Content = control
            };

            EventHandler closeHandler = null;
            closeHandler = (o, ea) =>
                               {
                                   tabControl.Items.Remove(item);
                                   instanceVM.CloseRequested -= closeHandler;
                               };
            instanceVM.CloseRequested += closeHandler;

            tabControl.Items.Add(item);
            item.Focus();
        }