private void panelElemsCount_ValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e, UIElementCollection c, FrameworkElement[] objArray) { DecimalUpDown d = (DecimalUpDown)sender; int Count = (int)d.Value; if (c.Count > Count) { int delNum = c.Count - Count; for (int i = 0; i < delNum; i++) { c.RemoveAt(c.Count - 1); } } else if (c.Count < Count) { for (int i = c.Count; i < Count; i++) { //c.Add(objArray[i % objArray.Length]); string gridXaml = XamlWriter.Save(objArray[i % objArray.Length]); StringReader stringReader = new StringReader(gridXaml); XmlReader xmlReader = XmlReader.Create(stringReader); c.Add((FrameworkElement)XamlReader.Load(xmlReader)); } } }
private void Decimal_InputValidationError(object sender, InputValidationErrorEventArgs e) { DecimalUpDown dSender = (DecimalUpDown)sender; string value = dSender.Text; value = value.Replace(',', '.'); decimal parseValue; if (decimal.TryParse(value, NumberStyles.Float, new CultureInfo("en-US"), out parseValue)) { if (parseValue > dSender.Maximum) { dSender.Value = dSender.Maximum; } else if (parseValue < dSender.Minimum) { dSender.Value = dSender.Minimum; } else { dSender.Value = parseValue; } } }
public DecimalPickerWidget() : base(new DecimalUpDown()) { Debug.Assert(Control.GetType() == typeof(DecimalUpDown)); SpinBox = Control as DecimalUpDown; SpinBox.AllowTextInput = false; SpinBox.ValueChanged += (sender, args) => OnInputChanged(new MoneyType(SpinBox.Value.Value)); }
private FrameworkElement GenerateDecimalUpDown(PropertyInfo property, Binding binding) { #if !SILVERLIGHT DecimalUpDown decimalUpDown = new DecimalUpDown() { Margin = new Thickness(0, 3, 18, 3) }; decimalUpDown.IsReadOnly = !(bindables[property.Name].Direction == BindingDirection.TwoWay); // Binding this.bindings.Add(property.Name, decimalUpDown.SetBinding(DecimalUpDown.ValueProperty, binding)); #else Border decimalUpDown = new Border() { Opacity = 1.0, Background = new SolidColorBrush(Colors.White), Margin = new Thickness(0, 3, 18, 3) }; NumericUpDown n = new NumericUpDown() { }; decimalUpDown.Child = n; n.IsEnabled = (bindables[property.Name].Direction == BindingDirection.TwoWay); n.Maximum = Convert.ToDouble(Decimal.MaxValue); n.Minimum = Convert.ToDouble(Decimal.MinValue); // Binding this.bindings.Add(property.Name, n.SetBinding(NumericUpDown.ValueProperty, binding)); #endif return(decimalUpDown); }
private async void CheckBox_Unchecked(object sender, RoutedEventArgs e) { CheckBox cb = sender as CheckBox; int tempID = Int32.Parse(cb.Name.Substring(1)); string stBor128 = "Bor128" + tempID; string stBor204 = "Bor204" + tempID; Border border128 = (Border)DynamicGrid.FindName(stBor128); Border border204 = (Border)DynamicGrid.FindName(stBor204); if (border128 != null) { border128.Background = new SolidColorBrush(Color.FromRgb(128, 0, 0)); border128.Background.Opacity = 0.5; } else { border204.Background = new SolidColorBrush(Color.FromRgb(204, 0, 0)); border204.Background.Opacity = 0.5; } if (EventHandler) { string stPaid = "P" + tempID; DecimalUpDown paid = (DecimalUpDown)DynamicGrid.FindName(stPaid); paid.Value = 0.0m; } }
private void clearAllControlFields() { for (int x = 0; x < controlTest.Count; x++) { if (controlTest[x] is TextBox) { TextBox tb = controlTest[x] as TextBox; tb.Clear(); } else if (controlTest[x] is IntegerUpDown) { IntegerUpDown iud = controlTest[x] as IntegerUpDown; iud.Value = null; } else if (controlTest[x] is DecimalUpDown) { DecimalUpDown dud = controlTest[x] as DecimalUpDown; dud.Value = null; } else if (controlTest[x] is DatePicker) { DatePicker dp = controlTest[x] as DatePicker; dp.Text = null; } else if (controlTest[x] is TimePicker) { TimePicker tp = controlTest[x] as TimePicker; tp.Value = null; } } }
/// <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(DecimalUpDown range) { if (range.MinValue <= range.Value && range.Value <= range.MaxValue) { return(true); } return(false); }
public int GetHomeRPM() { DecimalUpDown dudr = Recorder.FindName("GotoRPM") as DecimalUpDown; if (dudr != null) { return((int)dudr.Value.Value); } return(50); }
private void Render(Droprate droprate, DecimalUpDown r6Pre, DecimalUpDown r6Post, DecimalUpDown r7, DecimalUpDown r8, DecimalUpDown kjarr, TextBlock total) { r6Pre.Value = droprate.R6GoldPrefix; r6Post.Value = droprate.R6GoldPostfix; r7.Value = droprate.R7; r8.Value = droprate.R8; kjarr.Value = droprate.Kjarr; RenderTotal(droprate, total); }
//private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) //{ // Loaded -= OnLoaded; // NameTextBox.Dispatcher.BeginInvoke((Action)delegate // { // NameTextBox.Focus(); // Keyboard.Focus(NameTextBox); // }, DispatcherPriority.Input); //} private void UpDownBase_OnValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { DecimalUpDown @this = sender as DecimalUpDown; if (@this == null) { return; } @this.Text = @this.Text.Replace('.', ','); }
private void pleatCenterManualCheckBox_Checked(object sender, RoutedEventArgs e) { for (int i = 0; i < this.numPleats; i++) { DecimalUpDown pleatCenterDUP = ((DecimalUpDown)this.mainGrid.FindName("pleatCenter" + (i + 1))); DecimalUpDown sideDUP = ((DecimalUpDown)this.mainGrid.FindName("side" + (i + 1))); pleatCenterDUP.IsEnabled = false; pleatCenterDUP.Value = sideDUP.Value / 2; } }
public float GetGotoPosition() { DecimalUpDown dudr = Recorder.FindName("GotoPosition") as DecimalUpDown; if (dudr != null) { return((float)dudr.Value.Value); } return((float)0.0); }
private void DecimalUpDown_OnValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { // DecimalUpDown uses current culture and it seems fr-BE doesn't use . but , as decimal separator DecimalUpDown @this = sender as DecimalUpDown; if (@this == null) { return; } @this.Text = @this.Text.Replace('.', ','); }
private bool checkIfControlsAreEmpty() { for (int x = 1; x < controlTest.Count; x++) { if (controlTest[x] is TextBox) { TextBox tb = controlTest[x] as TextBox; if (tb.Text == string.Empty) { Console.WriteLine("Textbox empty"); return(true); } } else if (controlTest[x] is IntegerUpDown) { IntegerUpDown iud = controlTest[x] as IntegerUpDown; if (iud.Text == string.Empty) { Console.WriteLine("IntegerUpDown empty"); return(true); } } else if (controlTest[x] is DecimalUpDown) { DecimalUpDown dud = controlTest[x] as DecimalUpDown; if (dud.Text == string.Empty) { Console.WriteLine("DecimalUpDown empty"); return(true); } } else if (controlTest[x] is DatePicker) { DatePicker dp = controlTest[x] as DatePicker; if (dp.Text == string.Empty) { Console.WriteLine("DatePicker empty"); return(true); } } else if (controlTest[x] is TimePicker) { TimePicker tp = controlTest[x] as TimePicker; if (tp.Text == string.Empty) { Console.WriteLine("TimePicker empty"); return(true); } } } return(false); }
private decimal GetSum() { decimal sum = 0.0m; foreach (Depth d in depths) { int tempIDd = d.DepthID; string stPaidd = "P" + tempIDd; DecimalUpDown paidd = (DecimalUpDown)DynamicGrid.FindName(stPaidd); sum += paidd.Value ?? 0.0m; } return(sum); }
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); }
private void CreateComment() { string comment = ""; List <string> comments = new List <string>(); foreach (Depth d in depths) { int tempID = d.DepthID; string stDif = "D" + tempID; string stPaid = "P" + tempID; string stCheck = "C" + tempID; DecimalUpDown paid = (DecimalUpDown)DynamicGrid.FindName(stPaid); TextBlock dif = (TextBlock)DynamicGrid.FindName(stDif); CheckBox check = (CheckBox)DynamicGrid.FindName(stCheck); if (paid.Value != 0.0m) { comments.Add(", " + d.DepthDate.ToString("dd/MM/yyyy") + " "); } } if (comments.Count > 1) { comment += "Πληρωμή βάρδιας για τις ημερομηνίες : "; } else if (comments.Count == 1) { comment += "Πληρωμή βάρδιας για την ημερομηνία : "; } foreach (string s in comments) { comment += s; } decimal sum = GetSum(); if (sum != TotalPaid) { decimal difRes = TotalPaid - sum; if (difRes > 0) { comment += $"-Πρόσθετο αποθεματικό : {difRes}. "; } } comentbox.Text = comment; }
public override Control ProvideControl(PropertyInfo propertyInfo, object viewModel) { Binding binding = propertyInfo.GetBinding(); var editableAttribute = propertyInfo.GetAttribute <EditableAttribute>(); Control control = new DecimalUpDown(); control.SetBinding(DecimalUpDown.ValueProperty, binding); control.IsEnabled = propertyInfo.IsControlEnabled(); return(control); }
private Control GetControlByType(RdlType.ReportParameterType parameter, Binding paramValueBind) { Control paramControl = new TextBox(); BindingExpressionBase expr = null; if (parameter.HasValidValues) { paramControl = new ComboBox() { ItemsSource = viewModel.ReportType.GetReportParameterValidValues(parameter.Name), SelectedValuePath = "Value", DisplayMemberPath = "Key" }; expr = paramControl.SetBinding(ComboBox.SelectedValueProperty, paramValueBind); } else { switch (parameter.DataType) { case RdlType.ReportParameterType.DataTypeEnum.DateTime: paramControl = new DatePicker(); expr = paramControl.SetBinding(DatePicker.SelectedDateProperty, paramValueBind); break; case RdlType.ReportParameterType.DataTypeEnum.Boolean: paramControl = new CheckBox(); expr = paramControl.SetBinding(CheckBox.IsCheckedProperty, paramValueBind); break; case RdlType.ReportParameterType.DataTypeEnum.Integer: paramControl = new IntegerUpDown(); expr = paramControl.SetBinding(IntegerUpDown.ValueProperty, paramValueBind); break; case RdlType.ReportParameterType.DataTypeEnum.Float: paramControl = new DecimalUpDown(); expr = paramControl.SetBinding(DecimalUpDown.ValueProperty, paramValueBind); break; default: expr = paramControl.SetBinding(TextBox.TextProperty, paramValueBind); break; } } viewModel.ClearParameters += (sender, args) => expr.UpdateTarget(); return(paramControl); }
public override Control ProvideControl(PropertyInfo propertyInfo, object viewModel) { Binding binding = propertyInfo.GetBinding(); var editableAttribute = propertyInfo.GetAttribute <EditableAttribute>(); Control control = new DecimalUpDown(); control.SetBinding(DecimalUpDown.ValueProperty, binding); control.IsEnabled = editableAttribute == null || editableAttribute.AllowEdit || binding.Mode == BindingMode.TwoWay; return(control); }
private void DecimalUpDown_OnGotFocus(object sender, RoutedEventArgs e) { // Crappy workaround because FocusManager.FocusedElement doesn't set Keyboard focus DecimalUpDown @this = sender as DecimalUpDown; TextBox partTextBox = @this?.FindVisualChildren <TextBox>().FirstOrDefault(x => x.Name == "PART_TextBox"); if (partTextBox == null) { return; } Dispatcher.BeginInvoke((Action) delegate { Keyboard.Focus(partTextBox); partTextBox.SelectAll(); }, DispatcherPriority.Render); }
private async void Decimal_Changed(object sender, RoutedEventArgs e) { if (EventHandler) { DecimalUpDown cb = sender as DecimalUpDown; decimal sum = GetSum(); int tempID = Int32.Parse(cb.Name.Substring(1)); string stDif = "D" + tempID; string stPaid = "P" + tempID; string stCheck = "C" + tempID; DecimalUpDown paid = (DecimalUpDown)DynamicGrid.FindName(stPaid); TextBlock dif = (TextBlock)DynamicGrid.FindName(stDif); CheckBox check = (CheckBox)DynamicGrid.FindName(stCheck); //reserveNEW = TotalPaid - GetSum(); if (sum > MaxPaid) { paid.Value = MaxPaid - sum + paid.Value; //this might be wrong //reserveNEW = TotalPaid - GetSum(); return; } if (paid.Value == decimal.Parse(dif.Text)) { EventHandler = false; check.IsChecked = true; EventHandler = true; } if (paid.Value < decimal.Parse(dif.Text)) { EventHandler = false; check.IsChecked = false; EventHandler = true; } } }
private void SetNewPropertyControles() { _distributionControles.Clear(); foreach (string parameterName in Distribution.ParameterNames) { _distributionControles.Add(new Label { Content = parameterName }); var bind = new Binding(parameterName) { Source = Distribution, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; var control = new DecimalUpDown { DefaultValue = (decimal)0.0, MinWidth = 60, Increment = (decimal)0.5, Minimum = 0 }; control.SetBinding(DecimalUpDown.ValueProperty, bind); _distributionControles.Add(control); } }
private void side_ValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { DecimalUpDown sideDUP = (DecimalUpDown)sender; if (e.NewValue != null) { this.sides[(int)sideDUP.Tag] = (double)sideDUP.Value; sides = Utils.calculatePolygonSides(sides, angles); ((DecimalUpDown)this.mainGrid.FindName("side" + (this.numPleats))).Value = (decimal)sides[this.numPleats - 1]; ((DecimalUpDown)this.mainGrid.FindName("side" + (this.numPleats - 1))).Value = (decimal)sides[this.numPleats - 2]; if (this.pleatCenterManualCheckBox.IsChecked.Value) { for (int i = 0; i < this.numPleats; i++) { DecimalUpDown pleatCenterDUP = ((DecimalUpDown)this.mainGrid.FindName("pleatCenter" + (i + 1))); DecimalUpDown currSideDUP = ((DecimalUpDown)this.mainGrid.FindName("side" + (i + 1))); pleatCenterDUP.Value = currSideDUP.Value / 2; } } List <Dictionary <string, Point> > pleatsRotTras; pleatsRotTras = renderInputNode(); //Highlight focused input on input node canvas Point canvasCenter = new Point(this.inputNodeCanvas.Width / 2, this.inputNodeCanvas.Height / 2); //Center of the node canvas panel Point inputCenter = new Point((double)this.centerX.Value, (double)this.centerY.Value); //Center of the node Point trs = new Point(canvasCenter.X - inputCenter.X, canvasCenter.Y + inputCenter.Y); //Translation needed to move the node figure to the center of the node canvas panel Line hl = Utils.line(pleatsRotTras[(int)sideDUP.Tag]["V1"].X + trs.X, -pleatsRotTras[(int)sideDUP.Tag]["V1"].Y + trs.Y, pleatsRotTras[(int)sideDUP.Tag]["V2"].X + trs.X, -pleatsRotTras[(int)sideDUP.Tag]["V2"].Y + trs.Y, Brushes.Red); hl.StrokeThickness = 1.5d; this.inputNodeCanvas.Children.Add(hl); this.inputNodeCanvas.Children.Add(Utils.ellipse(4, 4, hl.X1 - 2, hl.Y1 - 2, Brushes.Red)); this.inputNodeCanvas.Children.Add(Utils.ellipse(4, 4, hl.X2 - 2, hl.Y2 - 2, Brushes.Red)); renderCreasePattern(); } else { sideDUP.Value = (decimal)e.OldValue; } }
//Обработка изменения количества комплектаций (в каждой строке) void DudCount_ValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { DecimalUpDown decimalUpDown = sender as DecimalUpDown; if (decimalUpDown == null) { return; } DataGridRow row = FindItem.FindParentItem <DataGridRow>(decimalUpDown); if (row == null) { return; } Complectation complectation = (Complectation)row.Item; if (complectation == null) { return; } try { if (complectation.Complectation_count == (int)decimalUpDown.Value) { complectation.IsSaved = true; return; } } catch { complectation.Complectation_count = 0; } complectation.IsSaved = false; complectation.Complectation_count = (int)decimalUpDown.Value; }
private void SelectKit(Kit kit) { // Replace item's name by empty string if it hasn't units kit_name.Text = kit.ResourceID == -1 ? "" : kit.Description; foreach (ListItem resource in units_list.Items) { ResourceItem ri = resource as ResourceItem; int toAdd = 0; // Get kit's units number if (kit.ResourceID != -1) { foreach (ElectronicUnit unit in kit.Units) { if (ri.Resource.Equals(unit.Model)) { toAdd++; } } } // Find the listbox template fields var container = units_list.ItemContainerGenerator.ContainerFromItem(resource) as FrameworkElement; ContentPresenter listBoxItemCP = Helpers.FindVisualChild <ContentPresenter>(container); if (listBoxItemCP == null) { throw new Exception("Invalid item"); } DataTemplate dataTemplate = listBoxItemCP.ContentTemplate; DecimalUpDown unitsTextBox = (DecimalUpDown)units_list.ItemTemplate.FindName("equipment_units", listBoxItemCP); int units = kit.ResourceID == -1 ? 0 : toAdd; unitsTextBox.Value = units; } }
private void pleatCenter_ValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { DecimalUpDown pleatCenterDUP = (DecimalUpDown)sender; if (e.NewValue != null) { this.pleatCenters[(int)pleatCenterDUP.Tag] = (double)pleatCenterDUP.Value; List <Dictionary <string, Point> > pleatsRotTras; pleatsRotTras = renderInputNode(); //Highlight focused input on input node canvas Point canvasCenter = new Point(this.inputNodeCanvas.Width / 2, this.inputNodeCanvas.Height / 2); //Center of the node canvas panel Point inputCenter = new Point((double)this.centerX.Value, (double)this.centerY.Value); //Center of the node Point trs = new Point(canvasCenter.X - inputCenter.X, canvasCenter.Y + inputCenter.Y); //Translation needed to move the node figure to the center of the node canvas panel Line hl = new Line(); if ((int)pleatCenterDUP.Tag % 2 == 0) { hl = Utils.line(pleatsRotTras[(int)pleatCenterDUP.Tag]["V1"].X + trs.X, -pleatsRotTras[(int)pleatCenterDUP.Tag]["V1"].Y + trs.Y, pleatsRotTras[(int)pleatCenterDUP.Tag]["C"].X + trs.X, -pleatsRotTras[(int)pleatCenterDUP.Tag]["V1"].Y + trs.Y, Brushes.Red); } else { hl = Utils.line(pleatsRotTras[(int)pleatCenterDUP.Tag]["V1"].X + trs.X, -pleatsRotTras[(int)pleatCenterDUP.Tag]["V1"].Y + trs.Y, pleatsRotTras[(int)pleatCenterDUP.Tag]["V1"].X + trs.X, -pleatsRotTras[(int)pleatCenterDUP.Tag]["C"].Y + trs.Y, Brushes.Red); } hl.StrokeThickness = 1.5d; this.inputNodeCanvas.Children.Add(hl); this.inputNodeCanvas.Children.Add(Utils.ellipse(4, 4, hl.X1 - 2, hl.Y1 - 2, Brushes.Red)); this.inputNodeCanvas.Children.Add(Utils.ellipse(4, 4, hl.X2 - 2, hl.Y2 - 2, Brushes.Red)); renderCreasePattern(); } else { pleatCenterDUP.Value = (decimal)e.OldValue; } }
private void angle_ValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { DecimalUpDown angleDUP = (DecimalUpDown)sender; if (e.NewValue != null) { decimal anglesum = 0.0M; for (int i = 0; i < this.numPleats - 1; i++) { anglesum += (decimal)((DecimalUpDown)this.mainGrid.FindName("angle" + (i + 1))).Value; } ((DecimalUpDown)this.mainGrid.FindName("angle" + this.numPleats)).Value = 360 - anglesum; this.angles[(int)angleDUP.Tag] = Utils.DegToRad((double)angleDUP.Value); this.angles[this.numPleats - 1] = Utils.DegToRad((double)(360 - anglesum)); sides = Utils.calculatePolygonSides(sides, angles); ((DecimalUpDown)this.mainGrid.FindName("side" + (this.numPleats))).Value = (decimal)sides[this.numPleats - 1]; ((DecimalUpDown)this.mainGrid.FindName("side" + (this.numPleats - 1))).Value = (decimal)sides[this.numPleats - 2]; renderAllCanvasWithAngleFocus((int)angleDUP.Tag); } else { angleDUP.Value = (decimal)e.OldValue; } }
private void Row_DoubleClick(object sender, MouseButtonEventArgs e) { DataRowView drv = (DataRowView)SQLTableDataGrid.SelectedItem; for (int x = 0; x < tableColumnCount; x++) { Console.WriteLine(drv[x].ToString()); if (controlTest[x] is TextBox) { TextBox tb = controlTest[x] as TextBox; tb.Text = drv[x].ToString(); } else if (controlTest[x] is IntegerUpDown) { IntegerUpDown iud = controlTest[x] as IntegerUpDown; iud.Value = (int)drv[x]; } else if (controlTest[x] is DecimalUpDown) { DecimalUpDown dud = controlTest[x] as DecimalUpDown; dud.Text = drv[x].ToString(); } else if (controlTest[x] is DatePicker) { DatePicker dp = controlTest[x] as DatePicker; dp.Text = drv[x].ToString(); } else if (controlTest[x] is TimePicker) { TimePicker tp = controlTest[x] as TimePicker; TimeSpan ts = TimeSpan.Parse(drv[x].ToString()); tp.Text = ts.ToString(@"hh\:mm"); } } }
// TODO: Infer Null value type to handle public static FrameworkElement GetBsonValueEditor( OpenEditorMode openMode, string bindingPath, BsonValue bindingValue, object bindingSource, bool readOnly, string keyName) { var binding = new Binding { Path = new PropertyPath(bindingPath), Source = bindingSource, Mode = BindingMode.TwoWay, Converter = new BsonValueToNetValueConverter(), UpdateSourceTrigger = UpdateSourceTrigger.Explicit }; if (bindingValue.IsArray) { var arrayValue = bindingValue as BsonArray; if (openMode == OpenEditorMode.Window) { var button = new Button { Content = $"[Array] {arrayValue?.Count} {keyName}", Style = StyleKit.MaterialDesignEntryButtonStyle }; button.Click += (s, a) => { arrayValue = bindingValue as BsonArray; var windowController = new WindowController { Title = "Array Editor" }; var control = new ArrayEntryControl(arrayValue, readOnly, windowController); var window = new DialogWindow(control, windowController) { Owner = Application.Current.MainWindow, Height = 600 }; if (window.ShowDialog() == true) { arrayValue?.Clear(); arrayValue?.AddRange(control.EditedItems); button.Content = $"[Array] {arrayValue?.Count} {keyName}"; } }; return(button); } var contentView = new ContentExpander { LoadButton = { Content = $"[Array] {arrayValue?.Count} {keyName}" } }; contentView.LoadButton.Click += (s, a) => { if (contentView.ContentLoaded) { return; } arrayValue = bindingValue as BsonArray; var control = new ArrayEntryControl(arrayValue, readOnly); control.CloseRequested += (sender, args) => { contentView.Content = null; }; contentView.Content = control; }; return(contentView); } if (bindingValue.IsDocument) { var expandLabel = "[Document]"; if (openMode == OpenEditorMode.Window) { var button = new Button { Content = expandLabel, Style = StyleKit.MaterialDesignEntryButtonStyle }; button.Click += (s, a) => { var windowController = new WindowController { Title = "Document Editor" }; var bsonDocument = bindingValue as BsonDocument; var control = new DocumentEntryControl(bsonDocument, readOnly, windowController); var window = new DialogWindow(control, windowController) { Owner = Application.Current.MainWindow, Height = 600 }; window.ShowDialog(); }; return(button); } var contentView = new ContentExpander { LoadButton = { Content = expandLabel } }; contentView.LoadButton.Click += (s, a) => { if (contentView.ContentLoaded) { return; } var bsonDocument = bindingValue as BsonDocument; var control = new DocumentEntryControl(bsonDocument, readOnly); control.CloseRequested += (sender, args) => { contentView.Content = null; }; contentView.Content = control; }; return(contentView); } if (bindingValue.IsBoolean) { var check = new CheckBox { IsEnabled = !readOnly, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 0, 0) }; check.SetBinding(ToggleButton.IsCheckedProperty, binding); return(check); } if (bindingValue.IsDateTime) { var datePicker = new DateTimePicker { TextAlignment = TextAlignment.Left, IsReadOnly = readOnly, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 0, 0) }; datePicker.SetBinding(DateTimePicker.ValueProperty, binding); return(datePicker); } if (bindingValue.IsDouble) { var numberEditor = new DoubleUpDown { TextAlignment = TextAlignment.Left, IsReadOnly = readOnly, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 0, 0) }; numberEditor.SetBinding(DoubleUpDown.ValueProperty, binding); return(numberEditor); } if (bindingValue.IsDecimal) { var numberEditor = new DecimalUpDown { TextAlignment = TextAlignment.Left, IsReadOnly = readOnly, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 0, 0) }; numberEditor.SetBinding(DecimalUpDown.ValueProperty, binding); return(numberEditor); } if (bindingValue.IsInt32) { var numberEditor = new IntegerUpDown { TextAlignment = TextAlignment.Left, IsReadOnly = readOnly, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 0, 0) }; numberEditor.SetBinding(IntegerUpDown.ValueProperty, binding); return(numberEditor); } if (bindingValue.IsInt64) { var numberEditor = new LongUpDown { TextAlignment = TextAlignment.Left, IsReadOnly = readOnly, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 0, 0) }; numberEditor.SetBinding(LongUpDown.ValueProperty, binding); return(numberEditor); } if (bindingValue.IsString) { var stringEditor = new TextBox { IsReadOnly = readOnly, AcceptsReturn = true, VerticalAlignment = VerticalAlignment.Center, MaxHeight = 200, MaxLength = 1024, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, }; stringEditor.SetBinding(TextBox.TextProperty, binding); return(stringEditor); } if (bindingValue.IsBinary) { var text = new TextBlock { Text = "[Binary Data]", VerticalAlignment = VerticalAlignment.Center, }; return(text); } if (bindingValue.IsObjectId) { var text = new TextBox { Text = bindingValue.AsString, IsReadOnly = true, VerticalAlignment = VerticalAlignment.Center, }; return(text); } var defaultEditor = new TextBox { VerticalAlignment = VerticalAlignment.Center, MaxHeight = 200, MaxLength = 1024, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, }; defaultEditor.SetBinding(TextBox.TextProperty, binding); return(defaultEditor); }
private Control GetControlByType(RdlType.ReportParameterType parameter, Binding paramValueBind) { Control paramControl = new TextBox(); BindingExpressionBase expr = null; if (parameter.HasValidValues) { paramControl = new ComboBox() { ItemsSource = viewModel.ReportType.GetReportParameterValidValues(parameter.Name), SelectedValuePath = "Value", DisplayMemberPath = "Key" }; expr = paramControl.SetBinding(ComboBox.SelectedValueProperty, paramValueBind); } else { switch (parameter.DataType) { case RdlType.ReportParameterType.DataTypeEnum.DateTime: paramControl = new DatePicker(); expr = paramControl.SetBinding(DatePicker.SelectedDateProperty, paramValueBind); break; case RdlType.ReportParameterType.DataTypeEnum.Boolean: paramControl = new CheckBox(); expr = paramControl.SetBinding(CheckBox.IsCheckedProperty, paramValueBind); break; case RdlType.ReportParameterType.DataTypeEnum.Integer: paramControl = new IntegerUpDown(); expr = paramControl.SetBinding(IntegerUpDown.ValueProperty, paramValueBind); break; case RdlType.ReportParameterType.DataTypeEnum.Float: paramControl = new DecimalUpDown(); expr = paramControl.SetBinding(DecimalUpDown.ValueProperty, paramValueBind); break; default: expr = paramControl.SetBinding(TextBox.TextProperty, paramValueBind); break; } } viewModel.ClearParameters += (sender, args) => expr.UpdateTarget(); return paramControl; }