public void AddNewItem(ISecureItemVM secureItem)
        {
            //if (secureItem is SecureItemWithCountryViewModel)
            //{
            //    ((SecureItemWithCountryViewModel)secureItem).Countries = new ObservableCollection<KeyValuePair<string, string>>(pbData.GetCountries());

            //    string country = pbData.GetPrivateSetting(DefaultProperties.Settings_Country);
            //    if (String.IsNullOrEmpty(country))
            //    {
            //        pbData.ChangePrivateSetting(DefaultProperties.Settings_Country, DefaultProperties.Settings_DefaultCountryCode);
            //        country = DefaultProperties.Settings_DefaultCountryCode;
            //    }
            //     ((SecureItemWithCountryViewModel)secureItem).SelectedCountry = ((SecureItemWithCountryViewModel)secureItem).Countries.FirstOrDefault(x => x.Key == country);
            //}



            //AddSecureItemWindow addWindow = new AddSecureItemWindow(Application.Current.Resources["SNSecureItemTemplateSelector"] as DataTemplateSelector) { Title = secureItem.ItemTitel };
            //addWindow.DataContext = secureItem;
            //bool? dialogResult = addWindow.ShowDialog();
            //if (dialogResult.Value)
            //{

            //}
        }
Beispiel #2
0
        public void AddSecureItem(ISecureItemVM newItem)
        {
            if (!ChildList.Any() || !(ChildList.First() is SecureItemsView))
            {
                ChildList.Insert(0, SecureItemsView);
            }

            SecureItemsView.SecureList.Add(newItem);
            RaisePropertyChanged("Count");
        }
        private void SetCountriesValue(ISecureItemVM secureItem, bool setDefaulCountry = true)
        {
            SecureItemWithCountryViewModel countrySecureItem = secureItem as SecureItemWithCountryViewModel;

            if (countrySecureItem != null)
            {
                countrySecureItem.Countries = new ObservableCollection <Country>(pbData.GetCountryList());
                if (setDefaulCountry)
                {
                    SetDefaultCountry(countrySecureItem);
                }
            }
        }
Beispiel #4
0
        public void RemoveSecureItem(ISecureItemVM item)
        {
            if (ChildList.Any() && ChildList.First() is SecureItemsView)
            {
                if (SecureItemsView.SecureList.FirstOrDefault(x => x.Id == item.Id) != null)
                {
                    SecureItemsView.SecureList.Remove(SecureItemsView.SecureList.FirstOrDefault(x => x.Id == item.Id));
                    if (!SecureItemsView.SecureList.Any())
                    {
                        ChildList.Remove(SecureItemsView);
                    }
                }
            }

            RaisePropertyChanged("ChildList");
            RaisePropertyChanged("Count");
        }
        public void AddNewItem(ISecureItemVM secureItem)
        {
            if (secureItem == null)
            {
                return;
            }
            SetCountriesValue(secureItem);

            AddSecureItemWindow addWindow = new AddSecureItemWindow(CurrentDataTemplateSelector)
            {
                Title = secureItem.ItemTitel
            };

            addWindow.DataContext = secureItem;
            addWindow.Closing    += (o, args) =>
            {
                if (addWindow.DialogResult == null)
                {
                    args.Cancel = true;
                }

                if (addWindow.DialogResult.HasValue && addWindow.DialogResult.Value)
                {
                    args.Cancel = !secureItem.Validate();
                }
            };
            bool?dialogResult = addWindow.ShowDialog();

            if (dialogResult.Value)
            {
                if (SaveItem(secureItem.CreateSecureItem()))
                {
                    RefreshData();
                }
            }
        }
 public void AddItemToCategory(ISecureItemVM item)
 {
     Items.Add(item);
     RaisePropertyChanged("Items");
     RaisePropertyChanged("Count");
 }