private void PropertiesTextChanged(object sender, TextChangedEventArgs e) { TextBox currentTextBox = (TextBox)sender; if (this.previousTextBox == currentTextBox) { try { double parsed = Double.Parse(currentTextBox.Text, CultureInfo.InvariantCulture); if (currentTextBox.Text.Contains(',')) { currentTextBox.Text = currentTextBox.Text.Replace(',', '.'); } if (parsed < 0 || parsed > 1) { currentTextBox.Text = previousString; e.Handled = true; } else { TextBox diffusion, reflection, transparency; diffusion = (TextBox)this.FindName("diffusion"); reflection = (TextBox)this.FindName("reflection"); transparency = (TextBox)this.FindName("transparency"); float d = (float)Double.Parse(diffusion.Text, CultureInfo.InvariantCulture); float r = (float)Double.Parse(reflection.Text, CultureInfo.InvariantCulture); float t = (float)Double.Parse(transparency.Text, CultureInfo.InvariantCulture); RayTracer.AObject aObject = objects[selected.Name]; aObject.kd = d; aObject.ks = r; aObject.kt = t; } } catch (Exception) { if (!(currentTextBox.Text == "-" || currentTextBox.Text == "")) { currentTextBox.Text = previousString; e.Handled = true; } } } this.previousTextBox = (TextBox)sender; }
private void FillProperties(Shape shape) { TextBox r, g, b, reflection, diffusion, transparency; r = (TextBox)this.FindName("ColorR"); g = (TextBox)this.FindName("ColorG"); b = (TextBox)this.FindName("ColorB"); diffusion = (TextBox)this.FindName("diffusion"); reflection = (TextBox)this.FindName("reflection"); transparency = (TextBox)this.FindName("transparency"); RayTracer.AObject aObject = objects[shape.Name]; r.Text = (aObject.color.r * 256).ToString().Replace(',', '.'); g.Text = (aObject.color.g * 256).ToString().Replace(',', '.'); b.Text = (aObject.color.b * 256).ToString().Replace(',', '.'); diffusion.Text = aObject.kd.ToString().Replace(',', '.'); reflection.Text = aObject.ks.ToString().Replace(',', '.'); transparency.Text = aObject.kt.ToString().Replace(',', '.'); }
private void ColorTextChanged(object sender, TextChangedEventArgs e) { TextBox currentTextBox = (TextBox)sender; if (this.previousTextBox == currentTextBox) { try { int parsed = Int32.Parse(currentTextBox.Text, CultureInfo.InvariantCulture); if (parsed < 0 || parsed > 255) { currentTextBox.Text = previousString; e.Handled = true; } else { TextBox r, g, b; r = (TextBox)this.FindName("ColorR"); g = (TextBox)this.FindName("ColorG"); b = (TextBox)this.FindName("ColorB"); int colorR = Int32.Parse(r.Text); int colorG = Int32.Parse(g.Text); int colorB = Int32.Parse(b.Text); selected.Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb((byte)colorR, (byte)colorG, (byte)colorB)); RayTracer.AObject aObject = objects[selected.Name]; aObject.SetColor((float)(colorR / 256.0), (float)(colorG / 256.0), (float)(colorB / 256.0)); } } catch (Exception) { if (!(currentTextBox.Text == "-" || currentTextBox.Text == "")) { currentTextBox.Text = previousString; e.Handled = true; } } } this.previousTextBox = (TextBox)sender; }
/// <summary> /// Constructor /// </summary> /// <param name="ID">ID</param> /// <param name="a">Object a</param> /// <param name="b">Object b</param> public Unification(int ID, AObject a, AObject b) { this.ID = ID; this.a = a; this.b = b; }
/// <summary> /// Constructor /// </summary> /// <param name="ID">ID of created object</param> /// <param name="a">Basis</param> /// <param name="b">Body which we remove</param> public Diff(int ID, AObject a, AObject b) { this.ID = ID; this.a = a; this.b = b; }