Esempio n. 1
0
        private void Edit_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            NumberAddressWindow numberAddressWindow = new NumberAddressWindow((Values.SelectedItem as TextBlock).Text);

            if ((bool)numberAddressWindow.ShowDialog(this))
            {
                long selectedValueId = (long)(Values.SelectedItem as TextBlock).Tag;
                switch (CommunicationMean.SelectedIndex)
                {
                case 0:
                    Contact.Phones.First(x => x.Id == selectedValueId).Value = numberAddressWindow.Value;
                    break;

                case 1:
                    Contact.Faxes.First(x => x.Id == selectedValueId).Value = numberAddressWindow.Value;
                    break;

                case 2:
                    Contact.Emails.First(x => x.Id == selectedValueId).Value = numberAddressWindow.Value;
                    break;
                }
                UpdateValues();
                Values.SelectItem(Values.Items.FirstOrDefault <TextBlock>(x => (long)x.Tag == selectedValueId));
            }
        }
Esempio n. 2
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            NumberAddressWindow numberAddressWindow = new NumberAddressWindow();

            if ((bool)numberAddressWindow.ShowDialog(this))
            {
                long insertedValueId;
                switch (CommunicationMean.SelectedIndex)
                {
                case 0:
                    insertedValueId = Contact.Phones.Count != 0 ? Contact.Phones.Max(x => x.Id) + 1 : 1;
                    Contact.Phones.Add(new Phone()
                    {
                        Id    = insertedValueId,
                        Value = numberAddressWindow.Value
                    });
                    break;

                case 1:
                    insertedValueId = Contact.Faxes.Count != 0 ? Contact.Faxes.Max(x => x.Id) + 1 : 1;
                    Contact.Faxes.Add(new Fax()
                    {
                        Id    = insertedValueId,
                        Value = numberAddressWindow.Value
                    });
                    break;

                default:
                    insertedValueId = Contact.Emails.Count != 0 ? Contact.Emails.Max(x => x.Id) + 1 : 1;
                    Contact.Emails.Add(new Email()
                    {
                        Id    = insertedValueId,
                        Value = numberAddressWindow.Value
                    });
                    break;
                }
                UpdateValues();
                Values.SelectItem(Values.Items.FirstOrDefault <TextBlock>(x => (long)x.Tag == insertedValueId));
            }
        }