Пример #1
0
        private void buttonInsertContact_Click(object sender, EventArgs e)
        {
            if (CheckContactInformations())
            {
                if (!ClassContact.InsertContact(textBoxContactName.Text, textBoxContactWalletAddress.Text))
                {
#if WINDOWS
                    ClassFormPhase.MessageBoxInterface(ClassTranslation.GetLanguageTextFromOrder("CONTACT_SUBMENU_ERROR_INSERT_CONTACT_CONTENT_TEXT"), ClassTranslation.GetLanguageTextFromOrder("CONTACT_SUBMENU_ERROR_INSERT_CONTACT_TITLE_TEXT"), MessageBoxButtons.OK, MessageBoxIcon.Information);
#else
                    MessageBox.Show(ClassTranslation.GetLanguageTextFromOrder("CONTACT_SUBMENU_ERROR_INSERT_CONTACT_CONTENT_TEXT"), ClassTranslation.GetLanguageTextFromOrder("CONTACT_SUBMENU_ERROR_INSERT_CONTACT_TITLE_TEXT"), MessageBoxButtons.OK, MessageBoxIcon.Information);
#endif
                }
                else
                {
#if WINDOWS
                    ClassFormPhase.MessageBoxInterface(ClassTranslation.GetLanguageTextFromOrder("CONTACT_SUBMENU_SUCCESS_INSERT_CONTACT_CONTENT_TEXT"), ClassTranslation.GetLanguageTextFromOrder("CONTACT_SUBMENU_SUCCESS_INSERT_CONTACT_TITLE_TEXT"), MessageBoxButtons.OK, MessageBoxIcon.Information);
#else
                    MessageBox.Show(ClassTranslation.GetLanguageTextFromOrder("CONTACT_SUBMENU_SUCCESS_INSERT_CONTACT_CONTENT_TEXT"), ClassTranslation.GetLanguageTextFromOrder("CONTACT_SUBMENU_SUCCESS_INSERT_CONTACT_TITLE_TEXT"), MessageBoxButtons.OK, MessageBoxIcon.Information);
#endif
                    string[]     objectContact = { textBoxContactName.Text, textBoxContactWalletAddress.Text, "X" };
                    ListViewItem itemContact   = new ListViewItem(objectContact);
                    ClassFormPhase.WalletXiropht.ContactWalletForm.listViewExContact.Items.Add(itemContact);
                    Close();
                }
            }
        }
Пример #2
0
    private void _69()
    {
        //编一个程序,定义类(有姓名,年龄,手机号码,三个字段)再定义一个一维数组,
        //使数组元素为类,存入数据,然后依次输出,使用for循环语句进行输入输出操作

        int n = 3;

        ClassContact[] c = new ClassContact[n];
        for (int j = 0; j < n; j++)
        {
            c[j] = new ClassContact();
        }
        for (int k = 0; k < n; k++)
        {
            Console.Write("请输入学生的名字:");
            c[k].name = Console.ReadLine();

            Console.Write("请输入学生年龄:");
            c[k].age = int.Parse(Console.ReadLine());

            Console.Write("请输入手机号码");
            c[k].tele = Console.ReadLine();
        }

        for (int i = 0; i < n; i++)
        {
            Console.Write("姓名{0}", c[i].name);
            // Console.WriteLine(); 分行
            Console.Write("年龄{0}", c[i].age);
            // Console.WriteLine(); 分行
            Console.Write("手机号码{0}", c[i].tele);
        }
    }
        private void listViewExContact_MouseClick(object sender, MouseEventArgs e)
        {
            var item = listViewExContact.GetItemAt(0, e.Y);

            var found = false;

            if (item == null)
            {
                return;
            }
            for (var ix = item.SubItems.Count - 1; ix >= 0; --ix)
            {
                if (item.SubItems[ix].Bounds.Contains(e.Location))
                {
                    if (!found)
                    {
                        found = true;
                        if (item.SubItems[ix].Text != "X")
                        {
                            Clipboard.SetText(item.SubItems[ix].Text);
#if WINDOWS
                            new Thread(() =>
                                       ClassFormPhase.MessageBoxInterface(
                                           item.SubItems[ix].Text + " " +
                                           ClassTranslation.GetLanguageTextFromOrder(
                                               "CONTACT_LIST_COPY_ACTION_CONTENT_TEXT"), string.Empty,
                                           MessageBoxButtons.OK, MessageBoxIcon.Information))
                            .Start();
#else
                            new Thread(delegate()
                            {
                                MethodInvoker invoker =
                                    () => MessageBox.Show(Program.WalletXiropht, item.SubItems[ix].Text + " " + ClassTranslation.GetLanguageTextFromOrder("CONTACT_LIST_COPY_ACTION_CONTENT_TEXT"));
                                BeginInvoke(invoker);
                            }).Start();
#endif
                        }
                        else
                        {
#if WINDOWS
                            if (ClassFormPhase.MessageBoxInterface(
                                    ClassTranslation.GetLanguageTextFromOrder(
                                        "CONTACT_LIST_REMOVE_ACTION_CONTENT_TEXT"), string.Empty,
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
#else
                            if (MessageBox.Show(ClassTranslation.GetLanguageTextFromOrder("CONTACT_LIST_REMOVE_ACTION_CONTENT_TEXT"), string.Empty, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
#endif
                            {
                                ClassContact.RemoveContact(item.SubItems[0].Text); // Remove contact by his name.
                                listViewExContact.Items.Remove(item);
                                listViewExContact.Refresh();
                            }
                        }

                        return;
                    }
                }
            }
        }