Beispiel #1
0
        private TreeNode DoFind(TreeNode selectedNode, InlineSearchControl.SearchEventArgs e, bool next)
        {
            byte[]          searchBytes  = e.Data != null ? e.Data : new BinaryEncoding().GetBytes(e.Text);
            string          searchString = e.Text != null ? e.Text : new BinaryEncoding().GetString(e.Data);
            List <TreeNode> nodes        = new List <TreeNode>();
            TreeNode        foundNode    = null;

            FlattenTree(nodes, treeViewNodes.TopNode);

            if (nodes.Count > 0)
            {
                int startIndex = nodes.IndexOf(selectedNode);

                if (startIndex < 0)
                {
                    startIndex = 0;
                }

                if (next)
                {
                    for (int i = startIndex + 1; i < nodes.Count; ++i)
                    {
                        if (MatchDataValue(nodes[i].Tag as DataValue, searchBytes, searchString))
                        {
                            foundNode = nodes[i];
                            break;
                        }
                    }
                }
                else
                {
                    for (int i = startIndex - 1; i >= 0; --i)
                    {
                        if (MatchDataValue(nodes[i].Tag as DataValue, searchBytes, searchString))
                        {
                            foundNode = nodes[i];
                            break;
                        }
                    }
                }
            }

            return(foundNode);
        }
Beispiel #2
0
        private void DoFind(InlineSearchControl.SearchEventArgs e, bool next)
        {
            bool found = false;

            if (radioButtonHex.Checked)
            {
                byte[] data;

                if (e.Data != null)
                {
                    data = e.Data;
                }
                else
                {
                    data = new BinaryEncoding().GetBytes(e.Text);
                }

                found = hexEditorControl.FindAndSelect(data, next);
            }
            else
            {
                string s;

                if (e.Text != null)
                {
                    s = e.Text;
                }
                else
                {
                    s = new BinaryEncoding().GetString(e.Data);
                }

                found = textEditorControl.FindAndSelect(s, next);
            }

            if (!found)
            {
                MessageBox.Show(this, CANAPE.Properties.Resources.BinaryDataEditorControl_NoMatch,
                                CANAPE.Properties.Resources.BinaryDataEditorControl_NoMatchCaption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        private void StartFind(InlineSearchControl.SearchEventArgs e, bool next)
        {
            TreeNode selectedNode = treeViewNodes.SelectedNode == null ? treeViewNodes.TopNode : treeViewNodes.SelectedNode;

            if (selectedNode != null)
            {
                TreeNode node = DoFind(selectedNode, e, next);

                if (node != null)
                {
                    treeViewNodes.SelectedNode = node;
                }
                else
                {
                    MessageBox.Show(this, CANAPE.Properties.Resources.TreeDataKeyEditorControl_NoMatch,
                                    CANAPE.Properties.Resources.TreeDataKeyEditorControl_NoMatchCaption,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #4
0
 private void inlineSearchControl_SearchPrev(object sender, InlineSearchControl.SearchEventArgs e)
 {
     DoFind(e, false);
 }
Beispiel #5
0
 private void inlineSearchControl_SearchNext(object sender, InlineSearchControl.SearchEventArgs e)
 {
     DoFind(e, true);
 }