Beispiel #1
0
        /// <summary>
        /// Add P50x command station
        /// </summary>
        private void tbbAddP50x_Click(object sender, EventArgs e)
        {
            var cs = appState.Package.AddNewP50xCommandStation();

            cs.Description = Strings.NewP50xCommandStationDescription;
            var csRef = appState.Package.Railway.CommandStations.Add(cs);
            var node  = new EntityRefNode <ICommandStation>(csRef, cs);

            activeCommandStationsRoot.Nodes.Add(node);
            tvItems.SelectedNode = node;
            UpdateAppTitle.Fire(this);
            ValidateRailway();
        }
Beispiel #2
0
        /// <summary>
        /// Add a new locomotive
        /// </summary>
        private void tbAddLoc_Click(object sender, EventArgs e)
        {
            var loc = appState.Package.AddNewLoc();

            loc.Description = Strings.NewLocDescription;
            var locRef = appState.Package.Railway.Locs.Add(loc);
            var node   = new EntityRefNode <ILoc>(locRef, loc);

            activeLocsRoot.Nodes.Add(node);
            tvItems.SelectedNode = node;
            UpdateAppTitle.Fire(this);
            ValidateRailway();
        }
Beispiel #3
0
        /// <summary>
        /// Add a new module
        /// </summary>
        private void tbAddModule_Click(object sender, EventArgs e)
        {
            var module = appState.Package.AddNewModule();

            module.Description = Strings.NewModuleDescription;
            var moduleRef = appState.Package.Railway.Modules.Add(module);
            var node      = new EntityRefNode <IModule>(moduleRef, module);

            activeModulesRoot.Nodes.Add(node);
            tvItems.SelectedNode = node;
            UpdateAppTitle.Fire(this);
            ValidateRailway();
        }
        /// <summary>
        /// Reload the package data into this control
        /// </summary>
        private void ReloadNodes()
        {
            using (tvItems.BeginUpdate())
            {
                var modulesNodes   = new TreeNode("Modules");
                var locsNodes      = new TreeNode("Locs");
                var locGroupsNodes = new TreeNode("Loc groups");
                tvItems.Nodes.Add(new EntityNode(railway, null));
                tvItems.Nodes.Add(locsNodes);
                tvItems.Nodes.Add(locGroupsNodes);
                tvItems.Nodes.Add(modulesNodes);

                foreach (var locRef in railway.Locs.OrderBy(x => x.ToString()))
                {
                    ILoc loc;
                    if (locRef.TryResolve(out loc))
                    {
                        locsNodes.Nodes.Add(new EntityRefNode <ILoc>(locRef, loc));
                    }
                }
                foreach (var locGroup in railway.LocGroups.OrderBy(x => x.ToString()))
                {
                    locGroupsNodes.Nodes.Add(new EntityNode(locGroup, null));
                }
                foreach (var moduleRef in railway.Modules.OrderBy(x => x.ToString()))
                {
                    IModule module;
                    if (moduleRef.TryResolve(out module))
                    {
                        if (firstModule == null)
                        {
                            firstModule = module;
                        }
                        var moduleNode = new EntityRefNode <IModule>(moduleRef, module);
                        modulesNodes.Nodes.Add(moduleNode);

                        var moduleTree = new ModuleTree(moduleNode.Nodes);
                        moduleTree.ReloadModule(module, null, false);
                        moduleNode.Collapse(false);
                    }
                }

                tvItems.ExpandAll();
            }
        }