Пример #1
0
        private void GetCurrentGroupNode(out FtpSiteDataGroup group, out TreeNode groupNode)
        {
            group     = null;
            groupNode = null;

            if (tvSites.SelectedNode != null)
            {
                var obj = tvSites.SelectedNode.Tag;
                if (obj is FtpSiteDataGroup)
                {
                    group     = obj as FtpSiteDataGroup;
                    groupNode = tvSites.SelectedNode;
                }
                else if (obj is FtpSiteData)
                {
                    group     = (obj as FtpSiteData).Group;
                    groupNode = tvSites.SelectedNode.Parent;
                }
            }
            if (group == null)
            {
                group = MainForm.RootSiteGroup;
            }
            if (groupNode == null)
            {
                groupNode = tvSites.Nodes[0];
            }
        }
Пример #2
0
        private void btnAddGroup_Click(object sender, EventArgs e)
        {
            if (CheckSiteSettingChanged(sender) == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }

            FtpSiteDataGroup group     = null;
            TreeNode         groupNode = null;

            GetCurrentGroupNode(out group, out groupNode);

            //用户输入新建站点名称
            var tmpGroupName = InputForm.GetInput("新建组", "组名称", "");

            if (String.IsNullOrEmpty(tmpGroupName))
            {
                return;
            }
            //创建FtpSiteDataGroup对象
            var tmpGroup = new FtpSiteDataGroup()
            {
                GUID  = Guid.NewGuid().ToString(),
                Name  = tmpGroupName,
                Group = group
            };
            //在树形控件中创建节点
            var tmpNode = groupNode.Nodes.Add(tmpGroupName, tmpGroupName, "Group", "Group");

            tmpNode.Tag = tmpGroup;
            //添加到组的组列表中
            group.Groups.Add(tmpGroup);
            //设置选中的节点为新建节点
            tvSites.SelectedNode = tmpNode;
        }
Пример #3
0
 private void ClearFtpSiteDataGroupRelationship(FtpSiteDataGroup group)
 {
     group.Group = null;
     foreach (var subgroup in group.Groups)
     {
         ClearFtpSiteDataGroupRelationship(subgroup);
     }
     foreach (var subsite in group.Sites)
     {
         if (!String.IsNullOrEmpty(subsite.Password))
         {
             subsite.Password = CryptographyHelper.DesEncrypt(subsite.Password, subsite.Name);
         }
         subsite.Group = null;
     }
 }
Пример #4
0
        private void _BindData(FtpSiteDataGroup group, TreeNode node)
        {
            node.Name     = group.Name;
            node.Text     = group.Name;
            node.ImageKey = "Group";
            node.Tag      = group;

            foreach (var subGroup in group.Groups)
            {
                _BindData(subGroup, node.Nodes.Add(""));
            }

            foreach (var site in group.Sites)
            {
                var tmpNode = node.Nodes.Add(site.Name, site.Name, "Site", "Site");
                tmpNode.Tag = site;
            }
        }
Пример #5
0
 private void AddItemToToolStripMenu(ToolStripMenuItem item, FtpSiteDataGroup group)
 {
     foreach (var subgroup in group.Groups)
     {
         ToolStripMenuItem tsi = new ToolStripMenuItem(subgroup.Name);
         tsi.Image = ilSites.Images["Group"];
         tsi.Tag   = subgroup;
         item.DropDownItems.Add(tsi);
         AddItemToToolStripMenu(tsi, subgroup);
     }
     foreach (var site in group.Sites)
     {
         ToolStripMenuItem tsi = new ToolStripMenuItem(site.Name);
         tsi.Image = ilSites.Images["Site"];
         tsi.Tag   = site;
         item.DropDownItems.Add(tsi);
         tsi.Click += new EventHandler(tsi_Click);
     }
 }
Пример #6
0
        /// <summary>
        /// 加载设置
        /// </summary>
        public void ReadSetting()
        {
            FtpSiteDataGroup tmpGroup = null;

            if (File.Exists(FtpSitesFileName))
            {
                //读取站点信息
                Byte[] buffer = File.ReadAllBytes(FtpSitesFileName);
                tmpGroup = SerializeHelper.XmlDeserializeObject(buffer, typeof(FtpSiteDataGroup)) as FtpSiteDataGroup;
            }

            if (tmpGroup == null)
            {
                RootSiteGroup = new FtpSiteDataGroup()
                {
                    Name = "根"
                };
            }
            else
            {
                SetFtpSiteDataGroupRelationship(tmpGroup);
                RootSiteGroup = tmpGroup;
            }
        }