/// <summary> /// Generate the Joker, Faker, or "eXercise" character. /// </summary> /// <param name="symbolCode"> /// The symbol code for which to generate the large character string. /// </param> /// <param name="labels"> /// A dictionary of the labels to be drawn. /// </param> /// <param name="style"> /// The style to apply to the labels. /// </param> /// <returns> /// The TextBlock that incorporates the labels. /// </returns> internal static TextBlock GenerateJokerFakerExercise(string symbolCode, IDictionary <string, string> labels, Style style) { // Check for matching code char theChar = StandardIdentity.GetExerciseAmplifyingDescriptor(symbolCode); if (theChar == (char)0) { return(null); } #if WINDOWS_UWP string theString = theChar.ToString(); #else string theString = theChar.ToString(Culture); #endif if (labels != null && labels.ContainsKey("F")) { theString += " " + labels["F"]; } Rect r = SymbolData.GetBounds(symbolCode); var tb = new TextBlock { Style = style, // BigLabels, Text = theString }; tb.FindTextExtent(); tb.SetValue(Canvas.TopProperty, r.Top - tb.Height); tb.SetValue(Canvas.LeftProperty, r.Right); return(tb); }
/// <summary> /// Generate the right labels for the symbol. /// </summary> /// <param name="symbolCode"> /// The symbol code for which to generate the labels. /// </param> /// <param name="labels"> /// The dictionary of labels to generate. /// </param> /// <param name="style"> /// The style with which to render the labels. /// </param> /// <returns> /// A TextBlock that represents the rendered labels. /// </returns> internal static TextBlock GenerateRight(string symbolCode, IDictionary <string, string> labels, Style style) { // Pick off the left-oriented strings and write them out if (labels == null) { return(null); } var right = new TextBlock { Style = style /*RightLabels*/ }; bool gotLine = false; // If we have an X, J, or K modifier character, skip label F because it is already written out. if (StandardIdentity.GetExerciseAmplifyingDescriptor(symbolCode) != (char)0) { ProcessLabels(labels, false, new[] { string.Empty }, right, ref gotLine); } else { ProcessLabels(labels, false, new[] { "F" }, right, ref gotLine); } var height = gotLine ? (double)right.GetValue(TextBlock.LineHeightProperty) : 0.0; // At this point we need to process the remaining labels as if each row has a label. // Otherwise some label lines may appear in the wrong position // if other label lines are empty. // Setting "gotLine" to true forces a new line for each of the label lines. // More complicated logic might consider the height of the text block, prior to // the elimination of the empty lines. gotLine = true; ProcessLabels(labels, false, new[] { "G" }, right, ref gotLine); ProcessLabels(labels, false, new[] { "H" }, right, ref gotLine); ProcessLabels(labels, false, new[] { "M" }, right, ref gotLine); ProcessLabels(labels, true, new[] { "J", "K", "L", "N", "P" }, right, ref gotLine); TruncateNewLines(right); Rect b = SymbolData.GetBounds(symbolCode); SetTopLeft(right, b.Right + (height / 5.0), b.Top - height); return(right); }