public FrameworkElement ResolveEditor(PropertyItem propertyItem) { bool writable = !propertyItem.IsReadOnly; DoubleUpDown editor = new DoubleUpDown(); editor.Style = Style; editor.IsEnabled = writable; editor.ShowButtonSpinner = writable; if (!writable) { editor.Minimum = null; editor.Maximum = null; } //create the binding from the bound property item to the editor var _binding = new Binding("Value"); //bind to the Value property of the PropertyItem _binding.Source = propertyItem; _binding.ValidatesOnExceptions = true; _binding.ValidatesOnDataErrors = true; _binding.Mode = writable ? BindingMode.TwoWay : BindingMode.OneWay; BindingOperations.SetBinding(editor, DoubleUpDown.ValueProperty, _binding); return(editor); }
private void DoubleUpDown_ValueChanged_1(object sender, RoutedPropertyChangedEventArgs <object> e) { DoubleUpDown d = sender as DoubleUpDown; WeaponScaleLabel.Content = d.Value * 50; WeaponSumLabel.Content = WeaponBaseMultInput.Value + d.Value * 50; }
/// <summary> /// Generates the numeric double row. /// </summary> /// <param name="gridContainer">The grid container.</param> /// <param name="item">The item.</param> /// <param name="row">The row.</param> private void GenerateNumericDoubleRow(Grid gridContainer, DnwSetting item, int row) { try { GenerateDescriptions(gridContainer, item, row); DoubleUpDown dud = new DoubleUpDown(); if (item.Mask.XDwIsNullOrTrimEmpty()) { dud.FormatString = "F6"; } else { dud.FormatString = item.Mask; } dud.Padding = new Thickness(2); dud.Margin = new Thickness(5); Binding vBinding = new Binding(DnwSetting.FLD_Value); vBinding.Source = item; dud.SetBinding(DoubleUpDown.ValueProperty, vBinding); gridContainer.Children.Add(dud); Grid.SetRow(dud, row); Grid.SetColumn(dud, 2); } catch (Exception ex) { EventLogger.SendMsg(ex); throw; } }
private void MatrixSizeClick(object sender, RoutedEventArgs e) { int width = MatrixWidth.Value.Value; int height = MatrixHeight.Value.Value; Console.WriteLine(width + " " + height); Grid.ColumnDefinitions.Clear(); Grid.RowDefinitions.Clear(); for (int i = 0; i < width; i++) { Grid.ColumnDefinitions.Add(new ColumnDefinition()); } for (int i = 0; i < height; i++) { Grid.RowDefinitions.Add(new RowDefinition()); } Grid.Children.Clear(); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { DoubleUpDown upDown = new DoubleUpDown(); upDown.Value = 0; upDown.Tag = $"{i}x{j}"; upDown.ValueChanged += CellValueChanged; Grid.SetColumn(upDown, i); Grid.SetRow(upDown, j); Grid.Children.Add(upDown); } } _ownMatrix = new double[width, height]; }
private static void DbUpDown_PreviewTextInput(object sender, TextCompositionEventArgs e) { DoubleUpDown dp = ( DoubleUpDown )sender; char input = e.Text[0]; if (!Char.IsDigit(input)) { if (input == '.') //判断小数点是否有效 { if (DoubleUpDownInputHelper.IsDotValid(dp)) { return; } } if (input == '-') //判断负号是否有效 { if (DoubleUpDownInputHelper.IsNegativeSignValid(dp)) { return; } } e.Handled = true; } }
private void Listbox_SelectionChanged(object sender, SelectionChangedEventArgs e) { ListBox listbox = (ListBox)sender; if (listbox.SelectedIndex == listbox.Items.Count - 1) { WrapPanel panel = new WrapPanel(); ComboBox comboBox = new ComboBox(); comboBox.ItemsSource = DataBase.dishes; comboBox.Text = "Wybierz posiłek"; comboBox.IsEditable = true; panel.Children.Add(comboBox); Label label = new Label(); label.Content = "Ilość: "; panel.Children.Add(label); DoubleUpDown doubleUpDown = new DoubleUpDown(); doubleUpDown.Value = 1; panel.Children.Add(doubleUpDown); Button OK = new Button(); OK.Click += OK_Click; OK.Content = "OK"; panel.Children.Add(OK); listbox.Items.Insert(listbox.Items.Count - 1, panel); listbox.SelectedIndex = listbox.Items.Count - 2; } }
private FrameworkElement GenerateDoubleUpDown(PropertyInfo property, Binding binding) { #if !SILVERLIGHT DoubleUpDown calculatorUpDown = new DoubleUpDown() { Margin = new Thickness(0, 3, 18, 3) }; calculatorUpDown.IsReadOnly = !(bindables[property.Name].Direction == BindingDirection.TwoWay); // Binding this.bindings.Add(property.Name, calculatorUpDown.SetBinding(DoubleUpDown.ValueProperty, binding)); #else Border calculatorUpDown = new Border() { Opacity = 1.0, Background = new SolidColorBrush(Colors.White), Margin = new Thickness(0, 3, 18, 3) }; NumericUpDown n = new NumericUpDown() { }; calculatorUpDown.Child = n; n.IsEnabled = (bindables[property.Name].Direction == BindingDirection.TwoWay); // Binding this.bindings.Add(property.Name, n.SetBinding(NumericUpDown.ValueProperty, binding)); #endif return(calculatorUpDown); }
private static FrameworkElement ExtractDouble(DisplayOption option) { var ctrl = new DoubleUpDown { FormatString = "F2", Margin = new Thickness(3), HorizontalAlignment = HorizontalAlignment.Left, MinWidth = 50 }; ctrl.SetBinding(DoubleUpDown.ValueProperty, new Binding(option.PropertyName)); double newVal; if (option.Minimum != null) { newVal = Convert.ToDouble(option.Minimum); ctrl.Minimum = newVal; } if (option.Maximum != null) { newVal = Convert.ToDouble(option.Maximum); ctrl.Maximum = newVal; } return(ctrl); }
private static void InitializeObject(KeyValuePair <string, object> prop, Panel content, object parent) { content.Children.Add(new TextBlock { Text = prop.Key, Padding = new Thickness(0, 10, 0, 0) }); if (prop.Value is int) { var input = new IntegerUpDown(); BindingOperations.SetBinding(input, IntegerUpDown.ValueProperty, GetBinding(prop, parent)); content.Children.Add(input); } else if (prop.Value is double) { var input = new DoubleUpDown(); BindingOperations.SetBinding(input, DoubleUpDown.ValueProperty, GetBinding(prop, parent)); content.Children.Add(input); } else if (prop.Value is IList) { ProcessList(prop, content); } else { var input = new TextBox { HorizontalContentAlignment = HorizontalAlignment.Right }; BindingOperations.SetBinding(input, TextBox.TextProperty, GetBinding(prop, parent)); content.Children.Add(input); } }
private void loadDataFromGUItoSelectedPart() { List <float> angles = new List <float>(); List <int> joints = new List <int>(); List <float> lengths = new List <float>(); Debug.WriteLine(corners_stackPanel.Children.Count); foreach (UIElement element in corners_stackPanel.Children) { Grid grid = (Grid)element; DoubleUpDown angle = (DoubleUpDown)grid.Children[0]; DoubleUpDown length = (DoubleUpDown)grid.Children[1]; IntegerUpDown joint = (IntegerUpDown)grid.Children[2]; angles.Add((float)angle.Value); joints.Add((int)joint.Value); lengths.Add((float)length.Value); Debug.WriteLine(angle.Value + " " + joint.Value + " " + length.Value); } parts[partIndex].Relative = new Vector2((float)rellativeX_DoubleUpDown.Value, (float)rellativeY_DoubleUpDown.Value); parts[partIndex].Collide = collide_checkBox.IsChecked.Value; parts[partIndex].setAnglesJointsLengths(angles.Count, angles, lengths, joints); }
public static DoubleUpDown GetDoubleEditor(Binding valuePropertyBinding, double minValue = Double.MinValue, double maxValue = Double.MaxValue, bool isReadOnly = false) { var control = new DoubleUpDown(); SetNumericProperties(control, minValue, maxValue, isReadOnly); control.SetBinding(DoubleUpDown.ValueProperty, valuePropertyBinding); return(control); }
internal static string GetCellValueControl(ref DataGrid Grid1, string strControl, int iColumn, int iRow) { string strReturnValue = ""; DataGridRow row = Grid1.ItemContainerGenerator.ContainerFromIndex(iRow) as DataGridRow; ContentPresenter CP = Grid1.Columns[iColumn].GetCellContent(row) as ContentPresenter; if (strControl == "Date") { DatePicker DP = FindVisualChild <DatePicker>(CP); if (DP != null) { strReturnValue = DP.SelectedDate.Value.ToString("dd/MM/yyyy"); } else { strReturnValue = ""; } } if (strControl == "TextBox") { TextBox DP = FindVisualChild <TextBox>(CP); if (DP != null) { strReturnValue = DP.Text.Trim(); } else { strReturnValue = ""; } } if (strControl == "Double") { DoubleUpDown DP = FindVisualChild <DoubleUpDown>(CP); if (DP != null) { strReturnValue = DP.Value.ToString().Trim(); } else { strReturnValue = ""; } } if (strControl == "Int") { IntegerUpDown DP = FindVisualChild <IntegerUpDown>(CP); if (DP != null) { strReturnValue = DP.Value.ToString().Trim(); } else { strReturnValue = ""; } } return(strReturnValue); }
/// <summary> /// Determines whether the given set of values defines a valid range or not. /// A valid range adheres to this constrain: MinValue <= Value <= MaxValue. /// </summary> /// <param name="range"></param> /// <returns></returns> bool IsValidRange(DoubleUpDown range) { if (range.MinValue <= range.Value && range.Value <= range.MaxValue) { return(true); } return(false); }
public static UIElement CreateSpinner(object source, string path, AnnotationVariable var, object storedValue) { if (var.DataType.IsIntegral()) { IntegerUpDown spinner = new IntegerUpDown(); spinner.Increment = var.GetStepInteger(); spinner.Minimum = var.GetMinimumInteger(); spinner.Maximum = var.GetMaximumInteger(); Binding binding = new Binding(); binding.Source = source; binding.Mode = BindingMode.TwoWay; binding.Path = new PropertyPath(path); BindingOperations.SetBinding(spinner, IntegerUpDown.ValueProperty, binding); if (storedValue == null) { spinner.Value = Math.Max(Math.Min(0, spinner.Maximum.Value), spinner.Minimum.Value); } else { spinner.Value = (int)storedValue; } spinner.HorizontalContentAlignment = HorizontalAlignment.Stretch; spinner.HorizontalAlignment = HorizontalAlignment.Stretch; return(spinner); } else { DoubleUpDown spinner = new DoubleUpDown(); spinner.Increment = var.GetStepDouble(); spinner.Minimum = var.GetMinimumDouble(); spinner.Maximum = var.GetMaximumDouble(); Binding binding = new Binding(); binding.Source = source; binding.Mode = BindingMode.TwoWay; binding.Path = new PropertyPath(path); BindingOperations.SetBinding(spinner, DoubleUpDown.ValueProperty, binding); if (storedValue == null) { spinner.Value = Math.Max(Math.Min(0, spinner.Maximum.Value), spinner.Minimum.Value); } else { spinner.Value = (double)storedValue; } spinner.HorizontalContentAlignment = HorizontalAlignment.Stretch; spinner.HorizontalAlignment = HorizontalAlignment.Stretch; return(spinner); } }
protected override FrameworkElement CreateEditingElement() { var updown = new DoubleUpDown(); this.ResetBinding(updown); this.SetAutomationElement(updown); return(updown); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); mValue = GetTemplateChild(PART_Value) as DoubleUpDown; if (mValue != null) { mValue.ValueChanged += mValue_ValueChanged; } }
protected override FrameworkElement CreateEditingElement() { var updown = new DoubleUpDown(); this.ResetBinding(updown); this.SetAutomationElement(updown); return updown; }
private void btnMaterialCreate_Click(object sender, RoutedEventArgs e) { TextBox tb = new TextBox(); tb.Text = "Hammadde Adı : "; tb.Name = "btn" + i; tb.Margin = new Thickness(0, y, 0, 0); this.canContainer.Children.Add(tb); y += 40; ComboBox cb = new ComboBox(); cb.Width = 100; cb.Name = "combo" + i; cb.Margin = new Thickness(120, b, 0, 0); this.canContainer.Children.Add(cb); b += 40; TextBox tb1 = new TextBox(); tb1.Text = "Ölçü birimi : "; tb1.Name = "btn" + i; tb1.Margin = new Thickness(260, a, 0, 0); this.canContainer.Children.Add(tb1); a += 40; ComboBox cb1 = new ComboBox(); cb1.Width = 100; cb1.Name = "comboOlcu" + i; cb1.Margin = new Thickness(345, d, 0, 0); this.canContainer.Children.Add(cb1); d += 40; TextBox tb2 = new TextBox(); tb2.Text = "Miktar : "; tb2.Name = "btn" + i; tb2.Margin = new Thickness(470, c, 0, 0); this.canContainer.Children.Add(tb2); c += 40; DoubleUpDown upDown = new DoubleUpDown(); upDown.Width = 100; upDown.Name = "updown" + i; upDown.Margin = new Thickness(530, f, 0, 0); this.canContainer.Children.Add(upDown); f += 40; i++; }
protected override Control CreateValueControl() { var control = new DoubleUpDown { ToolTip = Definition.Description, Watermark = Definition.Hint }; var formatString = Definition.Settings.Get("Format"); if (!string.IsNullOrWhiteSpace(formatString)) { control.FormatString = formatString; } return(control); }
private void addValueBox() { DoubleUpDown box = new DoubleUpDown() { Width = 40, Height = 25, Value = 0.0, ShowButtonSpinner = false }; valueBoxes.Add(box); valuesPanel.Children.Add(box); }
private void DoubleUpDown_ValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { DoubleUpDown d = ((DoubleUpDown)sender); if (d.Value == null) { return; } switch (d.Name) { case "HpGrow": HealthL.Content = Math.Round((double)d.Value * 100f, 1, MidpointRounding.AwayFromZero); break; case "SpGrow": SoulL.Content = Math.Round((double)d.Value * 100f, 1, MidpointRounding.AwayFromZero); break; case "StrGrow": StrL.Content = Math.Round((double)d.Value * 100f, 1, MidpointRounding.AwayFromZero); break; case "IntGrow": IntL.Content = Math.Round((double)d.Value * 100f, 1, MidpointRounding.AwayFromZero); break; case "AgiGrow": AgiL.Content = Math.Round((double)d.Value * 100f, 1, MidpointRounding.AwayFromZero); break; case "WillGrow": WillL.Content = Math.Round((double)d.Value * 100f, 1, MidpointRounding.AwayFromZero); break; } if (ArchetypesList.SelectedItem == null) { return; } ArchetypeBase selected = (ArchetypeBase)ArchetypesList.SelectedItem; double totalstats = 0, totalhpsp = 0, total = 0; totalstats = selected.StrengthGrowth + selected.IntelligenceGrowth + selected.AgilityGrowth + selected.WillGrowth; //totalhpsp = selected.HealthGrowth + selected.SoulPointGrowth * 50; totalhpsp = selected.HealthGrowth; total = totalhpsp + totalstats; TotalL.Content = totalstats.ToString("F2") + " + " + totalhpsp.ToString("F2") + " = " + total.ToString("F2"); }
public Visual GetControl(Application application) { if (control == null) { control = new DoubleUpDown { Margin = new System.Windows.Thickness(0, 0, 0, 6) }; control.SetBinding(DoubleUpDown.ValueProperty, new Binding("Value") { Source = this }); } return(control); }
internal void SetData <T>(NumericUpDownData <T> numericUpDownControl) where T : struct, IFormattable, IComparable <T> { Control control; Binding binding = new Binding("Value"); binding.Source = numericUpDownControl; if (typeof(T) == typeof(int)) { var numeric = new IntegerUpDown(); numeric.Minimum = Convert.ToInt32(numericUpDownControl._min); numeric.Maximum = Convert.ToInt32(numericUpDownControl._max); numeric.UpdateValueOnEnterKey = true; numeric.FormatString = numericUpDownControl.FormatString; numeric.SetBinding(IntegerUpDown.ValueProperty, binding); control = numeric; } else if (typeof(T) == typeof(decimal)) { var numeric = new DecimalUpDown(); numeric.Minimum = Convert.ToDecimal(numericUpDownControl._min); numeric.Maximum = Convert.ToDecimal(numericUpDownControl._max); numeric.Increment = (numeric.Maximum - numeric.Minimum) / 100; numeric.UpdateValueOnEnterKey = true; numeric.FormatString = numericUpDownControl.FormatString; numeric.SetBinding(DecimalUpDown.ValueProperty, binding); control = numeric; } else if (typeof(T) == typeof(double)) { var numeric = new DoubleUpDown(); numeric.Minimum = Convert.ToDouble(numericUpDownControl._min); numeric.Maximum = Convert.ToDouble(numericUpDownControl._max); numeric.UpdateValueOnEnterKey = true; numeric.SetBinding(DoubleUpDown.ValueProperty, binding); numeric.FormatString = numericUpDownControl.FormatString; control = numeric; } else { throw new Exception($"Inavlid type, Expected int,double or decimal received {typeof(T)}"); } //control.Width = 200; //control.Height = 24; control.Name = "Numeric"; control.Background = Brushes.LightGoldenrodYellow; control.KeyDown += Control_KeyDown; this.PlaceHolder.Children.Add(control); }
protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem) { var numericEditor = new DoubleUpDown(); numericEditor.Minimum = Minimum; numericEditor.Maximum = Maximum; numericEditor.Increment = Increment; numericEditor.FormatString = FormatString; var sourceBinding = this.Binding as System.Windows.Data.Binding; var binding = new System.Windows.Data.Binding(); binding.Path = sourceBinding.Path; binding.Converter = new TargetTypeConverter(); numericEditor.SetBinding(DoubleUpDown.ValueProperty, binding); return numericEditor; }
private void GranularityPopup_Closed(object sender, EventArgs e) { ChildWindow popup = sender as ChildWindow; DoubleUpDown result = (DoubleUpDown)popup.Resources["value"]; string file = (string)popup.Resources["file"]; IEnumerable <Path> paths = (IEnumerable <Path>)popup.Resources["paths"]; bool success = (bool)(popup.Resources["success"] ?? false); if (success) { PathFileOperations.Export(file, paths, result.Value ?? 0); ShowMessageBox("Exported motion profile at " + file, "Success!", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void dudNumPlay_ValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { try { DoubleUpDown dud = (DoubleUpDown)sender; if (dud.IsMouseOver) { base.IndexP = dgVoice.SelectedIndex; ParVoice.P_I.BasicParVoice_L[base.IndexP].NumPlay = (int)dud.Value; } } catch (Exception ex) { } }
public override Control ProvideControl(PropertyInfo propertyInfo, object viewModel) { Binding binding = propertyInfo.GetBinding(); var editableAttribute = propertyInfo.GetAttribute <EditableAttribute>(); Control control = new DoubleUpDown(); control.SetBinding(DoubleUpDown.ValueProperty, binding); control.IsEnabled = propertyInfo.IsControlEnabled(); return(control); }
public override Control ProvideControl(PropertyInfo propertyInfo, object viewModel) { Binding binding = propertyInfo.GetBinding(); var editableAttribute = propertyInfo.GetAttribute <EditableAttribute>(); Control control = new DoubleUpDown(); control.SetBinding(DoubleUpDown.ValueProperty, binding); control.IsEnabled = editableAttribute == null || editableAttribute.AllowEdit || binding.Mode == BindingMode.TwoWay; return(control); }
protected override FrameworkElement BuildElement(ValueContainer value) { DoubleUpDown dud = new DoubleUpDown() { Width = 200, Increment = 0.1 }; dud.ValueChanged += (s, e) => { value.Value = dud.Value; }; Action onValueChanged = () => { dud.Value = Convert.ToDouble(value.Value); }; value.ValueChanged += onValueChanged; onValueChanged(); return dud; }
public override void OnApplyTemplate() { base.OnApplyTemplate(); mBorderPanel = GetTemplateChild(PART_PANEL) as Border; if (mBorderPanel != null) { } mTxtTextBox = GetTemplateChild(PART_TEXTBOX) as AutoSelectTextBox; if (mTxtTextBox != null) { mTxtTextBox.TextChanged += TxtTextBox_TextChanged; } mTxtIntTextBox = GetTemplateChild(PART_INTTEXTBOX) as IntegerUpDown; if (mTxtIntTextBox != null) { mTxtIntTextBox.ValueChanged += TxtIntTextBox_ValueChanged; } mTxtDoubleTextBox = GetTemplateChild(PART_DOUBLETEXTBOX) as DoubleUpDown; if (mTxtDoubleTextBox != null) { mTxtDoubleTextBox.ValueChanged += mTxtDoubleTextBox_ValueChanged; } mBoolCheckBox = GetTemplateChild(PART_BOOLCHECKBOX) as CheckBox; if (mBoolCheckBox != null) { mBoolCheckBox.Click += BoolCheckBox_Click; } mDatetimeTextBox = GetTemplateChild(PART_DATETIMETEXTBOX) as DateTimePicker; if (mDatetimeTextBox != null) { mDatetimeTextBox.ValueChanged += mDatetimeTextBox_ValueChanged; } mItemSelectControl = GetTemplateChild(PART_ITEMSSELECTCONTROL) as Selector; if (mItemSelectControl != null) { mItemSelectControl.ItemsSource = mListEnumValueItems; mItemSelectControl.SelectionChanged += ItemSelectControl_SelectionChanged; ShowValue(); } mColorPickerTextBox = GetTemplateChild(PART_COLORTEXTBOX) as ColorPicker; if (mColorPickerTextBox != null) { mColorPickerTextBox.SelectedColorChanged += mColorPickerTextBox_SelectedColorChanged; } }
private static void OnDigitOnlyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DoubleUpDown dp = d as DoubleUpDown; if (dp == null) { return; } if (( bool )e.NewValue) { dp.PreviewTextInput += DbUpDown_PreviewTextInput; } else { dp.PreviewTextInput -= DbUpDown_PreviewTextInput; } }
private static FrameworkElement DoubleWidget(string propertyName, Action updateAction) { var widget = new DoubleUpDown() { MaxWidth = 50, Increment = .1, FormatString = "F1", HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center }; widget.ValueChanged += (sender, args) => updateAction(); var bind = new Binding(propertyName) { Mode = BindingMode.TwoWay }; BindingOperations.SetBinding(widget, DoubleUpDown.ValueProperty, bind); return(widget); }
public void ExpectEventHandlers() { var dud = new DoubleUpDown(); bool eventWasRaised; dud.ValueChanged += (s, e) => { Assert.AreSame(dud, s); eventWasRaised = true; e.Handled = true; }; { eventWasRaised = false; dud.Value = 867.5309; Assert.IsTrue(eventWasRaised); } }
/// <summary> /// Creates a new instance of the IntegerOption /// </summary> /// <param name="xmlNode">The node that contains the data for the integerOption</param> /// <param name="xsdNode">The corresponding xsdNode.</param> /// <param name="panel">The panel in which this option should be placed.</param> /// <param name="parentForm">The form of which this option is a part.</param> public DocUIInteger(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm) : base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm) { int maxIncl = XmlSchemaUtilities.tryGetMaxIncl(xsdNode); int minIncl = XmlSchemaUtilities.tryGetMinIncl(xsdNode); _defaultValue = minIncl; Control = new DoubleUpDown() { ShowButtonSpinner = true, AllowSpin = true, MouseWheelActiveTrigger = MouseWheelActiveTrigger.MouseOver, Increment = 1, ClipValueToMinMax = true, Minimum = minIncl, Maximum = maxIncl }; (Control as DoubleUpDown).ValueChanged += (s, e) => { hasPendingChanges(); }; setup(); }
FrameworkElement GetValueEditor(elementDescr element) { FrameworkElement felem = null; switch (element.QName.Name) { case "int": IntegerUpDown numUp = new IntegerUpDown(); numUp.Margin = new Thickness(3); numUp.Increment = 1; numUp.VerticalAlignment = VerticalAlignment.Center; numUp.MinWidth = 50; numUp.CreateBinding(IntegerUpDown.ValueProperty, element, x => { int val = 0; int.TryParse(element.Value, out val); return val; }, (o, v) => { o.Value = v.ToString(); }); felem = numUp; break; case "float": DoubleUpDown doubleUp = new DoubleUpDown(); doubleUp.CultureInfo = System.Globalization.CultureInfo.InvariantCulture; doubleUp.Margin = new Thickness(3); doubleUp.Increment = 0.01f; doubleUp.FormatString = "F3"; doubleUp.VerticalAlignment = VerticalAlignment.Center; doubleUp.MinWidth = 50; doubleUp.CreateBinding(DoubleUpDown.ValueProperty, element, x => { float val = 0; //float.TryParse(element.Value, out val); try { val = XmlConvert.ToSingle(element.Value); }catch(Exception err){ dbg.Error(err); } return val; }, (o, v) => { o.Value = XmlConvert.ToString(v); }); felem = doubleUp; break; case "boolean": CheckBox chBox = new CheckBox(); chBox.Margin = new Thickness(3); chBox.CreateBinding(CheckBox.IsCheckedProperty, element, x => { bool val = false; bool.TryParse(element.Value, out val); return val; }, (o, v) => { o.Value = v.ToString(); }); felem = chBox; break; default: TextBox tbox = new TextBox(); tbox.Margin = new Thickness(3); tbox.CreateBinding(TextBox.TextProperty, element, x => x.Value, (o, v) => { o.Value = v; }); tbox.MinWidth = 50; tbox.VerticalAlignment = System.Windows.VerticalAlignment.Center; felem = tbox; break; } return felem; }
/// <summary> /// Populates the settings panel with the settings of a given plugin. /// </summary> /// <param name="plugin">The plugin whose settings to display</param> private void PopulateSettings(Plugin plugin) { SettingsGrid.RowDefinitions.Clear(); SettingsGrid.Children.Clear(); for (int i = 0; i < plugin.Settings.Count; i++) { Setting s = plugin.Settings[i]; // add row SettingsGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); // create label TextBlock tb = new TextBlock() { Text = plugin.T(s.ID), Margin = new Thickness(5, 5, 10, 5), VerticalAlignment = VerticalAlignment.Center }; tb.SetBinding(TextBlock.VisibilityProperty, new Binding("IsVisible") { Source = s, Mode = BindingMode.OneWay, Converter = new BooleanToVisibilityConverter() }); Grid.SetRow(tb, i); Grid.SetColumn(tb, 0); SettingsGrid.Children.Add(tb); FrameworkElement control = null; // create control if (s.Type == typeof(Boolean)) { // checkbox control = new CheckBox() { Height = 15 }; control.SetBinding(CheckBox.IsCheckedProperty, new Binding("Value") { Source = s, Mode = BindingMode.TwoWay }); } else if (s.Type == typeof(Color)) { // color selector control = new ColorPicker() { ShowAvailableColors = false, ShowStandardColors = true, Width = 50, }; if (s.PossibleValues != null) { ColorConverter converter = new ColorConverter(); ((ColorPicker)control).AvailableColors.Clear(); foreach (Color c in s.PossibleValues) { System.Windows.Media.Color color = (System.Windows.Media.Color)converter.Convert(c, null, null, null); ((ColorPicker)control).AvailableColors.Add(new ColorItem(color, c.Name)); } } control.SetBinding(ColorPicker.SelectedColorProperty, new Binding("Value") { Source = s, Mode = BindingMode.TwoWay, Converter = new ColorConverter() }); } else if (s.PossibleValues != null) { // dropdown control = new ComboBox(); foreach (Object val in s.PossibleValues) { try { String content = val.ToString(); if (s.Type == typeof(String)) content = plugin.T(val.ToString()); ((ComboBox)control).Items.Add(new ComboBoxItem { Content = content, Name = val.ToString() }); } catch (Exception exc) { U.L(LogLevel.Warning, "PLUGIN", "Could not add combobox item in plugin settings: " + exc.Message); } } ((ComboBox)control).SelectedValuePath = "Name"; control.SetBinding(ComboBox.SelectedValueProperty, new Binding("Value") { Source = s, Mode = BindingMode.TwoWay }); } else if (s.Type == typeof(String)) { // text input control = new TextBox() { MaxWidth = 400, MinWidth = 250 }; control.SetBinding(TextBox.TextProperty, new Binding("Value") { Source = s, Mode = BindingMode.TwoWay }); } else if (s.Type == typeof(Int32)) { if (s.Maximum != null) { // slider control = new Slider() { Maximum = (Int32)s.Maximum, AutoToolTipPlacement = AutoToolTipPlacement.TopLeft, Width = 200, }; if (s.Minimum != null) ((Slider)control).Minimum = (Int32)s.Minimum; control.SetBinding(Slider.ValueProperty, new Binding("Value") { Source = s, Mode = BindingMode.TwoWay }); } else { // spinner control = new IntegerUpDown(); control.SetBinding(IntegerUpDown.ValueProperty, new Binding("Value") { Source = s, Mode = BindingMode.TwoWay }); } } else if (s.Type == typeof(Double)) { if (s.Maximum != null) { // slider control = new Slider() { Maximum = (Double)s.Maximum, AutoToolTipPlacement = AutoToolTipPlacement.TopLeft, Width = 200, }; if (s.Minimum != null) ((Slider)control).Minimum = (Double)s.Minimum; control.SetBinding(Slider.ValueProperty, new Binding("Value") { Source = s, Mode = BindingMode.TwoWay }); } else { // spinner control = new DoubleUpDown(); control.SetBinding(DoubleUpDown.ValueProperty, new Binding("Value") { Source = s, Mode = BindingMode.TwoWay }); } } if (control != null) { control.Margin = new Thickness(0, 5, 0, 5); control.VerticalAlignment = VerticalAlignment.Center; control.HorizontalAlignment = HorizontalAlignment.Left; control.SetBinding(FrameworkElement.VisibilityProperty, new Binding("IsVisible") { Source = s, Mode = BindingMode.OneWay, Converter = new BooleanToVisibilityConverter() }); Grid.SetRow(control, i); Grid.SetColumn(control, 1); SettingsGrid.Children.Add(control); } } }
public Card(CustomButton close, int _h = 300, int _w = 370) { closeBtn = close; closeBtn.Margin = new Thickness(2); Height = _h; Width = _w; this.index = close.Index; hasPlayed = false; //UpDown control mediaPosition = new DoubleUpDown { Width = 75, Height = 30, Margin = new Thickness(2) }; mediaPosition.Value = 0; //Groupbox Box = new GroupBox(); Box.Width = Width; Box.Height = Height; Box.Header = new Label { Content = string.Format("Video {0}", index + 1) }; Box.Margin = new Thickness(5, 2, 5, 2); //StackPanels Panel = new StackPanel(); Panel.Orientation = Orientation.Vertical; //bottomPanel WrapPanel bottomPanel = new WrapPanel(); bottomPanel.Orientation = Orientation.Horizontal; bottomPanel.Height = 50; //MediaUriElement player = new MediaUriElement(); player.LoadedBehavior = WPFMediaKit.DirectShow.MediaPlayers.MediaState.Manual; player.PreferedPositionFormat = WPFMediaKit.DirectShow.MediaPlayers.MediaPositionFormat.MediaTime; player.Height = 225; player.Margin = new Thickness(1); //BusyIndicator busy = new BusyIndicator(); //Buttons Open = new Button { Content = "Open Video" }; PlayPause = new Button { Content = sPlay, Height = 30, Width = 30, Margin = new Thickness(2) }; //Slider slider = new Slider { Width = 200, Minimum = 0, SmallChange = 1, LargeChange = 10, Value = 0, Margin = new Thickness(2) }; PlayPause.IsEnabled = false; slider.IsEnabled = false; mediaPosition.IsEnabled = false; SetLayout(); Open.Click += Open_Click; PlayPause.Click += PlayPause_Click; }
public UserControl_DoubleData(string dataName, double dataValue) : base(dataName) { var grid_main = Content as Grid; if (grid_main != null) { var control_dataValue = new DoubleUpDown(); Binding binding_control_dataValue = new Binding("DataValue") { Source = this, Mode = BindingMode.TwoWay }; control_dataValue.SetBinding(DoubleUpDown.ValueProperty, binding_control_dataValue); grid_main.SetRowColumn(control_dataValue, 0, 1); } DataValue = dataValue; }
private DoubleUpDown AddDouble(string title, string subTitle, double min, double max, double increment, string format, string unit) { DoubleUpDown element = new DoubleUpDown(); element.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; element.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; element.Margin = new Thickness(10, 3, 0, 3); element.Minimum = min; element.Maximum = max; element.Increment = increment; element.FormatString = format; element.MouseWheelActiveTrigger = Xceed.Wpf.Toolkit.Primitives.MouseWheelActiveTrigger.Disabled; AddRow(title, subTitle, element, unit); return element; }
private void BuildUI() { AddCategory("Scanner Settings"); UpDownDoubleCustomPageWidth = AddDouble("Custom Page Size:", "Width:", 0.1, 100, 0.1, "##.##", "inches"); UpDownDoubleCustomPageHeight = AddDouble("", "Height:", 0.1, 100, 0.1, "##.##", "inches"); List<string> colorMode = new List<string>() { "Black/White", "Grayscale", "Color" }; ComboBoxScannerColorMode = AddList("Color Mode:", "", colorMode, ""); UpDownIntegerScannerResolution = AddInteger("Resolution:", "", 1, 2400, "DPI"); UpDownDoubleScannerThreshold = AddDouble("Threshold:", "", 0, 1, 0.01, "0.##", ""); UpDownDoubleScannerBrightness = AddDouble("Brightness:", "", 0, 1, 0.01, "0.##", ""); UpDownDoubleScannerContrast = AddDouble("Contrast:", "", 0, 1, 0.01, "0.##", ""); AddCategory("Program Settings"); UpDownDoubleDefaultPageWidth = AddDouble("Default Page Size (for image import):", "Width:", 0.1, 100, 0.1, "##.##", "inches"); UpDownDoubleDefaultPageHeight = AddDouble("", "Height:", 0.1, 100, 0.1, "##.##", "inches"); // List<string> pageScaling = new List<string>() { "Use DPI", "Fit (Only Shrink)", "Fit(Stretch / Shrink)" }; // ComboBoxPageScaling = AddList("Page Scaling:", "", pageScaling, ""); UpDownIntegerDpiPdfRendering = AddInteger("PDF Viewing Resolution:", "", 1, 2400, "DPI"); UpDownIntegerDpiPdfExport = AddInteger("PDF Export (Max) Resolution:", "", 1, 2400, "DPI"); CheckBoxPdfImageImport = AddCheck("Attempt PDF Image Import:", ""); CheckBoxExportCompressImages = AddCheck("Compress Images For PDF Export:", ""); UpDownIntegerExportCompressionFactor = AddInteger("PDF Export Compression Factor:", "", 1, 100, ""); List<string> pdfImportAction = new List<string>() { "Native", "Render" }; ComboBoxPdfImportAction = AddList("PDF Page Import Action:", "", pdfImportAction, ""); CheckBoxRemovePagesPdfExport = AddCheck("Remove Pages on PDF Save:", ""); CheckBoxShowPrintButton = AddCheck("Show Print Button:", ""); }
FrameworkElement GetTypeEditor(XmlSchemaType xtype, ItemList.SimpleItem sitem) { FrameworkElement felement = null; if (XmlSchemaType.IsDerivedFrom(xtype, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Boolean), XmlSchemaDerivationMethod.All)) { try { var val = XmlConvert.ToBoolean(sitem.value); felement = new CheckBox() { IsChecked = val, Margin = new Thickness(3) }; felement.SetUpdateTrigger( CheckBox.IsCheckedProperty, (bool v) => { sitem.value = XmlConvert.ToString(v); } ); } catch { felement = CreateTextEditor(sitem); } } else if (XmlSchemaType.IsDerivedFrom(xtype, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Integer), XmlSchemaDerivationMethod.All)) { try { var val = XmlConvert.ToInt32(sitem.value); felement = new IntegerUpDown() { Value = val, Margin = new Thickness(3), Increment = 1, VerticalAlignment = VerticalAlignment.Center, MinWidth = 50 }; felement.SetUpdateTrigger( IntegerUpDown.ValueProperty, (int v) => { sitem.value = v.ToString(); } ); } catch { felement = CreateTextEditor(sitem); } } else if (XmlSchemaType.IsDerivedFrom(xtype, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Float), XmlSchemaDerivationMethod.All)) { try { var val = XmlConvert.ToDouble(sitem.value); felement = new DoubleUpDown() { Value = val, CultureInfo = System.Globalization.CultureInfo.InvariantCulture, Margin = new Thickness(3), Increment = 0.1, FormatString = "F1", VerticalAlignment = VerticalAlignment.Center, MinWidth = 50 }; felement.SetUpdateTrigger( DoubleUpDown.ValueProperty, (double v) => { sitem.value = v.ToString(); } ); } catch { felement = CreateTextEditor(sitem); } } else if (XmlSchemaType.IsDerivedFrom(xtype, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Double), XmlSchemaDerivationMethod.All)) { try { var val = XmlConvert.ToDouble(sitem.value); felement = new DoubleUpDown() { Value = val, CultureInfo = System.Globalization.CultureInfo.InvariantCulture, Margin = new Thickness(3), Increment = 0.1, FormatString = "F2", VerticalAlignment = VerticalAlignment.Center, MinWidth = 50 }; felement.SetUpdateTrigger( DoubleUpDown.ValueProperty, (double v) => { sitem.value = v.ToString(); } ); } catch { felement = CreateTextEditor(sitem); } } else { felement = CreateTextEditor(sitem); } return felement; }
protected override void SetThisContent() { Grid grid_main = new Grid(); grid_main.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_main.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_main.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_main.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); Grid grid_sub = new Grid(); grid_sub.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); grid_sub.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(100.0, GridUnitType.Star) }); grid_main.SetRowColumn(grid_sub, 3, 0); Grid grid_left = new Grid(); grid_left.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_left.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_left.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_left.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_left.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_left.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_left.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_left.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_sub.SetRowColumn(grid_left, 0, 0); //////// // Id m_textBlock_id = new TextBlock() { VerticalAlignment = VerticalAlignment.Center }; Label label_id = new Label() { Content = "Id: ", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center }; Grid grid_id = new Grid(); grid_id.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); grid_id.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); grid_id.SetRowColumn(m_textBlock_id, 0, 1); grid_id.SetRowColumn(label_id, 0, 0); grid_main.SetRowColumn(grid_id, 0, 0); //////// // Name m_textBox_name = new TextBox() { VerticalAlignment = VerticalAlignment.Center }; ValidatorPanel validator_name = new ValidatorPanel(m_textBox_name, TextBox.TextProperty, new Validate_StringIsNotNullOrEmpty()); Label label_name = new Label() { Content = "Name: ", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center }; Grid grid_name = new Grid(); grid_name.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_name.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_name.SetRowColumn(validator_name, 1, 0); grid_name.SetRowColumn(label_name, 0, 0); grid_main.SetRowColumn(grid_name, 1, 0); //////// // Texture Button button_texture = new Button() { Content = " ... " }; button_texture.Click += (x, y) => { SelectTextureFile(); }; m_textBox_texture = new TextBox() { VerticalAlignment = VerticalAlignment.Center }; ValidatorPanel validator_texture = new ValidatorPanel(m_textBox_texture, TextBox.TextProperty, new Validate_StringIsNotNullOrEmpty()); Label label_texture = new Label() { Content = "Texture File: ", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center }; Grid grid_texture = new Grid(); grid_texture.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_texture.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_texture.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(100.0, GridUnitType.Star) }); grid_texture.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); grid_texture.SetRowColumn(button_texture, 1, 1); grid_texture.SetRowColumn(validator_texture, 1, 0); Grid.SetColumnSpan(label_texture, 2); grid_texture.SetRowColumn(label_texture, 0, 0); grid_main.SetRowColumn(grid_texture, 2, 0); //////// // Duration m_doubleUpDown_duration = new DoubleUpDown() { VerticalAlignment = VerticalAlignment.Center }; Label label_duration = new Label() { Content = "Duration: ", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center }; Grid grid_duration = new Grid(); grid_duration.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_duration.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_duration.SetRowColumn(m_doubleUpDown_duration, 1, 0); grid_duration.SetRowColumn(label_duration, 0, 0); grid_left.SetRowColumn(grid_duration, 0, 0); //////// // Width m_doubleUpDown_width = new DoubleUpDown() { VerticalAlignment = VerticalAlignment.Center }; ValidatorPanel validator_width = new ValidatorPanel(m_doubleUpDown_width, IntegerUpDown.ValueProperty, new Validate_NotNull()); Label label_width = new Label() { Content = "Width: ", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center }; Grid grid_width = new Grid(); grid_width.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_width.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_width.SetRowColumn(validator_width, 1, 0); grid_width.SetRowColumn(label_width, 0, 0); grid_left.SetRowColumn(grid_width, 1, 0); //////// // Height m_doubleUpDown_height = new DoubleUpDown() { VerticalAlignment = VerticalAlignment.Center }; ValidatorPanel validator_height = new ValidatorPanel(m_doubleUpDown_height, IntegerUpDown.ValueProperty, new Validate_NotNull()); Label label_height = new Label() { Content = "Height: ", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center }; Grid grid_height = new Grid(); grid_height.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_height.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_height.SetRowColumn(validator_height, 1, 0); grid_height.SetRowColumn(label_height, 0, 0); grid_left.SetRowColumn(grid_height, 2, 0); //////// // Get/Set Width/Height Button button_getLengths = new Button() { Content = "Get Lengths" }; button_getLengths.Click += (x, y) => { if (m_canvasWithRectangle != null && m_canvasWithRectangle.SizableRectangle != null) { m_doubleUpDown_width.Value = m_canvasWithRectangle.SizableRectangle.Width; m_doubleUpDown_height.Value = m_canvasWithRectangle.SizableRectangle.Height; } }; Button button_setLengths = new Button() { Content = "Set Lengths" }; button_setLengths.Click += (x, y) => { if (m_canvasWithRectangle != null && m_canvasWithRectangle.SizableRectangle != null && m_doubleUpDown_width.Value.HasValue && m_doubleUpDown_height.Value.HasValue) { m_canvasWithRectangle.SizableRectangle.Width = m_doubleUpDown_width.Value.Value; m_canvasWithRectangle.SizableRectangle.Height = m_doubleUpDown_height.Value.Value; } }; Grid grid_getSetLengths = new Grid() { Margin = new Thickness(1.0, 2.5, 1.0, 0.0) }; grid_getSetLengths.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(50.0, GridUnitType.Star) }); grid_getSetLengths.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(50.0, GridUnitType.Star) }); grid_getSetLengths.SetRowColumn(button_getLengths, 0, 0); grid_getSetLengths.SetRowColumn(button_setLengths, 0, 1); grid_left.SetRowColumn(grid_getSetLengths, 3, 0); //////// // TexCoordTop m_doubleUpDown_texCoordTop = new DoubleUpDown() { Increment = .005, VerticalAlignment = VerticalAlignment.Center }; ValidatorPanel validator_texCoordTop = new ValidatorPanel(m_doubleUpDown_texCoordTop, IntegerUpDown.ValueProperty, new Validate_NotNull()); Label label_texCoordTop = new Label() { Content = "TexCoordTop: ", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center }; Grid grid_texCoordTop = new Grid(); grid_texCoordTop.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_texCoordTop.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_texCoordTop.SetRowColumn(validator_texCoordTop, 1, 0); grid_texCoordTop.SetRowColumn(label_texCoordTop, 0, 0); grid_left.SetRowColumn(grid_texCoordTop, 4, 0); //////// // TexCoordRight m_doubleUpDown_texCoordRight = new DoubleUpDown() { Increment = .005, VerticalAlignment = VerticalAlignment.Center }; ValidatorPanel validator_texCoordRight = new ValidatorPanel(m_doubleUpDown_texCoordRight, IntegerUpDown.ValueProperty, new Validate_NotNull()); Label label_texCoordRight = new Label() { Content = "TexCoordRight: ", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center }; Grid grid_texCoordRight = new Grid(); grid_texCoordRight.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_texCoordRight.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_texCoordRight.SetRowColumn(validator_texCoordRight, 1, 0); grid_texCoordRight.SetRowColumn(label_texCoordRight, 0, 0); grid_left.SetRowColumn(grid_texCoordRight, 5, 0); //////// // TexCoordBottom m_doubleUpDown_texCoordBottom = new DoubleUpDown() { Increment = .005, VerticalAlignment = VerticalAlignment.Center }; ValidatorPanel validator_texCoordBottom = new ValidatorPanel(m_doubleUpDown_texCoordBottom, IntegerUpDown.ValueProperty, new Validate_NotNull()); Label label_texCoordBottom = new Label() { Content = "TexCoordBottom: ", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center }; Grid grid_texCoordBottom = new Grid(); grid_texCoordBottom.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_texCoordBottom.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_texCoordBottom.SetRowColumn(validator_texCoordBottom, 1, 0); grid_texCoordBottom.SetRowColumn(label_texCoordBottom, 0, 0); grid_left.SetRowColumn(grid_texCoordBottom, 6, 0); //////// // TexCoordLeft m_doubleUpDown_texCoordLeft = new DoubleUpDown() { Increment = .005, VerticalAlignment = VerticalAlignment.Center }; ValidatorPanel validator_texCoordLeft = new ValidatorPanel(m_doubleUpDown_texCoordLeft, IntegerUpDown.ValueProperty, new Validate_NotNull()); Label label_texCoordLeft = new Label() { Content = "TexCoordLeft: ", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center }; Grid grid_texCoordLeft = new Grid(); grid_texCoordLeft.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_texCoordLeft.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_texCoordLeft.SetRowColumn(validator_texCoordLeft, 1, 0); grid_texCoordLeft.SetRowColumn(label_texCoordLeft, 0, 0); grid_left.SetRowColumn(grid_texCoordLeft, 7, 0); //////// // Canvas m_image = new Image() { Stretch = System.Windows.Media.Stretch.None }; Binding binding_image_imageSource = new Binding("Text") { Source = m_textBox_texture, Mode = BindingMode.OneWay, UpdateSourceTrigger = System.Windows.Data.UpdateSourceTrigger.PropertyChanged, Converter = new BitmapSourceConverter() }; m_image.SetBinding(Image.SourceProperty, binding_image_imageSource); m_canvasWithRectangle = new UserControl_CanvasWithRectangle(new[] { m_image }) { Width = 500, Height = 500 }; m_zoomBox = new Zoombox() { Content = m_canvasWithRectangle, Background = Brushes.Black, Width = m_canvasWithRectangle.Width, Height = m_canvasWithRectangle.Height, Margin = new Thickness(5.0), HorizontalAlignment = System.Windows.HorizontalAlignment.Center, VerticalAlignment = System.Windows.VerticalAlignment.Center, MinScale = 1.0, MaxScale = 100 }; grid_sub.SetRowColumn(m_zoomBox, 0, 1); //////// // FIN ThisContent = new ActivatableContent() { Content = grid_main, FirstFocus = m_textBox_name, Validators = new ValidatorBase[] { validator_name, validator_texture, validator_width, validator_height, validator_texCoordTop, validator_texCoordRight, validator_texCoordBottom, validator_texCoordLeft }}; }
protected override void SetThisContent() { Grid grid_main = new Grid(); grid_main.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_main.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_main.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_main.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_main.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); //////// // Id m_textBlock_id = new TextBlock() { VerticalAlignment = VerticalAlignment.Center }; Label label_id = new Label() { Content = "Id: ", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center }; Grid grid_id = new Grid(); grid_id.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); grid_id.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); grid_id.SetRowColumn(m_textBlock_id, 0, 1); grid_id.SetRowColumn(label_id, 0, 0); grid_main.SetRowColumn(grid_id, 0, 0); //////// // Name m_textBox_name = new TextBox() { VerticalAlignment = VerticalAlignment.Center }; ValidatorPanel validator_name = new ValidatorPanel(m_textBox_name, TextBox.TextProperty, new Validate_StringIsNotNullOrEmpty()); Label label_name = new Label() { Content = "Name: ", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center }; Grid grid_name = new Grid(); grid_name.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_name.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_name.SetRowColumn(validator_name, 1, 0); grid_name.SetRowColumn(label_name, 0, 0); grid_main.SetRowColumn(grid_name, 1, 0); //////// // Order m_integerUpDown_order = new IntegerUpDown() { VerticalAlignment = VerticalAlignment.Center }; Label label_order = new Label() { Content = "Order: ", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center }; Grid grid_order = new Grid(); grid_order.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_order.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_order.SetRowColumn(m_integerUpDown_order, 1, 0); grid_order.SetRowColumn(label_order, 0, 0); grid_main.SetRowColumn(grid_order, 2, 0); //////// // Width m_doubleUpDown_width = new DoubleUpDown() { VerticalAlignment = VerticalAlignment.Center }; ValidatorPanel validator_width = new ValidatorPanel(m_doubleUpDown_width, IntegerUpDown.ValueProperty, new Validate_NotNull()); Label label_width = new Label() { Content = "Width: ", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center }; Grid grid_width = new Grid(); grid_width.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_width.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_width.SetRowColumn(validator_width, 1, 0); grid_width.SetRowColumn(label_width, 0, 0); grid_main.SetRowColumn(grid_width, 3, 0); //////// // Height m_doubleUpDown_height = new DoubleUpDown() { VerticalAlignment = VerticalAlignment.Center }; ValidatorPanel validator_height = new ValidatorPanel(m_doubleUpDown_height, IntegerUpDown.ValueProperty, new Validate_NotNull()); Label label_height = new Label() { Content = "Height: ", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center }; Grid grid_height = new Grid(); grid_height.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_height.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid_height.SetRowColumn(validator_height, 1, 0); grid_height.SetRowColumn(label_height, 0, 0); grid_main.SetRowColumn(grid_height, 4, 0); //////// // FIN ThisContent = new ActivatableContent() { Content = grid_main, FirstFocus = m_textBox_name, Validators = new ValidatorBase[] { validator_name, validator_width, validator_height }}; }
public static bool IsDotValid( DoubleUpDown dp ) { return !dp.Text.Contains( '.' ); }
public static bool IsNegativeSignValid( DoubleUpDown dp ) { return dp.Minimum < 0; }