Пример #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();
        }
Пример #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();
        }
Пример #3
0
        private void DeleteControlSubtree(ConditionControlBase control)
        {
            foreach (ConditionControlBase subcontrol in control.SubconditionControls)
            {
                DeleteControlSubtree(subcontrol);
            }

            Controls.Remove(control);
        }
Пример #4
0
        protected void DrawLinksToSubconditionControls(Graphics g, ConditionControlBase c)
        {
            foreach (ConditionControlBase child in c.SubconditionControls)
            {
                //g.DrawLine(SystemPens.ControlDark, c.Center, child.Center);
                //DrawLinksToSubconditionControls(g, child);

                Point[] points = new Point[4];
                points[0] = c.Center;
                points[1] = new Point(c.Center.X, c.Bounds.Bottom + verticalMargin);
                points[2] = new Point(child.Center.X, child.Top - verticalMargin);
                points[3] = child.Center;
                g.DrawLines(SystemPens.ControlDark, points);
                DrawLinksToSubconditionControls(g, child);
            }
        }
        public override void LayoutChildControls(int horizontalMargin, int verticalMargin)
        {
            ConditionControlBase rightControl = SubconditionControls[0];
            ConditionControlBase leftControl  = SubconditionControls[1];

            int rihgtSubtreeWidth = rightControl.GetSubtreeWidth(horizontalMargin, 0);
            int leftSubtreeWidth  = leftControl.GetSubtreeWidth(horizontalMargin, 0);

            int x = Center.X + rihgtSubtreeWidth / 2;
            int y = Bounds.Bottom + 2 * verticalMargin + rightControl.Height / 2;

            //int y = Bounds.Y + Bounds.Height + 2 * verticalMargin + rightControl.Height / 2;
            rightControl.Center = new Point(x, y);


            x = Center.X - leftSubtreeWidth / 2;
            y = Bounds.Bottom + 2 * verticalMargin + leftControl.Height / 2;
            //y = Bounds.Y + Bounds.Height + 2 * verticalMargin + leftControl.Height / 2;
            leftControl.Center = new Point(x, y);

            base.LayoutChildControls(horizontalMargin, verticalMargin);
        }
        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();
        }
        private ConditionControlBase GetControlForCondition(ICondition c, ConditionControlBase parent)
        {
            ConditionControlBase control = null;

            if (c == null)
            {
                ConditionPlaceholderControl cpc = new ConditionPlaceholderControl();
                cpc.ParentConditionControl = parent;
                cpc.InsertCondition += new EventHandler<InsertConditionEventArgs>(InsertCondition);
                Controls.Add(cpc);
                control = cpc;
            }
            else if (c.GetType() == typeof(ResponseStatusCodeEqualToCondition))
            {
                ResponseStatusEqualToControl ctl = new ResponseStatusEqualToControl();
                ctl.Condition = c;
                Controls.Add(ctl);
                control = ctl;
            }
            else if (c.GetType() == typeof(ResponseStatusCodeEqualToNotCondition))
            {
                ResponseStatusNotEqualToControl ctl = new ResponseStatusNotEqualToControl();
                ctl.Condition = c;
                Controls.Add(ctl);
                control = ctl;
            }
            else if (c.GetType() == typeof(ResponseBodyContainsCondition))
            {
                ResponseBodyContainsControl ctl = new ResponseBodyContainsControl();
                ctl.Condition = c;
                Controls.Add(ctl);
                control = ctl;
            }
            else if (c.GetType() == typeof(ResponseBodyContainsNotCondition))
            {
                ResponseBodyContainsNotControl ctl = new ResponseBodyContainsNotControl();
                ctl.Condition = c;
                Controls.Add(ctl);
                control = ctl;
            }
            else if (c.GetType() == typeof(ResponseBodyRegexMatchCondition))
            {
                ResponseBodyContainsRegexControl ctl = new ResponseBodyContainsRegexControl();
                ctl.Condition = c;
                Controls.Add(ctl);
                control = ctl;
            }
            else if (c.GetType() == typeof(ResponseBodyRegexMatchNotCondition))
            {
                ResponseBodyContainsRegexNotControl ctl = new ResponseBodyContainsRegexNotControl();
                ctl.Condition = c;
                Controls.Add(ctl);
                control = ctl;
            }
            else if (c.GetType() == typeof(AndCondition) || c.GetType() == typeof(OrCondition))
            {
                BinaryCondition bc = c as BinaryCondition;
                BinaryConditionControl ctl = (c.GetType() == typeof(AndCondition) ? (BinaryConditionControl)new AndControl() : (BinaryConditionControl)new OrControl());
                ctl.Condition = c;
                Controls.Add(ctl);
                control = ctl;

                ctl.SubconditionControls.Add(GetControlForCondition(bc.Condition2 as ICondition, ctl));

                ctl.SubconditionControls.Add(GetControlForCondition(bc.Condition1 as ICondition, ctl));
            }

            control.ParentConditionControl = parent;

            //if (parent != null)
            //    parent.SubconditionControls.Add(control);

            control.DeleteCondition += new EventHandler<DeleteConditionEventArgs>(DeleteCondition);

            return control;
        }
        private void DeleteControlSubtree(ConditionControlBase control)
        {
            foreach (ConditionControlBase subcontrol in control.SubconditionControls)
                DeleteControlSubtree(subcontrol);

            Controls.Remove(control);
        }
        protected void DrawLinksToSubconditionControls(Graphics g, ConditionControlBase c)
        {
            foreach (ConditionControlBase child in c.SubconditionControls)
            {
                //g.DrawLine(SystemPens.ControlDark, c.Center, child.Center);
                //DrawLinksToSubconditionControls(g, child);

                Point[] points = new Point[4];
                points[0] = c.Center;
                points[1] = new Point(c.Center.X, c.Bounds.Bottom + verticalMargin);
                points[2] = new Point(child.Center.X, child.Top - verticalMargin);
                points[3] = child.Center;
                g.DrawLines(SystemPens.ControlDark, points);
                DrawLinksToSubconditionControls(g, child);
            }
        }
        //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();
        }
Пример #11
0
        private ConditionControlBase GetControlForCondition(ICondition c, ConditionControlBase parent)
        {
            ConditionControlBase control = null;

            if (c == null)
            {
                ConditionPlaceholderControl cpc = new ConditionPlaceholderControl();
                cpc.ParentConditionControl = parent;
                cpc.InsertCondition       += new EventHandler <InsertConditionEventArgs>(InsertCondition);
                Controls.Add(cpc);
                control = cpc;
            }
            else if (c.GetType() == typeof(ResponseStatusCodeEqualToCondition))
            {
                ResponseStatusEqualToControl ctl = new ResponseStatusEqualToControl();
                ctl.Condition = c;
                Controls.Add(ctl);
                control = ctl;
            }
            else if (c.GetType() == typeof(ResponseStatusCodeEqualToNotCondition))
            {
                ResponseStatusNotEqualToControl ctl = new ResponseStatusNotEqualToControl();
                ctl.Condition = c;
                Controls.Add(ctl);
                control = ctl;
            }
            else if (c.GetType() == typeof(ResponseBodyContainsCondition))
            {
                ResponseBodyContainsControl ctl = new ResponseBodyContainsControl();
                ctl.Condition = c;
                Controls.Add(ctl);
                control = ctl;
            }
            else if (c.GetType() == typeof(ResponseBodyContainsNotCondition))
            {
                ResponseBodyContainsNotControl ctl = new ResponseBodyContainsNotControl();
                ctl.Condition = c;
                Controls.Add(ctl);
                control = ctl;
            }
            else if (c.GetType() == typeof(ResponseBodyRegexMatchCondition))
            {
                ResponseBodyContainsRegexControl ctl = new ResponseBodyContainsRegexControl();
                ctl.Condition = c;
                Controls.Add(ctl);
                control = ctl;
            }
            else if (c.GetType() == typeof(ResponseBodyRegexMatchNotCondition))
            {
                ResponseBodyContainsRegexNotControl ctl = new ResponseBodyContainsRegexNotControl();
                ctl.Condition = c;
                Controls.Add(ctl);
                control = ctl;
            }
            else if (c.GetType() == typeof(AndCondition) || c.GetType() == typeof(OrCondition))
            {
                BinaryCondition        bc  = c as BinaryCondition;
                BinaryConditionControl ctl = (c.GetType() == typeof(AndCondition) ? (BinaryConditionControl) new AndControl() : (BinaryConditionControl) new OrControl());
                ctl.Condition = c;
                Controls.Add(ctl);
                control = ctl;

                ctl.SubconditionControls.Add(GetControlForCondition(bc.Condition2 as ICondition, ctl));

                ctl.SubconditionControls.Add(GetControlForCondition(bc.Condition1 as ICondition, ctl));
            }

            control.ParentConditionControl = parent;

            //if (parent != null)
            //    parent.SubconditionControls.Add(control);

            control.DeleteCondition += new EventHandler <DeleteConditionEventArgs>(DeleteCondition);

            return(control);
        }