using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Data; using System.Windows; namespace Aitex.UI.RecipeEditor { public class BoolToVisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) return Visibility.Collapsed; return ((bool)value) ? Visibility.Visible:Visibility.Collapsed; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) return null; return object.Equals(value, parameter); } } class VisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { try { SmartCellData cellData = value as SmartCellData; if (cellData == null) return Visibility.Collapsed; CellType cellType = cellData.RecipeVariableDefine.CellType; bool isMasked = cellData.IsMasked; string controlName = (string)parameter; if ( (controlName == "ReadonlyComboBox" && (cellType == CellType.ReadOnlySelection) && !isMasked) || (controlName == "EditableComboBox" && (cellType == CellType.EditableSelection) && !isMasked) || (controlName == "TextBox" && (cellType == CellType.TextInput) && !isMasked) || (controlName == "DecimalUpDown" && (cellType == CellType.NumInput) && !isMasked) || (controlName == "CheckBox" && (cellType == CellType.CheckBox) && !isMasked) || (controlName == "EndPoint" && (cellType == CellType.EndPointSetting) && !isMasked) || (controlName == "TextBlock" && (cellType == CellType.ReadOnly || isMasked) && (cellType!=CellType.EndPointSetting)) || (controlName == "TimePicker" && (cellType == CellType.TimeInput) && !isMasked)) return Visibility.Visible; return Visibility.Collapsed; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } return Visibility.Collapsed; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return Visibility.Collapsed; } } }