コード例 #1
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            element = value as UserDefinedSizeItem;
            string flag = parameter as string;

            if (element != null)
            {
                return((flag == "1") ? string.Format("{0:0.0}", element.Height) : string.Format("{0:0.00}", element.Height));
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string flag = parameter as string;

            element = value as UserDefinedSizeItem;

            if (element != null)
            {
                return((flag == "flip") ? !element.IsMM : element.IsMM);
            }
            else
            {
                return((flag == "flip") ? false : true);
            }
        }
コード例 #3
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (myComboBox.Text.Trim() != "")
            {
                double w = GetWidthTextValue();
                double h = GetHeightTextValue();

                var result = (from item in UserDefinedSizeItems
                              where item.UserDefinedName == myComboBox.Text.Trim()
                              select item).ToList();

                if (result.Count == 1)
                {
                    UserDefinedSizeItem item = (UserDefinedSizeItem)result[0];
                    item.UserDefinedName = myComboBox.Text.Trim();
                    item.IsMM            = (bool)RadioButtonMM.IsChecked;
                    item.Width           = w;
                    item.Height          = h;
                }
                else if (result.Count == 0)
                {
                    if (UserDefinedSizeItems.Count() < 20)
                    {
                        UserDefinedSizeItems.Add(new UserDefinedSizeItem()
                        {
                            UserDefinedName = myComboBox.Text.Trim(),
                            IsMM            = (bool)RadioButtonMM.IsChecked,
                            Width           = w,
                            Height          = h
                        });
                    }
                    else
                    {
                        MessageBoxEx_Simple messageBox = new MessageBoxEx_Simple(
                            (string)this.FindResource("ResStr_Warning_Custom_Exceed"),
                            (string)this.FindResource("ResStr_Warning_2"));
                        messageBox.Owner = App.Current.MainWindow;
                        messageBox.ShowDialog();
                    }
                }
                myComboBox.Text = "";
            }
        }
コード例 #4
0
        private void UserDefinedNameComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (myComboBox.SelectedIndex != -1)
            {
                UserDefinedSizeItem item = UserDefinedSizeItems[myComboBox.SelectedIndex];

                if (item.IsMM == true)
                {
                    RadioButtonMM.IsChecked   = true;
                    RadioButtonInch.IsChecked = false;
                }
                else
                {
                    RadioButtonMM.IsChecked   = false;
                    RadioButtonInch.IsChecked = true;
                }

                SetWidthTextValue(item.Width);
                SetHeightTextValue(item.Height);
            }
        }