Beispiel #1
0
        public static CustomButton CreateCustomButton(ValueDataField field, ICommand command, double fontSize, bool isWfDesignMode)
        {
            var hotkey = field.Value.To(Key.None);

            var    hotkey2 = Key.None;
            string svalue;

            if (DataField.TryGetFieldProperties(field, ValueDataFieldConstants.HotKey2, isWfDesignMode, out svalue))
            {
                hotkey2 = svalue.To(Key.None);
            }

            var button = new CustomButton
            {
                Text = field.Caption,
                HorizontalContentAlignment = HorizontalAlignment.Left,
                HotKey           = hotkey,
                HotKey2          = hotkey2,
                Command          = command,
                CommandParameter = field,
                IsEnabled        = field.IsEnabled.HasValue && field.IsEnabled.Value,
                Visibility       = field.Visible ? Visibility.Visible : Visibility.Collapsed,
            };

            if (DataField.TryGetFieldProperties(field, ValueDataFieldConstants.SuffixText, isWfDesignMode, out svalue))
            {
                button.SuffixText = svalue;
            }

            bool isNotMenuButton;

            if (DataField.TryGetFieldProperties(field, ValueDataFieldConstants.IsNotMenuButton, isWfDesignMode, out isNotMenuButton))
            {
                button.IsNotMenuButton = isNotMenuButton;
            }

            bool transferHotKeyToControls;

            if (DataField.TryGetFieldProperties(field, ValueDataFieldConstants.TransferHotKeyToControls, isWfDesignMode, out transferHotKeyToControls))
            {
                button.TransferHotKeyToControls = transferHotKeyToControls;
            }

            ICommand icommand;

            if (DataField.TryGetFieldProperties(field, ValueDataFieldConstants.Command, isWfDesignMode, out icommand))
            {
                button.Command = icommand;
            }

            if (fontSize > 0)
            {
                button.FontSize = fontSize;
            }

            if (field.SetFocus)
            {
                button.BackgroundFocus();
            }

            return(button);
        }