public TextLineContainer(Point point, TextLine line, TextOffset offset, TextBlockContent content ) { Line = line; Point = point; Offset = offset; Content = content; }
/// <summary>Formats the value of the current instance using the specified format.</summary> /// <param name="format">The format to use. -or- A null reference (Nothing in Visual Basic) to use the default format defined for the type of the <see cref="IFormattable"></see> implementation.</param> /// <param name="formatProvider">The provider to use to format the value. -or- A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.</param> /// <returns>The value of the current instance in the specified format.</returns> public string ToString(string format, IFormatProvider formatProvider) { StringBuilder sb = new StringBuilder(); sb.Append("Bdc(") .Append("p=") .Append(Position.ToString(format, formatProvider)) .Append(",o=") .Append(TextOffset.ToString(format, formatProvider)) .Append(",h=") .Append(TextHeight.ToString(format, formatProvider)) .Append(')'); return(sb.ToString()); }
private void Apply_Button_Click(object sender, RoutedEventArgs e) { if (!long.TryParse(Properties.Settings.Default.Offset, System.Globalization.NumberStyles.AllowHexSpecifier, null, out _)) { MessageBox.Show("偏移坐标格式不合法!\n应为相对偏移的十六进制数值", "渔人的直感", MessageBoxButton.OK, MessageBoxImage.Error); LockOffset.IsChecked = true; TextOffset.SelectAll(); TextOffset.Focus(); return; } Properties.Settings.Default.Offset = Properties.Settings.Default.Offset.ToUpper(); Properties.Settings.Default.Save(); if (MessageBox.Show("设置已保存\n将在下次启动应用后生效\n是否现在重启应用?", "渔人的直感", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location); Application.Current.Shutdown(); } }
private void Update(EvaluationContext context) { var text = Text.GetValue(context); var bufferSize = BufferSize.GetValue(context); var wrapText = WrapText.GetValue(context); var textOffset = TextOffset.GetValue(context); var columns = bufferSize.Width; var rows = bufferSize.Height; if (columns <= 0 || rows <= 0) { return; } if (string.IsNullOrEmpty(text)) { return; } var textCycle = (int)textOffset.X + (int)(textOffset.Y) * columns; var size = rows * columns; if (_bufferContent == null || _bufferContent.Length != size) { _bufferContent = new BufferLayout[size]; } var index = 0; char c; var highlightChars = HighlightCharacters.GetValue(context); for (var rowIndex = 0; rowIndex < rows; rowIndex++) { for (var columnIndex = 0; columnIndex < columns; columnIndex++) { if (wrapText) { var i = (index + textCycle) % text.Length; if (i < 0) { i += text.Length; } c = text[i]; } else { var i = index + textCycle; var indexIsValid = i >= 0 && i < text.Length; c = indexIsValid ? text[i] : ' '; } var highlight = highlightChars.IndexOf(c) > -1 ? 1f : 0; // oh, that's slow! _bufferContent[index] = new BufferLayout( pos: new Vector2((float)columnIndex / columns, 1 - (float)rowIndex / rows), uv: new Vector2(c % 16, (c >> 4)), highlight: highlight); index++; } } ResourceManager.Instance().SetupStructuredBuffer(_bufferContent, ref Buffer.Value); Buffer.Value.DebugName = nameof(TypoGridBuffer); VertexCount.Value = size * 6; }
public TemplateText(string originalText, TextOffset startOffset, TextOffset endOffset) { _originalText = originalText; _offset = startOffset; _length = endOffset - startOffset; }