Exemple #1
0
        private void TvSiteMapNodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            TreeNode selectedNode = e.Node;

            selectedNode.TreeView.SelectedNode = selectedNode;
            var collec = (Dictionary <string, string>)selectedNode.Tag;

            TreeNodeHelper.AddContextMenu(e.Node, this);
            Control existingControl = panelContainer.Controls.Count > 0 ? panelContainer.Controls[0] : null;

            if (existingControl != null)
            {
                panelContainer.Controls.Remove(existingControl);
                existingControl.Dispose();
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            }

            switch (selectedNode.Text.Split(' ')[0])
            {
            case "SiteMap":
            {
                var ctrl = new SiteMapControl(collec);
                ctrl.Saved += CtrlSaved;

                panelContainer.Controls.Add(ctrl);
                ctrl.BringToFront();
                if (existingControl != null)
                {
                    panelContainer.Controls.Remove(existingControl);
                }
                tsbItemSave.Visible = true;
            }
            break;

            case "Area":
            {
                if (collec.Count == 0)
                {
                    collec.Add("Id", string.Format("tempId_{0}", DateTime.Now.Ticks));
                }
                var ctrl = new AreaControl(collec, webResourcesImageCache, webResourcesHtmlCache, Service);
                ctrl.Saved += CtrlSaved;

                panelContainer.Controls.Add(ctrl);
                ctrl.BringToFront();
                if (existingControl != null)
                {
                    panelContainer.Controls.Remove(existingControl);
                }
                tsbItemSave.Visible = true;
            }
            break;

            case "SubArea":
            {
                if (collec.Count == 0)
                {
                    collec.Add("Id", string.Format("tempId_{0}", DateTime.Now.Ticks));
                }
                var ctrl = new SubAreaControl(collec, entityCache, webResourcesImageCache, webResourcesHtmlCache,
                                              Service);
                ctrl.Saved += CtrlSaved;

                panelContainer.Controls.Add(ctrl);
                ctrl.BringToFront();
                if (existingControl != null)
                {
                    panelContainer.Controls.Remove(existingControl);
                }
                tsbItemSave.Visible = true;
            }
            break;

            case "Group":
            {
                if (collec.Count == 0)
                {
                    collec.Add("Id", string.Format("tempId_{0}", DateTime.Now.Ticks));
                }
                var ctrl = new GroupControl(collec);
                ctrl.Saved += CtrlSaved;

                panelContainer.Controls.Add(ctrl);
                ctrl.BringToFront();
                if (existingControl != null)
                {
                    panelContainer.Controls.Remove(existingControl);
                }
                tsbItemSave.Visible = true;
            }
            break;

            case "Privilege":
            {
                var ctrl = new PrivilegeControl(collec);
                ctrl.Saved += CtrlSaved;

                panelContainer.Controls.Add(ctrl);
                ctrl.BringToFront();
                if (existingControl != null)
                {
                    panelContainer.Controls.Remove(existingControl);
                }
                tsbItemSave.Visible = true;
            }
            break;

            case "Description":
            {
                var ctrl = new DescriptionControl(collec);
                ctrl.Saved += CtrlSaved;

                panelContainer.Controls.Add(ctrl);
                ctrl.BringToFront();
                if (existingControl != null)
                {
                    panelContainer.Controls.Remove(existingControl);
                }
                tsbItemSave.Visible = true;
            }
            break;

            case "Title":
            {
                var ctrl = new TitleControl(collec);
                ctrl.Saved += CtrlSaved;

                panelContainer.Controls.Add(ctrl);
                ctrl.BringToFront();
                if (existingControl != null)
                {
                    panelContainer.Controls.Remove(existingControl);
                }
                tsbItemSave.Visible = true;
            }
            break;

            default:
            {
                panelContainer.Controls.Clear();
                tsbItemSave.Visible = false;
            }
            break;
            }

            ManageMenuDisplay();
        }