private void OnMouseEnter(object sender, MouseEventArgs e)
{
if (sender == this.CloseImage)
{
this.closeIsHover = true;
}
else if (sender == this.BackImage)
{
this.backIsHover = true;
}
else if (sender == this.UpImage)
{
this.upIsHover = true;
}
else if (sender == this.DownImage)
{
this.downIsHover = true;
}
else if (sender == this.MessageCanvas)
{
this.attachmentsAreHover = true;
}
else if (sender == this.InspectorImage)
{
this.imageIsHover = true;
if (this.switchTimer.IsEnabled && this.inspectorEntry != null)
{
bool stopRequired = true;
if (!this.inspectorEntry.HasMultipleImages)
{
const double space = 10;
double x = 0;
foreach (string tag in this.inspectorEntry.Tags)
{
Dictionary<int, int> dictionary = new Dictionary<int, int>();
StringBuilder lineStringBuilder = new StringBuilder();
foreach (System.Text.RegularExpressions.Match match in System.Text.RegularExpressions.Regex.Matches(tag, @"[\p{IsBasicLatin}-[\s]]+\s?"))
{
dictionary.Add(match.Index, match.Length);
}
if (x + space + Math.Ceiling(new FormattedText(tag, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface(this.FontFamily, this.FontStyle, this.FontWeight, this.FontStretch), this.FontSize, this.linkBrush).WidthIncludingTrailingWhitespace) > this.baseWidth - 74 && x != 0)
{
stopRequired = false;
break;
}
for (int i = 0; i < tag.Length; i++)
{
int length;
if (dictionary.TryGetValue(i, out length) && x + space + Math.Ceiling(new FormattedText(String.Concat(lineStringBuilder.ToString(), tag.Substring(i, length)), CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface(this.FontFamily, this.FontStyle, this.FontWeight, this.FontStretch), this.FontSize, this.linkBrush).WidthIncludingTrailingWhitespace) > this.baseWidth - 74 && lineStringBuilder.Length > 0)
{
stopRequired = false;
break;
}
lineStringBuilder.Append(tag[i]);
if (lineStringBuilder.ToString().EndsWith(Environment.NewLine, StringComparison.Ordinal))
{
stopRequired = false;
break;
}
else if (lineStringBuilder.Length > 0 && x + space + Math.Ceiling(new FormattedText(lineStringBuilder.ToString(), CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface(this.FontFamily, this.FontStyle, this.FontWeight, this.FontStretch), this.FontSize, this.linkBrush).WidthIncludingTrailingWhitespace) > this.baseWidth - 74)
{
stopRequired = false;
break;
}
}
if (!stopRequired)
{
break;
}
if (lineStringBuilder.Length > 0)
{
x += space + Math.Ceiling(new FormattedText(lineStringBuilder.ToString(), CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface(this.FontFamily, this.FontStyle, this.FontWeight, this.FontStretch), this.FontSize, this.linkBrush).WidthIncludingTrailingWhitespace);
}
}
}
if (stopRequired)
{
this.switchTimer.Stop();
}
}
}
else
{
this.isPinned = true;
this.waitTimer.Stop();
}
}