| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 | 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);        }    }    public class BoolToUnVisibilityConverter : IValueConverter    {        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)        {            if (value == null) return Visibility.Collapsed;            return ((bool)value) ? Visibility.Collapsed : Visibility.Visible;        }        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;        }    }}
 |