Label type control that can be used to display text using a specified font.
Наследование: OverlayElement
Пример #1
0
		/// <summary>
		/// Do not instantiate any widgets directly. Use SdkTrayManager.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="caption"></param>
		/// <param name="width"></param>
		public CheckBox( String name, String caption, Real width )
		{
			IsCursorOver = false;
			isFitToContents = width <= 0;
			element = OverlayManager.Instance.Elements.CreateElementFromTemplate
				( "SdkTrays/CheckBox", "BorderPanel", name );
			OverlayElementContainer c = (OverlayElementContainer)element;
			this.textArea = (TextArea)c.Children[ Name + "/CheckBoxCaption" ];
			this.square = (BorderPanel)c.Children[ Name + "/CheckBoxSquare" ];
			this.x = this.square.Children[ this.square.Name + "/CheckBoxX" ];
			this.x.Hide();
			element.Width = width;
			this.Caption = caption;
		}
Пример #2
0
		/// <summary>
		/// Do not instantiate any widgets directly. Use SdkTrayManager.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="width"></param>
		/// <param name="lines"></param>
		public ParamsPanel( String name, Real width, int lines )
		{
			element = OverlayManager.Instance.Elements.CreateElementFromTemplate( "SdkTrays/ParamsPanel", "BorderPanel", name );
			var c = (OverlayElementContainer)element;
			this.namesArea = (TextArea)c.Children[ Name + "/ParamsPanelNames" ];
			this.valuesArea = (TextArea)c.Children[ Name + "/ParamsPanelValues" ];
			element.Width = width;
			element.Height = this.namesArea.Top*2 + lines*this.namesArea.CharHeight;
			this.values = new List<string>();
		}
Пример #3
0
		/// <summary>
		/// Do not instantiate any widgets directly. Use SdkTrayManager.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="caption"></param>
		/// <param name="width"></param>
		/// <param name="commentBoxWidth"></param>
		public ProgressBar( String name, String caption, Real width, Real commentBoxWidth )
		{
			element = OverlayManager.Instance.Elements.CreateElementFromTemplate( "SdkTrays/ProgressBar", "BorderPanel", name );
			element.Width = ( width );
			var c = (OverlayElementContainer)element;
			this.textArea = (TextArea)c.Children[ Name + "/ProgressCaption" ];
			var commentBox = (OverlayElementContainer)c.Children[ Name + "/ProgressCommentBox" ];
			commentBox.Width = ( commentBoxWidth );
			commentBox.Left = ( -( commentBoxWidth + 5 ) );
			this.commentTextArea = (TextArea)commentBox.Children[ commentBox.Name + "/ProgressCommentText" ];
			this.meter = c.Children[ Name + "/ProgressMeter" ];
			this.meter.Width = ( width - 10 );
			this.fill = ( (OverlayElementContainer)this.meter ).Children[ this.meter.Name + "/ProgressFill" ];
			Caption = caption;
		}
Пример #4
0
		/// <summary>
		/// Do not instantiate any widgets directly. Use SdkTrayManager.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="caption"></param>
		/// <param name="width"></param>
		/// <param name="height"></param>
		public TextBox( String name, String caption, Real width, Real height )
		{
			this.lines = new List<string>();
			element = OverlayManager.Instance.Elements.CreateElementFromTemplate( "SdkTrays/TextBox", "BorderPanel", name );
			element.Width = width;
			element.Height = height;
			var container = (OverlayElementContainer)element;
			this.textArea = (TextArea)container.Children[ Name + "/TextBoxText" ];
			this.captionBar = (BorderPanel)container.Children[ Name + "/TextBoxCaptionBar" ];
			this.captionBar.Width = width - 4;
			this.captionTextArea = (TextArea)this.captionBar.Children[ this.captionBar.Name + "/TextBoxCaption" ];
			Caption = caption;
			this.scrollTrack = (BorderPanel)container.Children[ Name + "/TextBoxScrollTrack" ];
			this.scrollHandle = (Panel)this.scrollTrack.Children[ this.scrollTrack.Name + "/TextBoxScrollHandle" ];
			this.scrollHandle.Hide();
			this.isDragging = false;
			this.scrollPercentage = 0;
			this.startingLine = 0;
			this.padding = 15;
			this.text = "";
			RefitContents();
		}
Пример #5
0
		/// <summary>
		///  Do not instantiate any widgets directly. Use SdkTrayManager.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="caption"></param>
		/// <param name="width"></param>
		/// <param name="boxWidth"></param>
		/// <param name="maxItemsShown"></param>
		public SelectMenu( String name, String caption, Real width, Real boxWidth, int maxItemsShown )
		{
			items = new List<string>();
			itemElements = new List<BorderPanel>();

			this.sectionIndex = -1;
			this.isFitToContents = false;
			this.IsCursorOver = false;
			this.isExpanded = false;
			this.isDragging = false;
			this.maxItemsShown = maxItemsShown;
			this.itemsShown = 0;
			element = (BorderPanel)OverlayManager.Instance.Elements.CreateElementFromTemplate
										( "SdkTrays/SelectMenu", "BorderPanel", name );
			this.textArea = (TextArea)( (OverlayElementContainer)element ).Children[ name + "/MenuCaption" ];
			this.smallBox = (BorderPanel)( (OverlayElementContainer)element ).Children[ name + "/MenuSmallBox" ];
			this.smallBox.Width = width - 10;
			this.smallTextArea = (TextArea)this.smallBox.Children[ name + "/MenuSmallBox/MenuSmallText" ];
			element.Width = width;

			if ( boxWidth > 0 )  // long style
			{
				if ( width <= 0 )
					this.isFitToContents = true;
				this.smallBox.Width = boxWidth;
				this.smallBox.Top = 2;
				this.smallBox.Left = width - boxWidth - 5;
				element.Height = this.smallBox.Height + 4;
				this.textArea.HorizontalAlignment = HorizontalAlignment.Left;
				this.textArea.TextAlign = HorizontalAlignment.Left;
				this.textArea.Left = 12;
				this.textArea.Top = 10;
			}

			this.expandedBox = (BorderPanel)( (OverlayElementContainer)element ).Children[ name + "/MenuExpandedBox" ];
			this.expandedBox.Width = this.smallBox.Width + 10;
			this.expandedBox.Hide();
			this.scrollTrack = (BorderPanel)this.expandedBox.Children[ this.expandedBox.Name + "/MenuScrollTrack" ];
			this.scrollHandle = (Panel)this.scrollTrack.Children[ this.scrollTrack.Name + "/MenuScrollHandle" ];

			this.Caption = caption;
		}
Пример #6
0
		/// <summary>
		/// Do not instantiate any widgets directly. Use SdkTrayManager.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="caption"></param>
		/// <param name="width"></param>
		/// <param name="trackWidth"></param>
		/// <param name="valueBoxWidth"></param>
		/// <param name="minValue"></param>
		/// <param name="maxValue"></param>
		/// <param name="snaps"></param>
		public Slider( String name, String caption, Real width, Real trackWidth, Real valueBoxWidth, Real minValue,
		               Real maxValue, int snaps )
		{
			this.isDragging = false;
			this.isFitToContents = false;
			element = OverlayManager.Instance.Elements.CreateElementFromTemplate( "SdkTrays/Slider", "BorderPanel", name );
			element.Width = width;
			var c = (OverlayElementContainer)element;
			this.textArea = (TextArea)c.Children[ Name + "/SliderCaption" ];
			var valueBox = (OverlayElementContainer)c.Children[ Name + "/SliderValueBox" ];
			valueBox.Width = valueBoxWidth;
			valueBox.Left = -( valueBoxWidth + 5 );
			this.valueTextArea = (TextArea)valueBox.Children[ valueBox.Name + "/SliderValueText" ];
			this.track = (BorderPanel)c.Children[ Name + "/SliderTrack" ];
			this.handle = (Panel)this.track.Children[ this.track.Name + "/SliderHandle" ];

			if ( trackWidth <= 0 ) // tall style
			{
				this.track.Width = width - 16;
			}
			else // long style
			{
				if ( width <= 0 )
				{
					this.isFitToContents = true;
				}
				element.Height = 34;
				this.textArea.Top = 10;
				valueBox.Top = 2;
				this.track.Top = -23;
				this.track.Width = trackWidth;
				this.track.HorizontalAlignment = HorizontalAlignment.Right;
				this.track.Left = -( trackWidth + valueBoxWidth + 5 );
			}

			Caption = caption;
			SetRange( minValue, maxValue, snaps, false );
		}
Пример #7
0
		/// <summary>
		/// Creates a new instance of <see cref="Button" />
		/// </summary>
		/// <param name="name"></param>
		/// <param name="caption"></param>
		/// <param name="width"></param>
		/// <remarks>
		/// Do not instantiate any widgets directly. Use SdkTrayManager.
		/// </remarks>
		public Button( String name, String caption, Real width )
		{
			element = OverlayManager.Instance.Elements.CreateElementFromTemplate( "SdkTrays/Button", "BorderPanel", name );
			this.BorderPanel = (BorderPanel)element;
			this.TextArea = (TextArea)this.BorderPanel.Children[ this.BorderPanel.Name + "/ButtonCaption" ];
			this.TextArea.Top = -( this.TextArea.CharHeight/2 ); //
			if ( width > 0 )
			{
				element.Width = width;
				this.isFitToContents = false;
			}
			else
			{
				this.isFitToContents = true;
			}

			Caption = caption;
			State = ButtonState.Up;
		}
Пример #8
0
		/// <summary>
		/// Static utility method to cut off a string to fit in a text area.
		/// </summary>
		/// <param name="caption"></param>
		/// <param name="area"></param>
		/// <param name="maxWidth"></param>
		public static void FitCaptionToArea( String caption, TextArea area, Real maxWidth )
		{
			var f = (Font)FontManager.Instance.GetByName( area.FontName );
			String s = caption;

			int nl = s.IndexOf( '\n' );
			if ( nl != -1 )
			{
				s = s.Substring( 0, nl );
			}

			Real width = 0;

			for ( int i = 0; i < s.Length; i++ )
			{
				if ( s[ i ] == ' ' && area.SpaceWidth != 0 )
				{
					width += area.SpaceWidth;
				}
				else
				{
					width += f.GetGlyphAspectRatio( s[ i ] )*area.CharHeight;
				}
				if ( width > maxWidth )
				{
					s = s.Substring( 0, i );
					break;
				}
			}

			area.Text = s;
		}
Пример #9
0
		/// <summary>
		/// Static utility method used to get the width of a caption in a text area.
		/// </summary>
		/// <param name="caption"></param>
		/// <param name="area"></param>
		/// <returns></returns>
		public static Real GetCaptionWidth( String caption, TextArea area )
		{
			var font = (Font)FontManager.Instance.GetByName( area.FontName );
			String current = caption;
			Real lineWidth = 0;

			for ( int i = 0; i < current.Length; i++ )
			{
				// be sure to provide a line width in the text area
				if ( current[ i ] == ' ' )
				{
					if ( area.SpaceWidth != 0 )
					{
						lineWidth += area.SpaceWidth;
					}
					else
					{
						lineWidth += font.GetGlyphAspectRatio( ' ' )*area.CharHeight;
					}
				}
				else if ( current[ i ] == '\n' )
				{
					break;
				}
					// use glyph information to calculate line width
				else
				{
					lineWidth += font.GetGlyphAspectRatio( current[ i ] )*area.CharHeight;
				}
			}

			return lineWidth;
		}