예제 #1
0
		private void AddFloatTextBoxToScene(float value)
		{
			var label = new Label(GetNextLabelDrawArea(), "Rotation");
			var textbox = new TextBox(GetNextControlDrawArea(), value.ToInvariantString());
			componentControls.Add(typeof(float), new List<Control> { label, textbox });
			scene.Add(label);
			scene.Add(textbox);
		}
예제 #2
0
 public void AddControlToScene(Control control, UIEditorScene scene)
 {
     Control newControl = null;
     if (control.GetType() == typeof(Picture))
         newControl = new Picture(control.Get<Theme>(), control.Get<Material>(), control.DrawArea);
     else if (control.GetType() == typeof(Label))
     {
         newControl = new Label(control.Get<Theme>(), control.DrawArea, (control as Label).Text);
         newControl.Set(control.Get<Material>());
     }
     else if (control.GetType() == typeof(Button))
         newControl = new Button(control.Get<Theme>(), control.DrawArea, (control as Button).Text);
     else if (control.GetType() == typeof(Slider))
         newControl = new Slider(control.Get<Theme>(), control.DrawArea);
     newControl.AddTag(control.GetTags()[0]);
     newControl.RenderLayer = control.RenderLayer;
     scene.Scene.Add(newControl);
 }
예제 #3
0
		public void AddControlToScene(Control control)
		{
			Control newControl = null;
			if (control.GetType() == typeof(Picture))
				newControl = new Picture(control.Get<Theme>(), control.Get<Material>(), control.DrawArea);
			else if (control.GetType() == typeof(Label))
			{
				newControl = new Label(control.Get<Theme>(), control.DrawArea, (control as Label).Text);
				newControl.Set(control.Get<BlendMode>());
				newControl.Set(control.Get<Material>());
			}
			else if (control.GetType() == typeof(Button))
				newControl = new Button(control.Get<Theme>(), control.DrawArea, (control as Button).Text);
			else if (control.GetType() == typeof(InteractiveButton))
				newControl = new InteractiveButton(control.Get<Theme>(), control.DrawArea,
					(control as Button).Text);
			else if (control.GetType() == typeof(Slider))
				newControl = new Slider(control.Get<Theme>(), control.DrawArea);
			newControl.RenderLayer = control.RenderLayer;
			if (!newControl.Contains<AnchoringState>())
				newControl.Add(new AnchoringState()); //ncrunch: no coverage
			CheckIfAnyMaterialIsCorrupt(newControl);
			Scene.Add(newControl);
		}
예제 #4
0
			private void AddSoundOption()
			{
				var labelTheme = new Theme();
				labelTheme.Label = new Material(ShaderFlags.Position2DColoredTextured, "SoundLabel");
				var label = new Label(labelTheme,
					Rectangle.FromCenter(0.3f, ScreenSpace.Current.Viewport.Top + 0.6f, 0.2f, 0.1f));
				Add(label);

				var soundSlider = new Slider(menuTheme,
					Rectangle.FromCenter(0.6f, ScreenSpace.Current.Viewport.Top + 0.6f, 0.4f, 0.05f))
				{
					MaxValue = 100,
					MinValue = 0,
					Value = (int)(Settings.Current.SoundVolume * 100)
				};
				soundSlider.ValueChanged += val =>
				{
					Settings.Current.SoundVolume = val / 100.0f;
					if (!parent.EnterSound.IsAnyInstancePlaying)
						parent.EnterSound.Play(Settings.Current.SoundVolume);
				};
				soundSlider.Start<SettingsUpdater>();
				Add(soundSlider);
			}
예제 #5
0
 private void AddGenericComponentToScene(object component)
 {
     var label = new Label(GetNextLabelDrawArea(), GetName(component));
     var textbox = new TextBox(GetNextControlDrawArea(), component.ToString());
     var controls = new List<Control> { label, textbox };
     componentControls.Add(component.GetType(), controls);
     scene.Add(controls);
 }
예제 #6
0
 private static void ChangeLabel(Label label, UIControl uiControl)
 {
     label.Size = new Size(uiControl.EntityWidth, uiControl.EntityHeight);
     label.Text = uiControl.contentText;
 }
예제 #7
0
 public void SetUp()
 {
     label = new Label(Center, "Hello World");
 }
예제 #8
0
		public void AddControlToScene(Control control, Scene scene)
		{
			Control newControl = null;
			if (control.GetType() == typeof(Picture))
				newControl = new Picture((control as Picture).Theme, control.Material, control.DrawArea);
			else if (control.GetType() == typeof(Label))
			{
				newControl = new Label((control as Picture).Theme, control.DrawArea, (control as Label).Text);
				newControl.Set(control.Get<BlendMode>());
				newControl.Set(control.Material);
			}
			else if (control.GetType() == typeof(Button))
				newControl = new Button((control as Picture).Theme, control.DrawArea, (control as Button).Text);
			else if (control.GetType() == typeof(InteractiveButton))
				newControl = new InteractiveButton((control as Picture).Theme, control.DrawArea,
					(control as Button).Text);
			else if (control.GetType() == typeof(Slider))
				newControl = new Slider((control as Picture).Theme, control.DrawArea);
			newControl.Name = control.Name;
			if (newControl.Name == null && newControl.GetTags()[0] != null)
				newControl.Name = newControl.GetTags()[0];
			newControl.RenderLayer = control.RenderLayer;
			if (!control.Contains<AnchoringState>())
				newControl.Set(new AnchoringState()); //ncrunch: no coverage
			else
				newControl.Set(control.Get<AnchoringState>());
			scene.Add(newControl);
		}
예제 #9
0
		private static void SetDefaultNameOfLable(Label newLabel, UIEditorScene uiEditorScene)
		{
			uiEditorScene.UIImagesInList.Add(newLabel.Name);
			if (uiEditorScene.UIImagesInList[0] == null)
				uiEditorScene.UIImagesInList[0] = newLabel.Name;
		}
예제 #10
0
		private static Label AddNewLabelToList(Vector2D position, UIEditorScene uiEditorScene)
		{
			var newLabel = new Label(new Theme(), Rectangle.FromCenter(position, new Size(0.2f, 0.1f)),
				"DefaultLabel");
			uiEditorScene.Scene.Add(newLabel);
			SetDefaultNameOfLable(newLabel, uiEditorScene);
			newLabel.Set(BlendMode.Normal);
			return newLabel;
		}
예제 #11
0
		private static Control LoadControl(BinaryReader reader, bool doNotNullRead,
			byte[] versionBytes)
		{
			var controlType = reader.ReadString();
			Control control;
			if (controlType == "Button")
				control = new Button();
			else if (controlType == "InteractiveButton")
				control = new InteractiveButton();
			else if (controlType == "Picture")
				control = new Picture();
			else if (controlType == "Label")
				control = new Label();
			else if (controlType == "Slider")
				control = new Slider();
			else
				throw new ControlTypeNotImplemented(controlType);
			if (doNotNullRead)
				reader.ReadBoolean();
			LoadControl(control, reader, versionBytes);
			return control;
		}
예제 #12
0
		public void SetUp()
		{
			label = new Label(Rectangle.FromCenter(0.5f, 0.5f, 0.3f, 0.1f), "Hello World");
		}
예제 #13
0
 private static void SetDefaultNameOfLable(Label newLabel, UIEditorScene uiEditorScene)
 {
     bool freeName = false;
     int numberOfNames = 0;
     while (freeName == false)
         if (uiEditorScene.UIImagesInList.Contains("NewLabel" + numberOfNames))
             numberOfNames++;
         else
             freeName = true;
     uiEditorScene.UIImagesInList.Add("NewLabel" + numberOfNames);
     if (uiEditorScene.UIImagesInList[0] == null)
         uiEditorScene.UIImagesInList[0] = "NewLabel" + numberOfNames;
     newLabel.AddTag("NewLabel" + numberOfNames);
 }
예제 #14
0
		public void AddNewLabelToScene()
		{
			var label = new Label(Rectangle.One);
			CheckTypeOfNewControl(label, "Label1");
		}