Ejemplo n.º 1
0
        public void Panel_AutoSizeMode_SetWithCustomLayoutEngineParent_GetReturnsExpected(AutoSizeMode value, int expectedLayoutCallCount)
        {
            using var parent  = new CustomLayoutEngineControl();
            using var control = new SubPanel
                  {
                      Parent = parent
                  };
            parent.SetLayoutEngine(new SubLayoutEngine());
            int layoutCallCount = 0;

            control.Layout += (sender, e) => layoutCallCount++;
            int parentLayoutCallCount = 0;

            void parentHandler(object sender, LayoutEventArgs e)
            {
                Assert.Same(parent, sender);
                Assert.Same(control, e.AffectedControl);
                Assert.Equal("AutoSize", e.AffectedProperty);
                parentLayoutCallCount++;
            };
            parent.Layout += parentHandler;
            try
            {
                control.AutoSizeMode = value;
                Assert.Equal(value, control.AutoSizeMode);
                Assert.Equal(value, control.GetAutoSizeMode());
                Assert.False(control.IsHandleCreated);
                Assert.Equal(0, layoutCallCount);
                Assert.False(parent.IsHandleCreated);
                Assert.Equal(expectedLayoutCallCount, parentLayoutCallCount);

                // Set same.
                control.AutoSizeMode = value;
                Assert.Equal(value, control.AutoSizeMode);
                Assert.Equal(value, control.GetAutoSizeMode());
                Assert.False(control.IsHandleCreated);
                Assert.Equal(0, layoutCallCount);
                Assert.False(parent.IsHandleCreated);
                Assert.Equal(expectedLayoutCallCount, parentLayoutCallCount);
            }
            finally
            {
                parent.Layout -= parentHandler;
            }
        }
Ejemplo n.º 2
0
        public void Panel_CreateParams_GetDefault_ReturnsExpected()
        {
            var          control      = new SubPanel();
            CreateParams createParams = control.CreateParams;

            Assert.Null(createParams.Caption);
            Assert.Null(createParams.ClassName);
            Assert.Equal(0x8, createParams.ClassStyle);
            Assert.Equal(0x10000, createParams.ExStyle);
            Assert.Equal(100, createParams.Height);
            Assert.Equal(IntPtr.Zero, createParams.Parent);
            Assert.Null(createParams.Param);
            Assert.Equal(0x56000000, createParams.Style);
            Assert.Equal(200, createParams.Width);
            Assert.Equal(0, createParams.X);
            Assert.Equal(0, createParams.Y);
            Assert.Same(createParams, control.CreateParams);
        }
Ejemplo n.º 3
0
        public void Panel_AutoSizeMode_Set_GetReturnsExpected(AutoSizeMode value)
        {
            using var control = new SubPanel();
            int layoutCallCount = 0;

            control.Layout += (sender, e) => layoutCallCount++;

            control.AutoSizeMode = value;
            Assert.Equal(value, control.AutoSizeMode);
            Assert.Equal(value, control.GetAutoSizeMode());
            Assert.False(control.IsHandleCreated);
            Assert.Equal(0, layoutCallCount);

            // Set same.
            control.AutoSizeMode = value;
            Assert.Equal(value, control.AutoSizeMode);
            Assert.Equal(value, control.GetAutoSizeMode());
            Assert.False(control.IsHandleCreated);
            Assert.Equal(0, layoutCallCount);
        }
Ejemplo n.º 4
0
        public void Panel_OnResize_InvokeWithDesignModeAndResizeRedraw_CallsResizeAndInvalidate(EventArgs eventArgs)
        {
            var mockSite = new Mock <ISite>(MockBehavior.Strict);

            mockSite
            .Setup(s => s.DesignMode)
            .Returns(true);
            mockSite
            .Setup(s => s.GetService(typeof(AmbientProperties)))
            .Returns(null);
            var control = new SubPanel
            {
                Site = mockSite.Object
            };

            control.SetStyle(ControlStyles.ResizeRedraw, true);
            Assert.NotEqual(IntPtr.Zero, control.Handle);
            int          callCount = 0;
            EventHandler handler   = (sender, e) =>
            {
                Assert.Same(control, sender);
                Assert.Same(eventArgs, e);
                callCount++;
            };
            int invalidatedCallCount = 0;
            InvalidateEventHandler invalidatedHandler = (sender, e) => invalidatedCallCount++;

            // Call with handler.
            control.Resize      += handler;
            control.Invalidated += invalidatedHandler;
            control.OnResize(eventArgs);
            Assert.Equal(1, callCount);
            Assert.Equal(2, invalidatedCallCount);

            // Remove handler.
            control.Resize      -= handler;
            control.Invalidated -= invalidatedHandler;
            control.OnResize(eventArgs);
            Assert.Equal(1, callCount);
            Assert.Equal(2, invalidatedCallCount);
        }
Ejemplo n.º 5
0
        public void Panel_CreateParams_GetBorderStyle_ReturnsExpected(BorderStyle borderStyle, int expectedStyle, int expectedExStyle)
        {
            using var control = new SubPanel
                  {
                      BorderStyle = borderStyle
                  };
            CreateParams createParams = control.CreateParams;

            Assert.Null(createParams.Caption);
            Assert.Null(createParams.ClassName);
            Assert.Equal(0x8, createParams.ClassStyle);
            Assert.Equal(expectedExStyle, createParams.ExStyle);
            Assert.Equal(100, createParams.Height);
            Assert.Equal(IntPtr.Zero, createParams.Parent);
            Assert.Null(createParams.Param);
            Assert.Equal(expectedStyle, createParams.Style);
            Assert.Equal(200, createParams.Width);
            Assert.Equal(0, createParams.X);
            Assert.Equal(0, createParams.Y);
            Assert.Same(createParams, control.CreateParams);
        }
Ejemplo n.º 6
0
        public void Panel_OnKeyUp_Invoke_CallsKeyUp(KeyEventArgs eventArgs)
        {
            var             control   = new SubPanel();
            int             callCount = 0;
            KeyEventHandler handler   = (sender, e) =>
            {
                Assert.Same(control, sender);
                Assert.Same(eventArgs, e);
                callCount++;
            };

            // Call with handler.
            control.KeyUp += handler;
            control.OnKeyUp(eventArgs);
            Assert.Equal(1, callCount);

            // Remove handler.
            control.KeyUp -= handler;
            control.OnKeyUp(eventArgs);
            Assert.Equal(1, callCount);
        }
Ejemplo n.º 7
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (!Hidden)
            {
                NinePatchRegion2D ninePatch = _releasedTexture;
                if (ButtonState == ButtonState.Hover)
                {
                    ninePatch = _hoverTexture;
                }
                if (ButtonState == ButtonState.Pressed)
                {
                    ninePatch = _pressedTexture;
                }

                spriteBatch.Draw(ninePatch,
                                 new Rectangle((int)TopLeft.X,
                                               (int)TopLeft.Y,
                                               (int)Width,
                                               (int)Height),
                                 Color.White);
                SubPanel.Draw(spriteBatch);
            }
        }
Ejemplo n.º 8
0
 public void Panel_GetTopLevel_Invoke_ReturnsExpected()
 {
     using var control = new SubPanel();
     Assert.False(control.GetTopLevel());
 }
Ejemplo n.º 9
0
        string BuildSequentialPanelSql(Panel panel, bool showPersonId)
        {
            var firstSubpanelIndex = panel.SubPanels.ElementAt(0).Index;
            var panelSql           = new StringBuilder();
            var outputColumn       = showPersonId ? $"{Dialect.ALIAS_SUBQUERY}{firstSubpanelIndex}.{compilerOptions.FieldPersonId} " : "1 ";

            // SELECT ...
            // FROM ...
            panelSql.Append($"{Dialect.SQL_SELECT} {outputColumn}" +
                            $"{Dialect.SQL_FROM} ");

            bool   hasAnchorDate = false;
            bool   isAnchorDate  = false;
            string anchorDate    = string.Empty;

            for (int k = 0; k < panel.SubPanels.Count; k++)
            {
                string   nonEncounterJoinLogic = string.Empty;
                string   nonEventJoinLogic     = string.Empty;
                SubPanel subPanel  = panel.SubPanels.ElementAt(k);
                var      firstItem = subPanel.PanelItems.ElementAt(0);
                isAnchorDate = false;

                if (!hasAnchorDate)
                {
                    // In order to have a base date to join on later in the sequence,
                    // track the first included subpanel date field.
                    if (subPanel.JoinSequence.SequenceType != SequenceType.PlusMinus && subPanel.IncludeSubPanel)
                    {
                        hasAnchorDate = true;
                        isAnchorDate  = true;
                        anchorDate    = PrependSetAlias($"{Dialect.ALIAS_SUBQUERY}{k}", subPanel.PanelItems.ElementAt(0).Concept.SqlFieldDate);
                    }
                }
                else
                {
                    if (subPanel.IncludeSubPanel && subPanel.JoinSequence.SequenceType == SequenceType.WithinFollowing)
                    {
                        anchorDate = $"DATEADD({subPanel.JoinSequence.DateIncrementType.ToString()}, {subPanel.JoinSequence.Increment}, {anchorDate})";
                    }
                }

                // JOIN ...
                if (k > 0)
                {
                    panelSql.Append(" " + (subPanel.IncludeSubPanel ? Dialect.SQL_INNERJOIN : Dialect.SQL_LEFTJOIN) + Dialect.SQL_SPACE);
                }
                panelSql.Append("(");

                for (int j = 0; j < subPanel.PanelItems.Count(); j++)
                {
                    var itemConfig = new PanelItemContext
                    {
                        PanelItem = subPanel.PanelItems.ElementAt(j),
                        SubPanelHasNonEncounter = subPanel.HasNonEncounter,
                        TargetColumn            = compilerOptions.FieldPersonId,
                        FilterDate        = panel.IsDateFiltered,
                        FilterCount       = subPanel.HasCountFilter,
                        MinCount          = subPanel.MinimumCount,
                        DateStart         = panel.DateFilter?.Start,
                        DateStop          = panel.DateFilter?.End,
                        IsSequential      = true,
                        IsExists          = false,
                        ExistsParentAlias = string.Empty,
                        ExistsJoinColumn  = string.Empty
                    };

                    var itemSql = BuildPanelItemSql(itemConfig);
                    panelSql.Append(itemSql);

                    // Add UNION ALL if other panel items follow
                    if ((j + 1) < subPanel.PanelItems.Count())
                    {
                        panelSql.Append($" {Dialect.SQL_UNIONALL} ");
                    }
                }

                if (k == 0)
                {
                    panelSql.Append($") AS {Dialect.ALIAS_SUBQUERY}{k} ");
                }
                else
                {
                    // ON A.PersonID = B.PersonID
                    panelSql.Append(") AS " +
                                    $"{Dialect.ALIAS_SUBQUERY}{k} {Dialect.SQL_ON} {Dialect.ALIAS_SUBQUERY}{firstSubpanelIndex}.{compilerOptions.FieldPersonId} = " +
                                    $"{Dialect.ALIAS_SUBQUERY}{k}.{compilerOptions.FieldPersonId} ");

                    panelSql.Append(Dialect.SQL_AND + " ");
                    var prevSub = panel.SubPanels.ElementAt(k - 1);

                    // If the previous SubPanel was Excluded, append "( ... additional logic ... )"
                    if (!prevSub.IncludeSubPanel)
                    {
                        panelSql.Append("(");
                    }

                    // If same encounter as previous SubPanel
                    if (subPanel.JoinSequence.SequenceType == SequenceType.Encounter)
                    {
                        // A0.EncounterID = A1.EncounterID
                        panelSql.Append($"{Dialect.ALIAS_SUBQUERY}{k - 1}.{compilerOptions.FieldEncounterId} = {Dialect.ALIAS_SUBQUERY}{k}.{compilerOptions.FieldEncounterId} {nonEncounterJoinLogic}");
                    }

                    // If same event as previous SubPanel
                    else if (subPanel.JoinSequence.SequenceType == SequenceType.Event)
                    {
                        // A0.EventId = A1.EventId
                        panelSql.Append(
                            $"{PrependSetAlias($"{Dialect.ALIAS_SUBQUERY}{k - 1}", prevSub.PanelItems.ElementAt(0).Concept.SqlFieldEvent)} = " +
                            $"{PrependSetAlias($"{Dialect.ALIAS_SUBQUERY}{k}", firstItem.Concept.SqlFieldEvent)} {nonEventJoinLogic} ");
                    }

                    // If +/- date in previous SubPanel
                    else if (subPanel.JoinSequence.SequenceType == SequenceType.PlusMinus)
                    {
                        panelSql.Append(
                            // (A1.DateField BETWEEN
                            $"({PrependSetAlias($"{Dialect.ALIAS_SUBQUERY}{k}", firstItem.Concept.SqlFieldDate)} {Dialect.SQL_BETWEEN} " +
                            // DATEADD(MONTH, -1, A0.DateField
                            $"{Dialect.SQL_DATEADD}{subPanel.JoinSequence.DateIncrementType.ToString().ToUpper()}, -{subPanel.JoinSequence.Increment}, {PrependSetAlias($"{Dialect.ALIAS_SUBQUERY}{k - 1}", prevSub.PanelItems.ElementAt(0).Concept.SqlFieldDate)}) " +
                            // AND
                            Dialect.SQL_AND +
                            // DATEADD(MONTH, 1, A0.DateField)
                            $"{Dialect.SQL_DATEADD}{subPanel.JoinSequence.DateIncrementType.ToString().ToUpper()}, {subPanel.JoinSequence.Increment}, {PrependSetAlias($"{Dialect.ALIAS_SUBQUERY}{k - 1}", prevSub.PanelItems.ElementAt(0).Concept.SqlFieldDate)}) " +
                            $"{nonEncounterJoinLogic})");
                    }

                    // If follows within a range of previous SubPanel
                    else if (subPanel.JoinSequence.SequenceType == SequenceType.WithinFollowing)
                    {
                        panelSql.Append(
                            // (A1.DateField BETWEEN
                            $"({PrependSetAlias($"{Dialect.ALIAS_SUBQUERY}{k}", firstItem.Concept.SqlFieldDate)} {Dialect.SQL_BETWEEN} " +
                            // A0.DateField
                            $"{PrependSetAlias($"{Dialect.ALIAS_SUBQUERY}{k - 1}", prevSub.PanelItems.ElementAt(0).Concept.SqlFieldDate)} " +
                            // AND
                            Dialect.SQL_AND +
                            // DATEADD(MONTH, 1, A0.DateField)
                            $"{Dialect.SQL_DATEADD}{subPanel.JoinSequence.DateIncrementType.ToString().ToUpper()}, {subPanel.JoinSequence.Increment}, {PrependSetAlias($"{Dialect.ALIAS_SUBQUERY}{k - 1}", prevSub.PanelItems.ElementAt(0).Concept.SqlFieldDate)}) " +
                            $"{nonEncounterJoinLogic})");
                    }

                    // If follows anytime of previous SubPanel
                    else if (subPanel.JoinSequence.SequenceType == SequenceType.AnytimeFollowing)
                    {
                        panelSql.Append(
                            // (A1.DateField >
                            $"({PrependSetAlias($"{Dialect.ALIAS_SUBQUERY}{k}", firstItem.Concept.SqlFieldDate)} > " +
                            // A0.DateField)
                            $"{PrependSetAlias($"{Dialect.ALIAS_SUBQUERY}{k - 1}", prevSub.PanelItems.ElementAt(0).Concept.SqlFieldDate)} " +
                            $"{nonEncounterJoinLogic})");
                    }

                    // If the previous SubPanel was Excluded
                    if (!prevSub.IncludeSubPanel)
                    {
                        // ) OR (A0.PersonId IS NULL
                        panelSql.Append($" {Dialect.SQL_OR} ({Dialect.ALIAS_SUBQUERY}{k - 1}.{compilerOptions.FieldPersonId} {Dialect.SQL_ISNULL} ");

                        if (hasAnchorDate && !isAnchorDate && subPanel.JoinSequence.SequenceType != SequenceType.Encounter)
                        {
                            // AND A1.DateField >
                            panelSql.Append($"{Dialect.SQL_AND} ({PrependSetAlias($"{Dialect.ALIAS_SUBQUERY}{k}", firstItem.Concept.SqlFieldDate)} > " +
                                            $"{anchorDate})");
                        }
                        panelSql.Append(")) ");
                    }
                }
            }

            // JOIN to parent SQL set
            if (!showPersonId)
            {
                panelSql.Append($"{Dialect.SQL_WHERE} {Dialect.ALIAS_PERSON}.{compilerOptions.FieldPersonId} = {Dialect.ALIAS_PERSON}{panel.Index}.{compilerOptions.FieldPersonId} ");
            }

            List <int> subPanelsWithHavingClause = (from s in panel.SubPanels
                                                    where !s.IncludeSubPanel || s.HasCountFilter
                                                    select s.Index).ToList();

            if (subPanelsWithHavingClause.Count > 0 || showPersonId)
            {
                // GROUP BY PersonId
                panelSql.Append($" {Dialect.SQL_GROUPBY} {Dialect.ALIAS_SUBQUERY}{firstSubpanelIndex}.{compilerOptions.FieldPersonId} ");

                if (subPanelsWithHavingClause.Count > 0)
                {
                    panelSql.Append($"HAVING ");

                    foreach (int k in subPanelsWithHavingClause)
                    {
                        SubPanel subPanel          = panel.SubPanels.ElementAt(k);
                        string   countDistinctDate = $"{Dialect.SQL_COUNT}DISTINCT {PrependSetAlias($"{Dialect.ALIAS_SUBQUERY}{k}", subPanel.PanelItems.ElementAt(0).Concept.SqlFieldDate)}) ";

                        // If SubPanel is Included and has a COUNT filter
                        if (subPanel.HasCountFilter && subPanel.IncludeSubPanel)
                        {
                            panelSql.Append($"{countDistinctDate} >= {subPanel.MinimumCount} ");
                        }
                        // If SubPanel is Excluded and has a COUNT filter
                        else if (subPanel.HasCountFilter && !subPanel.IncludeSubPanel)
                        {
                            panelSql.Append($"{countDistinctDate} < {subPanel.MinimumCount} ");
                        }
                        // If SubPanel is Excluded and does not have a COUNT Filter
                        else if (!subPanel.HasCountFilter && !subPanel.IncludeSubPanel)
                        {
                            panelSql.Append($"{countDistinctDate} = 0");
                        }

                        if (k < subPanelsWithHavingClause.Max())
                        {
                            panelSql.Append($"{Dialect.SQL_AND} ");
                        }
                    }
                }
            }

            return(panelSql.ToString());
        }
Ejemplo n.º 10
0
        public void Panel_Ctor_Default()
        {
            using var control = new SubPanel();
            Assert.False(control.AllowDrop);
            Assert.Equal(AnchorStyles.Top | AnchorStyles.Left, control.Anchor);
            Assert.False(control.AutoScroll);
            Assert.Equal(Size.Empty, control.AutoScrollMargin);
            Assert.Equal(Size.Empty, control.AutoScrollMinSize);
            Assert.Equal(Point.Empty, control.AutoScrollPosition);
            Assert.False(control.AutoSize);
            Assert.Equal(AutoSizeMode.GrowOnly, control.AutoSizeMode);
            Assert.Equal(Control.DefaultBackColor, control.BackColor);
            Assert.Null(control.BackgroundImage);
            Assert.Equal(ImageLayout.Tile, control.BackgroundImageLayout);
            Assert.Null(control.BindingContext);
            Assert.Equal(BorderStyle.None, control.BorderStyle);
            Assert.Equal(100, control.Bottom);
            Assert.Equal(new Rectangle(0, 0, 200, 100), control.Bounds);
            Assert.True(control.CanEnableIme);
            Assert.True(control.CanRaiseEvents);
            Assert.True(control.CausesValidation);
            Assert.Equal(new Rectangle(0, 0, 200, 100), control.ClientRectangle);
            Assert.Equal(new Size(200, 100), control.ClientSize);
            Assert.Null(control.Container);
            Assert.Null(control.ContextMenuStrip);
            Assert.Empty(control.Controls);
            Assert.Same(control.Controls, control.Controls);
            Assert.False(control.Created);
            Assert.Equal(Cursors.Default, control.Cursor);
            Assert.Equal(Cursors.Default, control.DefaultCursor);
            Assert.Equal(ImeMode.Inherit, control.DefaultImeMode);
            Assert.Equal(new Padding(3), control.DefaultMargin);
            Assert.Equal(Size.Empty, control.DefaultMaximumSize);
            Assert.Equal(Size.Empty, control.DefaultMinimumSize);
            Assert.Equal(Padding.Empty, control.DefaultPadding);
            Assert.Equal(new Size(200, 100), control.DefaultSize);
            Assert.False(control.DesignMode);
            Assert.Equal(new Rectangle(0, 0, 200, 100), control.DisplayRectangle);
            Assert.Equal(DockStyle.None, control.Dock);
            Assert.NotNull(control.DockPadding);
            Assert.Same(control.DockPadding, control.DockPadding);
            Assert.Equal(0, control.DockPadding.Top);
            Assert.Equal(0, control.DockPadding.Bottom);
            Assert.Equal(0, control.DockPadding.Left);
            Assert.Equal(0, control.DockPadding.Right);
            Assert.False(control.DoubleBuffered);
            Assert.True(control.Enabled);
            Assert.NotNull(control.Events);
            Assert.Same(control.Events, control.Events);
            Assert.Equal(Control.DefaultFont, control.Font);
            Assert.Equal(control.Font.Height, control.FontHeight);
            Assert.Equal(Control.DefaultForeColor, control.ForeColor);
            Assert.False(control.HasChildren);
            Assert.Equal(100, control.Height);
            Assert.NotNull(control.HorizontalScroll);
            Assert.Same(control.HorizontalScroll, control.HorizontalScroll);
            Assert.False(control.HScroll);
            Assert.Equal(ImeMode.NoControl, control.ImeMode);
            Assert.Equal(ImeMode.NoControl, control.ImeModeBase);
            Assert.NotNull(control.LayoutEngine);
            Assert.Same(control.LayoutEngine, control.LayoutEngine);
            Assert.Equal(0, control.Left);
            Assert.Equal(Point.Empty, control.Location);
            Assert.Equal(new Padding(3), control.Margin);
            Assert.Equal(Size.Empty, control.MaximumSize);
            Assert.Equal(Size.Empty, control.MinimumSize);
            Assert.Equal(Padding.Empty, control.Padding);
            Assert.Equal(Size.Empty, control.PreferredSize);
            Assert.Equal("Microsoft\u00AE .NET", control.ProductName);
            Assert.False(control.RecreatingHandle);
            Assert.Null(control.Region);
            Assert.False(control.ResizeRedraw);
            Assert.Equal(200, control.Right);
            Assert.Equal(RightToLeft.No, control.RightToLeft);
            Assert.Equal(new Size(200, 100), control.Size);
            Assert.Equal(0, control.TabIndex);
            Assert.False(control.TabStop);
            Assert.Empty(control.Text);
            Assert.Equal(0, control.Top);
            Assert.Null(control.TopLevelControl);
            Assert.True(control.Visible);
            Assert.NotNull(control.VerticalScroll);
            Assert.Same(control.VerticalScroll, control.VerticalScroll);
            Assert.False(control.VScroll);
            Assert.Equal(200, control.Width);

            Assert.False(control.IsHandleCreated);
        }
Ejemplo n.º 11
0
 public void Panel_GetAutoSizeMode_Invoke_ReturnsExpected()
 {
     using var control = new SubPanel();
     Assert.Equal(AutoSizeMode.GrowOnly, control.GetAutoSizeMode());
 }
Ejemplo n.º 12
0
 public void Panel_GetScrollState_Invoke_ReturnsExpected(int bit, bool expected)
 {
     using var control = new SubPanel();
     Assert.Equal(expected, control.GetScrollState(bit));
 }
Ejemplo n.º 13
0
        public void Panel_Ctor_Default()
        {
            var panel = new SubPanel();

            Assert.False(panel.AllowDrop);
            Assert.Equal(AnchorStyles.Top | AnchorStyles.Left, panel.Anchor);
            Assert.False(panel.AutoScroll);
            Assert.Equal(Size.Empty, panel.AutoScrollMargin);
            Assert.Equal(Size.Empty, panel.AutoScrollMinSize);
            Assert.Equal(Point.Empty, panel.AutoScrollPosition);
            Assert.False(panel.AutoSize);
            Assert.Equal(AutoSizeMode.GrowOnly, panel.AutoSizeMode);
            Assert.Equal(Control.DefaultBackColor, panel.BackColor);
            Assert.Null(panel.BackgroundImage);
            Assert.Equal(ImageLayout.Tile, panel.BackgroundImageLayout);
            Assert.Null(panel.BindingContext);
            Assert.Equal(BorderStyle.None, panel.BorderStyle);
            Assert.Equal(100, panel.Bottom);
            Assert.Equal(new Rectangle(0, 0, 200, 100), panel.Bounds);
            Assert.True(panel.CanEnableIme);
            Assert.True(panel.CanRaiseEvents);
            Assert.Equal(new Rectangle(0, 0, 200, 100), panel.ClientRectangle);
            Assert.Equal(new Size(200, 100), panel.ClientSize);
            Assert.Null(panel.Container);
            Assert.True(panel.CausesValidation);
            Assert.Empty(panel.Controls);
            Assert.Same(panel.Controls, panel.Controls);
            Assert.False(panel.Created);
            Assert.Same(Cursors.Default, panel.Cursor);
            Assert.Same(Cursors.Default, panel.DefaultCursor);
            Assert.Equal(ImeMode.Inherit, panel.DefaultImeMode);
            Assert.Equal(new Padding(3), panel.DefaultMargin);
            Assert.Equal(Size.Empty, panel.DefaultMaximumSize);
            Assert.Equal(Size.Empty, panel.DefaultMinimumSize);
            Assert.Equal(Padding.Empty, panel.DefaultPadding);
            Assert.Equal(new Size(200, 100), panel.DefaultSize);
            Assert.False(panel.DesignMode);
            Assert.Equal(new Rectangle(0, 0, 200, 100), panel.DisplayRectangle);
            Assert.Equal(DockStyle.None, panel.Dock);
            Assert.NotNull(panel.DockPadding);
            Assert.Same(panel.DockPadding, panel.DockPadding);
            Assert.Equal(0, panel.DockPadding.Top);
            Assert.Equal(0, panel.DockPadding.Bottom);
            Assert.Equal(0, panel.DockPadding.Left);
            Assert.Equal(0, panel.DockPadding.Right);
            Assert.True(panel.Enabled);
            Assert.NotNull(panel.Events);
            Assert.Same(panel.Events, panel.Events);
            Assert.Equal(Control.DefaultFont, panel.Font);
            Assert.Equal(Control.DefaultForeColor, panel.ForeColor);
            Assert.False(panel.HasChildren);
            Assert.Equal(100, panel.Height);
            Assert.NotNull(panel.HorizontalScroll);
            Assert.Same(panel.HorizontalScroll, panel.HorizontalScroll);
            Assert.False(panel.HScroll);
            Assert.Equal(ImeMode.NoControl, panel.ImeMode);
            Assert.Equal(ImeMode.NoControl, panel.ImeModeBase);
            Assert.Equal(0, panel.Left);
            Assert.Equal(Point.Empty, panel.Location);
            Assert.Equal(Padding.Empty, panel.Padding);
            Assert.Equal(200, panel.Right);
            Assert.Equal(RightToLeft.No, panel.RightToLeft);
            Assert.Equal(new Size(200, 100), panel.Size);
            Assert.Equal(0, panel.TabIndex);
            Assert.False(panel.TabStop);
            Assert.Empty(panel.Text);
            Assert.Equal(0, panel.Top);
            Assert.True(panel.Visible);
            Assert.NotNull(panel.VerticalScroll);
            Assert.Same(panel.VerticalScroll, panel.VerticalScroll);
            Assert.False(panel.VScroll);
            Assert.Equal(200, panel.Width);
        }
Ejemplo n.º 14
0
        public void Panel_AutoSizeMode_SetWithCustomLayoutEngineParentWithHandle_GetReturnsExpected(AutoSizeMode value, int expectedLayoutCallCount)
        {
            using var parent  = new CustomLayoutEngineControl();
            using var control = new SubPanel
                  {
                      Parent = parent
                  };
            int layoutCallCount = 0;

            control.Layout += (sender, e) => layoutCallCount++;
            int parentLayoutCallCount = 0;

            void parentHandler(object sender, LayoutEventArgs e)
            {
                Assert.Same(parent, sender);
                Assert.Same(control, e.AffectedControl);
                Assert.Same("AutoSize", e.AffectedProperty);
                parentLayoutCallCount++;
            };
            parent.Layout += parentHandler;
            Assert.NotEqual(IntPtr.Zero, parent.Handle);
            int invalidatedCallCount = 0;

            control.Invalidated += (sender, e) => invalidatedCallCount++;
            int styleChangedCallCount = 0;

            control.StyleChanged += (sender, e) => styleChangedCallCount++;
            int createdCallCount = 0;

            control.HandleCreated += (sender, e) => createdCallCount++;
            int parentInvalidatedCallCount = 0;

            parent.Invalidated += (sender, e) => parentInvalidatedCallCount++;
            int parentStyleChangedCallCount = 0;

            parent.StyleChanged += (sender, e) => parentStyleChangedCallCount++;
            int parentCreatedCallCount = 0;

            parent.HandleCreated += (sender, e) => parentCreatedCallCount++;

            try
            {
                control.AutoSizeMode = value;
                Assert.Equal(value, control.AutoSizeMode);
                Assert.Equal(value, control.GetAutoSizeMode());
                Assert.Equal(0, layoutCallCount);
                Assert.Equal(expectedLayoutCallCount, parentLayoutCallCount);
                Assert.True(control.IsHandleCreated);
                Assert.Equal(0, invalidatedCallCount);
                Assert.Equal(0, styleChangedCallCount);
                Assert.Equal(0, createdCallCount);
                Assert.True(parent.IsHandleCreated);
                Assert.Equal(0, parentInvalidatedCallCount);
                Assert.Equal(0, parentStyleChangedCallCount);
                Assert.Equal(0, parentCreatedCallCount);

                // Set same.
                control.AutoSizeMode = value;
                Assert.Equal(value, control.AutoSizeMode);
                Assert.Equal(value, control.GetAutoSizeMode());
                Assert.Equal(0, layoutCallCount);
                Assert.Equal(expectedLayoutCallCount, parentLayoutCallCount);
                Assert.True(control.IsHandleCreated);
                Assert.Equal(0, invalidatedCallCount);
                Assert.Equal(0, styleChangedCallCount);
                Assert.Equal(0, createdCallCount);
                Assert.True(parent.IsHandleCreated);
                Assert.Equal(0, parentInvalidatedCallCount);
                Assert.Equal(0, parentStyleChangedCallCount);
                Assert.Equal(0, parentCreatedCallCount);
            }
            finally
            {
                parent.Layout -= parentHandler;
            }
        }
Ejemplo n.º 15
0
 public override int GetHashCode() =>
 base.GetHashCode() ^ SubPanel.GetHashCode() ^ Network.GetHashCode();
Ejemplo n.º 16
0
 public DatasetCachedPanelItemSqlSet(Panel panel, SubPanel subpanel, PanelItem panelitem, CompilerOptions comp) : base(panel, subpanel, panelitem, comp)
 {
     Panel           = panel;
     SubPanel        = subpanel;
     CompilerOptions = comp;
 }
Ejemplo n.º 17
0
 public void Add(Widget widget)
 {
     SubPanel.Add(widget);
     ComputeProperties();
 }
Ejemplo n.º 18
0
 protected override void OnComputeProperties()
 {
     SubPanel.ComputeProperties();
 }
Ejemplo n.º 19
0
 public void Remove(Widget widget)
 {
     SubPanel.Remove(widget);
     ComputeProperties();
 }
Ejemplo n.º 20
0
 public PanelItemSequentialSqlSet(Panel panel, SubPanel subpanel, PanelItem panelitem, CompilerOptions comp) : base(panel, subpanel, panelitem, comp)
 {
 }
Ejemplo n.º 21
0
        public void Panel_OnResize_InvokeWithDesignMode_CallsResize(bool resizeRedraw, BorderStyle borderStyle, EventArgs eventArgs, int expectedInvalidatedCallCount)
        {
            var mockSite = new Mock <ISite>(MockBehavior.Strict);

            mockSite
            .Setup(s => s.Container)
            .Returns((IContainer)null);
            mockSite
            .Setup(s => s.DesignMode)
            .Returns(true);
            mockSite
            .Setup(s => s.GetService(typeof(AmbientProperties)))
            .Returns(null);
            using var control = new SubPanel
                  {
                      Site        = mockSite.Object,
                      BorderStyle = borderStyle
                  };
            control.SetStyle(ControlStyles.ResizeRedraw, resizeRedraw);
            Assert.NotEqual(IntPtr.Zero, control.Handle);
            int          callCount = 0;
            EventHandler handler   = (sender, e) =>
            {
                Assert.Same(control, sender);
                Assert.Same(eventArgs, e);
                callCount++;
            };
            int layoutCallCount = 0;

            control.Layout += (sender, e) =>
            {
                Assert.Same(control, sender);
                Assert.Same(control, e.AffectedControl);
                Assert.Equal("Bounds", e.AffectedProperty);
                layoutCallCount++;
            };
            int invalidatedCallCount = 0;

            control.Invalidated += (sender, e) => invalidatedCallCount++;
            int styleChangedCallCount = 0;

            control.StyleChanged += (sender, e) => styleChangedCallCount++;
            int createdCallCount = 0;

            control.HandleCreated += (sender, e) => createdCallCount++;

            // Call with handler.
            control.Resize += handler;
            control.OnResize(eventArgs);
            Assert.Equal(1, callCount);
            Assert.Equal(1, layoutCallCount);
            Assert.True(control.IsHandleCreated);
            Assert.Equal(expectedInvalidatedCallCount, invalidatedCallCount);
            Assert.Equal(0, styleChangedCallCount);
            Assert.Equal(0, createdCallCount);

            // Remove handler.
            control.Resize -= handler;
            control.OnResize(eventArgs);
            Assert.Equal(1, callCount);
            Assert.Equal(2, layoutCallCount);
            Assert.True(control.IsHandleCreated);
            Assert.Equal(expectedInvalidatedCallCount * 2, invalidatedCallCount);
            Assert.Equal(0, styleChangedCallCount);
            Assert.Equal(0, createdCallCount);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Display a module given a command from the Navigation Panel
        /// </summary>
        /// <param name="module">The enumeration of the module to display</param>
        public void showModule(ModuleType module)
        {
            // remove the current panel
            this.Controls.Remove(currentpanel);
            // then show the one we care about
            switch (module)
            {
            case MainScreen.ModuleType.TimeSheets:
                TimeSheets   = new TimeSheetsPanel();
                currentpanel = TimeSheets;
                this.Controls.Add(TimeSheets);
                TimeSheets.Visible = true;
                break;

            case MainScreen.ModuleType.ApprovedSearch:
                ApprovedSearch = new ApproveTimeSheetSearch();
                this.Controls.Add(ApprovedSearch);
                currentpanel           = ApprovedSearch;
                ApprovedSearch.Visible = true;
                break;

            case MainScreen.ModuleType.EmployeeCRUD:
                EmployeeCRUD = new EmployeeCRUDPanel();
                this.Controls.Add(EmployeeCRUD);
                currentpanel         = EmployeeCRUD;
                EmployeeCRUD.Visible = true;
                break;

            case MainScreen.ModuleType.ProjectCRUD:
                ProjectCRUD = new ProjectCRUDPanel();
                this.Controls.Add(ProjectCRUD);
                currentpanel        = ProjectCRUD;
                ProjectCRUD.Visible = true;
                break;

            case MainScreen.ModuleType.ClientCRUD:
                ClientCRUD = new ClientCRUDPanel();
                this.Controls.Add(ClientCRUD);
                currentpanel       = ClientCRUD;
                ClientCRUD.Visible = true;
                break;

            case MainScreen.ModuleType.TypeCRUD:
                TypeCRUD = new TypeCRUDPanel();
                this.Controls.Add(TypeCRUD);
                currentpanel     = TypeCRUD;
                TypeCRUD.Visible = true;
                break;

            case MainScreen.ModuleType.ApproveTimeSheets:
                ApproveTS = new ApproveTimeSheets();
                this.Controls.Add(ApproveTS);
                currentpanel      = ApproveTS;
                ApproveTS.Visible = true;
                break;

            case MainScreen.ModuleType.EmployeeSummaryReport:
                EmpSummaryReport = new RPT_EmployeeTimeSummary();
                this.Controls.Add(EmpSummaryReport);
                currentpanel             = EmpSummaryReport;
                EmpSummaryReport.Visible = true;
                break;

            case MainScreen.ModuleType.ProjectSummaryReport:
                ProjectSummaryReport = new RPT_ProjectTimeSummary();
                this.Controls.Add(ProjectSummaryReport);
                currentpanel = ProjectSummaryReport;
                ProjectSummaryReport.Visible = true;
                break;
            }
        }
Ejemplo n.º 23
0
        public void Panel_DefaultSize_Get_ReturnsExpected()
        {
            var panel = new SubPanel();

            Assert.Equal(new Size(200, 100), panel.DefaultSizeEntry);
        }