当我用空格输入输入时,批处理cmd退出(batch cmd exits as I enter the input with space)
我正在为用户界面编写一个批处理脚本,您可以在其中输入数字1 - 10。它与此示例非常相似:
@echo OFF :ask cls echo press 1 for test1 echo press 2 for test2 set /p input= if %input% == 1 goto test1 if %input% == 2 goto test2 if %input% GTR 10 goto ask goto ask :test1 shutdown :test2 net view pause goto ask我有%%输入%GTR 10 goto问,最后goto问全球,因为如果有人输入不同的东西,它会回到问题。 但是,当我键入包含空格的任何内容时,它将退出提示。 我该如何解决?
提前致谢,
山姆I am writing a batch script for an user interface where you can enter the digits 1 - 10. its pretty much like this example:
@echo OFF :ask cls echo press 1 for test1 echo press 2 for test2 set /p input= if %input% == 1 goto test1 if %input% == 2 goto test2 if %input% GTR 10 goto ask goto ask :test1 shutdown :test2 net view pause goto aski have if %input% GTR 10 goto ask, and in the end goto ask in global because if someone types something different it will go back to the question. Why does it crash me out of the terminal when I type something different?
原文:https://stackoverflow.com/questions/48282362
最满意答案
使用
TextRenderer
或MeasureString
的常用方法将为您提供SizeF
,其中包含您测量的字符串的边界。 大多数格式都有一点松弛,因此您可以通过将字符串添加到一起来撰写文本。这些方法的目的是帮助您创建一个文本块,让您测量一条线是否已满或者为下一条线前进多少像素。
它们并不是真正意义上的单个字符。
为此, 这里描述了一个特殊的字符串格式
GenericTypographic
,它留下了空白区域。为了获得更精确的测量,可以使用
GraphicsPath.AddString
然后使用GetBounds
,可能在关闭了antialias之后。现在,如果你想精确地绘制一个角色,那么以按钮为中心就可以完成这项工作。
但是你知道所有这些并且你的目标是不同的 - 如果我理解你正确,你想要从每个角色创建位图,以便以后加入它们来形成文本。 这意味着您需要它们垂直排列,即坐在相同的基线上。
角色的大小对你没有帮助; 现在,通常你需要你没有得到的每个charcater的基线,至少不需要像'f'或甚至''等下降的任何东西。
但它也无济于事,因为在GDI中你无论如何都不打印/绘制基线。
你应该做什么,imo要么画一个长字符串和所有字符,所以它们都排成一行,然后逐个剪切字符。 或者您可以自己绘制每个字符,但是后缀全部或某些您知道具有上升和下降的字符,然后只从结果中选择第一列。
So the only way I figured out how to do this is is to first draw the string to a graphicpath, then measure all the empty spots in the graphic path, and get it's height only after I've measure every spot, then redraw the string (I have an attempt counter to limit attempts but increase em to pixel accuracy) taking the old size and new size into account by a modifier and then extract the final size and store it.
Only I got to get around the BS of every font having a weird top padding that isn't associated with it's ascent and internal overflow (ex: Ñ), as well as descent, in refrence to a 0,0 point, this way.
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
C#绘制一个完美的字符串像素(C# draw a string pixel perfect)[2022-11-22]
使用TextRenderer或MeasureString的常用方法将为您提供SizeF ,其中包含您测量的字符串的边界。 大多数格式都有一点松弛,因此您可以通过将字符串添加到一起来撰写文本。 这些方法的目的是帮助您创建一个文本块,让您测量一条线是否已满或者为下一条线前进多少像素。 它们并不是真正意义上的单个字符。 为此, 这里描述了一个特殊的字符串格式GenericTypographic ,它留下了空白区域。 为了获得更精确的测量,可以使用GraphicsPath.AddString然后使用GetBound ... -
试试Pixel Perfect扩展程序: https : //addons.mozilla.org/en-US/firefox/addon/pixel-perfect/ Pixel Perfect是一个Firefox / Firebug扩展,允许Web开发人员和设计人员轻松地将Web组合覆盖在开发的HTML之上。 Try the Pixel Perfect extension: https://addons.mozilla.org/en-US/firefox/addon/pixel-perfect/ Pix ...
-
在xaml中 ,将SnapsToDevicePixels设置为true。 在设置WritableBitmap的类中 ,查询ActualWidth和ActualHeight。 然后将这些与Dpi的比例因子相乘(dpi为1.25,等等)。 var width = ActualWidth * _dpi_x_scale; var height = ActualHeight * _dpi_y_scale; 我使用这些宽度和高度值来设置Gpu上渲染纹理的大小。 创建WritableBitmap时,还要使用那些缩放的宽 ...
-
您需要了解的第一件事是iOS的视网膜显示系统。 所有控件都以坐标布局,就像它们是3GS / iPad 2或更早版本一样。 具有视网膜显示器的设备(例如iPhone 4,5和iPad 3)都使用这些相同的坐标,但屏幕尺寸加倍。 对于您的图片,请使用PNG。 您将拥有2套,一套用于较小的显示屏,另一套用于视网膜显示屏。 Apple使用文件命名约定: yourImage.png - 3GS的小图片 yourImage@2x.png - 视网膜显示的放大图像 假设图像尺寸较小,为150像素×50像素。 要从C#正确 ...
-
使用这个xml
-
所以我发现问题是如果我在for循环中多次绘制,如下所示: for (int c = 0; c < currentwords; c++) { ev.Graphics.DrawString(allitems[index], f9, Brushes.Black, 100, 100); ev.Graphics.DrawString(allqty[index], f9, Brushes.Black, new Point(200, 200); ev.Graphics.DrawString((al ...
-
您应该首先考虑改进算法,而不是用C ++重写。 最低的答案是原始值的平方根,所有'?' 替换为0向上舍入,最高可能的答案是模式的平方根,'?'替换为1向下舍入。 找到这两个值,迭代它们,平方并检查模式。 这样做速度更快,因为您正在迭代更少的数字并且因为您没有计算循环中的任何平方根:平方更容易。 您不需要比较字符串来检查匹配: mask = int(pattern.replace('0', '1').replace('?', '0'), 2) test = int(pattern.replace('?', ' ...
-
使用的资源: https://stackoverflow.com/a/4847027/1815624 https://stackoverflow.com/a/21895626/1815624 得到屏幕宽度,文本大小与屏幕比例的一些参考,并计算。 结果如下: 和 注意第二个HOOOOOOOOOOOOOOOOOOOO! public class MainActivity extends Activity { Paint paint; @Override protected void o ...