Пример #1
0
        public void SelectedAssociationChanged(Class.TopApplication selectedApplication)
        {
            if (IsAssociationNew)
            {
                // Create new association and add a new parameter
                Class.Association association = CreateNewAssociation(selectedApplication);
                //Class.Parameter parameter = CreateNewParameter();

                //association.Parameters.Add(parameter);

                //// Add new association to the SelectedItem's association collection
                //SelectedItem.Associations.Add(association);

                // Make the new assoication the SelectedAssociation
                SelectedAssociation = association;
            }

            AvailableExistingAssociationCollection = new ObservableCollection <Association>();
            foreach (var association in ExistingAssociationCollection)
            {
                if (association.Name == selectedApplication.Name)
                {
                    AvailableExistingAssociationCollection.Add(association);
                }
            }
        }
Пример #2
0
        private void ChangeListViewItem_Click(object sender, RoutedEventArgs e)
        {
            Button b = (Button)sender;

            Class.ContextMenu cm = b.DataContext as Class.ContextMenu;

            if (cm != null)
            {
                switch (b.Tag.ToString())
                {
                case "Edit":
                    vm.SelectedContextMenu = cm;
                    break;

                case "Delete":
                    vm.DeleteContextMenu(cm);
                    break;

                default:
                    break;
                }
            }
            else
            {
                Class.Association association = b.DataContext as Class.Association;

                if (association != null)
                {
                    switch (b.Tag.ToString())
                    {
                    case "Edit":
                        //vm.SelectedAssociation = association;
                        vm.EditAssociation(false, association);
                        break;

                    case "Delete":
                        vm.DeleteAssociation(association);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Пример #3
0
        public void EditAssociation(bool isNew, Class.Association existingAssociation)
        {
            IsAssociationNew = isNew;

            if (isNew)
            {
                SelectedAssociation             = new Association();
                AvailableApplicationsCollection = new ObservableCollection <TopApplication>();

                if (EditedItem.Associations.Any())
                {
                    foreach (var app in ApplicationsCollection)
                    {
                        if (EditedItem.Associations.Any((a) => a.Name != app.Name))
                        {
                            AvailableApplicationsCollection.Add(app);
                        }
                    }
                }
                else
                {
                    foreach (var a in ApplicationsCollection)
                    {
                        AvailableApplicationsCollection.Add(a);
                    }
                }
            }
            else
            {
                SelectedAssociation             = existingAssociation;
                AvailableApplicationsCollection = new ObservableCollection <TopApplication>();
                SelectedApplication             = ApplicationsCollection.First((a) => a.Name == existingAssociation.Name);
                AvailableApplicationsCollection.Add(SelectedApplication);
            }

            SetViewVisibility(showEditAssociation: true);
        }
Пример #4
0
 public void DeleteAssociation(Class.Association association)
 {
     EditedItem.Associations.Remove(association);
 }