コード例 #1
0
    /// <summary>
    /// Rebuilds the whole structure according to the MacroDesignerTree object.
    /// </summary>
    public void RebuildDesigner()
    {
        MacroDesignerGroup root = GetRootGroup();

        root.StoreData();
        root.BuildDesigner(true);
    }
コード例 #2
0
 /// <summary>
 /// Saves the current data to the MacroDesignerTree object.
 /// </summary>
 public override void StoreData()
 {
     if (CurrentGroup.IsLeaf)
     {
         CurrentGroup.GroupOperator = GroupOperator;
         if (pnlGroups.Controls.Count > 0)
         {
             MacroBoolExpression expr = (MacroBoolExpression)pnlGroups.Controls[0];
             CurrentGroup.LeftExpression  = expr.LeftExpression;
             CurrentGroup.RightExpression = expr.RightExpression;
             CurrentGroup.Operator        = expr.Operator;
         }
     }
     else
     {
         CurrentGroup.GroupOperator = GroupOperator;
         foreach (Control item in pnlGroups.Controls)
         {
             if (item is MacroDesignerGroup)
             {
                 MacroDesignerGroup group = (MacroDesignerGroup)item;
                 group.StoreData();
             }
         }
     }
 }
コード例 #3
0
    /// <summary>
    /// Moves the group to given location.
    /// </summary>
    /// <param name="sourcePath">Position path of the source</param>
    /// <param name="targetPath">Position path of the target</param>
    /// <param name="targetPos">Position within the target</param>
    public void MoveGroup(string sourcePath, string targetPath, int targetPos)
    {
        MacroDesignerGroup root = GetRootGroup();

        root.StoreData();
        root.CurrentGroup.MoveGroup(sourcePath, targetPath, targetPos);
        root.BuildDesigner(true);
    }
コード例 #4
0
    /// <summary>
    /// Loads new group control into the child panel controls collection.
    /// </summary>
    /// <param name="idPath">IDPath to ensure unique ID of the control</param>
    public Control AddGroup(string idPath)
    {
        // Add control to a controls collection
        MacroDesignerGroup group = (MacroDesignerGroup)Page.LoadUserControl("~/CMSAdminControls/UI/Macros/MacroDesignerGroup.ascx");

        group.ID = "g" + idPath.Replace(".", "_");
        pnlGroups.Controls.Add(group);

        return(group);
    }
コード例 #5
0
    /// <summary>
    /// Returns the root group.
    /// </summary>
    /// <param name="recursive">If true, BuldDesigner is called to child groups as well</param>
    public MacroDesignerGroup GetRootGroup()
    {
        MacroDesignerGroup group = this;

        while ((group.Parent != null) && (group.Parent.Parent.Parent != null) && (group.Parent.Parent.Parent is MacroDesignerGroup))
        {
            group = (MacroDesignerGroup)group.Parent.Parent.Parent;
        }
        return(group);
    }
コード例 #6
0
    /// <summary>
    /// Builds the designer controls structure.
    /// </summary>
    public override void BuildDesigner(bool recursive)
    {
        // Append child groups and expressions
        pnlGroups.Controls.Clear();

        if (CurrentGroup.IsLeaf)
        {
            plcNoItems.Visible = false;

            AddExpression(CurrentGroup.LeftExpression, CurrentGroup.RightExpression, CurrentGroup.Operator, CurrentGroup.IDPath);
        }
        else
        {
            if (CurrentGroup.Level == 0)
            {
                plcNoItems.Visible = true;
            }

            // Add child groups
            foreach (MacroDesignerTree child in CurrentGroup.ChildGroups)
            {
                MacroDesignerGroup ctrl = (MacroDesignerGroup)AddGroup(child.IDPath);
                ctrl.GroupOperator = child.GroupOperator;
                ctrl.CurrentGroup  = child;
                if (recursive)
                {
                    ctrl.BuildDesigner(true);
                }

                plcNoItems.Visible = false;
            }

            // Drop cue
            Panel pnlCue = new Panel();
            pnlCue.ID       = "pnlCue";
            pnlCue.CssClass = "MacroDesignerCue";
            pnlGroups.Controls.Add(pnlCue);

            pnlCue.Controls.Add(new LiteralControl("&nbsp;"));
            pnlCue.Style.Add("display", "none");

            // Create drag and drop extender
            extDragDrop = new DragAndDropExtender();

            extDragDrop.ID = "extDragDrop";
            extDragDrop.TargetControlID     = pnlGroups.ID;
            extDragDrop.DragItemClass       = "MacroElement";
            extDragDrop.DragItemHandleClass = "MacroElementHandle";
            extDragDrop.DropCueID           = pnlCue.ID;
            extDragDrop.OnClientDrop        = "OnDropGroup";

            pnlGroups.Controls.Add(extDragDrop);
        }
    }
コード例 #7
0
    protected void btnAddGroup_Click(object sender, ImageClickEventArgs e)
    {
        MacroDesignerGroup root = GetRootGroup();

        root.StoreData();

        MacroDesignerTree item = CurrentGroup.AddGroup();

        AddGroup(item.IDPath);

        root.BuildDesigner(true);
    }
コード例 #8
0
    protected void btnAddExp_Click(object sender, ImageClickEventArgs e)
    {
        MacroDesignerGroup root = GetRootGroup();

        root.StoreData();

        MacroDesignerTree  item = this.CurrentGroup.AddExpression();
        MacroDesignerGroup ctrl = (MacroDesignerGroup)this.AddGroup(item.IDPath);

        ctrl.CurrentGroup = item;

        root.BuildDesigner(true);
    }