/*
		 * GetContinuousBounds
		 */

		/// <summary>
		/// </summary>
		public Rectangle GetContinuousBounds(Rectangle containerBounds, int min, int max, int value, NuGenOrientationStyle orientation)
		{
			Rectangle rect = Rectangle.Empty;

			if (max != min)
			{
				if (orientation == NuGenOrientationStyle.Horizontal)
				{
					rect = new Rectangle(
						containerBounds.Left,
						containerBounds.Top,
						(int)((float)containerBounds.Width / (float)(max - min) * (value - min)),
						containerBounds.Height
					);
				}
				else
				{
					int height = (int)((float)containerBounds.Height / (float)(max - min) * (value - min));

					rect = new Rectangle(
						containerBounds.Left,
						containerBounds.Bottom - height,
						containerBounds.Width,
						height
					);
				}
			}

			return rect;
		}
Пример #2
0
            /*
             * GetSize
             */

            /// <summary>
            /// </summary>
            /// <param name="containerBounds"></param>
            /// <param name="orientation"></param>
            /// <returns></returns>
            protected virtual Size GetSize(Rectangle containerBounds, NuGenOrientationStyle orientation)
            {
                if (orientation == NuGenOrientationStyle.Horizontal)
                {
                    return(new Size(containerBounds.Width / 4, containerBounds.Height));
                }

                return(new Size(containerBounds.Width, containerBounds.Height / 4));
            }
        /*
         * GetMarqueeBlockSize
         */

        private Size GetMarqueeBlockSize(Rectangle containerBounds, NuGenOrientationStyle orientation)
        {
            if (orientation == NuGenOrientationStyle.Horizontal)
            {
                return(new Size(containerBounds.Width / _marqueeBlockDivider, containerBounds.Height));
            }

            return(new Size(containerBounds.Width, containerBounds.Height / _marqueeBlockDivider));
        }
        /*
         * OrientationAgnosticRectangle
         */

        /// <summary>
        /// If the orientation is horizontal returns the specified rectangle as is. If the orientation is
        /// vertical returns the specified rectangle as if it was in horizontal orientation.
        /// </summary>
        /// <param name="rect"></param>
        /// <param name="orientation"></param>
        /// <returns></returns>
        public static Rectangle OrientationAgnosticRectangle(Rectangle rect, NuGenOrientationStyle orientation)
        {
            if (orientation == NuGenOrientationStyle.Vertical)
            {
                return(new Rectangle(rect.Top, rect.Left, rect.Height, rect.Width));
            }

            return(rect);
        }
Пример #5
0
        private void SetSwitchButtonDockStyle(NuGenSwitchButton switchButton, NuGenOrientationStyle orientation)
        {
            Debug.Assert(switchButton != null, "switchButton != null");
            switchButton.Orientation = orientation;

            if (orientation == NuGenOrientationStyle.Horizontal)
            {
                switchButton.Dock = DockStyle.Left;
            }
            else
            {
                switchButton.Dock = DockStyle.Top;
            }
        }
Пример #6
0
        /*
         * ResetOffset
         */

        private void ResetOffset(NuGenOrientationStyle orientation)
        {
            Debug.Assert(this.MarqueeBlockData != null, "this.MarqueeBlockData != null");
            Rectangle marqueeBounds = this.MarqueeBlockData.GetBounds(this.ClientRectangle, orientation);

            if (orientation == NuGenOrientationStyle.Horizontal)
            {
                this.MarqueeBlockData.Offset = this.ClientRectangle.Left - marqueeBounds.Width;
            }
            else
            {
                this.MarqueeBlockData.Offset = this.ClientRectangle.Bottom + marqueeBounds.Height;
            }
        }
Пример #7
0
        public void OrientationAgnosticRectangleTest()
        {
            Rectangle             rect         = new Rectangle(20, 30, 40, 50);
            NuGenOrientationStyle orientation  = NuGenOrientationStyle.Horizontal;
            Rectangle             agnosticRect = NuGenControlPaint.OrientationAgnosticRectangle(rect, orientation);

            Assert.AreEqual(20, agnosticRect.Left);
            Assert.AreEqual(30, agnosticRect.Top);
            Assert.AreEqual(40, agnosticRect.Width);
            Assert.AreEqual(50, agnosticRect.Height);

            orientation  = NuGenOrientationStyle.Vertical;
            agnosticRect = NuGenControlPaint.OrientationAgnosticRectangle(rect, orientation);

            Assert.AreEqual(30, agnosticRect.Left);
            Assert.AreEqual(20, agnosticRect.Top);
            Assert.AreEqual(50, agnosticRect.Width);
            Assert.AreEqual(40, agnosticRect.Height);
        }
			/*
			 * GetBounds
			 */

			/// <summary>
			/// </summary>
			/// <param name="containerBounds"></param>
			/// <param name="orientation"></param>
			/// <returns></returns>
			public Rectangle GetBounds(Rectangle containerBounds, NuGenOrientationStyle orientation)
			{
				if (containerBounds == Rectangle.Empty)
				{
					return Rectangle.Empty;
				}

				if (orientation == NuGenOrientationStyle.Horizontal)
				{
					return new Rectangle(
						new Point(this.Offset, containerBounds.Top),
						this.GetSize(containerBounds, orientation)
					);
				}

				return new Rectangle(
					new Point(containerBounds.Left, containerBounds.Top + this.Offset),
					this.GetSize(containerBounds, orientation)
				);
			}
Пример #9
0
            /*
             * GetBounds
             */

            /// <summary>
            /// </summary>
            /// <param name="containerBounds"></param>
            /// <param name="orientation"></param>
            /// <returns></returns>
            public Rectangle GetBounds(Rectangle containerBounds, NuGenOrientationStyle orientation)
            {
                if (containerBounds == Rectangle.Empty)
                {
                    return(Rectangle.Empty);
                }

                if (orientation == NuGenOrientationStyle.Horizontal)
                {
                    return(new Rectangle(
                               new Point(this.Offset, containerBounds.Top),
                               this.GetSize(containerBounds, orientation)
                               ));
                }

                return(new Rectangle(
                           new Point(containerBounds.Left, containerBounds.Top + this.Offset),
                           this.GetSize(containerBounds, orientation)
                           ));
            }
		/*
		 * GetBlocks
		 */

		/// <summary>
		/// </summary>
		/// <param name="continuousBounds"></param>
		/// <param name="orientation"></param>
		/// <returns></returns>
		public Rectangle[] GetBlocks(Rectangle continuousBounds, NuGenOrientationStyle orientation)
		{
			Rectangle[] blocks = new Rectangle[] { };

			if (orientation == NuGenOrientationStyle.Horizontal)
			{
				if (continuousBounds.Width > 0)
				{
					int blockCount = 1 + (continuousBounds.Width - _blockSize) / (_blockSize + _blockOffsetSize);
					blocks = new Rectangle[blockCount];
					int offset = continuousBounds.Left - (_blockSize + _blockOffsetSize);

					for (int i = 0; i < blockCount; i++)
					{
						offset += _blockSize;
						offset += _blockOffsetSize;

						blocks[i] = new Rectangle(offset, continuousBounds.Top, _blockSize, continuousBounds.Height);
					}
				}
			}
			else
			{
				if (continuousBounds.Height > 0)
				{
					int blockCount = 1 + (continuousBounds.Height - _blockSize) / (_blockSize + _blockOffsetSize);
					blocks = new Rectangle[blockCount];
					int offset = continuousBounds.Bottom + (_blockSize + _blockOffsetSize);

					for (int i = 0; i < blockCount; i++)
					{
						offset -= _blockSize;
						offset -= _blockOffsetSize;

						blocks[i] = new Rectangle(continuousBounds.Left, offset - _blockSize, continuousBounds.Width, _blockSize);
					}
				}
			}

			return blocks;
		}
        /*
         * GetBlocks
         */

        /// <summary>
        /// </summary>
        /// <param name="continuousBounds"></param>
        /// <param name="orientation"></param>
        /// <returns></returns>
        public Rectangle[] GetBlocks(Rectangle continuousBounds, NuGenOrientationStyle orientation)
        {
            Rectangle[] blocks = new Rectangle[] { };

            if (orientation == NuGenOrientationStyle.Horizontal)
            {
                if (continuousBounds.Width > 0)
                {
                    int blockCount = 1 + (continuousBounds.Width - _blockSize) / (_blockSize + _blockOffsetSize);
                    blocks = new Rectangle[blockCount];
                    int offset = continuousBounds.Left - (_blockSize + _blockOffsetSize);

                    for (int i = 0; i < blockCount; i++)
                    {
                        offset += _blockSize;
                        offset += _blockOffsetSize;

                        blocks[i] = new Rectangle(offset, continuousBounds.Top, _blockSize, continuousBounds.Height);
                    }
                }
            }
            else
            {
                if (continuousBounds.Height > 0)
                {
                    int blockCount = 1 + (continuousBounds.Height - _blockSize) / (_blockSize + _blockOffsetSize);
                    blocks = new Rectangle[blockCount];
                    int offset = continuousBounds.Bottom + (_blockSize + _blockOffsetSize);

                    for (int i = 0; i < blockCount; i++)
                    {
                        offset -= _blockSize;
                        offset -= _blockOffsetSize;

                        blocks[i] = new Rectangle(continuousBounds.Left, offset - _blockSize, continuousBounds.Width, _blockSize);
                    }
                }
            }

            return(blocks);
        }
			public Rectangle[] GetBlocks(Rectangle continuousBounds, NuGenOrientationStyle orientation)
			{
				return null;
			}
Пример #13
0
		/// <summary>
		/// Sets the layout according to the orientation specified.
		/// </summary>
		/// <param name="orientation">Orientation of the <see cref="T:Genetibase.UI.NuGenMeters.NuGenMeterBase"/> control.</param>
		private void SetLayout(NuGenOrientationStyle orientation)
		{			
			this.SuspendLayout();
			this.Controls.Clear();

			/*
			 * meter
			 */

			int meterWidth = this.meter.Width;
			int meterHeight = this.meter.Height;

			if (this.meter.Orientation == orientation)
			{
				this.Width = meterWidth;
				this.Height = meterHeight;
			}
			else
			{
				this.Height = meterWidth;
				this.Width = meterHeight;
			}

			this.meter.Orientation = orientation;
			this.meter.Top = 0;
			this.meter.Left = 0;
			
			this.Controls.Add(this.meter);

			/*
			 * progressText 
			 */

			if (this.progressText.Visible) 
			{
				if (orientation == NuGenOrientationStyle.Vertical) 
				{
					this.progressText.Height = this.ProgressTextEdgeIndent;
					this.Height += this.ProgressTextEdgeIndent;

					switch (this.ProgressTextPosition)
					{
						case NuGenProgressTextPositionStyle.Head:
							this.progressText.Dock = DockStyle.Bottom;
							break;
						case NuGenProgressTextPositionStyle.Tail:
							this.meter.Top += this.ProgressTextEdgeIndent;
							this.progressText.Dock = DockStyle.Top;
							break;
					}
				}
				else if (orientation == NuGenOrientationStyle.Horizontal)
				{
					this.progressText.Width = this.ProgressTextEdgeIndent;

					switch (this.ProgressTextPosition)
					{
						case NuGenProgressTextPositionStyle.Head:
							this.progressText.Width = this.ProgressTextEdgeIndent;
							this.Width += this.ProgressTextEdgeIndent;
							this.meter.Left += this.ProgressTextEdgeIndent;
							this.progressText.Dock = DockStyle.Left;
							break;
						case NuGenProgressTextPositionStyle.Tail:
							this.progressText.Width = this.ProgressTextEdgeIndent;
							this.Width += this.ProgressTextEdgeIndent;
							this.progressText.Dock = DockStyle.Right;
							break;
					}
				}

				this.Controls.Add(this.progressText);
			}
			
			/*
			 * captionText
			 */

			if (this.captionText.Visible)
			{
				this.captionText.Height = this.CaptionTextEdgeIndent;
				this.Height += this.CaptionTextEdgeIndent;
				
				switch (this.CaptionTextPosition)
				{
					case NuGenCaptionTextPositionStyle.Header:
						this.meter.Top += this.CaptionTextEdgeIndent;
						this.captionText.Dock = DockStyle.Top;
						break;
					case NuGenCaptionTextPositionStyle.Footer:
						this.captionText.Dock = DockStyle.Bottom;
						break;
				}

				this.Controls.Add(this.captionText);
			}

			this.ResumeLayout();
		}
		/*
		 * GetMarqueeBlockSize
		 */

		private Size GetMarqueeBlockSize(Rectangle containerBounds, NuGenOrientationStyle orientation)
		{
			if (orientation == NuGenOrientationStyle.Horizontal)
			{
				return new Size(containerBounds.Width / _marqueeBlockDivider, containerBounds.Height);
			}

			return new Size(containerBounds.Width, containerBounds.Height / _marqueeBlockDivider);
		}
		/*
		 * GetMarqueeBlockBounds
		 */

		/// <summary>
		/// </summary>
		public Rectangle GetMarqueeBlockBounds(Rectangle containerBounds, int offset, NuGenOrientationStyle orientation)
		{
			if (containerBounds == Rectangle.Empty)
			{
				return Rectangle.Empty;
			}

			Point location;

			if (orientation == NuGenOrientationStyle.Horizontal)
			{
				location = new Point(offset + containerBounds.Left, containerBounds.Top);
			}
			else
			{
				location = new Point(containerBounds.Left, containerBounds.Top + offset);
			}

			return new Rectangle(
				location,
				this.GetMarqueeBlockSize(containerBounds, orientation)
			);
		}
			/*
			 * GetSize
			 */

			/// <summary>
			/// </summary>
			/// <param name="containerBounds"></param>
			/// <param name="orientation"></param>
			/// <returns></returns>
			protected virtual Size GetSize(Rectangle containerBounds, NuGenOrientationStyle orientation)
			{
				if (orientation == NuGenOrientationStyle.Horizontal)
				{
					return new Size(containerBounds.Width / 4, containerBounds.Height);
				}

				return new Size(containerBounds.Width, containerBounds.Height / 4);
			}
Пример #17
0
		private void SetSwitchButtonDockStyle(NuGenSwitchButton switchButton, NuGenOrientationStyle orientation)
		{
			Debug.Assert(switchButton != null, "switchButton != null");
			switchButton.Orientation = orientation;

			if (orientation == NuGenOrientationStyle.Horizontal)
			{
				switchButton.Dock = DockStyle.Left;
			}
			else
			{
				switchButton.Dock = DockStyle.Top;
			}
		}
Пример #18
0
		/*
		 * ResetOffset
		 */

		private void ResetOffset(NuGenOrientationStyle orientation)
		{
			Debug.Assert(this.MarqueeBlockData != null, "this.MarqueeBlockData != null");
			Rectangle marqueeBounds = this.MarqueeBlockData.GetBounds(this.ClientRectangle, orientation);

			if (orientation == NuGenOrientationStyle.Horizontal)
			{
				this.MarqueeBlockData.Offset = this.ClientRectangle.Left - marqueeBounds.Width;
			}
			else
			{
				this.MarqueeBlockData.Offset = this.ClientRectangle.Bottom + marqueeBounds.Height;
			}
		}
Пример #19
0
 public Rectangle GetContinuousBounds(Rectangle containerBounds, int min, int max, int value, NuGenOrientationStyle orientation)
 {
     return(Rectangle.Empty);
 }
		/*
		 * OrientationAgnosticRectangle
		 */

		/// <summary>
		/// If the orientation is horizontal returns the specified rectangle as is. If the orientation is
		/// vertical returns the specified rectangle as if it was in horizontal orientation.
		/// </summary>
		/// <param name="rect"></param>
		/// <param name="orientation"></param>
		/// <returns></returns>
		public static Rectangle OrientationAgnosticRectangle(Rectangle rect, NuGenOrientationStyle orientation)
		{
			if (orientation == NuGenOrientationStyle.Vertical)
			{
				return new Rectangle(
					rect.Top,
					rect.Left,
					rect.Height,
					rect.Width
				);
			}

			return rect;
		}
        /*
         * GetContinuousBounds
         */

        /// <summary>
        /// </summary>
        public Rectangle GetContinuousBounds(Rectangle containerBounds, int min, int max, int value, NuGenOrientationStyle orientation)
        {
            Rectangle rect = Rectangle.Empty;

            if (max != min)
            {
                if (orientation == NuGenOrientationStyle.Horizontal)
                {
                    rect = new Rectangle(
                        containerBounds.Left,
                        containerBounds.Top,
                        (int)((float)containerBounds.Width / (float)(max - min) * (value - min)),
                        containerBounds.Height
                        );
                }
                else
                {
                    int height = (int)((float)containerBounds.Height / (float)(max - min) * (value - min));

                    rect = new Rectangle(
                        containerBounds.Left,
                        containerBounds.Bottom - height,
                        containerBounds.Width,
                        height
                        );
                }
            }

            return(rect);
        }
        /*
         * GetMarqueeBlockBounds
         */

        /// <summary>
        /// </summary>
        public Rectangle GetMarqueeBlockBounds(Rectangle containerBounds, int offset, NuGenOrientationStyle orientation)
        {
            if (containerBounds == Rectangle.Empty)
            {
                return(Rectangle.Empty);
            }

            Point location;

            if (orientation == NuGenOrientationStyle.Horizontal)
            {
                location = new Point(offset + containerBounds.Left, containerBounds.Top);
            }
            else
            {
                location = new Point(containerBounds.Left, containerBounds.Top + offset);
            }

            return(new Rectangle(
                       location,
                       this.GetMarqueeBlockSize(containerBounds, orientation)
                       ));
        }
Пример #23
0
 public Rectangle[] GetBlocks(Rectangle continuousBounds, NuGenOrientationStyle orientation)
 {
     return(null);
 }
			public Rectangle GetContinuousBounds(Rectangle containerBounds, int min, int max, int value, NuGenOrientationStyle orientation)
			{
				return Rectangle.Empty;
			}
Пример #25
0
 public Rectangle GetMarqueeBlockBounds(Rectangle containerBounds, int offset, NuGenOrientationStyle orientation)
 {
     return(Rectangle.Empty);
 }
			public Rectangle GetMarqueeBlockBounds(Rectangle containerBounds, int offset, NuGenOrientationStyle orientation)
			{
				return Rectangle.Empty;
			}