UltimateZoneBuilder/Source/Plugins/UMDFControls/Controls/ScaleControl.cs
MaxED 113f9c6039 GZDoom Builder 1.09:
Added UDMF Controls plugin.
Added "Snap selected vertices to grid" mode (Found in Edit menu).
2012-06-26 08:54:25 +00:00

63 lines
2.1 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using CodeImp.DoomBuilder.Geometry;
namespace CodeImp.DoomBuilder.UDMFControls
{
public partial class ScaleControl : UserControl
{
private bool linkSliders;
public event EventHandler OnValueChanged;
public Vector2D Value {
set {
floatSlider1.Value = value.x;
floatSlider2.Value = value.y;
}
get {
return new Vector2D(floatSlider1.Value, floatSlider2.Value);
}
}
public Vector2D Delta { get { return new Vector2D(floatSlider1.Delta, floatSlider2.Delta); } }
public ScaleControl() {
InitializeComponent();
setLinkButtonIcon(linkSliders);
floatSlider1.OnValueChanged += new EventHandler(floatSlider1_OnValueChanged);
floatSlider2.OnValueChanged += new EventHandler(floatSlider2_OnValueChanged);
button1.Click += new EventHandler(button1_Click);
}
private void setLinkButtonIcon(bool link){
button1.BackgroundImage = link ? Properties.Resources.Chain : Properties.Resources.Chain2;
}
public void SetLimits(float min, float max) {
floatSlider1.SetLimits(min, max, true);
floatSlider2.SetLimits(min, max, true);
}
//events
private void floatSlider1_OnValueChanged(object sender, EventArgs e) {
if (linkSliders) floatSlider2.Value = ((FloatSlider)sender).Value;
if (OnValueChanged != null) OnValueChanged(this, EventArgs.Empty);
}
private void floatSlider2_OnValueChanged(object sender, EventArgs e) {
if (linkSliders) floatSlider1.Value = ((FloatSlider)sender).Value;
if (OnValueChanged != null) OnValueChanged(this, EventArgs.Empty);
}
private void button1_Click(object sender, EventArgs e) {
setLinkButtonIcon(linkSliders = !linkSliders);
}
}
}