Esempio n. 1
0
        public bool updateQueryTree(QueryStruct q, bool saveNew = false)
        {
            TreeNode contextNode = null;

            foreach (TreeNode n in contextTreeView.Nodes)
            {
                if (n.Text == q.context)
                {
                    contextNode = n;
                    foreach (QueryTreeNode qn in n.Nodes)
                    {
                        if (qn.Text == q.name)
                        {
                            qn.query = q.query;
                            return(true);
                        }
                    }
                }
            }

            if (saveNew && contextNode != null)
            {
                var queryNode = new QueryTreeNode();
                queryNode.Text  = q.name;
                queryNode.query = q.query;
                contextNode.Nodes.Add(queryNode);
            }

            return(false);
        }
Esempio n. 2
0
 // Opens a new query on doubleclicking tree node.
 private void contextTreeView_DoubleClick(object sender, EventArgs e)
 {
     if (contextTreeView.SelectedNode is QueryTreeNode)
     {
         QueryTreeNode qtn = (QueryTreeNode)contextTreeView.SelectedNode;
         addQueryTab(qtn.Parent.Text, qtn.query, qtn.Text);
     }
     else
     {
         addQueryTab(contextTreeView.SelectedNode.Text, "");
     }
 }
Esempio n. 3
0
        private void loadQueryTree()
        {
            TreeNode currentQueryType = null;

            StreamReader ini = null;

            try
            {
                ini = new StreamReader("LogViewer.ini");

                while (!ini.EndOfStream)
                {
                    var s = ini.ReadLine().Trim();

                    if (s.Length >= 2)
                    {
                        if (s[0] == '[' && s[s.Length - 1] == ']')
                        {
                            // New Query Type
                            currentQueryType = new TreeNode(s.Substring(1, s.Length - 2));
                            contextTreeView.Nodes.Add(currentQueryType);
                        }
                        else if (s.IndexOf('=') >= 0)
                        {
                            // New query
                            if (currentQueryType == null)
                            {
                                Console.Error.WriteLine("MainView(), currentQueryType == null: {0}", s);
                            }
                            else
                            {
                                string[] split = { "", "" };

                                split[0] = s.Substring(0, s.IndexOf("="));
                                split[1] = s.Substring(s.IndexOf("=") + 1).Replace(INI_NEWLINE, Environment.NewLine);

                                var queryNode = new QueryTreeNode();
                                queryNode.Text  = split[0];
                                queryNode.query = split[1];
                                currentQueryType.Nodes.Add(queryNode);
                            }
                        }
                        else
                        {
                            // Junk
                            Console.Error.WriteLine("MainView(), bad line: {0}", s);
                        }
                    }
                    else
                    {
                        if (s.Length > 0)
                        {
                            Console.Error.WriteLine("MainView(), short line: {0}", s);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                // Anything goes wrong, we load up default query types.
                foreach (var s in QUERY_TYPES)
                {
                    contextTreeView.Nodes.Add(s);
                }
            }
            finally
            {
                if (ini != null)
                {
                    ini.Close();
                }
            }
        }