Beispiel #1
0
 void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "ActiveDocument")
     {
         if (ActiveDocument is GridView)
         {
             if (!OtherCommands.Contains(GridModel))
             {
                 OtherCommands.Remove(HelpModel);
                 OtherCommands.Add(GridModel);
                 OtherCommands.Add(HelpModel);
                 OtherToolbarCommands = GridModel.Commands;
                 OtherCommands.Remove(ChartModel);
                 OtherCommands.Remove(Chart1Model);
             }
         }
         else
         {
             if (!OtherCommands.Contains(ChartModel))
             {
                 OtherCommands.Remove(HelpModel);
                 OtherCommands.Add(ChartModel);
                 OtherToolbarCommands = ChartModel.Commands;
                 OtherCommands.Add(Chart1Model);
                 OtherCommands.Remove(GridModel);
                 OtherCommands.Add(HelpModel);
             }
         }
     }
     else if (e.PropertyName == "IsChecked")
     {
         if (checkedModel != null)
         {
             checkedModel.IsChecked = false;
         }
         checkedModel = sender as CommandModel;
     }
 }
Beispiel #2
0
        public ViewModel()
        {
            this.Products = new ObservableCollection <ChartModel>();
            Random rndm = new Random();

            Products.Add(new ChartModel()
            {
                ProductId = 1, ProductName = "Rice", Price2000 = rndm.Next(5, 40), Price2010 = rndm.Next(10, 60)
            });
            Products.Add(new ChartModel()
            {
                ProductId = 2, ProductName = "Wheat", Price2000 = rndm.Next(5, 80), Price2010 = rndm.Next(10, 60)
            });
            Products.Add(new ChartModel()
            {
                ProductId = 1, ProductName = "Oil", Price2000 = rndm.Next(5, 60), Price2010 = rndm.Next(10, 60)
            });
            Products.Add(new ChartModel()
            {
                ProductId = 4, ProductName = "Corn", Price2000 = rndm.Next(5, 40), Price2010 = rndm.Next(10, 60)
            });
            Products.Add(new ChartModel()
            {
                ProductId = 5, ProductName = "Gram", Price2000 = rndm.Next(5, 40), Price2010 = rndm.Next(10, 60)
            });
            Products.Add(new ChartModel()
            {
                ProductId = 6, ProductName = "Milk", Price2000 = rndm.Next(5, 90), Price2010 = rndm.Next(10, 60)
            });
            Products.Add(new ChartModel()
            {
                ProductId = 7, ProductName = "Butter", Price2000 = rndm.Next(5, 40), Price2010 = rndm.Next(10, 60)
            });
            Products.Add(new ChartModel()
            {
                ProductId = 8, ProductName = "Oil", Price2000 = rndm.Next(5, 60), Price2010 = rndm.Next(10, 60)
            });


            FileCommands   = new ObservableCollection <CommandModel>();
            WindowCommands = new ObservableCollection <CommandModel>();

            FileCommands.Add(new CommandModel()
            {
                Name = "New Product Details", Icon = "/Images/NewDocumentHS.png", Command = NewGridCommand
            });
            FileCommands.Add(new CommandModel()
            {
                Name = "New product Statistics", Icon = "/Images/graphhs.png", Command = NewChartCommand
            });
            FileCommands.Add(new CommandModel()
            {
                Name = "Open", Icon = "/Images/openfolderHS.png"
            });
            FileCommands.Add(new CommandModel()
            {
                Name = "Exit", Icon = "/Images/DeleteHS.png"
            });

            WindowCommands.Add(new CommandModel()
            {
                Name = "Cascade", Icon = "/Images/CascadeWindowsHS.png", Command = TileCascade, IsCheckable = true
            });
            WindowCommands.Add(new CommandModel()
            {
                Name = "Tile Horizontally", Icon = "/Images/ArrangeWindowsHS.png", Command = TileHorizontal, IsCheckable = true
            });
            WindowCommands.Add(new CommandModel()
            {
                Name = "Tile Vertically", Icon = "/Images/ArrangeSideBySideHS.png", Command = TileVertical, IsCheckable = true
            });

            WindowCommands[0].PropertyChanged += new PropertyChangedEventHandler(ViewModel_PropertyChanged);
            WindowCommands[1].PropertyChanged += new PropertyChangedEventHandler(ViewModel_PropertyChanged);
            WindowCommands[2].PropertyChanged += new PropertyChangedEventHandler(ViewModel_PropertyChanged);

            ChartModel = new CommandModel()
            {
                Name = "Chart View"
            };
            ChartModel.Commands.Add(new CommandModel()
            {
                Name = "New Statistics", Icon = "/Images/graphhs.png", Command = NewCommand
            });
            ChartModel.Commands.Add(new CommandModel()
            {
                Name = "Refresh Chart", Icon = "/Images/RepeatHS.png", Command = NewCommand
            });
            ChartModel.Commands.Add(new CommandModel()
            {
                Name = "Publish Data", Icon = "/Images/PublishToWebHS.png", Command = NewCommand
            });
            ChartModel.Commands.Add(new CommandModel()
            {
                Name = "Close View", Icon = "/Images/DeleteHS.png", Command = NewCommand
            });

            Chart1Model = new CommandModel()
            {
                Name = "Customize Chart"
            };
            Chart1Model.Commands.Add(new CommandModel()
            {
                Name = "Change Chart Type", Icon = "/Images/PieChartHS.png", Command = NewCommand
            });
            Chart1Model.Commands.Add(new CommandModel()
            {
                Name = "Add Series", Icon = "/Images/AlignObjectsBottomHS.png", Command = NewCommand
            });

            this.PropertyChanged += new PropertyChangedEventHandler(ViewModel_PropertyChanged);

            GridModel = new CommandModel()
            {
                Name = "Grid View"
            };
            GridModel.Commands.Add(new CommandModel()
            {
                Name = "New Payroll", Icon = "/Images/NewReportHS.png", Command = NewCommand
            });
            GridModel.Commands.Add(new CommandModel()
            {
                Name = "Refresh Grid", Icon = "/Images/RepeatHS.png", Command = NewCommand
            });
            GridModel.Commands.Add(new CommandModel()
            {
                Name = "Close View", Icon = "/Images/DeleteHS.png", Command = NewCommand
            });

            OtherCommands        = new ObservableCollection <CommandModel>();
            OtherToolbarCommands = new ObservableCollection <CommandModel>();
        }