gpt4 book ai didi

wpf - 音乐编辑器的歌词

转载 作者:行者123 更新时间:2023-12-02 18:13:32 25 4
gpt4 key购买 nike

我正在尝试创建一个neume(公历圣歌)编辑器。我确实做了很多,但我卡在了乐谱下的歌词主题上。

基本上我想要解决的问题是:有一些独立的用户控件 block 。在它们下面应该有放置歌词的文本区域。重点是 - 歌词是富文本(但只有文本 - 没有表格、图像等)。

为了让事情变得更有趣 - 我的用户控件渲染的图像必须知道下面文本中的第一个元音在哪里(第一个neume - 让我们称其为注意 - 必须恰好放在第一个元音上方)。

我真的很努力地想要完成它。我考虑过使用 RTB,但是调整它的大小存在整个问题 - 歌词的长度基本上可以是无限的 - (它向下调整大小,而不是向右),以及绑定(bind)到 RTB 确实是有趣交易。

您能告诉我如何解决这个问题吗?这是一张小图片,我希望能解释我的问题。

http://img833.imageshack.us/img833/7451/clipboard01fd.png

提前非常感谢您!

最佳答案

您查看过 TextBox.GetRectFromCharacterIndex 方法吗?

http://msdn.microsoft.com/en-us/library/ms603094.aspx

如果我正确理解您的问题,您应该能够在上面的示例中找到字母“O”的正确位置。

我有一个类似的问题,我需要在给定文本框的装饰层上绘制“红色波浪线”来表示自定义拼写检查器解决方案(WPF 拼写检查器对我们来说太有限了)。

这是该实现的部分示例,以防有帮助。

          //loop through the invalid words and draw the squiggilies
foreach (var word in rslt)
{
//find the index of the start of the invalid word
int idx1 = tbx.Text.ToLower().IndexOf(word.ToLower());
//find the index of the end of the invalid word
int idx2 = idx1 + (word.Length);

if (idx1 == -1)
continue;

//get a rect defining the location in coordinates of the invalid word.
var rec1 = tbx.GetRectFromCharacterIndex(idx1);
var rec2 = tbx.GetRectFromCharacterIndex(idx2);

//if the word is not visible or not fully visible, do not show the red line.
if (tbx.ActualWidth > 0)
{
if (rec1.X < 0 || rec2.X > tbx.ActualWidth)
continue;
}

if (rec1.Y < 0)
continue;

//actually draw the line under the word
SquigglyAdorner ado = new SquigglyAdorner(tbx, word, rec1.X, rec2.X, rec2.Bottom);
adornerLayer.Add(ado);
}

然后获取该矩形并将其转换为屏幕坐标(或您需要的任何坐标)

关于wpf - 音乐编辑器的歌词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16799374/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com