FindStringExact() публичный Метод

public FindStringExact ( string s ) : int
s string
Результат int
Пример #1
0
        public void SetFont(bool cleartype, Font ascii, Font japanese)
        {
            _ignoreEvent               = true;
            _asciiFont                 = ascii;
            _japaneseFont              = japanese;
            _checkClearType.Checked    = cleartype;
            _lASCIISample.ClearType    = cleartype;
            _lJapaneseSample.ClearType = cleartype;
            int s = (int)ascii.Size;

            _fontSizeList.SelectedIndex     = _fontSizeList.FindStringExact(s.ToString());
            _asciiFontList.SelectedIndex    = _asciiFontList.FindStringExact(ascii.Name);
            _japaneseFontList.SelectedIndex = _japaneseFontList.FindStringExact(japanese.Name);

            if (_asciiFontList.SelectedIndex == -1)
            {
                _asciiFontList.SelectedIndex = _asciiFontList.FindStringExact("Courier New");
            }
            if (_japaneseFontList.SelectedIndex == -1)
            {
                _japaneseFontList.SelectedIndex = _japaneseFontList.FindStringExact("MS ゴシック");
            }

            _lASCIISample.Font    = ascii;
            _lJapaneseSample.Font = japanese;
            _ignoreEvent          = false;
        }
Пример #2
0
        private void events_TestReloaded(object sender, NUnit.Util.TestEventArgs args)
        {
            // Get new list of available categories
            availableCategories = this.loader.GetCategories();

            // Remove any selected items that are no longer available
            int index = selectedList.Items.Count;

            selectedList.SuspendLayout();
            while (--index >= 0)
            {
                string category = selectedList.Items[index].ToString();
                if (!availableCategories.Contains(category))
                {
                    selectedList.Items.RemoveAt(index);
                }
            }
            selectedList.ResumeLayout();

            // Put any unselected available items availableList
            availableList.Items.Clear();
            availableList.SuspendLayout();
            foreach (string category in availableCategories)
            {
                if (selectedList.FindStringExact(category) < 0)
                {
                    availableList.Items.Add(category);
                }
            }
            availableList.ResumeLayout();

            // Tell the tree what is selected
            UpdateCategoryFilter();
        }
Пример #3
0
        //<Snippet1>
        private void FindAllOfMyExactStrings(string searchString)
        {
            // Set the SelectionMode property of the ListBox to select multiple items.
            listBox1.SelectionMode = SelectionMode.MultiExtended;

            // Set our initial index variable to -1.
            int x = -1;

            // If the search string is empty exit.
            if (searchString.Length != 0)
            {
                // Loop through and find each item that matches the search string.
                do
                {
                    // Retrieve the item based on the previous index found. Starts with -1 which searches start.
                    x = listBox1.FindStringExact(searchString, x);
                    // If no item is found that matches exit.
                    if (x != -1)
                    {
                        // Since the FindStringExact loops infinitely, determine if we found first item again and exit.
                        if (listBox1.SelectedIndices.Count > 0)
                        {
                            if (x == listBox1.SelectedIndices[0])
                            {
                                return;
                            }
                        }
                        // Select the item in the ListBox once it is found.
                        listBox1.SetSelected(x, true);
                    }
                }while(x != -1);
            }
        }
Пример #4
0
        // ========================= TABLE MANIPULATION ========================

        private void btnAddTable_Click(object sender, System.EventArgs e)
        {
            string tblName = edTableName.Text;

            if (!ValidateTableName(tblName))
            {
                return;
            }

            DataTable dt = new DataTable(tblName);

            currentTable = dt;
            lbTables.Items.Add(tblName);
            dataSet.Tables.Add(dt);
            lbTables.SelectedItem = lbTables.Items[lbTables.FindStringExact(tblName)];
        }
Пример #5
0
        /// <summary>
        /// Adds a document to the listbox. Document name is indented and
        /// preceeded with hierarchically outlined corresponding project name
        /// and solution name.
        /// </summary>
        /// <param name="document"></param>
        private void AddDocumentItem(Document document)
        {
            Project        project           = document.ProjectItem.ContainingProject;
            string         projectName       = project.Name;
            Solution       solution          = project.DTE.Solution;
            SolutionLBItem newSolutionLBItem = new SolutionLBItem(solution);

            if (m_listBoxUnsavedDocuments.FindStringExact(newSolutionLBItem.ToString()) == -1)
            {
                m_listBoxUnsavedDocuments.Items.Add(newSolutionLBItem);
            }
            ProjectLBItem newProjectLBItem = new ProjectLBItem(project);
            int           index            = m_listBoxUnsavedDocuments.FindStringExact(newProjectLBItem.ToString());

            if (index == -1)
            {
                index = m_listBoxUnsavedDocuments.Items.Add(newProjectLBItem);
            }
            m_listBoxUnsavedDocuments.Items.Insert(index + 1, new DocumentLBItem(document));
        }
        public void SetFont(bool cleartype, bool enable_bold, bool force_bold, Font ascii, Font cjk)
        {
            _ignoreEvent = true;
            _asciiFont   = ascii;
            if (force_bold)
            {
                _asciiFont = new Font(_asciiFont, _asciiFont.Style | FontStyle.Bold);
            }
            _cjkFont = cjk;
            if (force_bold)
            {
                _cjkFont = new Font(_cjkFont, _cjkFont.Style | FontStyle.Bold);
            }
            _checkClearType.Checked      = cleartype;
            _checkBoldStyle.Checked      = enable_bold;
            _checkForceBoldStyle.Checked = force_bold;
            _lASCIISample.ClearType      = cleartype;
            _lCJKSample.ClearType        = cleartype;
            int s = (int)ascii.Size;

            _fontSizeList.SelectedIndex  = _fontSizeList.FindStringExact(s.ToString());
            _asciiFontList.SelectedIndex = _asciiFontList.FindStringExact(ascii.Name);
            _cjkFontList.SelectedIndex   = _cjkFontList.FindStringExact(cjk.Name);

            if (_asciiFontList.SelectedIndex == -1)
            {
                _asciiFontList.SelectedIndex = _asciiFontList.FindStringExact("Courier New");
            }
            if (_cjkFontList.SelectedIndex == -1)
            {
                _cjkFontList.SelectedIndex = _cjkFontList.FindStringExact("MS ゴシック");
            }

            _lASCIISample.Font = ascii;
            _lCJKSample.Font   = cjk;
            _ignoreEvent       = false;
        }
Пример #7
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            if (searchResults.SelectedIndex != -1)
            {
                WeatherLocation       srcLoc = (WeatherLocation)searchResults.Items[searchResults.SelectedIndex];
                WeatherRegionForecast dstLoc = new WeatherRegionForecast();

                dstLoc.LocationId   = srcLoc.LocationId;
                dstLoc.Description  = srcLoc.Description;
                dstLoc.ForecastDays = Convert.ToInt16(forecastDays.Value);
                dstLoc.IsMetric     = rbUnitMetric.Checked;
                dstLoc.RadarMap     = XoapProvider.Instance.GetRadarUrl(srcLoc.LocationId);
                forecastRegions.Items.Add(dstLoc);
                forecastRegions.SelectedIndex = forecastRegions.FindStringExact(dstLoc.Description);
            }
        }
Пример #8
0
 //<Snippet1>
 private void FindMySpecificString(string searchString)
 {
     // Ensure we have a proper string to search for.
     if (searchString != string.Empty)
     {
         // Find the item in the list and store the index to the item.
         int index = listBox1.FindStringExact(searchString);
         // Determine if a valid index is returned. Select the item if it is valid.
         if (index != ListBox.NoMatches)
         {
             listBox1.SetSelected(index, true);
         }
         else
         {
             MessageBox.Show("The search string did not find any items in the ListBox that exactly match the specified search string");
         }
     }
 }
Пример #9
0
        public static int UI_LISTBOX_SELECT(System.Windows.Forms.ListBox Listbox, string sItem, bool bZeroBase = true)
        {
            int nIndex;

            nIndex = Listbox.FindStringExact(sItem);
            // Determine if a valid index is returned. Select the item if it is valid.

            if (nIndex < 0 && bZeroBase)
            {
                nIndex = -1;
            }

            if (nIndex >= 0)
            {
                if (Listbox.Items.Count > 0)
                {
                    Listbox.SetSelected(nIndex, true);
                }
            }
            return(nIndex);
        }
        private void SetChecked()
        {
            if (b_MultiSel)
            {
                for (int i = 0; i < box1.Items.Count; i++)
                {
                    string strField = box1.Items[i].ToString();
                    if (strCols.Contains(strField))
                    {
                        box1.SetSelected(i, true);
                    }
                    else
                    {
                        box1.SetSelected(i, false);
                    }
                }
            }
            else
            {
                int index = box1.FindStringExact(strResult);

                box1.SelectedIndex = index;
            }
        }
Пример #11
0
        //private void UserSettings_Changed(object sender, SettingsEventArgs args)
        //{
        //	//if ( args.SettingName == "Options.ShowCheckBoxes" )
        //	//	this.ShowCheckBoxes = Services.UserSettings.GetSetting( args.SettingName, false );
        //}

        #region IViewControl Implementation

        public void InitializeView(ITestModel model, TestCentricPresenter presenter)
        {
            Model = model;

            ShowCheckBoxes = Model.Services.UserSettings.Gui.TestTree.ShowCheckBoxes;

            Model.Events.TestLoaded += (TestNodeEventArgs e) =>
            {
                treeMenu.Visible = true;

                availableList.Items.Clear();
                selectedList.Items.Clear();

                availableList.SuspendLayout();
                foreach (string category in Model.AvailableCategories)
                {
                    availableList.Items.Add(category);
                }

                // We need to ensure the tree loads first because that's
                // where we restore visual state and possibly change the
                // selected categories.
                tests.Load(e.Test);

                // Reflect any changes in the controls
                if (Model.SelectedCategories != null && Model.SelectedCategories.Length > 0)
                {
                    selectedList.Items.AddRange(Model.SelectedCategories);
                    excludeCheckbox.Checked = Model.ExcludeSelectedCategories;

                    foreach (string cat in Model.SelectedCategories)
                    {
                        if (Model.AvailableCategories.Contains(cat))
                        {
                            availableList.Items.Remove(cat);
                            excludeCheckbox.Enabled = true;
                        }
                    }

                    UpdateCategorySelection();
                }

                availableList.ResumeLayout();
            };

            Model.Events.TestReloaded += (TestNodeEventArgs e) =>
            {
                // Remove any selected items that are no longer available
                int index = selectedList.Items.Count;
                selectedList.SuspendLayout();
                while (--index >= 0)
                {
                    string category = selectedList.Items[index].ToString();
                    if (!Model.AvailableCategories.Contains(category))
                    {
                        selectedList.Items.RemoveAt(index);
                    }
                }
                selectedList.ResumeLayout();

                // Clear check box if there are no more selected items.
                if (selectedList.Items.Count == 0)
                {
                    excludeCheckbox.Checked = excludeCheckbox.Enabled = false;
                }

                // Put any unselected available items on availableList
                availableList.Items.Clear();
                availableList.SuspendLayout();
                foreach (string category in Model.AvailableCategories)
                {
                    if (selectedList.FindStringExact(category) < 0)
                    {
                        availableList.Items.Add(category);
                    }
                }
                availableList.ResumeLayout();

                // Tell the tree what is selected
                UpdateCategorySelection();
            };

            Model.Events.TestUnloaded += (TestEventArgs e) =>
            {
                availableList.Items.Clear();
                selectedList.Items.Clear();
                excludeCheckbox.Checked = false;
                excludeCheckbox.Enabled = false;
                treeMenu.Visible        = false;
            };

            //Services.UserSettings.Changed += new SettingsEventHandler(UserSettings_Changed);
        }
Пример #12
0
        private void Transfer(ListBox from, ListBox to, bool selectionOnly)
        {
            string selectedText = "";
            if (selectionOnly)
                selectedText = from.SelectedItem.ToString();

            ArrayList temp = new ArrayList(to.Items.Count + 1);
            for (int i = 0; i < to.Items.Count; i++)
                temp.Add(to.Items[i]);

            if (selectionOnly)
            {
                temp.Add(from.SelectedItem);
            }
            else
            {
                for (int i = 0; i < from.Items.Count; i++)
                    temp.Add(from.Items[i]);
            }

            temp.Sort();

            to.Items.Clear();
            for (int i = 0; i < temp.Count; i++)
                to.Items.Add(temp[i]);

            to.SelectedIndex = to.FindStringExact(selectedText);

            if (selectionOnly)
            {
                from.Items.RemoveAt(from.SelectedIndex);
            }
            else
            {
                from.Items.Clear();
            }
        }
Пример #13
0
        public void InitializeView(ITestModel model)
        {
            Model = model;

            model.Events.TestLoaded += (TestNodeEventArgs e) =>
            {
                availableList.Items.Clear();
                selectedList.Items.Clear();

                availableList.SuspendLayout();
                foreach (string category in model.AvailableCategories)
                {
                    availableList.Items.Add(category);
                }

                // We need to ensure the tree loads first and restore the
                // visual state before checking the seleted categories.
                tests.LoadTests(e.Test);

                if (model.Services.UserSettings.Gui.TestTree.SaveVisualState)
                {
                    string fileName = VisualState.GetVisualStateFileName(Model.TestFiles[0]);
                    if (File.Exists(fileName))
                    {
                        var visualState = VisualState.LoadFrom(fileName);
                        tests.RestoreVisualState(visualState);
                        model.SelectCategories(visualState.SelectedCategories, visualState.ExcludeCategories);
                    }
                }

                // Reflect any changes in the controls
                if (model.SelectedCategories != null && model.SelectedCategories.Length > 0)
                {
                    selectedList.Items.AddRange(model.SelectedCategories);
                    excludeCheckbox.Checked = model.ExcludeSelectedCategories;

                    foreach (string cat in model.SelectedCategories)
                    {
                        if (model.AvailableCategories.Contains(cat))
                        {
                            availableList.Items.Remove(cat);
                            excludeCheckbox.Enabled = true;
                        }
                    }

                    UpdateCategorySelection();
                }

                availableList.ResumeLayout();
            };

            model.Events.TestReloaded += (TestNodeEventArgs e) =>
            {
                // Remove any selected items that are no longer available
                int index = selectedList.Items.Count;
                selectedList.SuspendLayout();
                while (--index >= 0)
                {
                    string category = selectedList.Items[index].ToString();
                    if (!model.AvailableCategories.Contains(category))
                    {
                        selectedList.Items.RemoveAt(index);
                    }
                }
                selectedList.ResumeLayout();

                // Clear check box if there are no more selected items.
                if (selectedList.Items.Count == 0)
                {
                    excludeCheckbox.Checked = excludeCheckbox.Enabled = false;
                }

                // Put any unselected available items on availableList
                availableList.Items.Clear();
                availableList.SuspendLayout();
                foreach (string category in model.AvailableCategories)
                {
                    if (selectedList.FindStringExact(category) < 0)
                    {
                        availableList.Items.Add(category);
                    }
                }
                availableList.ResumeLayout();

                // Tell the tree what is selected
                UpdateCategorySelection();
            };

            model.Events.TestUnloaded += (TestEventArgs e) =>
            {
                availableList.Items.Clear();
                selectedList.Items.Clear();
                excludeCheckbox.Checked = false;
                excludeCheckbox.Enabled = false;
            };
        }