コード例 #1
0
        private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ListBoxArticle selectedListBox = ActiveControl as ListBoxArticle;

            if (selectedListBox != null)
            {
                selectedListBox.BeginUpdate();

                // workaround for Wine issue: use of {HOME} then +{END} leads to 100% CPU and locked application
                // so use slower SetSelected if on Linux
                if (Globals.UsingLinux)
                {
                    for (int i = 0; i < selectedListBox.Items.Count; i++)
                    {
                        selectedListBox.SetSelected(i, true);
                    }
                }
                else
                {
                    SendKeys.SendWait("{HOME}");
                    SendKeys.SendWait("+{END}");
                }

                selectedListBox.EndUpdate();
            }
        }
コード例 #2
0
        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ListBoxArticle selectedListBox = this.ActiveControl as ListBoxArticle;

            if (selectedListBox != null)
            {
                Tools.Copy(selectedListBox);
            }
        }
コード例 #3
0
        private void mnuList_Opening(object sender, EventArgs e)
        {
            ListBoxArticle selectedListBox = this.ActiveControl as ListBoxArticle;

            if (selectedListBox != null)
            {
                transferToListMaker1ToolStripMenuItem.Enabled = transferToListMaker2ToolStripMenuItem.Enabled = openInBrowserToolStripMenuItem.Enabled
                                                                                                                    = copyToolStripMenuItem.Enabled = removeSelectedToolStripMenuItem.Enabled = selectAllToolStripMenuItem.Enabled = selectedListBox.Items.Count > 0;
            }
        }
コード例 #4
0
        private static void SaveList(ListBoxArticle lb)
        {
            if (lb.Items.Count == 0)
            {
                MessageBox.Show("Nothing to save", "No items in List Boxes");
                return;
            }

            lb.SaveList();
        }
コード例 #5
0
        private void removeSelectedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ListBoxArticle selectedListBox = this.ActiveControl as ListBoxArticle;

            if (selectedListBox != null)
            {
                selectedListBox.RemoveSelected(true);
            }

            UpdateCounts();
        }
コード例 #6
0
        public ListFilterForm(ListBoxArticle lb)
        {
            InitializeComponent();

            if (lb == null)
                throw new ArgumentNullException("lb");

            _destListBox = lb;

            if (_prefs != null)
                Settings = _prefs;
        }      
コード例 #7
0
        private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ListBoxArticle selectedListBox = this.ActiveControl as ListBoxArticle;

            if (selectedListBox != null)
            {
                selectedListBox.BeginUpdate();

                SendKeys.SendWait("{HOME}");
                SendKeys.SendWait("+{END}");

                selectedListBox.EndUpdate();
            }
        }
コード例 #8
0
        public ListFilterForm(ListBoxArticle lb)
        {
            InitializeComponent();

            if (lb == null)
            {
                throw new ArgumentNullException("lb");
            }

            _destListBox = lb;

            if (_prefs != null)
            {
                Settings = _prefs;
            }
        }
コード例 #9
0
        private void lb_MouseMove(object sender, MouseEventArgs e)
        {
            string strTip = "";

            //Get the item
            ListBoxArticle lba  = sender as ListBoxArticle;
            int            nIdx = lba.IndexFromPoint(e.Location);

            if ((nIdx >= 0) && (nIdx < lba.Items.Count))
            {
                strTip = lba.Items[nIdx].ToString();
            }

            if (strTip != tooltip.GetToolTip(lba))
            {
                tooltip.SetToolTip(lba, strTip);
            }
        }
コード例 #10
0
 private static void SaveList(ListBoxArticle lb)
 {
     lb.SaveList();
 }
コード例 #11
0
        private static void SaveList(ListBoxArticle lb)
        {
            if (lb.Items.Count == 0)
            {
                MessageBox.Show("Nothing to save", "No items in List Boxes");
                return;
            }

            lb.SaveList();
        }
コード例 #12
0
        public void RemoveSelected()
        {
            ListBoxArticle lbArticles = new ListBoxArticle();

            const int big = 70000, sel = 5000;

            // sequential block deletion performance
            for (int i = 0; i < big; i++)
                lbArticles.Items.Add(new Article(i.ToString()));

            for (int j = sel; j > 0; j--)
                lbArticles.SetSelected(big-j, true);

            lbArticles.RemoveSelected(true);

            if (Globals.UsingMono) // Mono implementation of SetSelected does not seem to honour second input to multi-select
                Assert.AreEqual(lbArticles.Items.Count, big-1);
            else
                Assert.AreEqual(lbArticles.Items.Count, big-sel);

            // single selected item deletion performance
            lbArticles.Items.Clear();
            for (int i = 0; i < big*3; i++)
                lbArticles.Items.Add(new Article(i.ToString()));
            lbArticles.SetSelected((int)big/2, true);
            lbArticles.RemoveSelected(true);
            Assert.AreEqual(lbArticles.Items.Count, big*3-1);

            // non-sequential deletion
            lbArticles.Items.Clear();
            for (int i = 0; i < 10; i++)
                lbArticles.Items.Add(new Article(i.ToString()));
            lbArticles.SetSelected(1, true);
            lbArticles.SetSelected(3, true);
            lbArticles.RemoveSelected(true);
            if (Globals.UsingMono)
            {
                lbArticles.SetSelected(1, true);
                lbArticles.RemoveSelected(true);
            }
            Assert.IsFalse(lbArticles.Items.Contains(new Article("1")));
            Assert.IsFalse(lbArticles.Items.Contains(new Article("3")));
            Assert.IsTrue(lbArticles.Items.Contains(new Article("2")));

            lbArticles.Items.Clear();
            for (int i = 0; i < 10; i++)
                lbArticles.Items.Add(new Article(i.ToString()));
            lbArticles.SetSelected(1, true);
            lbArticles.SetSelected(5, true);
            lbArticles.RemoveSelected(true);
            if (Globals.UsingMono)
            {
                lbArticles.SetSelected(1, true);
                lbArticles.RemoveSelected(true);
            }

            Assert.IsFalse(lbArticles.Items.Contains(new Article("1")));
            Assert.IsFalse(lbArticles.Items.Contains(new Article("5")));
            Assert.IsTrue(lbArticles.Items.Contains(new Article("2")));

            lbArticles.Items.Clear();
            lbArticles.Items.Add(new Article("A"));
            lbArticles.Items.Add(new Article("A"));
            lbArticles.Items.Add(new Article("B"));
            lbArticles.SetSelected(2, true);
            lbArticles.RemoveSelected(false);
            Assert.AreEqual(lbArticles.Items.Count, 2, "Duplicates not removed if not in duplicate mode");

            lbArticles.Items.Clear();
            lbArticles.Items.Add(new Article("A"));
            lbArticles.Items.Add(new Article("B"));
            lbArticles.Items.Add(new Article("C"));
            lbArticles.SetSelected(0, true);
            lbArticles.SetSelected(1, true);
            lbArticles.SetSelected(2, true);
            lbArticles.RemoveSelected(false);
            Assert.AreEqual(lbArticles.Items.Count, 0, "List cleared if all items selected and removed");
        }
コード例 #13
0
 private static void SaveList(ListBoxArticle lb)
 {
     lb.SaveList();
 }