コード例 #1
0
        public TraitElementControl(User user, TraitViewModel model, TraitCategoryType categoryType)
        {
            this.Model  = model;
            DataContext = model;
            InitializeComponent();
            txtValue.BindUser(user, PickListType.DistinctTraitList, model.Name, categoryType);
            if (!String.IsNullOrEmpty(model.Comment))
            {
                commentLink.Inlines.Clear();
                commentLink.Inlines.Add(new Run("Edit comment"));
            }

            Model.DataChanged += new DataChangedHandler((vm) => {
                FireTraitChanged();
            });
        }
コード例 #2
0
        private void AddTraitEditor(TraitViewModel model)
        {
            var itemControl = new TraitElementControl(User, model, TraitCategory);

            itemControl.TraitChanged += new TraitElementControl.TraitEventHandler((source, trait) => {
                RegisterUniquePendingChange(new UpdateTraitDatabaseCommand(trait.Model, Owner));
            });

            itemControl.TraitDeleted += new TraitElementControl.TraitEventHandler((source, trait) => {
                _model.Remove(trait);
                ReloadTraitPanel();
                RegisterPendingChange(new DeleteTraitDatabaseCommand(trait.Model, Owner));
            });

            itemControl.IsReadOnly = this.IsReadOnly;

            traitsPanel.Children.Add(itemControl);
        }
コード例 #3
0
 private void SelectTrait(TraitViewModel vm)
 {
     // find the trait editor for the selected trait...
     foreach (TraitElementControl ctl in traitsPanel.Children)
     {
         if (ctl.Model == vm)
         {
             if (!ctl.txtValue.IsLoaded)
             {
                 ctl.txtValue.txt.Loaded += new RoutedEventHandler((source, e) => {
                     Keyboard.Focus(ctl.txtValue.txt);
                 });
             }
             else
             {
                 Keyboard.Focus(ctl.txtValue.txt);
             }
             return;
         }
     }
 }
コード例 #4
0
        private void AddNewTrait()
        {
            var service = new SupportService(User);

            List <String> traitTypes = service.GetTraitNamesForCategory(TraitCategory.ToString());

            var picklist = new PickListWindow(User, "Choose a trait type...", () => {
                return(traitTypes);
            }, (text) => {
                traitTypes.Add(text);
                return(true);
            });

            picklist.Owner = this.FindParentWindow();
            if (picklist.ShowDialog().ValueOrFalse())
            {
                var existing = FindTraitByName(picklist.SelectedValue as string);
                if (existing == null)
                {
                    Trait t = new Trait();
                    t.TraitID    = -1;
                    t.Value      = "<New Trait Value>";
                    t.Category   = TraitCategory.ToString();
                    t.IntraCatID = Owner.ObjectID.Value;
                    t.Name       = picklist.SelectedValue as string;

                    TraitViewModel viewModel = new TraitViewModel(t);
                    _model.Add(viewModel);
                    RegisterUniquePendingChange(new UpdateTraitDatabaseCommand(t, Owner));
                    ReloadTraitPanel();

                    SelectTrait(viewModel);
                }
                else
                {
                    SelectTrait(existing);
                }
            }
        }