Esempio n. 1
0
        public IEnumerable Handle(CloseTabCommand c)
        {
            if (c.AmountPaid < _serveredItemsValue)
            {
                throw new NotEnoughPaid();
            }

            if (!_tabOpen)
            {
                throw new TabNotOpen();
            }

            if (_outstandingDrinks.Any() || _outstandingFood.Any() || _preparedFood.Any())
            {
                throw new TabHasUnservedItems();
            }

            yield return(new TabClosed
            {
                Id = c.Id,
                AmountPaid = c.AmountPaid,
                OrderValue = _serveredItemsValue,
                TipValue = c.AmountPaid - _serveredItemsValue
            });
        }
Esempio n. 2
0
        void closeButton_Click(object sender, RoutedEventArgs e)
        {
            //Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=InternalCloseTabCommand
            // Click event fires BEFORE the command does so we have time to set and handle the event before hand.

            if (CloseTabCommand != null)
            {
                // force the command handler to run
                CloseTabCommand.Execute(CloseTabCommandParameter);
                // cheat and dereference the handler now
                CloseTabCommand          = null;
                CloseTabCommandParameter = null;
            }

            if (OwningTabControl == null) // see #555
            {
                throw new InvalidOperationException();
            }

            // run the command handler for the TabControl
            var itemFromContainer = OwningTabControl.ItemContainerGenerator.ItemFromContainer(this);

            var data = itemFromContainer == DependencyProperty.UnsetValue ? this.Content : itemFromContainer;

            OwningTabControl.InternalCloseTabCommand.Execute(new Tuple <object, MetroTabItem>(data, this));
        }
Esempio n. 3
0
        internal void RemoveAllTabs(object exceptThis = null)
        {
            var objects = this.ItemsSource.Cast <object>().Where(x => x != exceptThis).ToList();

            foreach (object obj in objects)
            {
                CloseTabCommand.Execute(obj);
            }
        }
Esempio n. 4
0
        internal void RemoveTab(object tab)
        {
            ChromeTabItem removeItem = this.AsTabItem(tab);

            if (CloseTabCommand != null)
            {
                CloseTabCommand.Execute(removeItem.DataContext);
            }
        }
Esempio n. 5
0
        private void ToolbarButton_Click(object sender, RoutedEventArgs e)
        {
            try {
                switch ((sender as FrameworkElement).Tag.ToString().Replace("toolbar.", ""))
                {
                case "new":
                    NewFileCommand.Execute(null);
                    break;

                case "open":
                    OpenFileCommand.Execute(null);
                    break;

                case "save":
                    SaveFileCommand.Execute(null);
                    break;

                case "cut":
                    CutCommand.Execute(null);
                    break;

                case "copy":
                    CopyCommand.Execute(null);
                    break;

                case "paste":
                    PasteCommand.Execute(null);
                    break;

                case "build":
                    BuildRunCommand.Execute(false);
                    break;

                case "buildrun":
                    BuildRunCommand.Execute(true);
                    break;

                case "close":
                    CloseTabCommand.Execute(null);
                    break;
                }
            } catch (Exception ex) {
                Debug.Fail(ex.Message);
            }
        }
Esempio n. 6
0
        private TabItem CreateNewTabInternal(String header)
        {
            Tree treeView = new Tree();

            treeView.SelectedItemChanged += OnTreeViewSelectedItemChanged;

            TabItem tabItem = new TabItem {
                Header = header
            };

            tabItem.Content = treeView;

            ContextMenu   contextMenu   = new ContextMenu();
            FilterCommand filterCommand = new FilterCommand(this, treeView);

            contextMenu.Items.Add(new MenuItem {
                Header = "Filter", Command = filterCommand
            });

            if (_tabControl.Items.Count > 0)
            {
                CloseTabCommand closeTabCommand = new CloseTabCommand(_tabControl, tabItem);

                contextMenu.Items.Add(new MenuItem {
                    Header = "Close", Command = closeTabCommand
                });

                tabItem.MouseDown += (s, e) =>
                {
                    if (e.ChangedButton == MouseButton.Middle && e.ButtonState == MouseButtonState.Pressed)
                    {
                        closeTabCommand.Execute(null);
                    }
                };
            }

            tabItem.ContextMenu = contextMenu;

            _tabControl.Items.Add(tabItem);
            _tabControl.SelectedItem = tabItem;
            tabItem.Focus();

            return(tabItem);
        }
Esempio n. 7
0
 private void OnFormClosed(object sender, FormClosedEventArgs e)
 {
     CloseTabCommand.Execute(null);
 }