Exemplo n.º 1
0
        internal void DeleteCondition(object sender, DeleteConditionEventArgs e)
        {
            SuspendLayout();
            ConditionControlBase controlToDelete = sender as ConditionControlBase;
            ConditionControlBase parentControl   = controlToDelete.ParentConditionControl;

            Point center = controlToDelete.Center;

            DeleteControlSubtree(controlToDelete);
            ConditionControlBase newControl = GetControlForCondition(null, parentControl);

            if (parentControl != null)
            {
                int index = parentControl.SubconditionControls.IndexOf(controlToDelete);
                parentControl.SubconditionControls.Remove(controlToDelete);
                parentControl.SubconditionControls.Insert(index, newControl);
            }

            if (rootConditionControl == controlToDelete)
            {
                rootConditionControl = newControl;
            }

            newControl.Center = center;
            newControl.Focus();
            ResumeLayout();
            Invalidate();
        }
Exemplo n.º 2
0
        //internal void InsertCondition(object sender, InsertConditionEventArgs e)
        //{
        //    SuspendLayout();

        //    ICondition condition = Activator.CreateInstance(e.ConditiionType) as ICondition;

        //    ConditionControlBase placeholderControl = sender as ConditionControlBase;
        //    ConditionControlBase parentConditionControl = placeholderControl.ParentConditionControl;
        //    ConditionControlBase newControl;

        //    if (e.ConditiionType == typeof(AndCondition) || e.ConditiionType == typeof(OrCondition))
        //    {
        //        AndOrConditionControl binaryConditionControl = new AndOrConditionControl();
        //        binaryConditionControl.Condition = condition;

        //        ConditionPlaceholderControl cpc1 = new ConditionPlaceholderControl();
        //        cpc1.InsertCondition += new EventHandler<InsertConditionEventArgs>(InsertCondition);
        //        cpc1.ParentConditionControl = binaryConditionControl;
        //        binaryConditionControl.SubconditionControls.Add(cpc1);
        //        Controls.Add(cpc1);

        //        ConditionPlaceholderControl cpc2 = new ConditionPlaceholderControl();
        //        cpc2.InsertCondition += new EventHandler<InsertConditionEventArgs>(InsertCondition);
        //        cpc2.ParentConditionControl = binaryConditionControl;
        //        binaryConditionControl.SubconditionControls.Add(cpc2);
        //        Controls.Add(cpc2);

        //        newControl = binaryConditionControl;
        //    }
        //    else
        //    {
        //        ConditionControlWithTextBoxBase textControl = new ConditionControlWithTextBoxBase();
        //        textControl.Condition = condition;
        //        textControl.DeleteCondition += new EventHandler<DeleteConditionEventArgs>(DeleteCondition);

        //        newControl = textControl;
        //    }

        //    if (rootConditionControl == placeholderControl) rootConditionControl = newControl;

        //    if (parentConditionControl != null)
        //    {
        //        int index = parentConditionControl.SubconditionControls.IndexOf(placeholderControl);
        //        parentConditionControl.SubconditionControls.Remove(placeholderControl);
        //        parentConditionControl.SubconditionControls.Insert(index, newControl);

        //        newControl.ParentConditionControl = parentConditionControl;
        //    }

        //    Controls.Remove(placeholderControl);
        //    Controls.Add(newControl);

        //    newControl.Focus();

        //    ResumeLayout();
        //    Invalidate();
        //}

        internal void InsertCondition(object sender, InsertConditionEventArgs e)
        {
            SuspendLayout();

            ICondition condition = e.Condition;

            ConditionControlBase placeholderControl     = sender as ConditionControlBase;
            ConditionControlBase parentConditionControl = placeholderControl.ParentConditionControl;
            ConditionControlBase newControl             = GetControlForCondition(e.Condition, parentConditionControl);

            if (rootConditionControl == placeholderControl)
            {
                rootConditionControl = newControl;
            }

            if (parentConditionControl != null)
            {
                int index = parentConditionControl.SubconditionControls.IndexOf(placeholderControl);
                parentConditionControl.SubconditionControls.Remove(placeholderControl);
                parentConditionControl.SubconditionControls.Insert(index, newControl);

                newControl.ParentConditionControl = parentConditionControl;
            }

            Controls.Remove(placeholderControl);

            newControl.Focus();

            ResumeLayout();
            Invalidate();
        }