Пример #1
0
		//public event System.EventHandler ValueChangedEvent;

		public TrackSlider(string name, IGraphic track, IGraphic thumb,
						Orientation orient,
						float min, float max, 
						float initialValue)
			: base(name, 0,0,0,0)
		{
			fTrackGraphic = track;
			fThumbGraphic = thumb;
			fOrientation = orient;

			fMin = min;
			fMax = max;
			fCurrentValue = initialValue;
			fPosition = initialValue;

			int yoffset = 0;
			int xoffset = 0;
			int trackyoffset = 0;
			int trackxoffset = 0;
	
			if ((track==null) || (thumb==null))
				return ;
		
			AddGraphic(fTrackGraphic, null);
			AddGraphic(fThumbGraphic, null);

			if (orient == Orientation.Horizontal)
			{
				// Must align thumb vertically with track.
				int midy = fTrackGraphic.Frame.Top + (fTrackGraphic.Frame.Height+1)/2;
				int thumbHeight = fThumbGraphic.Frame.Height+1;
				yoffset = midy - (thumbHeight / 2);
				xoffset = fTrackGraphic.Frame.Left;
			} 
			else
			{
				// Must align thumb horizontally with track.
				int midx = Frame.Left+(Frame.Width+1)/2;
				int thumbWidth = fThumbGraphic.Frame.Width+1;
				int trackWidth = fTrackGraphic.Frame.Width+1;
				xoffset = midx - (thumbWidth / 2);
				yoffset = fTrackGraphic.Frame.Top;

				trackxoffset = midx - (trackWidth/2);
				trackyoffset = fTrackGraphic.Frame.Top;
		
				fTrackGraphic.MoveTo(trackxoffset, trackyoffset);
			}
	
			fThumbGraphic.MoveTo(xoffset,yoffset);
			RectangleI newFrame = fTrackGraphic.Frame;
			//newFrame.Union(fThumbGraphic.Frame);
			Frame = newFrame;

            SetValue(initialValue, false);
		}
Пример #2
0
		public override void AddToLayout(IGraphic trans)
		{
            int size;
			int height;
            int width;

			height = trans.Frame.Height;
			width = trans.Frame.Width;

			switch (fOrientation)
			{
				case Orientation.Horizontal:
					if (fNumElements == 0)
						fCurrentX = fCurrentX + fMargin;
					size = width;
					if (height > fTallest)
						fTallest = height;
					//trans.MoveTo(fCurrentX,fCurrentY);
					trans.MoveTo(fCurrentX,trans.Frame.Top);
					
					// Adjust widest, tallest, and new position
					fWidest = fCurrentX+size+1;	
					fCurrentX += size+1 + fGap;
				break;

				case Orientation.Vertical:
					if (fNumElements == 0)
						fCurrentY = fCurrentY + fMargin;
					size = height;
					if (width > fWidest)
						fWidest = width;
					trans.MoveTo(fCurrentX,fCurrentY);
					fTallest = fCurrentY + size+1;
					fCurrentY += size+1 + fGap;
				break;
			}

			fNumElements++;		
		}
Пример #3
0
		public override void AddToLayout(IGraphic g)
		{
			fWrappedGraphic = g;
			if (fWrappedGraphic == null)
			{
				return ;
			}

			int xpos = Frame.Left;
            int ypos = Frame.Top;
            int width = Frame.Width;
            int height = Frame.Height;
            int midx = Frame.Left + width / 2;
            int midy = Frame.Top + height / 2;

            int graphicwidth = fWrappedGraphic.Frame.Width;
            int graphicheight = fWrappedGraphic.Frame.Height;

			switch (fPosition)
			{
				case Position.Center:
					xpos = fMargin + midx-graphicwidth/2;
					ypos = fMargin + midy-graphicheight/2;
				break;
		
				case Position.Left:
					xpos = fMargin;
					ypos = midy-graphicheight/2;
				break;
		
				case Position.Top:
					xpos = midx-graphicwidth/2;
					ypos = fMargin;
				break;
		
				case Position.Right:
					xpos = Frame.Width-graphicwidth - fMargin;
					ypos = midy-graphicheight/2;
				break;
		
				case Position.Bottom:
					xpos = midx-graphicwidth/2;
					ypos = Frame.Height-graphicheight - fMargin;
				break;
		
				case Position.TopLeft:
					xpos = fMargin;
					ypos = fMargin;
				break;
		
				case Position.TopRight:
					xpos = Frame.Width-graphicwidth - fMargin;
					ypos = fMargin;
				break;
		
				case Position.BottomLeft:
					xpos = fMargin;
					ypos = Frame.Height-graphicheight - fMargin;
				break;
		
				case Position.BottomRight:
					xpos = Frame.Width-graphicwidth - fMargin;
					ypos = Frame.Height-graphicheight -fMargin;
				break;
			}

			fWrappedGraphic.MoveTo(xpos, ypos);
		}