Example #1
0
        public void SpreadOnForm(ScrollableControl i_ScrollableControl, Point i_StartPosition, int i_ItemsInALine)
        {
            Point currentPosition         = i_StartPosition;
            int   itemNumberInCurrentLine = 1;

            foreach (DescriptivePicture descriptivePicture in m_DescriptivePictures)
            {
                descriptivePicture.SetLocation(currentPosition);
                i_ScrollableControl.Invoke(new Action(() => descriptivePicture.AddToForm(i_ScrollableControl)));
                if (itemNumberInCurrentLine < i_ItemsInALine)
                {
                    currentPosition.X += descriptivePicture.Width + k_ItemsRelativeDistance;
                }
                else
                {
                    itemNumberInCurrentLine = 0;
                    currentPosition.X       = i_StartPosition.X;
                    currentPosition.Y      += descriptivePicture.Height + k_ItemsRelativeDistance;
                }

                itemNumberInCurrentLine++;
            }
        }
Example #2
0
        /// <summary>
        /// Thread safe set of the autoscrollposition of the the scroll panel.
        /// </summary>
        /// <param name="scrollPosition">A <see cref="Point"/> with the new scroll position.</param>
        protected void ThreadSafeSetAutoScrollPosition(Point scrollPosition)
        {
            if (this.Picture.Parent.Parent == null)
            {
                return;
            }

            ScrollableControl scrollPanel = this.Picture.Parent.Parent as ScrollableControl;

            if (scrollPanel == null)
            {
                return;
            }

            if (scrollPanel.InvokeRequired)
            {
                SetPointCallback d = new SetPointCallback(this.ThreadSafeSetAutoScrollPosition);
                scrollPanel.Invoke(d, new object[] { scrollPosition });
            }
            else
            {
                scrollPanel.AutoScrollPosition = scrollPosition;
            }
        }