Ejemplo n.º 1
0
 private void btn_add_Click(object sender, RoutedEventArgs e)
 {
     if(allowAction)
     {
         Window_AddEditContact win = new Window_AddEditContact(this, -1);
         win.ShowDialog();
     }
 }
Ejemplo n.º 2
0
        private void btn_edit_Click(object sender, RoutedEventArgs e)
        {
            if (allowAction)
            {
                int count = listview_contacts.Items.Count;
                int editId = -1;
                for (int i = 0; i < count; i++)
                {
                    Object item = listview_contacts.Items[i];
                    if (item is ListViewContactItem)
                    {
                        if (((ListViewContactItem)item).IsCheck)
                        {
                            editId = ((ListViewContactItem)item).Id;
                            break;
                        }

                    }
                }

                if (editId > 0)
                {
                    Window_AddEditContact win = new Window_AddEditContact(this, editId);
                    win.ShowDialog();
                }
            }
        }
Ejemplo n.º 3
0
 private void btn_edit_Click(object sender, RoutedEventArgs e)
 {
     if (allowAction)
     {
         ListViewContactItem item;
         int count = listview_contacts.Items.Count;
         for (int i = 0; i < count; i++)
         {
             item = (ListViewContactItem)listview_contacts.Items[i];
             if (item.IsCheck)
             {
                 int idx = item.Index;
                 Object contactObj = uc_AddressBook.ListDisplayContact[idx];
                 Window_AddEditContact frm = new Window_AddEditContact(this, contactObj, uc_AddressBook.ListGroupName);
                 frm.ShowDialog();
                 return;
             }
         }
     }
 }
Ejemplo n.º 4
0
        private void DoImportFromFile(string filePath)
        {
            int contactCount = dbController.GetAllContact().Count();
            FileImportResult res = fileController.ImportFromFile(filePath);
            string statusStr = "";
            if (res.errorCode == FileImExportController.CODE_FILE_NO_ERROR)
            {
                if (res.downloaded == 0)
                {
                    statusStr = CMLibrary.Properties.Resources.no_contact_added;
                }
                else
                {
                    statusStr = String.Format(CMLibrary.Properties.Resources.import_num_contacts, res.downloaded);
                }
                if (parent is Page_LocalContacts)
                {
                    Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                  new Action(((Page_LocalContacts)parent).NotifyNewContactAdded));
                }
            }
            else if(res.errorCode == FileImExportController.CODE_FILE_EXCEED_LIMITATION)
            {
                Application.Current.Dispatcher.Invoke((Action)delegate {

                    Window_AddEditContact win = new Window_AddEditContact(parent, res.downloaded);
                    win.updateContactCount = true;
                    bool increaseContactLimit = win.check_limit(res.downloaded + contactCount, 0, String.Format(Properties.Resources.exceed_limit_increase_number, res.downloaded + contactCount));
                    if(increaseContactLimit)
                    {
                        res = fileController.ImportFromFile(filePath);
                        statusStr = String.Format(CMLibrary.Properties.Resources.import_num_contacts, res.downloaded);
                    } else
                    {
                        statusStr = CMLibrary.Properties.Resources.no_contact_added;
                    }
                });

                if (parent is Page_LocalContacts)
                {
                    Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                  new Action(((Page_LocalContacts)parent).NotifyNewContactAdded));
                }
            }
            else
            {
                statusStr = FileImExportController.FromCodeToString(res.errorCode);
            }


            Application.Current.Dispatcher.BeginInvoke(
                  DispatcherPriority.Background,
                  new Action(() =>
                  {
                      label_status.Content = statusStr;
                      btn_back.IsEnabled = true;
                  }));
        }
Ejemplo n.º 5
0
        private void combox_add_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int index = combox_add.SelectedIndex;

            if (index < 0)
            {
                return;
            }
            switch (index)
            {
                case 0: // manually
                    if (uc_AddressBook.ListAllContact.Count() < printer.MaxContact)
                    {
                        Window_AddEditContact frm = new Window_AddEditContact(this, null, uc_AddressBook.ListGroupName);
                        frm.ShowDialog();
                    }
                    else
                    {
                        string msg = DownloadStatusUtility.StatusToString(DownloadStatus.MAXIMUM_CONTACT_EXEED);
                        MessageBox.Show(msg);
                    }
                    break;
                case 1: // from local
                    if (uc_AddressBook.ListAllContact.Count() < printer.MaxContact)
                    {
                        List<int> notInList = GetContactDBIDList();
                        Window_SelectLocalContact frm = new Window_SelectLocalContact(this, notInList, Window_SelectLocalContact.MODE_PRINTER_CONTACT);
                        frm.ShowDialog();
                    }
                    else
                    {
                        string msg = DownloadStatusUtility.StatusToString(DownloadStatus.MAXIMUM_CONTACT_EXEED);
                        MessageBox.Show(msg);
                    }
                    break;
            }
            Application.Current.Dispatcher.BeginInvoke(
              DispatcherPriority.Background,
              new Action(() => { combox_add.Text = CMLibrary.Properties.Resources.add; }));
        }