Пример #1
0
        private void OnListViewExpressionsAfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            try
            {
                if (e.CancelEdit || e.Label == null)
                {
                    return;
                }

                XPathExpressionListViewItem item = this.listViewExpressions.Items[e.Item] as XPathExpressionListViewItem;

                if (item == null)
                {
                    return;
                }

                item.XPathExpression.Name = e.Label;

                item.Text = e.Label;

                this.listViewExpressions.AutoResizeColumns();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                ExceptionDialog.ShowDialog(this, ex);
            }
        }
Пример #2
0
        private void OnListViewExpressionsKeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (this.listViewExpressions.SelectedItems.Count < 1)
                {
                    return;
                }

                XPathExpressionListViewItem item = this.listViewExpressions.SelectedItems[0] as XPathExpressionListViewItem;

                if (item == null)
                {
                    return;
                }

                switch (e.KeyCode)
                {
                case Keys.Delete:
                    this.DeleteSelectedExpressionItems(e.Shift);
                    break;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                ExceptionDialog.ShowDialog(this, ex);
            }
        }
Пример #3
0
        private void DeleteSelectedExpressions()
        {
            ArrayList selectedItems = new ArrayList(this.listViewExpressions.SelectedItems);

            string message = string.Format("Are you sure you want to delete the selected expression{0}?", selectedItems.Count == 1 ? "" : "s");

            var result = MessageBox.Show(this, message, "Delete Expressions", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result != System.Windows.Forms.DialogResult.Yes)
            {
                return;
            }

            foreach (var selectedItem in selectedItems)
            {
                XPathExpressionListViewItem item = selectedItem as XPathExpressionListViewItem;
                if (item != null)
                {
                    if (_expressions.Contains(item.XPathExpression))
                    {
                        _expressions.Remove(item.XPathExpression);
                    }
                }

                item.Remove();
            }
        }
Пример #4
0
        public void LoadExpressions(string filterText)
        {
            try
            {
                this.listViewExpressions.BeginUpdate();
                this.listViewExpressions.Items.Clear();

                if (_expressions == null)
                {
                    return;
                }

                string lowerSearchText = null;
                if (!string.IsNullOrEmpty(filterText))
                {
                    lowerSearchText = filterText.ToLower();
                }

                foreach (XPathExpression expression in _expressions)
                {
                    if (string.IsNullOrEmpty(filterText) || this.IsMatchingExpression(expression, lowerSearchText))
                    {
                        XPathExpressionListViewItem item = new XPathExpressionListViewItem(expression);

                        this.listViewExpressions.Items.Add(item);
                    }
                }

                this.listViewExpressions.AutoResizeColumns();
            }
            finally
            {
                this.listViewExpressions.EndUpdate();
            }
        }
Пример #5
0
        public void EditXPathExpression(XPathExpression xpathExpression)
        {
            using (XPathExpressionDialog dialog = new XPathExpressionDialog(xpathExpression))
            {
                if (dialog.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }
            }

            foreach (ListViewItem item in this.listViewExpressions.Items)
            {
                XPathExpressionListViewItem expressionItem = item as XPathExpressionListViewItem;
                if (expressionItem == null)
                {
                    continue;
                }

                if (expressionItem.XPathExpression == xpathExpression)
                {
                    expressionItem.Initialize();
                    //this.toolStripTextBoxXpath.Text = xpathExpression.Expression;
                    break;
                }
            }

            this.listViewExpressions.AutoResizeColumns();
        }
Пример #6
0
        public void AddXPathExpression(string expression)
        {
            XPathExpression xpathExpression = new XPathExpression();

            xpathExpression.Expression = expression;
            _expressions.Add(xpathExpression);
            XPathExpressionListViewItem item = new XPathExpressionListViewItem(xpathExpression);

            this.listViewExpressions.Items.Add(item);
            this.UpdateXPathExpressionTool(expression);
            this.listViewExpressions.AutoResizeColumns();
            //this.toolStripButtonXPathExpression.ToolTipText = "Edit expression";
        }
Пример #7
0
        public void DeleteSelectedExpressionItems(bool skipConfirmation)
        {
            DialogResult result = DialogResult.Yes;

            if (!skipConfirmation)
            {
                string message = "";
                string caption = "";

                int count = this.listViewExpressions.SelectedItems.Count;
                if (count > 1)
                {
                    message = string.Format("Are you sure you want to delete these {0} expressions?", count);
                    caption = "Confirm multiple expression delete";
                }
                else
                {
                    message = "Are you sure you want to delete this expression?";
                    caption = "Confirm expression delete";
                }
                result = MessageBox.Show(this, message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
            }

            if (result != DialogResult.Yes)
            {
                return;
            }

            foreach (ListViewItem item in this.listViewExpressions.SelectedItems)
            {
                XPathExpressionListViewItem expressionItem = item as XPathExpressionListViewItem;
                if (expressionItem != null)
                {
                    _expressions.Remove(expressionItem.XPathExpression);
                }

                item.Remove();
            }

            //string text = this.toolStripTextBoxXpath.Text;

            //this.UpdateXPathExpressionTool(text);
        }