mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-12-19 08:31:01 +00:00
7c93fad714
Added drawing modes to Mode menu, so they are much easier to spot now. Warnings notify panel blinks much more noticeable when there are warnings. UDMF Controls plugin: 3D-floor surfaces can be edited now. Relative mode is now enabled by default. Scale control now works properly in relative mode. Angle control's angle indicator in now drawn properly when value is changed using numeric control.
88 lines
2.9 KiB
C#
88 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;
|
|
}
|
|
|
|
if (OnValueChanged != null) OnValueChanged(this, EventArgs.Empty);
|
|
delta.x = (float)Math.Round(val - prevValues.x, 1);
|
|
prevValues.x = val;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
if (OnValueChanged != null) OnValueChanged(this, EventArgs.Empty);
|
|
delta.y = (float)Math.Round(val - prevValues.y, 1);
|
|
prevValues.y = val;
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e) {
|
|
setLinkButtonIcon(linkSliders = !linkSliders);
|
|
}
|
|
}
|
|
}
|