UltimateZoneBuilder/Source/Plugins/UMDFControls/Controls/ScaleControl.cs
MaxED 2006cdc7bb GZDoom Builder 1.12a:
AngleOffset, PitchOffset and RollOffset MODELDEF properties are now supported.
Fixed a crash when editor tries to display a model for an actor without a valid sprite in Visual mode.
Fixed a possible crash when MODELDEF is reloaded from 2d-mode.
Fixed several things in Doom2_things.cfg.
UDMF Controls plugin:
Fixed several bugs in plugin's sliders logic.
2012-07-28 20:36:28 +00:00

90 lines
2.9 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 static bool linkSliders;
public event EventHandler OnValueChanged;
public Vector2D Value {
set {
floatSlider1.Value = value.x;
floatSlider2.Value = value.y;
prevValues = value;
delta = new Vector2D();
}
get {
return new Vector2D(floatSlider1.Value, floatSlider2.Value);
}
}
private Vector2D prevValues;
private Vector2D delta;
public Vector2D Delta { get { return delta; } }
public ScaleControl() {
prevValues = new Vector2D();
delta = new Vector2D();
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) {
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;
if (OnValueChanged != null) OnValueChanged(this, EventArgs.Empty);
}
private void floatSlider2_OnValueChanged(object sender, EventArgs e) {
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;
if (OnValueChanged != null) OnValueChanged(this, EventArgs.Empty);
}
private void button1_Click(object sender, EventArgs e) {
setLinkButtonIcon(linkSliders = !linkSliders);
}
}
}