private static ParameterOverride ParseParameterSignature([NotNull] XElement paramElement) { var baseName = paramElement.GetRequiredAttribute("name").Value; var newName = paramElement.Element("name")?.Value; var newTypeElement = paramElement.Element("type"); var newType = newTypeElement is null ? null : ParseTypeSignature(newTypeElement.Value); var newFlowElement = paramElement.Element("flow"); FlowDirection?newFlow = null; if (!(newFlowElement is null)) { if (!Enum.TryParse <FlowDirection>(newFlowElement.Value, true, out var parsedFlow)) { throw new InvalidDataException("Could not parse the parameter flow."); } newFlow = parsedFlow; } var newCount = paramElement.Element("count")?.Value; return(new ParameterOverride ( baseName, newName, newType, newFlow, newCount )); }
/// <summary> /// Converts a given UI element and its associated <see cref="FlowDirection"/> to /// a <see cref="Visibility"/> enumeration value. /// </summary> /// <param name="value"> /// The UI element whose <see cref="FlowDirection"/> should be checked. /// </param> /// <param name="targetType"> /// This parameter is not used. /// </param> /// <param name="parameter"> /// The desired <see cref="FlowDirection"/> of the given UI element. /// </param> /// <param name="culture"> /// This parameter is not used. /// </param> /// <returns> /// Return a <see cref="Visibility"/> enumeration value indicating whether the UI element should be visible or hidden. /// </returns> public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { try { FlowDirection?desiredDirection = null; //Find the desired FlowDirection. if (parameter != null && parameter is string) { try { desiredDirection = (FlowDirection)Enum.Parse(typeof(FlowDirection), parameter as string, true); } catch { } } //If the desired FlowDirection was not found, then throw an exception. if (!desiredDirection.HasValue) { throw new ArgumentException("The ConverterParameter must be a string representing a valid FlowDirection value.", "parameter"); } //If the value represents an Image, then get its visual parent. while (value != null && value is Image) { try { value = VisualTreeHelper.GetParent(value as Image); } catch { value = null; } } //If the value is a FrameworkElement, then get its FlowDirection. if (value is FrameworkElement) { value = (value as FrameworkElement).FlowDirection; } //If the value is null, throw an exception. if (value == null) { throw new ArgumentException("The value to be converted must be a valid instance of FlowDirection or FrameworkElement.", "value"); //TODO: Instead of throwing an exception, will the following line of code work as expected??? //value = System.Threading.Thread.CurrentThread.CurrentUICulture.TextInfo.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight; } //If the value is a FlowDirection, then find out if it matches the desired FlowDirection. if (value is FlowDirection) { return(desiredDirection == (FlowDirection)value ? Visibility.Visible : Visibility.Collapsed); } } catch { } return(Visibility.Collapsed); }
private void SetFlowDirection(StyleDefinition result) { FlowDirection?flowDirection = this.GetFlowDirection(); if (flowDirection.HasValue && flowDirection != this.initialProperties.FlowDirection) { result.SetPropertyValue(Paragraph.FlowDirectionProperty, flowDirection); } }
/// <summary> /// Display a MessageBox /// </summary> /// <param name="messageBoxText">A <see cref="System.String"/> that specifies the text to display.</param> /// <param name="caption">A <see cref="System.String"/> that specifies the title bar caption to display.</param> /// <param name="buttons">A <see cref="System.Windows.MessageBoxButton"/> value that specifies which button or buttons to display.</param> /// <param name="icon">A <see cref="System.Windows.MessageBoxImage"/> value that specifies the icon to display.</param> /// <param name="defaultResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the default result of the message box.</param> /// <param name="cancelResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the cancel result of the message box</param> /// <param name="buttonLabels">A dictionary specifying the button labels, if desirable</param> /// <param name="flowDirection">The <see cref="System.Windows.FlowDirection"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultFlowDirection"/></param> /// <param name="textAlignment">The <see cref="System.Windows.TextAlignment"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultTextAlignment"/></param> /// <returns>The result chosen by the user</returns> public MessageBoxResult ShowMessageBox(string messageBoxText, string caption = "", MessageBoxButton buttons = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.None, MessageBoxResult cancelResult = MessageBoxResult.None, IDictionary <MessageBoxResult, string> buttonLabels = null, FlowDirection?flowDirection = null, TextAlignment?textAlignment = null) { var vm = this.messageBoxViewModelFactory(); vm.Setup(messageBoxText, caption, buttons, icon, defaultResult, cancelResult, buttonLabels, flowDirection, textAlignment); this.ShowDialog(vm); return(vm.ClickedButton); }
/// <summary> /// Initializes a new instance of the <see cref="ParameterOverride"/> class. /// </summary> /// <param name="name">The base name of the parameter.</param> /// <param name="newName">The new name of the parameter.</param> /// <param name="newType">The new type of the parameter.</param> /// <param name="newFlow">The new flow of the parameter.</param> /// <param name="newCount">The new count of the parameter.</param> public ParameterOverride ( [NotNull] string name, [CanBeNull] string newName, [CanBeNull] TypeSignature newType, FlowDirection?newFlow, [CanBeNull] string newCount ) { BaseName = name ?? throw new ArgumentNullException(nameof(name)); NewName = newName; NewType = newType; NewFlow = newFlow; NewCount = newCount; }
/// <summary> /// Setup the MessageBoxViewModel with the information it needs /// </summary> /// <param name="messageBoxText">A <see cref="System.String"/> that specifies the text to display.</param> /// <param name="caption">A <see cref="System.String"/> that specifies the title bar caption to display.</param> /// <param name="buttons">A <see cref="System.Windows.MessageBoxButton"/> value that specifies which button or buttons to display.</param> /// <param name="icon">A <see cref="System.Windows.MessageBoxImage"/> value that specifies the icon to display.</param> /// <param name="defaultResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the default result of the message box.</param> /// <param name="cancelResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the cancel result of the message box</param> /// <param name="buttonLabels">A dictionary specifying the button labels, if desirable</param> /// <param name="flowDirection">The <see cref="System.Windows.FlowDirection"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultFlowDirection"/></param> /// <param name="textAlignment">The <see cref="System.Windows.TextAlignment"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultTextAlignment"/></param> public void Setup(string messageBoxText, string caption = null, MessageBoxButton buttons = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.None, MessageBoxResult cancelResult = MessageBoxResult.None, IDictionary <MessageBoxResult, string> buttonLabels = null, FlowDirection?flowDirection = null, TextAlignment?textAlignment = null) { _messageBoxText = messageBoxText; _caption = caption; _buttons = buttons; _icon = icon; _defaultResult = defaultResult; _cancelResult = cancelResult; _buttonLabels = buttonLabels; _flowDirection = flowDirection; _textAlignment = textAlignment; Configure(); }
protected MessageBoxResult ShowMessageBox(string messageBoxText, MessageBoxButton buttons = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.None, MessageBoxResult cancelResult = MessageBoxResult.None, FlowDirection?flowDirection = null, TextAlignment?textAlignment = null) { var buttonsLabels = new Dictionary <MessageBoxResult, string> { { MessageBoxResult.Cancel, L("Cancel") }, { MessageBoxResult.No, L("No") }, { MessageBoxResult.None, L("None") }, { MessageBoxResult.OK, L("OK") }, { MessageBoxResult.Yes, L("Yes") } }; return(WindowManager.ShowMessageBox(messageBoxText, L("HotsBpHelper"), buttons, icon, defaultResult, cancelResult, buttonsLabels, flowDirection, textAlignment)); }
/// <summary> /// Display a MessageBox /// </summary> /// <param name="messageBoxText">A <see cref="System.String"/> that specifies the text to display.</param> /// <param name="caption">A <see cref="System.String"/> that specifies the title bar caption to display.</param> /// <param name="buttons">A <see cref="System.Windows.MessageBoxButton"/> value that specifies which button or buttons to display.</param> /// <param name="icon">A <see cref="System.Windows.MessageBoxImage"/> value that specifies the icon to display.</param> /// <param name="defaultResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the default result of the message box.</param> /// <param name="cancelResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the cancel result of the message box</param> /// <param name="buttonLabels">A dictionary specifying the button labels, if desirable</param> /// <param name="flowDirection">The <see cref="System.Windows.FlowDirection"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultFlowDirection"/></param> /// <param name="textAlignment">The <see cref="System.Windows.TextAlignment"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultTextAlignment"/></param> /// <returns>The result chosen by the user</returns> public MessageBoxResult ShowMessageBox(string messageBoxText, string caption = "", MessageBoxButton buttons = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.None, MessageBoxResult cancelResult = MessageBoxResult.None, IDictionary <MessageBoxResult, string> buttonLabels = null, FlowDirection?flowDirection = null, TextAlignment?textAlignment = null) { var vm = this.messageBoxViewModelFactory(); vm.Setup(messageBoxText, caption, buttons, icon, defaultResult, cancelResult, buttonLabels, flowDirection, textAlignment); // Don't go through the IoC container to get the View. This means we can simplify it... var messageBoxView = new MessageBoxView(); messageBoxView.InitializeComponent(); this.viewManager.BindViewToModel(messageBoxView, vm); this.ShowDialog(vm); return(vm.ClickedButton); }
/// <summary> /// Setup the MessageBoxViewModel with the information it needs /// </summary> /// <param name="messageBoxText">A <see cref="System.String"/> that specifies the text to display.</param> /// <param name="caption">A <see cref="System.String"/> that specifies the title bar caption to display.</param> /// <param name="buttons">A <see cref="System.Windows.MessageBoxButton"/> value that specifies which button or buttons to display.</param> /// <param name="icon">A <see cref="System.Windows.MessageBoxImage"/> value that specifies the icon to display.</param> /// <param name="defaultResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the default result of the message box.</param> /// <param name="cancelResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the cancel result of the message box</param> /// <param name="buttonLabels">A dictionary specifying the button labels, if desirable</param> /// <param name="flowDirection">The <see cref="System.Windows.FlowDirection"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultFlowDirection"/></param> /// <param name="textAlignment">The <see cref="System.Windows.TextAlignment"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultTextAlignment"/></param> public void Setup( string messageBoxText, string caption = null, MessageBoxButton buttons = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.None, MessageBoxResult cancelResult = MessageBoxResult.None, IDictionary <MessageBoxResult, string> buttonLabels = null, FlowDirection?flowDirection = null, TextAlignment?textAlignment = null) { this.Text = messageBoxText; this.DisplayName = caption; this.Icon = icon; var buttonList = new BindableCollection <LabelledValue <MessageBoxResult> >(); this.ButtonList = buttonList; foreach (var val in ButtonToResults[buttons]) { string label; if (buttonLabels == null || !buttonLabels.TryGetValue(val, out label)) { label = ButtonLabels[val]; } var lbv = new LabelledValue <MessageBoxResult>(label, val); buttonList.Add(lbv); if (val == defaultResult) { this.DefaultButton = lbv; } else if (val == cancelResult) { this.CancelButton = lbv; } } // If they didn't specify a button which we showed, then pick a default, if we can if (this.DefaultButton == null) { if (defaultResult == MessageBoxResult.None && this.ButtonList.Any()) { this.DefaultButton = buttonList[0]; } else { throw new ArgumentException("DefaultButton set to a button which doesn't appear in Buttons"); } } if (this.CancelButton == null) { if (cancelResult == MessageBoxResult.None && this.ButtonList.Any()) { this.CancelButton = buttonList.Last(); } else { throw new ArgumentException("CancelButton set to a button which doesn't appear in Buttons"); } } this.FlowDirection = flowDirection ?? DefaultFlowDirection; this.TextAlignment = textAlignment ?? DefaultTextAlignment; }
public HStack(VerticalAlignment alignment, FlowDirection?flowDirection, params Expand[] children) : base(children) { Alignment = alignment; FlowDirection = flowDirection; }
public HStack(FlowDirection?flowDirection, params Expand[] children) : this(VerticalAlignment.Top, flowDirection, children) { }
private void UpdateFlowDirectionUI(FlowDirection?flowDirection) { this.radioButtonLeftToRight.IsChecked = flowDirection == FlowDirection.LeftToRight; this.radioButtonRightToLeft.IsChecked = flowDirection == FlowDirection.RightToLeft; }
internal static IModelLayoutGroup AddGroup(this IModelNode view, string id = null, FlowDirection?direction = null, bool?showCaption = null, string caption = null, string imageName = null, int?index = null) { var v = view as IModelNode; IModelLayoutGroup rst = v.AddNode <IModelLayoutGroup>(id); if (direction.HasValue) { rst.Direction = direction.Value; } if (showCaption.HasValue) { rst.ShowCaption = showCaption.Value; rst.Caption = caption; } if (string.IsNullOrEmpty(imageName)) { rst.ImageName = imageName; } if (index.HasValue) { rst.Index = index.Value; } return(rst); }