Esempio n. 1
0
        static private bool FindFirstInProductList(ListView list, ProductSearchSettings settings)
        {
            foreach (ListViewItem lvi in list.Items)
            {
                lvi.Selected = false;
            }

            if (settings.SearchStartingRow >= list.Items.Count)
            {
                return(false);
            }

            for (int i = settings.SearchStartingRow; i < list.Items.Count; i++)
            {
                ListViewItem lvi = list.Items[i];
                if (FindInItem(lvi, settings))
                {
                    lvi.Selected = true;
                    settings.SearchStartingRow = i + 1;
                    list.EnsureVisible(i);
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 2
0
 static private bool FindInItem(ListViewItem lvi, ProductSearchSettings settings)
 {
     if (settings.SearchProductName)
     {
         if (lvi.SubItems[CatalogForm.ColProdName].Text.IndexOf(settings.SearchString, StringComparison.CurrentCultureIgnoreCase) >= 0)
         {
             return(true);
         }
     }
     if (settings.SearchProductCode)
     {
         if (lvi.SubItems[CatalogForm.ColProdCode].Text.IndexOf(settings.SearchString, StringComparison.CurrentCultureIgnoreCase) >= 0)
         {
             return(true);
         }
     }
     if (settings.SearchVersion)
     {
         if (lvi.SubItems[CatalogForm.ColVersion].Text.IndexOf(settings.SearchString, StringComparison.CurrentCultureIgnoreCase) >= 0)
         {
             return(true);
         }
     }
     if (settings.SearchModDate)
     {
         if (lvi.SubItems[CatalogForm.ColModDate].Text.IndexOf(settings.SearchString, StringComparison.CurrentCultureIgnoreCase) >= 0)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 3
0
 private static bool FindAllInProductList(ListView list, ProductSearchSettings settings)
 {
     bool found = false;
     foreach (ListViewItem lvi in list.Items)
     {
         lvi.Selected = FindInItem(lvi, settings);
         if (lvi.Selected) found = true;
     }
     return found;
 }
Esempio n. 4
0
 static public bool FindInProductList(ListView list, ProductSearchSettings settings)
 {
     if (settings.SearchAll)
     {
         return(FindAllInProductList(list, settings));
     }
     else
     {
         return(FindFirstInProductList(list, settings));
     }
 }
Esempio n. 5
0
        private void Find(bool withUI)
        {
            // If the user has changed the selection since the last search,
            // Set the starting row at the row after the current first selection,
            // or at 0 if no selection of the last line is selected
            if (_userChangedSelection)
            {
                _findSettings.SearchStartingRow = 0;
                int row = 0;
                while (row < productList.Items.Count)
                {
                    if (productList.Items[row].Selected)
                    {
                        _findSettings.SearchStartingRow = row + 1;
                        break;
                    }
                    row++;
                }
                _userChangedSelection = false;
            }

            if (withUI)
            {
                FindProductForm dlg = new FindProductForm(_findSettings);
                dlg.Settings = _findSettings;
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    _findSettings = dlg.Settings;
                    // If nothing was found, reset search next time.
                    // If something was found, ignore selection changes made by finding.
                    bool result = Search.FindInProductList(productList, _findSettings);
                    _userChangedSelection = !result;
                    if (!result)
                    {
                        productList.EnsureVisible(0);
                    }
                    findAgainToolStripMenuItem.Enabled = true;
                }
            }
            else
            {
                if (_findSettings.IsValid)
                {
                    bool result = Search.FindInProductList(productList, _findSettings);
                    _userChangedSelection = !result;
                    if (!result)
                    {
                        productList.EnsureVisible(0);
                    }
                }
            }
        }
Esempio n. 6
0
        static private bool FindAllInProductList(ListView list, ProductSearchSettings settings)
        {
            bool found = false;

            foreach (ListViewItem lvi in list.Items)
            {
                lvi.Selected = FindInItem(lvi, settings);
                if (lvi.Selected)
                {
                    found = true;
                }
            }
            return(found);
        }
Esempio n. 7
0
        private static bool FindFirstInProductList(ListView list, ProductSearchSettings settings)
        {
            foreach (ListViewItem lvi in list.Items) lvi.Selected = false;

            if (settings.SearchStartingRow >= list.Items.Count)
                return false;

            for (int i = settings.SearchStartingRow; i < list.Items.Count; i++)
            {
                ListViewItem lvi = list.Items[i];
                if (FindInItem(lvi, settings))
                {
                    lvi.Selected = true;
                    settings.SearchStartingRow = i + 1;
                    list.EnsureVisible(i);
                    return true;
                }
            }
            return false;
        }
Esempio n. 8
0
 private static bool FindInItem(ListViewItem lvi, ProductSearchSettings settings)
 {
     if (settings.SearchProductName)
         if (lvi.SubItems[CatalogForm.ColProdName].Text.IndexOf(settings.SearchString, StringComparison.CurrentCultureIgnoreCase) >= 0)
             return true;
     if (settings.SearchProductCode)
         if (lvi.SubItems[CatalogForm.ColProdCode].Text.IndexOf(settings.SearchString, StringComparison.CurrentCultureIgnoreCase) >= 0)
             return true;
     if (settings.SearchVersion)
         if (lvi.SubItems[CatalogForm.ColVersion].Text.IndexOf(settings.SearchString, StringComparison.CurrentCultureIgnoreCase) >= 0)
             return true;
     if (settings.SearchModDate)
         if (lvi.SubItems[CatalogForm.ColModDate].Text.IndexOf(settings.SearchString, StringComparison.CurrentCultureIgnoreCase) >= 0)
             return true;
     return false;
 }
Esempio n. 9
0
 public FindProductForm(ProductSearchSettings settings)
 {
     InitializeComponent();
     Settings = settings;
 }
Esempio n. 10
0
        private void Find(bool withUI)
        {
            // If the user has changed the selection since the last search,
            // Set the starting row at the row after the current first selection,
            // or at 0 if no selection of the last line is selected
            if (_userChangedSelection)
            {
                _findSettings.SearchStartingRow = 0;
                int row = 0;
                while (row < productList.Items.Count)
                {
                    if (productList.Items[row].Selected)
                    {
                        _findSettings.SearchStartingRow = row + 1;
                        break;
                    }
                    row++;
                }
                _userChangedSelection = false;
            }

            if (withUI)
            {
                FindProductForm dlg = new FindProductForm(_findSettings);
                dlg.Settings = _findSettings;
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    _findSettings = dlg.Settings;
                    // If nothing was found, reset search next time.
                    // If something was found, ignore selection changes made by finding.
                    bool result = Search.FindInProductList(productList, _findSettings);
                    _userChangedSelection = !result;
                    if (!result) productList.EnsureVisible(0);
                    findAgainToolStripMenuItem.Enabled = true;
                }
            }
            else
            {
                if (_findSettings.IsValid)
                {
                    bool result = Search.FindInProductList(productList, _findSettings);
                    _userChangedSelection = !result;
                    if (!result) productList.EnsureVisible(0);
                }
            }
        }
Esempio n. 11
0
 public FindProductForm(ProductSearchSettings settings)
 {
     InitializeComponent();
     Settings = settings;
 }
Esempio n. 12
-1
 public static bool FindInProductList(ListView list, ProductSearchSettings settings)
 {
     if (settings.SearchAll)
         return FindAllInProductList(list, settings);
     else
         return FindFirstInProductList(list, settings);
 }