void UpdateTextState() { if ((m_textContainer == null) || (m_textBlock == null)) { return; } var containerSize = m_textContainer.ActualWidth; string oldText = m_textBlock.Text; string newText = Utils.LRO + DisplayValue + Utils.PDF; // Initiate the scaling operation // UpdateLayout will keep calling us until we make it through the below 2 if-statements if (!m_isScalingText || oldText != newText) { m_textBlock.Text = newText; m_isScalingText = true; m_haveCalculatedMax = false; m_textBlock.InvalidateArrange(); return; } if (containerSize > 0) { double widthDiff = Math.Abs(m_textBlock.ActualWidth - containerSize); double fontSizeChange = INCREMENTOFFSET; if (widthDiff > WIDTHCUTOFF) { fontSizeChange = Math.Min(Math.Max(Math.Floor(WIDTHTOFONTSCALAR * widthDiff) - WIDTHTOFONTOFFSET, INCREMENTOFFSET), MAXFONTINCREMENT); } if (m_textBlock.ActualWidth < containerSize && Math.Abs(m_textBlock.FontSize - MaxFontSize) > FONTTOLERANCE && !m_haveCalculatedMax) { ModifyFontAndMargin(m_textBlock, fontSizeChange); m_textBlock.InvalidateArrange(); return; } if (fontSizeChange < 5) { m_haveCalculatedMax = true; } if (m_textBlock.ActualWidth >= containerSize && Math.Abs(m_textBlock.FontSize - MinFontSize) > FONTTOLERANCE) { ModifyFontAndMargin(m_textBlock, -1 * fontSizeChange); m_textBlock.InvalidateArrange(); return; } Debug.Assert(m_textBlock.FontSize >= MinFontSize && m_textBlock.FontSize <= MaxFontSize); m_isScalingText = false; if (IsOperatorCommand) { m_textContainer.ChangeView(0.0, null, null); } else { m_textContainer.ChangeView(m_textContainer.ExtentWidth - m_textContainer.ViewportWidth, null, null); } if (m_scrollLeft != null && m_scrollRight != null) { if (m_textBlock.ActualWidth < containerSize) { ShowHideScrollButtons(Visibility.Collapsed, Visibility.Collapsed); } else { if (IsOperatorCommand) { ShowHideScrollButtons(Visibility.Collapsed, Visibility.Visible); } else { ShowHideScrollButtons(Visibility.Visible, Visibility.Collapsed); } } } m_textBlock.InvalidateArrange(); } }