예제 #1
0
        private void BtnSearch_Click(object sender, EventArgs e)
        {
            List <Energosphere.Point> foundPoints;

            TreeNode[]   nodes;
            formInputBox dlg = new formInputBox("Введите строку поиска", "");

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                found.Clear();
                lastSearch  = dlg.Result;
                foundPoints = aiis.Search(lastSearch);
                foreach (Energosphere.Point p in foundPoints)
                {
                    nodes = treePoints.Nodes.Find(p.ID.ToString(), true);
                    if (nodes.Length == 1)
                    {
                        found.Add(nodes[0]);
                    }
                }
                if (found.Count > 0)
                {
                    treePoints.CollapseAll();
                    found[0].EnsureVisible();
                    treePoints.SelectedNode = found[0];
                }
                tipSelectAll.SetToolTip(btnFindNext,
                                        "Поиск: " + lastSearch + Environment.NewLine +
                                        "Найдено: " + found.Count.ToString() + " узлов");
            }
        }
예제 #2
0
        private void BtnSavePreset_Click(object sender, EventArgs e)
        {
            string        presetName;
            StringBuilder fileName;
            formInputBox  dlg = new formInputBox("Введите название набора", "");

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                presetName = dlg.Result;
                fileName   = new StringBuilder(presetName.Length + 4);
                foreach (char c in presetName)
                {
                    if (invalidChars.Contains(c))
                    {
                        fileName.Append("_");
                    }
                    else
                    {
                        fileName.Append(c);
                    }
                }
                if (fileName.Length < 1)
                {
                    fileName.Append(DateTime.Now.ToString("yyyyMMdd_HHmmss"));
                }
                if (File.Exists(fileName.ToString() + ".pst"))
                {
                    MessageBox.Show(this, "Набор с именем " + presetName + " уже существует" +
                                    Environment.NewLine + "Необходимо ввести уникальное название набора",
                                    "Такой набор уже существует", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                File.WriteAllLines(fileName.ToString() + ".pst", selected.Select(p => p.Id.ToString()));
                lstPresets.Items.Add(fileName);
            }
        }