示例#1
0
        /// <summary>
        /// We initialize here the necessary data what is needed to the view. The Buttons commands, the foods .
        /// </summary>
        void Initialize()
        {
            var databasehelper = DatabaseHelperProxy.getInstance();

            Meats = databasehelper.GetFoodsByType("meat");
            SelectedMeatCommand    = new RelayCommand(MeatSelected, param => this.canExecute);
            ScrollerToLeftCommand  = new RelayCommand(ScrollerToLeft, param => this.canExecute);
            ScrollerToRightCommand = new RelayCommand(ScrollerToRight, param => this.canExecute);
            toggleExecuteCommand   = new RelayCommand(ChangeCanExecute);
        }
        /// <summary>
        /// We initialize here the necessary data what is needed to the view. The Buttons commands, the foods .
        /// </summary>
        private void Initialize()
        {
            var dataaccess = DatabaseHelperProxy.getInstance();

            Doughs = dataaccess.GetFoodsByType("dough");
            SelectedDoughCommand   = new RelayCommand(DoughSelected, param => this.canExecute);
            ScrollerToLeftCommand  = new RelayCommand(ScrollerToLeft, param => this.canExecute);
            ScrollerToRightCommand = new RelayCommand(ScrollerToRight, param => this.canExecute);
            toggleExecuteCommand   = new RelayCommand(ChangeCanExecute);
        }
示例#3
0
        /// <summary>
        /// We initialize here the necessary data what is needed to the view. The Buttons commands, the foods .
        /// </summary>
        private void Initialize()
        {
            var databasehelper = DatabaseHelperProxy.getInstance();

            Toppings = databasehelper.GetFoodsByType("topping");
            ScrollerToLeftCommand  = new RelayCommand(ScrollerToLeft, param => this.canExecute);
            ScrollerToRightCommand = new RelayCommand(ScrollerToRight, param => this.canExecute);
            toggleExecuteCommand   = new RelayCommand(ChangeCanExecute);
            ToppingSelectedCommand = new RelayCommand(ToppingSelected, param => this.canExecute);
            ToppingRemoveCommand   = new RelayCommand(RemoveTopping, param => this.canExecute);
        }
示例#4
0
 /// <summary>
 /// First gives back a placeholder picture for enhance the speed of the view load. When its downloaded the picture notifys the view to changed the placeholder.
 /// </summary>
 protected override void CreateBitMapImage()
 {
     try {
         var image = new BitmapImage();
         lock (lockobj) {
             if (food == null)
             {
                 if (!retrieving)
                 {
                     retrieving = true;
                     image.BeginInit();
                     image.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
                     image.CacheOption   = BitmapCacheOption.OnLoad;
                     image.UriSource     = new Uri(Directory.GetCurrentDirectory() + @"\imgs\imgicon.png", UriKind.Relative);
                     image.EndInit();
                     image.Freeze();
                     Picture = image;
                     Task.Factory.StartNew(() =>
                     {
                         food = new Food();
                         var databasehelper = DatabaseHelperProxy.getInstance();
                         food.RawPicture    = databasehelper.GetRawPicture(Id);
                         CreateBitMapImage();
                     });
                 }
             }
             else
             {
                 using (var mem = new MemoryStream(food.RawPicture))
                 {
                     mem.Position = 0;
                     image.BeginInit();
                     image.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
                     image.CacheOption   = BitmapCacheOption.OnLoad;
                     image.UriSource     = null;
                     image.StreamSource  = mem;
                     image.EndInit();
                     mem.Close();
                 }
                 image.Freeze();
                 Picture = image;
             }
         }
         NotifyOfPropertyChange(() => Picture);
     }
     catch (Exception e)
     {
         var logger = LogHelper.getInstance();
         logger.Log(Logging.LogType.DbLog, this.GetType().ToString(), "CreateBitMapImage", e.Message);
     }
 }