VIS2 SS2013 CVD DVR
 All Classes Namespaces Functions Enumerations Properties
SlicingForm.cs
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Windows.Forms;
9 
10 namespace visLU.Gui
11 {
15  public partial class SlicingForm : Form
16  {
17 
18  private MainWindow mainForm;
19 
23  public SlicingForm()
24  {
25  InitializeComponent();
26  }
27 
31  public MainWindow MainForm
32  {
33  set { mainForm = value; }
34  }
35 
43  public void setSlicingGroups(int slice, Decimal increment, int decimalPlaces, Decimal value)
44  {
45  switch (slice)
46  {
47  case 1:
48  XSliceNumericUpDown.Increment = increment;
49  XSliceNumericUpDown.DecimalPlaces = decimalPlaces;
50  XSliceNumericUpDown.Value = value;
51  break;
52  case 2:
53  YSliceNumericUpDown.Increment = increment;
54  YSliceNumericUpDown.DecimalPlaces = decimalPlaces;
55  YSliceNumericUpDown.Value = value;
56  break;
57  case 3:
58  ZSliceNumericUpDown.Increment = increment;
59  ZSliceNumericUpDown.DecimalPlaces = decimalPlaces;
60  ZSliceNumericUpDown.Value = value;
61  break;
62  default:
63  break;
64 
65  }
66 
67  }
68 
75  public void setSlicingGroups(int slice, int maximum, int value)
76  {
77  switch (slice)
78  {
79  case 1:
80  XSlider.Maximum = maximum;
81  XSlider.Value = value;
82  break;
83  case 2:
84  YSlider.Maximum = maximum;
85  YSlider.Value = value;
86  break;
87  case 3:
88  ZSlider.Maximum = maximum;
89  ZSlider.Value = value;
90  break;
91  default:
92  break;
93 
94  }
95 
96  }
97 
98  #region event handler
99  private void handleSliceNumericUpDown(object sender, EventArgs e)
105  {
106  if (sender == XSliceNumericUpDown)
107  {
108  XSlider.Value = Decimal.ToInt32(Decimal.Multiply(XSliceNumericUpDown.Value, new Decimal(XSlider.Maximum)));
109  GameProperties.Instance.xSliceValue = (float)XSliceNumericUpDown.Value;
110 
111  }
112  else if (sender == YSliceNumericUpDown)
113  {
114  YSlider.Value = Decimal.ToInt32(Decimal.Multiply(YSliceNumericUpDown.Value, new Decimal(YSlider.Maximum)));
115  GameProperties.Instance.ySliceValue = (float)YSliceNumericUpDown.Value;
116 
117  }
118  else if (sender == ZSliceNumericUpDown)
119  {
120  ZSlider.Value = Decimal.ToInt32(Decimal.Multiply(ZSliceNumericUpDown.Value, new Decimal(ZSlider.Maximum)));
121  GameProperties.Instance.zSliceValue = (float)ZSliceNumericUpDown.Value;
122 
123  }
124  else { return; }
125 
126  mainForm.setSlicingGroups(1, XSliceNumericUpDown.Increment, XSliceNumericUpDown.DecimalPlaces, XSliceNumericUpDown.Value);
127  mainForm.setSlicingGroups(2, YSliceNumericUpDown.Increment, YSliceNumericUpDown.DecimalPlaces, YSliceNumericUpDown.Value);
128  mainForm.setSlicingGroups(3, ZSliceNumericUpDown.Increment, YSliceNumericUpDown.DecimalPlaces, ZSliceNumericUpDown.Value);
129  mainForm.setSlicingGroups(1, XSlider.Maximum, XSlider.Value);
130  mainForm.setSlicingGroups(2, YSlider.Maximum, YSlider.Value);
131  mainForm.setSlicingGroups(3, ZSlider.Maximum, ZSlider.Value);
132  mainForm.updateSliceGroups();
133 
134  if (!GameProperties.Instance.viewMode.Equals(ViewMode.VolView))
135  {
136  mainForm.updateXnaEngineState(false, false, false, true);
137  }
138  }
139 
145  private void handleScrollSlider(object sender, EventArgs e)
146  {
147  if (sender == XSlider)
148  {
149  Decimal newValue = Decimal.Divide(new Decimal(XSlider.Value), new Decimal(XSlider.Maximum));
150  XSliceNumericUpDown.Value = newValue;
151  GameProperties.Instance.xSliceValue = (float)newValue;
152 
153  }
154  else if (sender == YSlider)
155  {
156  Decimal newValue = Decimal.Divide(new Decimal(YSlider.Value), new Decimal(YSlider.Maximum));
157  YSliceNumericUpDown.Value = newValue;
158  GameProperties.Instance.ySliceValue = (float)newValue;
159 
160  }
161  else if (sender == ZSlider)
162  {
163  Decimal newValue = Decimal.Divide(new Decimal(ZSlider.Value), new Decimal(ZSlider.Maximum));
164  ZSliceNumericUpDown.Value = newValue;
165  GameProperties.Instance.zSliceValue = (float)newValue;
166 
167  }
168  else { return; }
169 
170  mainForm.setSlicingGroups(1, XSliceNumericUpDown.Increment, XSliceNumericUpDown.DecimalPlaces, XSliceNumericUpDown.Value);
171  mainForm.setSlicingGroups(2, YSliceNumericUpDown.Increment, YSliceNumericUpDown.DecimalPlaces, YSliceNumericUpDown.Value);
172  mainForm.setSlicingGroups(3, ZSliceNumericUpDown.Increment, YSliceNumericUpDown.DecimalPlaces, ZSliceNumericUpDown.Value);
173  mainForm.setSlicingGroups(1, XSlider.Maximum, XSlider.Value);
174  mainForm.setSlicingGroups(2, YSlider.Maximum, YSlider.Value);
175  mainForm.setSlicingGroups(3, ZSlider.Maximum, ZSlider.Value);
176  mainForm.updateSliceGroups();
177 
178  if (!GameProperties.Instance.viewMode.Equals(ViewMode.VolView))
179  {
180  mainForm.updateXnaEngineState(false, false, false, true);
181  }
182  }
183 
189  private void handleSlicingFormOnClosing(object sender, FormClosingEventArgs e)
190  {
191  mainForm.setSlicingGroups(1, XSliceNumericUpDown.Increment, XSliceNumericUpDown.DecimalPlaces, XSliceNumericUpDown.Value);
192  mainForm.setSlicingGroups(2, YSliceNumericUpDown.Increment, YSliceNumericUpDown.DecimalPlaces, YSliceNumericUpDown.Value);
193  mainForm.setSlicingGroups(3, ZSliceNumericUpDown.Increment, YSliceNumericUpDown.DecimalPlaces, ZSliceNumericUpDown.Value);
194  mainForm.setSlicingGroups(1, XSlider.Maximum, XSlider.Value);
195  mainForm.setSlicingGroups(2, YSlider.Maximum, YSlider.Value);
196  mainForm.setSlicingGroups(3, ZSlider.Maximum, ZSlider.Value);
197  mainForm.updateSliceGroups();
198  mainForm.SliceFormOpen = false;
199  }
200 
201  #endregion
202  }
203 }