예제 #1
0
        private void CopyButton_Click(object sender, EventArgs e)
        {
            if (Varor.SelectedItems.Count <= 0)
            {
                return;
            }

            var name   = Varor.Items[Varor.SelectedItems[0].Index].SubItems[0].Text;
            var count  = Varor.Items[Varor.SelectedItems[0].Index].SubItems[1].Text;
            var price  = Varor.Items[Varor.SelectedItems[0].Index].SubItems[2].Text;
            var adress = Varor.Items[Varor.SelectedItems[0].Index].SubItems[3].Text;

            ListViewItem item = new ListViewItem(name, 0);

            item.SubItems.Add(count);
            item.SubItems.Add(price);
            item.SubItems.Add(adress);
            Varor.Items.Add(item);

            foreach (ListViewItem selectedItem in Varor.SelectedItems)
            {
                selectedItem.Selected = false;
            }

            Varor.Items[item.Index].Selected = true;
            Varor.Select();
            UpdateSelection();
        }
예제 #2
0
        public void Remove()
        {
            int firstIndex = -1;

            foreach (ListViewItem item in Varor.Items)
            {
                if (item.Checked)
                {
                    if (firstIndex == -1)
                    {
                        firstIndex = item.Index;
                    }

                    string adress = Varor.Items[Varor.SelectedItems[0].Index].SubItems[3].Text;

                    /*
                     * if (File.Exists(adress))
                     * {
                     *      Bitmap Placeholder = Properties.Resources.Ping;
                     *      pictureBox1.Image = Placeholder;
                     *      GC.Collect();
                     *      GC.WaitForPendingFinalizers();
                     *      File.Delete(adress);
                     * }
                     */

                    Varor.Items.Remove(item);
                }
            }

            foreach (ListViewItem selectedItem in Varor.SelectedItems)
            {
                selectedItem.Selected = false;
            }

            if (firstIndex != -1)
            {
                int i = firstIndex - 1;
                if (i < 0)
                {
                    i = 0;
                }

                if (Varor.Items.Count != 0)
                {
                    Varor.Items[i].Selected = true;
                    Varor.Items[i].Focused  = true;

                    Varor.Select();
                    UpdateSelection();
                }
            }
        }
예제 #3
0
        private void Box_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Enter:
                Apply();
                e.SuppressKeyPress = true;
                break;

            case Keys.Escape:
                Varor.Select();
                if (Varor.Items.Count > 0 && Varor.SelectedItems.Count <= 0)
                {
                    Varor.Items[0].Selected = true;
                }
                e.SuppressKeyPress = true;
                break;

            case Keys.Up:
            case Keys.Down:
                for (int i = 0; i < textBoxes.Length; i++)
                {
                    if (textBoxes[i].Focused)
                    {
                        if (e.KeyCode == Keys.Up)
                        {
                            if (i != 0)
                            {
                                textBoxes[i - 1].Focus();
                            }
                            else
                            {
                                ApplyButton.Focus();
                            }
                        }
                        else
                        {
                            if (i != 2)
                            {
                                textBoxes[i + 1].Focus();
                            }
                            else
                            {
                                BrowseButton.Focus();
                            }
                        }
                        break;
                    }
                }
                break;
            }
        }
예제 #4
0
        private void Button_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Escape:
                Varor.Select();
                if (Varor.Items.Count > 0 && Varor.SelectedItems.Count <= 0)
                {
                    Varor.Items[0].Selected = true;
                }
                e.SuppressKeyPress = true;
                break;
            }

            e.Handled = true;
        }
예제 #5
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            Random       random = new Random();
            ListViewItem item   = new ListViewItem("Item" + Varor.Items.Count, 0);
            string       price  = random.Next(0, 100).ToString();
            string       count  = random.Next(0, 1000).ToString();
            string       adress = "-";

            item.SubItems.Add(count);
            item.SubItems.Add(price);
            item.SubItems.Add(adress);
            Varor.Items.Add(item);

            foreach (ListViewItem selectedItem in Varor.SelectedItems)
            {
                selectedItem.Selected = false;
            }

            Varor.Items[item.Index].Selected = true;
            Varor.Select();
            UpdateSelection();
        }