public void TestDefine1()
        {
            TableTree tree = new TableTree();

            tree.Define("Foobar", "string_Const");
            Assert.IsTrue(tree.Lookup("Foobar").Unassigned);
        }
        internal static XElement DeserializeXElement(this Parser <char, ParseResult> parser, ITokenStream <char> stream)
        {
            var result = parser(stream).Case(
                (s, err) =>
            {
                ThrowFormatException("Parse failed: " + err, s);
                return(null);
            },
                (s, r) => Tuple.Create(s, r)
                );

            if (result.Item1.MoveNext().Current.HasValue)
            {
                ThrowFormatException("Parse stopped", result.Item1);
            }

            var root = new TableTree(new string[0], result.Item2.RootNodes);

            foreach (var t in result.Item2.Tables)
            {
                var current = root;
                var name    = t.Info.Name;
                for (var i = 0; i < name.Length - 1; i++)
                {
                    var currentName = name[i];
                    if (current.ArrayOfTables.ContainsKey(currentName))
                    {
                        current = current.ArrayOfTables[currentName].Last();
                    }
                    else if (current.Children.ContainsKey(currentName))
                    {
                        current = current.Children[currentName];
                    }
                    else
                    {
                        var newt = new TableTree(name.Take(i + 1).ToArray(), null);
                        current.Children.Add(currentName, newt);
                        current = newt;
                    }
                }

                var lastName = name[name.Length - 1];
                if (t.Info.IsArrayOfTable)
                {
                    List <TableTree> arrayOfTables;
                    if (!current.ArrayOfTables.TryGetValue(lastName, out arrayOfTables))
                    {
                        arrayOfTables = new List <TableTree>();
                        current.ArrayOfTables.Add(lastName, arrayOfTables);
                    }
                    arrayOfTables.Add(new TableTree(t.Info.Name, t.Content));
                }
                else
                {
                    current.Children.Add(lastName, new TableTree(t.Info.Name, t.Content));
                }
            }

            return(root.ToXElement("root"));
        }
        public void TestLookup1()
        {
            TableTree tree = new TableTree();

            tree.Define("Foobar", "string_Const");
            tree.Bind("Foobar", "bar");
            Assert.IsFalse(tree.Lookup("Foobar").Unassigned);
            Assert.AreEqual(tree.Lookup("Foobar").GetValue(), "bar");
        }
Example #4
0
        void treeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            TreeView tree = (TreeView)sender;

            tree.SelectedNode = e.Node;

            TableTree      tt            = (TableTree)tree.Parent;
            CWindowControl WindowControl = (CWindowControl)tt.Tag;

            RefreshLinkageWindowControl(WindowControl);
        }
Example #5
0
        public MainPage()
        {
            this.InitializeComponent();

            var defaultInst = NetworkTableInstance.Default;

            ConnectionBlock.StartNetworking(new NetworkTableConnectionHandler(defaultInst));
            serverClientManager = new NetworkTableServerClientManager(defaultInst);

            defaultInst.GetEntry("Hello").SetString("42");
            defaultInst.GetEntry("Inner/S1").SetString("56");
            defaultInst.GetEntry("Inner/S2").SetString("56hh");

            defaultInst.GetEntry("Inner/N2/v2").SetString("5asdasd6");
            defaultInst.GetEntry("Inner/N2/v1").SetString("5hdfgh6");

            entryHandler = new NetworkTableEntryHandler(defaultInst);
            TableTree.StartNetworking(entryHandler);
        }
 public void TestConstructor1()
 {
     TableTree tree = new TableTree();
 }
Example #7
0
        private void load_table()
        {
            TableTree.BeginUpdate();
            TableTree.Nodes.Clear();

            List_Strings.Items.Clear();
            Split.Panel2.Enabled = false;

            for (int i = 0; i < current_controller.Tables.Count; i++)
            {
                TreeNode main = new TreeNode(i.ToString("X2"));

                TextTable table = (TextTable)current_controller.Tables[i];

                string lang = "";
                switch (main.Text)
                {
                case "00":
                    lang = "JPN";
                    break;

                case "01":
                    lang = "ENG_E";
                    break;

                case "02":
                    lang = "ENG_U";
                    break;

                case "03":
                    lang = "DEU";
                    break;

                case "04":
                    lang = "FRA_E";
                    break;

                case "05":
                    lang = "FRA_U";
                    break;

                case "06":
                    lang = "ES_E";
                    break;

                case "07":
                    lang = "ES_U";
                    break;

                case "08":
                    lang = "IT";
                    break;

                case "09":
                    lang = "KOR";
                    break;

                case "0A":
                    lang = "ZH_TW";
                    break;

                case "0B":
                    lang = "ZH_CN";
                    break;
                }

                main.Text += " (" + lang + ")";

                for (int i2 = 0; i2 < table.archives.Count; i2++)
                {
                    main.Nodes.Add("archive_" + i2, i2.ToString("X2"), 1);
                }
                TableTree.Nodes.Add(main);
            }
            TableTree.EndUpdate();
        }
Example #8
0
        void LoadData()
        {
            if (Window == null)
            {
                return;
            }

            this.Width          = Window.Width;
            this.Height         = Window.Height;
            panelTop.Height     = Window.TopPanelHeight;
            panelBottom.Height  = Window.BottomPanelHeight;
            panelLeft.Width     = Window.LeftPanelWidth;
            panelRight.Width    = Window.RightPanelWidth;
            panelTop.Visible    = Window.TopPanelVisible;
            panelBottom.Visible = Window.BottomPanelVisible;
            panelLeft.Visible   = Window.LeftPanelVisible;
            panelRight.Visible  = Window.RightPanelVisible;

            List <CBaseObject> lstWindowControl = Window.WindowControlMgr.GetList();

            foreach (CBaseObject obj in lstWindowControl)
            {
                CWindowControl WindowControl = (CWindowControl)obj;
                Panel          panel         = null;
                if (WindowControl.Dock == (int)DockStyle.Top)
                {
                    panel = panelTop;
                }
                else if (WindowControl.Dock == (int)DockStyle.Bottom)
                {
                    panel = panelBottom;
                }
                else if (WindowControl.Dock == (int)DockStyle.Left)
                {
                    panel = panelLeft;
                }
                else if (WindowControl.Dock == (int)DockStyle.Right)
                {
                    panel = panelRight;
                }
                else
                {
                    panel = panelFill;
                }

                if (WindowControl.CtrlType == ControlType.NavBar)
                {
                    UIToolbar toolbar = new UIToolbar();
                    toolbar.WindowControl = WindowControl;
                    toolbar.Name          = WindowControl.Name;
                    panel.Controls.Add(toolbar);
                    toolbar.Dock = DockStyle.Fill;
                    toolbar.SendToBack();
                }
                else if (WindowControl.CtrlType == ControlType.TableGrid)
                {
                    if (WindowControl.TableInWindowControlMgr.GetList().Count == 0)
                    {
                        continue;
                    }
                    CTableInWindowControl TableInWindowControl = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();
                    CTable table = (CTable)Program.Ctx.TableMgr.Find(TableInWindowControl.FW_Table_id);
                    if (table == null)
                    {
                        continue;
                    }

                    CBaseObjectMgr objMgr = new CBaseObjectMgr();
                    objMgr.TbCode = table.Code;
                    objMgr.Ctx    = Program.Ctx;
                    TableGrid te = new TableGrid();
                    te.TableInWindowControl = TableInWindowControl;
                    te.BaseObjectMgr        = objMgr;
                    te.Name         = WindowControl.Name;
                    te.ShowToolBar  = TableInWindowControl.ShowToolBar;
                    te.ShowTitleBar = TableInWindowControl.ShowTitleBar;
                    te.CaptionText  = WindowControl.Name;
                    te.Tag          = WindowControl;
                    panel.Controls.Add(te);
                    te.Dock = (DockStyle)WindowControl.Dock;
                    te.BringToFront();
                    te.dataGridView.CellClick += new DataGridViewCellEventHandler(dataGridView_CellClick);
                }
                else if (WindowControl.CtrlType == ControlType.TableTree)
                {
                    TableTree tt = new TableTree();
                    tt.CaptionText   = WindowControl.Name;
                    tt.ShowTitleBar  = WindowControl.ShowTitleBar;
                    tt.WindowControl = WindowControl;
                    tt.Name          = WindowControl.Name;
                    tt.Tag           = WindowControl;
                    panel.Controls.Add(tt);
                    tt.Dock = DockStyle.Fill;
                    tt.BringToFront();

                    tt.treeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(treeView_NodeMouseClick);
                }
                else if (WindowControl.CtrlType == ControlType.TableTab)
                {
                    TableTab tab = new TableTab();
                    tab.WindowControl = WindowControl;
                    tab.CaptionText   = WindowControl.Name;
                    tab.Name          = WindowControl.Name;
                    tab.ShowTitleBar  = WindowControl.ShowTitleBar;
                    tab.Tag           = WindowControl;
                    panel.Controls.Add(tab);
                    tab.Dock = DockStyle.Fill;
                    tab.BringToFront();
                }
                else if (WindowControl.CtrlType == ControlType.ComboBox)
                {
                    if (WindowControl.TableInWindowControlMgr.GetList().Count == 0)
                    {
                        continue;
                    }
                    CTableInWindowControl TableInWindowControl = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();
                    CTable table = (CTable)Program.Ctx.TableMgr.Find(TableInWindowControl.FW_Table_id);
                    if (table == null)
                    {
                        continue;
                    }

                    CBaseObjectMgr objMgr = new CBaseObjectMgr();
                    objMgr.TbCode = table.Code;
                    objMgr.Ctx    = Program.Ctx;

                    UIComboBox cb = new UIComboBox();
                    cb.CaptionText          = WindowControl.Name + ":";
                    cb.TableInWindowControl = TableInWindowControl;
                    cb.BaseObjectMgr        = objMgr;
                    cb.Name = WindowControl.Name;
                    cb.Tag  = WindowControl;
                    panel.Controls.Add(cb);
                    cb.Dock = DockStyle.Top;
                    cb.BringToFront();

                    cb.comboBox.SelectedIndexChanged += new EventHandler(comboBox_SelectedIndexChanged);
                }
                else if (WindowControl.CtrlType == ControlType.ListBox)
                {
                    if (WindowControl.TableInWindowControlMgr.GetList().Count == 0)
                    {
                        continue;
                    }
                    CTableInWindowControl TableInWindowControl = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();
                    CTable table = (CTable)Program.Ctx.TableMgr.Find(TableInWindowControl.FW_Table_id);
                    if (table == null)
                    {
                        continue;
                    }

                    CBaseObjectMgr objMgr = new CBaseObjectMgr();
                    objMgr.TbCode = table.Code;
                    objMgr.Ctx    = Program.Ctx;

                    UIListBox listBox = new UIListBox();
                    listBox.CaptionText          = WindowControl.Name;
                    listBox.TableInWindowControl = TableInWindowControl;
                    listBox.BaseObjectMgr        = objMgr;
                    listBox.Name = WindowControl.Name;
                    listBox.Tag  = WindowControl;
                    panel.Controls.Add(listBox);
                    listBox.Dock = DockStyle.Fill;
                    listBox.BringToFront();

                    listBox.listBox.SelectedIndexChanged += new EventHandler(listBox_SelectedIndexChanged);
                }
            }
        }
Example #9
0
 public static void Init(TableTree tt)
 {
     tableTree  = tt;
     alertBox   = new AlertBox();
     confirmBox = new ConfirmBox();
 }