123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using MECF.Framework.Common.OperationCenter;
- using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
- using OpenSEMI.ClientBase;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Input;
- namespace MECF.Framework.UI.Client.CenterViews.Dialogs
- {
- public class RadioButtonIsSelectedConvert : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- if (value == null)
- return false;
- bool result = false;
- if (value.ToString() == parameter.ToString())
- result = true;
- else
- result = false;
- return result;
- }
- public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- return parameter.ToString();
- }
- }
- public class InputDialogViewModel:DialogViewModel<string>
- {
- #region Items Property
- public int Left { get; set; }
- public string Content { get; set; }
- public bool IsSelected { get; set; }
- public string KeyboardType { get; set; } = "Number";
- #endregion
- public ConfigItem Item { get; set; }
- public ObservableCollection<InputDialogViewModel> SubItems { get; set; } = new ObservableCollection<InputDialogViewModel>();
- public Visibility TextVisibility { get; set; }
- private const string YesString = "Yes";
- private const string NoString = "No";
- public string HeaderText
- {
- get { return "Congfig Set"; }
- }
- protected override void OnViewLoaded(object view)
- {
- base.OnViewLoaded(view);
- SubItems.Clear();
- if(Item.Type ==DataType.Bool)
- {
- bool bYes = Item.CurrentValue == YesString ? true : false;
- SubItems.Add(new InputDialogViewModel() { Content = YesString, IsSelected = bYes, Left = 100 }) ;
- SubItems.Add(new InputDialogViewModel() { Content = NoString,IsSelected=!bYes, Left = 200});
- }
- if (Item.Tag == "ReadOnlySelection")
- {
-
- string[] values = Item.Parameter.Split(';');
- for (int i = 0; i < values.Length; i++)
- {
- bool bSelected = Item.CurrentValue == values[i] ? true : false;
- SubItems.Add(new InputDialogViewModel() { Content = values[i],IsSelected=bSelected, Left = (i+1) * 60});
- }
- }
- if (SubItems.Count > 0) TextVisibility = Visibility.Hidden;
- }
- public void OK()
- {
- //Item.CurrentValue = YesChecked ? "Yes" : "No";
- foreach (var item in SubItems)
- {
- if (item.IsSelected)
- Item.CurrentValue = item.Content;
- }
- if (!string.IsNullOrEmpty(Item.CurrentValue))
- {
- this.DialogResult = Item.CurrentValue;
- IsCancel = false;
- TryClose(true);
- }
- }
- public void Cancel()
- {
- IsCancel = true;
- TryClose(false);
- }
- }
- }
|