コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Trim() == "")
            {
                MessageBox.Show("Please enter your name!", "Register", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox1.Focus();
                return;
            }

            if (textBox2.Text.Trim() == "")
            {
                MessageBox.Show("Please enter your registeration code!", "Register", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox2.Focus();
                return;
            }

            if (PublicVar.IsKeyValue(textBox2.Text.Trim(), textBox1.Text.Trim()))
            {
                MessageBox.Show("Congratulations! Your copy of Personal Files Manager is licnesed.", "Register", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("The registeration code is not valid! Please input again.", "Register", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox2.Focus();
            }
        }
コード例 #2
0
        private void ButtonOK_Click(object sender, EventArgs e)
        {
            int count = 0;

            if (!PublicVar.IsRegisted())
            {
                for (int i = 0; i < PublicVar.root.Collection.Count; i++)
                {
                    for (int j = 0; j < PublicVar.root.Collection[i].Count; j++)
                    {
                        count++;
                        if (count >= 10)
                        {
                            if (MessageBox.Show("You can only manage 10 folders with Unregisteration version! Do you want to register now?", "Add Folder", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
                            {
                                DialogResult = DialogResult.Yes;
                            }
                            else
                            {
                                DialogResult = DialogResult.Cancel;
                            }
                            return;
                        }
                    }
                }
            }

            for (int i = 0; i < ListViewPlugins.Items.Count; i++)
            {
                if (ListViewPlugins.Items[i].Checked)
                {
                    Plugins.Add(ps[i]);
                }
            }

            if (!PublicVar.IsRegisted() && Plugins.Count > 0)
            {
                if (MessageBox.Show("You cannot using Plug-ins with Unregisteration version! Do you want to register now?", "Add Folder", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
                {
                    DialogResult = DialogResult.Yes;
                }
                else
                {
                    DialogResult = DialogResult.Cancel;
                }
                return;
            }

            switch (nft)
            {
            case CommVar.NewFolderType.CD:
            {
                if (ListViewCD.Items.Count == 0)
                {
                    MessageBox.Show("No Compact Disc selected! please insert your Compact Disc and refresh.", "New Folder", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                if (ListViewCD.SelectedItems.Count == 0)
                {
                    MessageBox.Show("No CD selected! ", "New Folder", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                Path       = ListViewCD.SelectedItems[0].Name;
                FolderName = ListViewCD.SelectedItems[0].Text;
                IconIndex  = ListViewCD.SelectedItems[0].ImageIndex;
                Memo       = TextBoxMemo.Text;
            }
            break;

            case CommVar.NewFolderType.Removable:
            {
                if (ListViewRemovable.Items.Count == 0)
                {
                    MessageBox.Show("No Removable Drive selected! please insert your compact disc and refresh.", "New Folder", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                if (ListViewRemovable.SelectedItems.Count == 0)
                {
                    MessageBox.Show("No Removable Drive selected! ");
                    return;
                }

                Path       = ListViewRemovable.SelectedItems[0].Name;
                FolderName = ListViewRemovable.SelectedItems[0].Text;
                IconIndex  = ListViewRemovable.SelectedItems[0].ImageIndex;
                Memo       = TextBoxMemo.Text;
            }
            break;

            case CommVar.NewFolderType.LocalFolder:
            {
                if (TreeViewLocalFolder.SelectedNode == null)
                {
                    MessageBox.Show("No Folder selected! ");
                    return;
                }

                Path       = TreeViewLocalFolder.SelectedNode.Name;
                FolderName = TreeViewLocalFolder.SelectedNode.Text;
                IconIndex  = TreeViewLocalFolder.SelectedNode.ImageIndex;
                Memo       = TextBoxMemo.Text;
            }
            break;
            }

            thisCollectionIndex = comboBox1.SelectedIndex;

            for (int i = 0; i < PublicVar.root.Collection[CollectionIndex].Count; i++)
            {
                if (FolderName == PublicVar.root.Collection[CollectionIndex][i].Name)
                {
                    //MessageBox.Show("A Folder have the same name is already exist in this Collection,
                    int temp = 1;
                    while (PublicVar.root.Collection[CollectionIndex].Contains(FolderName + "_" + temp))
                    {
                        temp++;
                    }

                    FolderName = FolderName + "_" + temp;
                    break;
                }
            }

            DialogResult = System.Windows.Forms.DialogResult.OK;
        }