2012-06-26 08:54:25 +00:00
|
|
|
|
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
|
|
|
|
|
{
|
2012-06-28 20:27:48 +00:00
|
|
|
|
private static bool linkSliders;
|
2012-06-26 08:54:25 +00:00
|
|
|
|
public event EventHandler OnValueChanged;
|
|
|
|
|
|
|
|
|
|
public Vector2D Value {
|
|
|
|
|
set {
|
|
|
|
|
floatSlider1.Value = value.x;
|
|
|
|
|
floatSlider2.Value = value.y;
|
2012-06-28 20:27:48 +00:00
|
|
|
|
prevValues = value;
|
|
|
|
|
delta = new Vector2D();
|
2012-06-26 08:54:25 +00:00
|
|
|
|
}
|
|
|
|
|
get {
|
|
|
|
|
return new Vector2D(floatSlider1.Value, floatSlider2.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-28 20:27:48 +00:00
|
|
|
|
private Vector2D prevValues;
|
|
|
|
|
private Vector2D delta;
|
|
|
|
|
public Vector2D Delta { get { return delta; } }
|
|
|
|
|
|
2012-06-26 08:54:25 +00:00
|
|
|
|
public ScaleControl() {
|
2012-06-28 20:27:48 +00:00
|
|
|
|
prevValues = new Vector2D();
|
|
|
|
|
delta = new Vector2D();
|
|
|
|
|
|
2012-06-26 08:54:25 +00:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
setLinkButtonIcon(linkSliders);
|
|
|
|
|
|
|
|
|
|
floatSlider1.OnValueChanged += new EventHandler(floatSlider1_OnValueChanged);
|
|
|
|
|
floatSlider2.OnValueChanged += new EventHandler(floatSlider2_OnValueChanged);
|
|
|
|
|
button1.Click += new EventHandler(button1_Click);
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-28 20:27:48 +00:00
|
|
|
|
private void setLinkButtonIcon(bool link) {
|
2012-06-26 08:54:25 +00:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-28 20:27:48 +00:00
|
|
|
|
//events
|
2012-06-26 08:54:25 +00:00
|
|
|
|
private void floatSlider1_OnValueChanged(object sender, EventArgs e) {
|
2012-06-28 20:27:48 +00:00
|
|
|
|
float val = ((FloatSlider)sender).Value;
|
|
|
|
|
|
|
|
|
|
if (linkSliders) {
|
|
|
|
|
delta.y = (float)Math.Round(val - floatSlider2.Value, 1);
|
|
|
|
|
prevValues.y = floatSlider2.Value;
|
|
|
|
|
floatSlider2.Value = val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delta.x = (float)Math.Round(val - prevValues.x, 1);
|
|
|
|
|
prevValues.x = val;
|
2012-07-28 20:36:28 +00:00
|
|
|
|
|
|
|
|
|
if (OnValueChanged != null) OnValueChanged(this, EventArgs.Empty);
|
2012-06-26 08:54:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void floatSlider2_OnValueChanged(object sender, EventArgs e) {
|
2012-06-28 20:27:48 +00:00
|
|
|
|
float val = ((FloatSlider)sender).Value;
|
|
|
|
|
|
|
|
|
|
if (linkSliders) {
|
|
|
|
|
delta.x = (float)Math.Round(val - floatSlider1.Value, 1);
|
|
|
|
|
prevValues.x = floatSlider1.Value;
|
|
|
|
|
floatSlider1.Value = val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delta.y = (float)Math.Round(val - prevValues.y, 1);
|
|
|
|
|
prevValues.y = val;
|
2012-07-28 20:36:28 +00:00
|
|
|
|
|
|
|
|
|
if (OnValueChanged != null) OnValueChanged(this, EventArgs.Empty);
|
2012-06-26 08:54:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void button1_Click(object sender, EventArgs e) {
|
|
|
|
|
setLinkButtonIcon(linkSliders = !linkSliders);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|