当前位置:网站首页>Halcon C # sets the form font and adaptively displays pictures
Halcon C # sets the form font and adaptively displays pictures
2022-06-26 14:59:00 【Tingyi - flying bird】
Set form font
// Use
Form1.set_display_font(this.hWindowControl1, 24, "mono", "true", "false");
public static void set_display_font(HalconDotNet.HWindowControl hWindowCtl, HTuple hv_Size, HTuple hv_Font,
HTuple hv_Bold, HTuple hv_Slant)
{
HTuple hv_OS = null, hv_Fonts = new HTuple();
HTuple hv_Style = null, hv_Exception = new HTuple(), hv_AvailableFonts = null;
HTuple hv_Fdx = null, hv_Indices = new HTuple();
HTuple hv_Font_COPY_INP_TMP = hv_Font.Clone();
HTuple hv_Size_COPY_INP_TMP = hv_Size.Clone();
HOperatorSet.GetSystem("operating_system", out hv_OS);
// dev_get_preferences(...); only in hdevelop
// dev_set_preferences(...); only in hdevelop
if ((int)((new HTuple(hv_Size_COPY_INP_TMP.TupleEqual(new HTuple()))).TupleOr(
new HTuple(hv_Size_COPY_INP_TMP.TupleEqual(-1)))) != 0)
{
hv_Size_COPY_INP_TMP = 16;
}
if ((int)(new HTuple(((hv_OS.TupleSubstr(0, 2))).TupleEqual("Win"))) != 0)
{
//Restore previous behaviour
hv_Size_COPY_INP_TMP = ((1.13677 * hv_Size_COPY_INP_TMP)).TupleInt();
}
else
{
hv_Size_COPY_INP_TMP = hv_Size_COPY_INP_TMP.TupleInt();
}
if ((int)(new HTuple(hv_Font_COPY_INP_TMP.TupleEqual("Courier"))) != 0)
{
hv_Fonts = new HTuple();
hv_Fonts[0] = "Courier";
hv_Fonts[1] = "Courier 10 Pitch";
hv_Fonts[2] = "Courier New";
hv_Fonts[3] = "CourierNew";
hv_Fonts[4] = "Liberation Mono";
}
else if ((int)(new HTuple(hv_Font_COPY_INP_TMP.TupleEqual("mono"))) != 0)
{
hv_Fonts = new HTuple();
hv_Fonts[0] = "Consolas";
hv_Fonts[1] = "Menlo";
hv_Fonts[2] = "Courier";
hv_Fonts[3] = "Courier 10 Pitch";
hv_Fonts[4] = "FreeMono";
hv_Fonts[5] = "Liberation Mono";
}
else if ((int)(new HTuple(hv_Font_COPY_INP_TMP.TupleEqual("sans"))) != 0)
{
hv_Fonts = new HTuple();
hv_Fonts[0] = "Luxi Sans";
hv_Fonts[1] = "DejaVu Sans";
hv_Fonts[2] = "FreeSans";
hv_Fonts[3] = "Arial";
hv_Fonts[4] = "Liberation Sans";
}
else if ((int)(new HTuple(hv_Font_COPY_INP_TMP.TupleEqual("serif"))) != 0)
{
hv_Fonts = new HTuple();
hv_Fonts[0] = "Times New Roman";
hv_Fonts[1] = "Luxi Serif";
hv_Fonts[2] = "DejaVu Serif";
hv_Fonts[3] = "FreeSerif";
hv_Fonts[4] = "Utopia";
hv_Fonts[5] = "Liberation Serif";
}
else
{
hv_Fonts = hv_Font_COPY_INP_TMP.Clone();
}
hv_Style = "";
if ((int)(new HTuple(hv_Bold.TupleEqual("true"))) != 0)
{
hv_Style = hv_Style + "Bold";
}
else if ((int)(new HTuple(hv_Bold.TupleNotEqual("false"))) != 0)
{
hv_Exception = "Wrong value of control parameter Bold";
throw new HalconException(hv_Exception);
}
if ((int)(new HTuple(hv_Slant.TupleEqual("true"))) != 0)
{
hv_Style = hv_Style + "Italic";
}
else if ((int)(new HTuple(hv_Slant.TupleNotEqual("false"))) != 0)
{
hv_Exception = "Wrong value of control parameter Slant";
throw new HalconException(hv_Exception);
}
if ((int)(new HTuple(hv_Style.TupleEqual(""))) != 0)
{
hv_Style = "Normal";
}
hv_AvailableFonts = hWindowCtl.HalconWindow.QueryFont();
//HOperatorSet.QueryFont(hv_WindowHandle, out hv_AvailableFonts);
hv_Font_COPY_INP_TMP = "";
for (hv_Fdx = 0; (int)hv_Fdx <= (int)((new HTuple(hv_Fonts.TupleLength())) - 1); hv_Fdx = (int)hv_Fdx + 1)
{
hv_Indices = hv_AvailableFonts.TupleFind(hv_Fonts.TupleSelect(hv_Fdx));
if ((int)(new HTuple((new HTuple(hv_Indices.TupleLength())).TupleGreater(0))) != 0)
{
if ((int)(new HTuple(((hv_Indices.TupleSelect(0))).TupleGreaterEqual(0))) != 0)
{
hv_Font_COPY_INP_TMP = hv_Fonts.TupleSelect(hv_Fdx);
break;
}
}
}
if ((int)(new HTuple(hv_Font_COPY_INP_TMP.TupleEqual(""))) != 0)
{
throw new HalconException("Wrong value of control parameter Font");
}
hv_Font_COPY_INP_TMP = (((hv_Font_COPY_INP_TMP + "-") + hv_Style) + "-") + hv_Size_COPY_INP_TMP;
hWindowCtl.HalconWindow.SetFont(hv_Font_COPY_INP_TMP);
return;
}
Adaptive display picture
// Use display
Form1.DisplayImage(this.hWindowControl1, imgSub);
// display picture
private static void DisplayImage(HalconDotNet.HWindowControl hWindowCtl, HImage imgShow)
{
// Set the display size
imgShow.GetImageSize(out int imgWidth, out int imgHeight);
double ratioWidth = (1.0) * imgWidth / hWindowCtl.Width;
double ratioHeight = (1.0) * imgHeight / hWindowCtl.Height;
HTuple row1, column1, row2, column2;
if (ratioWidth >= ratioHeight)
{
row1 = -(1.0) * ((hWindowCtl.Height * ratioWidth) - imgHeight) / 2;
column1 = 0;
row2 = row1 + hWindowCtl.Height * ratioWidth;
column2 = column1 + hWindowCtl.Width * ratioWidth;
}
else
{
row1 = 0;
column1 = -(1.0) * ((hWindowCtl.Width * ratioHeight) - imgWidth) / 2;
row2 = row1 + hWindowCtl.Height * ratioHeight;
column2 = column1 + hWindowCtl.Width * ratioHeight;
}
// display picture
hWindowCtl.HalconWindow.SetPart(row1, column1, row2, column2);
hWindowCtl.HalconWindow.DispObj(imgShow);
}
Be careful dll Need to be placed in a folder
halcon.dll
hcanvas.dll
halcondotnet.dll
边栏推荐
- Oracle ASMM和AMM
- SAP 销售数据 实际发货数据导出 销量
- Deploy the flask environment using the pagoda panel
- R语言caTools包进行数据划分、scale函数进行数据缩放、class包的knn函数构建K近邻分类器
- Unity uses skybox panoramic shader to make panorama preview. There is a gap. Solution
- Keil4打开单片机工程一片空白,cpu100%程序卡死的问题解决
- 聊聊 RPA 方向的规划:简单有价值的事情长期坚持做
- The intersect function in the dplyr package of R language obtains the data lines that exist in both dataframes and the data lines that cross the two dataframes
- 聊聊几位大厂清华同学的近况
- 【 Native cloud】 Éditeur ivx Programmable par tout le monde
猜你喜欢

710. 黑名单中的随机数

Keil4打开单片机工程一片空白,cpu100%程序卡死的问题解决

Document 1

使用 Abp.Zero 搭建第三方登录模块(一):原理篇

备战数学建模30-回归分析2

Get the intersection union difference set of two dataframes

This is the graceful file system mounting method, which is effective through personal testing

Detailed explanation of C language programming problem: can any three sides form a triangle, output the area of the triangle and judge its type

TCP拥塞控制详解 | 1. 概述

【雲原生】 ”人人皆可“ 編程的無代碼 iVX 編輯器
随机推荐
Authoritative announcement on the recruitment of teachers in Yan'an University in 2022
国信证券的排名如何?办理股票开户安全吗?
Attention meets geometry: geometry guided spatiotemporal attention consistency self supervised monocular depth estimation
这才是优美的文件系统挂载方式,亲测有效
SAP 销售数据 实际发货数据导出 销量
大学生值得珍藏的实用网站推荐
2022年最新贵州建筑八大员(机械员)模拟考试题库及答案
Deploy the flask environment using the pagoda panel
Is it safe to open an online stock account? Somebody give me an answer
[cloud native] codeless IVX editor programmable by "everyone"
Stream常用操作以及原理探索
Combat readiness mathematical modeling 31 data interpolation and curve fitting 3
clustermeet
One copy ten, CVPR oral was accused of plagiarizing a lot, and it was exposed on the last day of the conference!
Redis事务与watch指令
Informatics Olympiad 1405: sum and product of prime numbers (thinking problem)
关于 selenium.common.exceptions.WebDriverException: Message: An unknown server-side error 解决方案(已解决)
Can wptx64 be uninstalled_ Which software of win10 can be uninstalled
JVM 输出 GC 日志导致 JVM 卡住,我 TM 人傻了
'coach, I want to play basketball!'—— AI Learning Series booklet for system students
