コード例 #1
0
        private void ProductWindowLoaded(object sender, RoutedEventArgs e)
        {
            ResourceDictionary resource = new ResourceDictionary()
            {
                Source = new Uri("view\\products\\ReadonlyProductDictionary.xaml", UriKind.Relative)
            };

            View.Resources.MergedDictionaries.Clear();
            View.Resources.MergedDictionaries.Add(resource);


            foreach (var textBox in ChildFinder.FindVisualChildren <TextBox>(View))
            {
                textBox.Style = resource["BoxStyle"] as Style;
                if (textBox.Text.Length == 0)
                {
                    textBox.Text = "-";
                }
            }
            foreach (var comboBox in ChildFinder.FindVisualChildren <ComboBox>(View))
            {
                comboBox.Visibility = Visibility.Collapsed;
            }
            foreach (var textblock in ChildFinder.FindVisualChildren <TextBlock>(View))
            {
                textblock.Visibility = Visibility.Visible;
            }
            foreach (var button in ChildFinder.FindVisualChildren <Button>(View))
            {
                button.Visibility = Visibility.Collapsed;
            }
        }
コード例 #2
0
 private void TreeItemExecute(object sender, RoutedEventArgs e)
 {
     foreach (var item in ChildFinder.FindVisualChildren <TreeViewItem>(AdminMenu))
     {
         item.IsSelected = false;
     }
     (DataContext as MainWindowViewModel).TreeItemExecute();
 }
コード例 #3
0
        private void AdminToolsSelectedItemChanged(object sender, RoutedEventArgs e)
        {
            foreach (var item in ChildFinder.FindVisualChildren <TreeViewItem>(Tree))
            {
                item.IsSelected = false;
            }
            string tool = (sender as TreeViewItem).Header.ToString();

            (DataContext as MainWindowViewModel).SelectAdminTool(tool);
        }
コード例 #4
0
        public void UpdateButtons()
        {
            Order order = MainVM.Customer.Order.FirstOrDefault(ord => ord.State == State.Created);

            if (order != null)
            {
                if (MainVM.Customer.Role == model.enums.Role.User)
                {
                    foreach (Button button in ChildFinder.FindVisualChildren <Button>(View.ProductList))
                    {
                        if (order.Ordered.FirstOrDefault(ord => ord.Product.Id == ((Product)button.DataContext).Id) != null && MainVM.Customer.Role == model.enums.Role.User)
                        {
                            button.IsEnabled = false;
                            button.Content   = "В корзине";
                        }
                        else if (((Product)button.DataContext).Amount <= 0)
                        {
                            button.IsEnabled = false;
                            button.Content   = "Нет на складе";
                        }
                        else
                        {
                            button.IsEnabled = true;
                            button.Content   = "В корзину";
                        }
                    }
                }
                else
                {
                    foreach (Button button in ChildFinder.FindVisualChildren <Button>(View.ProductList))
                    {
                        button.Visibility = Visibility.Collapsed;
                    }
                }
            }
        }