コード例 #1
0
ファイル: NewTaskForm.cs プロジェクト: hong1975/wats
 public NewTaskForm(SubRegion region)
 {
     InitializeComponent();
     mRegion = region;
 }
コード例 #2
0
ファイル: WorkspaceForm.cs プロジェクト: hong1975/wats
        private void LoadRegion(TreeNode parentNode, SubRegion parentRegion)
        {
            TreeNode node;
            TreeNode adminNode;
            TreeNode managersNode;
            TreeNode managerNode;
            TreeNode sitesNode;
            TreeNode siteNode;
            TreeNode settingsNode;
            TreeNode channelSettingsNode;
            TreeNode linkSettingsNode;
            TreeNode equipmentSettingsNode;
            UsersModel usersModel;
            TreeNode channelSettingNode;
            TreeNode linkConfigurationNode;
            TreeNode equipmentParameterNode;
            if (parentRegion.Sub == null)
                return;
            foreach (SubRegion region in parentRegion.Sub)
            {
                node = parentNode.Nodes.Add(region.Name);
                node.Tag = region;
                node.ImageIndex = node.SelectedImageIndex = ICON_REGION;

                if (node.Parent != mGlobalNode)
                    adminNode = node.Nodes.Add("Administrator - " + region.Owner);
                else
                    adminNode = node.Nodes.Add("Administrator - [SYSTEM ADMIN]");
                adminNode.SelectedImageIndex = adminNode.ImageIndex = ICON_ADMIN;

                if (region.Manager.IndexOf(HTTPAgent.Username) >= 0
                    || region.Manager.Count == 0 && region.Owner != null && region.Owner.Equals(HTTPAgent.Username))
                {
                    managersNode = node.Nodes.Add("Managers");
                    usersModel = new UsersModel();
                    managersNode.Tag = usersModel;
                    managersNode.SelectedImageIndex = managersNode.ImageIndex = ICON_USERS;
                    if (region.Manager != null)
                    {
                        foreach (string manager in region.Manager)
                        {
                            managerNode = managersNode.Nodes.Add(manager);
                            managerNode.SelectedImageIndex = managerNode.ImageIndex = ICON_MANAGER;
                            usersModel.Add(manager);
                        }
                    }

                    sitesNode = node.Nodes.Add("Sites");
                    sitesNode.SelectedImageIndex = sitesNode.ImageIndex = ICON_SITES;
                    sitesNode.Tag = new SitesModel();
                    Site site;
                    if (region.Site != null)
                    {
                        foreach (string siteID in region.Site)
                        {
                            if (DataCenter.Instance().Sites.ContainsKey(siteID))
                                site = DataCenter.Instance().Sites[siteID];
                            else
                                site = new Site(siteID);
                            siteNode = sitesNode.Nodes.Add(site.ToString());
                            siteNode.SelectedImageIndex = siteNode.ImageIndex = ICON_SITE;
                            siteNode.Tag = new SiteModel(site);
                        }
                    }
                    SiteNodeListSorter.SortByName(sitesNode);

                    settingsNode = node.Nodes.Add("Settings");
                    settingsNode.SelectedImageIndex = settingsNode.ImageIndex = ICON_SETTINGS;

                    channelSettingsNode = settingsNode.Nodes.Add("Channel Settings");
                    channelSettingsNode.SelectedImageIndex = channelSettingsNode.ImageIndex = ICON_CHANNELSETTINGS;

                    linkSettingsNode = settingsNode.Nodes.Add("Link Configuration Settings");
                    linkSettingsNode.SelectedImageIndex = linkSettingsNode.ImageIndex = ICON_LINKSETTINGS;

                    equipmentSettingsNode = settingsNode.Nodes.Add("Equipment Parameter Settings");
                    equipmentSettingsNode.SelectedImageIndex = equipmentSettingsNode.ImageIndex = ICON_EQUIPMENTSETTINGS;

                    /*
                    channelSettingNode = settingsNode.Nodes.Add("");
                    if (region.ChannelSettingID == -1)
                        channelSettingNode.Text = "Channel setting - <Not set>";
                    else
                        channelSettingNode.Text = "Channel setting - " + DataCenter.Instance().ChannelSettingDescriptions[region.ChannelSettingID].FileName;
                    channelSettingNode.SelectedImageIndex = channelSettingNode.ImageIndex = ICON_CHANNELSETTING;
                    channelSettingNode.Tag = new ChannelModel(region.ChannelSettingID);

                    linkConfigurationNode = settingsNode.Nodes.Add("");
                    if (region.LinkConfigurationID == -1)
                        linkConfigurationNode.Text = "Link configuration - <Not set>";
                    else
                        linkConfigurationNode.Text = DataCenter.Instance().LinkConfigurationDescriptions[region.LinkConfigurationID].FileName;
                    linkConfigurationNode.SelectedImageIndex = linkConfigurationNode.ImageIndex = ICON_LINKCONFIGURATION;
                    linkConfigurationNode.Tag = new LinkModel(region.LinkConfigurationID);

                    equipmentParameterNode = settingsNode.Nodes.Add("");
                    if (region.EquipmentParameterID == -1)
                        equipmentParameterNode.Text = "Equipment parameter - <Not set>";
                    else
                        equipmentParameterNode.Text = DataCenter.Instance().EquipmentParameterDescriptions[region.EquipmentParameterID].FileName;
                    equipmentParameterNode.SelectedImageIndex = equipmentParameterNode.ImageIndex = ICON_EQUIPMENTPARAMETER;
                    equipmentParameterNode.Tag = new EquipmentModel(region.EquipmentParameterID);
                    */

                    if (region.Task != null)
                    {
                        foreach (long taskID in region.Task)
                        {
                            LoadTask(node, taskID);
                        }
                    }

                }
                else
                {
                    node.ImageIndex = node.SelectedImageIndex = ICON_REGIONUNAUTHORIZED;
                }

                LoadRegion(node, region);
            }
        }