コード例 #1
0
        private void _Reset()
        {
            var promptRequired = App.Settings.PromptBeforeClear && UnitPrices.Any(x => x.Model.Price != 0 || x.Model.Volume != 0);

            if (promptRequired && MessageBox.Show(AppResources.MSG_ResetCurrentPrices, AppResources.Title_Reset, MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
            {
                return;
            }

            UnitPrices = new UnitPriceCollectionViewModel
            {
                new UnitPriceViewModel
                {
                    GetFocusWhenLoaded = true
                },
                new UnitPriceViewModel()
            };
        }
コード例 #2
0
        public void LoadStateFromIsolatedStorage()
        {
            var collectionViewModel = new UnitPriceCollectionViewModel();

            try
            {
                var prices = new IsolatedStorageSerializer <UnitPrice[]>().ReadObject(STATE_FILE);
                collectionViewModel.Add(prices);
            }
            catch (Exception)
            {
                collectionViewModel.Add(new UnitPriceViewModel());
                collectionViewModel.Add(new UnitPriceViewModel());
            }

            var zero = collectionViewModel.FirstOrDefault(x => x.Model.Price == 0 && x.Model.Volume == 0);

            if (zero != null)
            {
                zero.GetFocusWhenLoaded = true;
            }

            UnitPrices = collectionViewModel;
        }