fix SoftNcRunner GM code normalization.
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>GUI File Path Assignment | HiAPI-C# 2025 </title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="title" content="GUI File Path Assignment | HiAPI-C# 2025 ">
|
||||
|
||||
|
||||
<link rel="icon" href="../../img/HiAPI.favicon.ico">
|
||||
<link rel="stylesheet" href="../../public/docfx.min.css">
|
||||
<link rel="stylesheet" href="../../public/main.css">
|
||||
<meta name="docfx:navrel" content="../../toc.html">
|
||||
<meta name="docfx:tocrel" content="../toc.html">
|
||||
|
||||
<meta name="docfx:rel" content="../../">
|
||||
|
||||
|
||||
|
||||
<meta name="loc:inThisArticle" content="In this article">
|
||||
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
||||
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
||||
<meta name="loc:tocFilter" content="Filter by title">
|
||||
<meta name="loc:nextArticle" content="Next">
|
||||
<meta name="loc:prevArticle" content="Previous">
|
||||
<meta name="loc:themeLight" content="Light">
|
||||
<meta name="loc:themeDark" content="Dark">
|
||||
<meta name="loc:themeAuto" content="Auto">
|
||||
<meta name="loc:changeTheme" content="Change theme">
|
||||
<meta name="loc:copy" content="Copy">
|
||||
<meta name="loc:downloadPdf" content="Download PDF">
|
||||
|
||||
<script type="module" src="./../../public/docfx.min.js"></script>
|
||||
|
||||
<script>
|
||||
const theme = localStorage.getItem('theme') || 'auto'
|
||||
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
|
||||
<header class="bg-body border-bottom">
|
||||
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
||||
<div class="container-xxl flex-nowrap">
|
||||
<a class="navbar-brand" href="../../index.html">
|
||||
<img id="logo" class="svg" src="../../img/HiAPI.logo.png" alt="">
|
||||
|
||||
</a>
|
||||
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<i class="bi bi-three-dots"></i>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navpanel">
|
||||
<div id="navbar">
|
||||
<form class="search" role="search" id="search">
|
||||
<i class="bi bi-search"></i>
|
||||
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container-xxl">
|
||||
<div class="toc-offcanvas">
|
||||
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<nav class="toc" id="toc"></nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="actionbar">
|
||||
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
|
||||
<i class="bi bi-list"></i>
|
||||
</button>
|
||||
|
||||
<nav id="breadcrumb"></nav>
|
||||
</div>
|
||||
|
||||
<article data-uid="">
|
||||
<h1 id="gui-file-path-assignment">GUI File Path Assignment</h1>
|
||||
|
||||
<p>See the remarks of <a class="xref" href="../../api/Hi.Common.XmlUtils.IMakeXmlSource.html#Hi_Common_XmlUtils_IMakeXmlSource_MakeXmlSource_System_String_System_String_System_Boolean_">MakeXmlSource(string, string, bool)</a> to know the design pattern of file path treatment.</p>
|
||||
<p>if the assigned file path is descendent of the configuration directory, it is straight forward that set the <code>baseDirectory</code> to the configuration directory and apply relative path to <code>relFile</code>; if not, set <code>baseDirectory</code> to null and set <code>relFile</code> to absolute path.</p>
|
||||
<p>GUI that needs to assign file generally requires a code-behind <code>BaseDirectory</code> property as assistent model. The property is assigned by the parent model from the parent GUI.</p>
|
||||
<p>In most cases, the first <code>BaseDirectory</code> is the project directory if the project has assigned (created or loaded).</p>
|
||||
<h2 id="portability">Portability</h2>
|
||||
<p>To maintain For the portability of project or the other folder-based unit, if the sub-item is loaded by absolute path outside the folder-based unit directory, redirect the saving path to the folder-based unit directory, i.e. the SubItemFile below.</p>
|
||||
<div class="NOTE">
|
||||
<h5>Note</h5>
|
||||
<p>You have no need to do an additional action to create a duplicate in the folder-based unit directory. Since the file-writing pattern of <a class="xref" href="../../api/Hi.Common.XmlUtils.IMakeXmlSource.html#Hi_Common_XmlUtils_IMakeXmlSource_MakeXmlSource_System_String_System_String_System_Boolean_">MakeXmlSource(string, string, bool)</a> create files when user call to save. In other perspective, if user does not call to save, the local duplicate should be created.</p>
|
||||
</div>
|
||||
<p>The design pattern is usually saw in the HiAPI program, a object contains the properties:</p>
|
||||
<ul>
|
||||
<li>object SubItem;</li>
|
||||
<li>string SubItemFile;</li>
|
||||
</ul>
|
||||
<p>Then you should keep the Protability.</p>
|
||||
<h2 id="file-path-of-load-button-and-save-button">File Path of Load Button and Save Button</h2>
|
||||
<p>The genneral convention of the File Path of Load and Save is different by the single-user desktop application and web page application.</p>
|
||||
<div class="TIP">
|
||||
<h5>Tip</h5>
|
||||
<p>Always preserve an empty filter ( * . * ) for the browser.</p>
|
||||
</div>
|
||||
<h3 id="single-user-desktop-application">Single-User Desktop Application</h3>
|
||||
<p>The default directory of the Save/Load button are generally:</p>
|
||||
<ul>
|
||||
<li>System Default Directory or Project Directory (default, if not explicitly indicated)
|
||||
The initial directory is the project directory.</li>
|
||||
<li>Resource Directory
|
||||
The path always point to <code><application path>/Resource/<classification></code> directory.
|
||||
The button label has to explicitly show ‘Load Resource’.</li>
|
||||
</ul>
|
||||
<p>The kinds of buttons are not exclusive, they can be existed on the same tool bar.</p>
|
||||
<p>If the selected file path is under the project directory, apply the relative path from the project, i.e. baseDirectory is project directory and relFile is the relative path.</p>
|
||||
<h3 id="web-page-application">Web Page Application</h3>
|
||||
<p>The default directory of the Save/Load button are generally:</p>
|
||||
<ul>
|
||||
<li>Admin Directory</li>
|
||||
<li>Project Directory</li>
|
||||
<li>Resource Directory</li>
|
||||
</ul>
|
||||
<p>The Resource Directory and Project Directory are generally under the Admin Directory. And the admin directory is generally set in the appsettings.json file.</p>
|
||||
<h2 id="typical-action-if-exhibitiononly-false">Typical Action if <code>exhibitionOnly</code> false</h2>
|
||||
<p>On <a class="xref" href="../../api/Hi.Common.XmlUtils.IMakeXmlSource.html">IMakeXmlSource</a>.<a class="xref" href="../../api/Hi.Common.XmlUtils.IMakeXmlSource.html#Hi_Common_XmlUtils_IMakeXmlSource_MakeXmlSource_System_String_System_String_System_Boolean_">MakeXmlSource(string, string, bool)</a> with <code>exhibitionOnly</code> false, the argument (<code>baseDirectory</code> and <code>relFile</code>) should be the same from object's host (if exist) XML output function.</p>
|
||||
|
||||
</article>
|
||||
|
||||
<div class="contribution d-print-none">
|
||||
</div>
|
||||
|
||||
<div class="next-article d-print-none border-top" id="nextArticle"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="affix">
|
||||
<nav id="affix"></nav>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<div class="container-xxl search-results" id="search-results"></div>
|
||||
|
||||
<footer class="border-top text-secondary">
|
||||
<div class="container-xxl">
|
||||
<div class="flex-fill">
|
||||
<span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,145 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Mat4dControl Component | HiAPI-C# 2025 </title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="title" content="Mat4dControl Component | HiAPI-C# 2025 ">
|
||||
|
||||
|
||||
<link rel="icon" href="../../../img/HiAPI.favicon.ico">
|
||||
<link rel="stylesheet" href="../../../public/docfx.min.css">
|
||||
<link rel="stylesheet" href="../../../public/main.css">
|
||||
<meta name="docfx:navrel" content="../../../toc.html">
|
||||
<meta name="docfx:tocrel" content="../../toc.html">
|
||||
|
||||
<meta name="docfx:rel" content="../../../">
|
||||
|
||||
|
||||
|
||||
<meta name="loc:inThisArticle" content="In this article">
|
||||
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
||||
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
||||
<meta name="loc:tocFilter" content="Filter by title">
|
||||
<meta name="loc:nextArticle" content="Next">
|
||||
<meta name="loc:prevArticle" content="Previous">
|
||||
<meta name="loc:themeLight" content="Light">
|
||||
<meta name="loc:themeDark" content="Dark">
|
||||
<meta name="loc:themeAuto" content="Auto">
|
||||
<meta name="loc:changeTheme" content="Change theme">
|
||||
<meta name="loc:copy" content="Copy">
|
||||
<meta name="loc:downloadPdf" content="Download PDF">
|
||||
|
||||
<script type="module" src="./../../../public/docfx.min.js"></script>
|
||||
|
||||
<script>
|
||||
const theme = localStorage.getItem('theme') || 'auto'
|
||||
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
|
||||
<header class="bg-body border-bottom">
|
||||
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
||||
<div class="container-xxl flex-nowrap">
|
||||
<a class="navbar-brand" href="../../../index.html">
|
||||
<img id="logo" class="svg" src="../../../img/HiAPI.logo.png" alt="">
|
||||
|
||||
</a>
|
||||
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<i class="bi bi-three-dots"></i>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navpanel">
|
||||
<div id="navbar">
|
||||
<form class="search" role="search" id="search">
|
||||
<i class="bi bi-search"></i>
|
||||
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container-xxl">
|
||||
<div class="toc-offcanvas">
|
||||
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<nav class="toc" id="toc"></nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="actionbar">
|
||||
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
|
||||
<i class="bi bi-list"></i>
|
||||
</button>
|
||||
|
||||
<nav id="breadcrumb"></nav>
|
||||
</div>
|
||||
|
||||
<article data-uid="">
|
||||
<h1 id="mat4dcontrol-component">Mat4dControl Component</h1>
|
||||
|
||||
<p>Mat4dControl is a user control for <a class="xref" href="../../../api/Hi.Geom.Mat4d.html">Mat4d</a> editing and display.</p>
|
||||
<h2 id="main-features">Main Features</h2>
|
||||
<ol>
|
||||
<li><p>Dual Input Modes</p>
|
||||
<ul>
|
||||
<li>Grid Mode: Input 4x4 matrix elements in a grid layout (formatted display with 4 significant digits)</li>
|
||||
<li>Text Mode: Input complete matrix in text format (full precision, no information loss)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p>Matrix Operations</p>
|
||||
<ul>
|
||||
<li>Identity: Set matrix to identity matrix</li>
|
||||
<li>Transpose: Transpose the matrix</li>
|
||||
<li>Inverse: Compute the inverse matrix</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p>Special Value Handling (Web)</p>
|
||||
<ul>
|
||||
<li>Supports Infinity, -Infinity, and NaN values</li>
|
||||
<li>Uses <a href="../numeric-io-utilities.html">Numeric Input/Output Utilities</a> for display and parsing</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ol>
|
||||
<h2 id="source-code-path">Source Code Path</h2>
|
||||
<p>See <a href="../../index.html">this page</a> for git repository.</p>
|
||||
<h3 id="web-service-application-source-code-path">Web Service Application Source Code Path</h3>
|
||||
<ul>
|
||||
<li>wwwroot/widget/mat4d-control.js</li>
|
||||
<li>Widget/Mat4dHub.cs</li>
|
||||
</ul>
|
||||
|
||||
</article>
|
||||
|
||||
<div class="contribution d-print-none">
|
||||
</div>
|
||||
|
||||
<div class="next-article d-print-none border-top" id="nextArticle"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="affix">
|
||||
<nav id="affix"></nav>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<div class="container-xxl search-results" id="search-results"></div>
|
||||
|
||||
<footer class="border-top text-secondary">
|
||||
<div class="container-xxl">
|
||||
<div class="flex-fill">
|
||||
<span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,162 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Numeric Input/Output Utilities | HiAPI-C# 2025 </title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="title" content="Numeric Input/Output Utilities | HiAPI-C# 2025 ">
|
||||
|
||||
|
||||
<link rel="icon" href="../../img/HiAPI.favicon.ico">
|
||||
<link rel="stylesheet" href="../../public/docfx.min.css">
|
||||
<link rel="stylesheet" href="../../public/main.css">
|
||||
<meta name="docfx:navrel" content="../../toc.html">
|
||||
<meta name="docfx:tocrel" content="../toc.html">
|
||||
|
||||
<meta name="docfx:rel" content="../../">
|
||||
|
||||
|
||||
|
||||
<meta name="loc:inThisArticle" content="In this article">
|
||||
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
||||
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
||||
<meta name="loc:tocFilter" content="Filter by title">
|
||||
<meta name="loc:nextArticle" content="Next">
|
||||
<meta name="loc:prevArticle" content="Previous">
|
||||
<meta name="loc:themeLight" content="Light">
|
||||
<meta name="loc:themeDark" content="Dark">
|
||||
<meta name="loc:themeAuto" content="Auto">
|
||||
<meta name="loc:changeTheme" content="Change theme">
|
||||
<meta name="loc:copy" content="Copy">
|
||||
<meta name="loc:downloadPdf" content="Download PDF">
|
||||
|
||||
<script type="module" src="./../../public/docfx.min.js"></script>
|
||||
|
||||
<script>
|
||||
const theme = localStorage.getItem('theme') || 'auto'
|
||||
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
|
||||
<header class="bg-body border-bottom">
|
||||
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
||||
<div class="container-xxl flex-nowrap">
|
||||
<a class="navbar-brand" href="../../index.html">
|
||||
<img id="logo" class="svg" src="../../img/HiAPI.logo.png" alt="">
|
||||
|
||||
</a>
|
||||
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<i class="bi bi-three-dots"></i>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navpanel">
|
||||
<div id="navbar">
|
||||
<form class="search" role="search" id="search">
|
||||
<i class="bi bi-search"></i>
|
||||
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container-xxl">
|
||||
<div class="toc-offcanvas">
|
||||
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<nav class="toc" id="toc"></nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="actionbar">
|
||||
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
|
||||
<i class="bi bi-list"></i>
|
||||
</button>
|
||||
|
||||
<nav id="breadcrumb"></nav>
|
||||
</div>
|
||||
|
||||
<article data-uid="">
|
||||
<h1 id="numeric-inputoutput-utilities">Numeric Input/Output Utilities</h1>
|
||||
|
||||
<p>Handle special numeric values (Infinity, -Infinity, NaN) in web forms to prevent JSON serialization issues between JavaScript frontend and C# backend.</p>
|
||||
<h2 id="implementation-requirements">Implementation Requirements</h2>
|
||||
<p>Your <code>numeric-utils.js</code> module should:</p>
|
||||
<ul>
|
||||
<li>Convert special values for display: Infinity → “INF”, -Infinity → “-INF”, NaN → “NaN”</li>
|
||||
<li>Parse display strings back to numeric values</li>
|
||||
<li>Format regular numbers with 4 significant digits (for standard display mode)</li>
|
||||
<li>Provide full precision output without information loss (for text mode editing)</li>
|
||||
<li>Provide Vue mixin for component integration</li>
|
||||
</ul>
|
||||
<h2 id="required-exports">Required Exports</h2>
|
||||
<ul>
|
||||
<li><code>numericToDisplay(value)</code> - Converts numeric to display string (4 significant digits)</li>
|
||||
<li><code>numericToFullPrecision(value)</code> - Converts numeric to full precision string (no information loss, for text mode)</li>
|
||||
<li><code>displayToNumeric(displayValue, defaultValue)</code> - Parses display to numeric</li>
|
||||
<li><code>NumericInputMixin</code> - Vue mixin with formatNumericDisplay, toFullPrecision, and parseNumericDisplay methods</li>
|
||||
</ul>
|
||||
<h2 id="usage-guidelines">Usage Guidelines</h2>
|
||||
<ul>
|
||||
<li>Use <code>numericToDisplay()</code> for standard input fields where formatted display is preferred</li>
|
||||
<li>Use <code>numericToFullPrecision()</code> for text mode inputs (e.g., array-like number editors) where users need to see/edit exact values without precision loss</li>
|
||||
</ul>
|
||||
<h2 id="avoiding-precision-loss">Avoiding Precision Loss</h2>
|
||||
<p>When a component has multiple numeric inputs (e.g., <a class="xref" href="../../api/Hi.Geom.Vec3d.html">Vec3d</a> with X, Y, Z or <a class="xref" href="../../api/Hi.Geom.Mat4d.html">Mat4d</a> with 16 elements), parsing display values back to numeric on unchanged fields will cause precision loss due to the 4-digit formatting.</p>
|
||||
<p><strong>Problem</strong>: If user only edits X, but <code>displayToNumeric()</code> is called on all fields (X, Y, Z), the unchanged Y and Z values lose precision.</p>
|
||||
<p><strong>Solution</strong>: Update only the edited field by:</p>
|
||||
<ol>
|
||||
<li>Each input field should have its own <code>@change</code> handler (e.g., <code>onXChanged</code>, <code>onYChanged</code>, <code>onZChanged</code>)</li>
|
||||
<li>Backend should provide single-element update API (e.g., <code>UpdateAt(key, index, value)</code>)</li>
|
||||
<li>Only parse and send the edited value to backend</li>
|
||||
</ol>
|
||||
<p><strong>Example</strong> (Vec3d):</p>
|
||||
<ul>
|
||||
<li>Frontend: <code>@change="onXChanged"</code> calls <code>/api/Vec3d/UpdateAt?index=0&value=...</code></li>
|
||||
<li>Backend: <code>vec3d.At(index) = value;</code></li>
|
||||
</ul>
|
||||
<p><strong>Example</strong> (Mat4d):</p>
|
||||
<ul>
|
||||
<li>Frontend: <code>@change="onCellChanged(row, col)"</code> calls <code>/api/Mat4d/UpdateAt?index=...&value=...</code></li>
|
||||
<li>Backend: <code>mat4d.m[index] = value;</code></li>
|
||||
</ul>
|
||||
<h2 id="source-code-path">Source Code Path</h2>
|
||||
<p>See <a href="../index.html">this page</a> for git repository.</p>
|
||||
<h3 id="web-page-application-source-code-path">Web Page Application Source Code Path</h3>
|
||||
<ul>
|
||||
<li>wwwroot/common/numeric-utils.js</li>
|
||||
</ul>
|
||||
|
||||
</article>
|
||||
|
||||
<div class="contribution d-print-none">
|
||||
</div>
|
||||
|
||||
<div class="next-article d-print-none border-top" id="nextArticle"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="affix">
|
||||
<nav id="affix"></nav>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<div class="container-xxl search-results" id="search-results"></div>
|
||||
|
||||
<footer class="border-top text-secondary">
|
||||
<div class="container-xxl">
|
||||
<div class="flex-fill">
|
||||
<span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,218 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Object Management Menu Button | HiAPI-C# 2025 </title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="title" content="Object Management Menu Button | HiAPI-C# 2025 ">
|
||||
|
||||
|
||||
<link rel="icon" href="../../img/HiAPI.favicon.ico">
|
||||
<link rel="stylesheet" href="../../public/docfx.min.css">
|
||||
<link rel="stylesheet" href="../../public/main.css">
|
||||
<meta name="docfx:navrel" content="../../toc.html">
|
||||
<meta name="docfx:tocrel" content="../toc.html">
|
||||
|
||||
<meta name="docfx:rel" content="../../">
|
||||
|
||||
|
||||
|
||||
<meta name="loc:inThisArticle" content="In this article">
|
||||
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
||||
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
||||
<meta name="loc:tocFilter" content="Filter by title">
|
||||
<meta name="loc:nextArticle" content="Next">
|
||||
<meta name="loc:prevArticle" content="Previous">
|
||||
<meta name="loc:themeLight" content="Light">
|
||||
<meta name="loc:themeDark" content="Dark">
|
||||
<meta name="loc:themeAuto" content="Auto">
|
||||
<meta name="loc:changeTheme" content="Change theme">
|
||||
<meta name="loc:copy" content="Copy">
|
||||
<meta name="loc:downloadPdf" content="Download PDF">
|
||||
|
||||
<script type="module" src="./../../public/docfx.min.js"></script>
|
||||
|
||||
<script>
|
||||
const theme = localStorage.getItem('theme') || 'auto'
|
||||
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
|
||||
<header class="bg-body border-bottom">
|
||||
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
||||
<div class="container-xxl flex-nowrap">
|
||||
<a class="navbar-brand" href="../../index.html">
|
||||
<img id="logo" class="svg" src="../../img/HiAPI.logo.png" alt="">
|
||||
|
||||
</a>
|
||||
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<i class="bi bi-three-dots"></i>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navpanel">
|
||||
<div id="navbar">
|
||||
<form class="search" role="search" id="search">
|
||||
<i class="bi bi-search"></i>
|
||||
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container-xxl">
|
||||
<div class="toc-offcanvas">
|
||||
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<nav class="toc" id="toc"></nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="actionbar">
|
||||
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
|
||||
<i class="bi bi-list"></i>
|
||||
</button>
|
||||
|
||||
<nav id="breadcrumb"></nav>
|
||||
</div>
|
||||
|
||||
<article data-uid="">
|
||||
<h1 id="object-management-menu-button">Object Management Menu Button</h1>
|
||||
|
||||
<p>The menu button represent the target object with getter function and setter function. The target object generally is <a class="xref" href="../../api/Hi.Common.XmlUtils.IMakeXmlSource.html">IMakeXmlSource</a>.</p>
|
||||
<p>the target object with getter function and setter function is such like:</p>
|
||||
<pre><code class="lang-csharp">object TargetObject{get=>TargetObjectGetter?.Invoke();set=>TargetObjectSetter?.Invoke(value);}
|
||||
Func<TargetObject> TargetObjectGetter{get;set;}
|
||||
Action<TargetObject> TargetObjectSetter{get;set;}
|
||||
</code></pre>
|
||||
<p>The target object has the following functions:</p>
|
||||
<ul>
|
||||
<li>File Save/Load
|
||||
<ul>
|
||||
<li>See <a href="gui-file-path-assignment.html">GUI File Path Assignment</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Object Copy/Paste</li>
|
||||
<li>Editor Panel Mode Selection
|
||||
<ul>
|
||||
<li>GUI (user-friendly)</li>
|
||||
<li>XML
|
||||
<ul>
|
||||
<li>Get XML by <a class="xref" href="../../api/Hi.Common.XmlUtils.IMakeXmlSource.html">IMakeXmlSource</a> with <code>exhibitionOnly</code> true.</li>
|
||||
<li>Set XML by <a class="xref" href="../../api/Hi.Common.XmlUtils.XFactory.html">XFactory</a>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p>If the target object is not <a class="xref" href="../../api/Hi.Common.XmlUtils.IMakeXmlSource.html">IMakeXmlSource</a>, then the XML Editor Panel Mode should not appear. The other functions are still buildable.</p>
|
||||
<p>On <a class="xref" href="../../api/Hi.Common.XmlUtils.XFactory.html">XFactory</a> functions, set <code>enableRebase</code> to <code>true</code> (which is the default). The rebase mode resolves relative file paths from the file's own directory, preventing silent inner exceptions.</p>
|
||||
<h2 id="layout">Layout</h2>
|
||||
<ul>
|
||||
<li>Object Management Menu Button
|
||||
<ul>
|
||||
<li>Load Button</li>
|
||||
<li>Load Resource Button</li>
|
||||
<li>Save As Button</li>
|
||||
<li>(splitter)</li>
|
||||
<li>Copy Button (with hotkey support if the Object Management Menu Button is focused)</li>
|
||||
<li>Paste Button (with hotkey support if the Object Management Menu Button is focused)</li>
|
||||
<li>(splitter)</li>
|
||||
<li>GUI Ratio Button</li>
|
||||
<li>XML Ratio Button</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="TIP">
|
||||
<h5>Tip</h5>
|
||||
<ul>
|
||||
<li>Since the Object Management Menu Button has special meaning, use icon instead of text label.</li>
|
||||
<li>Do not use icon on the other child buttons. The icons gains nothing but hard to keep style to the full application.</li>
|
||||
<li>If the model is selected, show a different style (may be color) on the menu button.</li>
|
||||
<li>The model should contain a ResourceDirectory property.</li>
|
||||
<li>Do not show Load Resource Button if Resource directory not explicitly gave.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<h2 id="copy--paste">Copy & Paste</h2>
|
||||
<ul>
|
||||
<li>Object Copy/Paste (i.e. Select/Set or Duplicated-Set)
|
||||
<ul>
|
||||
<li>Copy (i.e. Select)
|
||||
Set the model to <a class="xref" href="../../api/Hi.HiNcKits.UserService.html#Hi_HiNcKits_UserService_SelectedItem">SelectedItem</a>.</li>
|
||||
<li>Paste
|
||||
Set <a class="xref" href="../../api/Hi.HiNcKits.UserService.html#Hi_HiNcKits_UserService_SelectedItem">SelectedItem</a> to the model.
|
||||
Set by reference is default. Apply Duplicated-Set if explicitly required.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p>While a object is copied (selected) here, it can also be paste (drag) to:</p>
|
||||
<ul>
|
||||
<li>Text editor
|
||||
Use <a class="xref" href="../../api/Hi.Common.XmlUtils.IMakeXmlSource.html">IMakeXmlSource</a>.<a class="xref" href="../../api/Hi.Common.XmlUtils.IMakeXmlSource.html#Hi_Common_XmlUtils_IMakeXmlSource_MakeXmlSource_System_String_System_String_System_Boolean_">MakeXmlSource(string, string, bool)</a> with <code>exhibitionOnly</code> false and the argument (<code>baseDirectory</code> and <code>relFile</code>) from object's host to paste the text, it should be the same text content by the host XML output.</li>
|
||||
<li>File browser
|
||||
Use <a class="xref" href="../../api/Hi.Common.XmlUtils.IMakeXmlSource.html">IMakeXmlSource</a>.<a class="xref" href="../../api/Hi.Common.XmlUtils.IMakeXmlSource.html#Hi_Common_XmlUtils_IMakeXmlSource_MakeXmlSource_System_String_System_String_System_Boolean_">MakeXmlSource(string, string, bool)</a> with <code>exhibitionOnly</code> true, <code>baseDirectory</code> destination folder, <code>relFile</code> destination file name (maybe xxx.class-name) to paste the file.</li>
|
||||
</ul>
|
||||
<p>Show message when paste action success or failed. See <a href="../general-rules.html">Handle Message and Exception</a>.</p>
|
||||
<p>If the data type is not matched, show the un-matched message.</p>
|
||||
<h2 id="editor-panel-mode-ratio-button">Editor Panel Mode Ratio Button</h2>
|
||||
<p>The Editor Panel switched by the Editor Panel Mode Ratio Button.</p>
|
||||
<p>The BaseDirectory and RelFile properties should exist. Use the RelFile property if the object's host has the corresponding property like XXXFile.</p>
|
||||
<p>The Apply action should be well-set. Include <a class="xref" href="../../api/Hi.Common.XmlUtils.SetFileDelegate.html">SetFileDelegate</a> from <a class="xref" href="../../api/Hi.Common.XmlUtils.XFactory.html#Hi_Common_XmlUtils_XFactory_Gen_">Gen</a> function.
|
||||
The last argument should also be delivered by the host. So there must exist an property to pass the argument.</p>
|
||||
<h3 id="xml-editor-panel-layout">XML Editor Panel Layout</h3>
|
||||
<ul>
|
||||
<li>XML Editor Panel
|
||||
<ul>
|
||||
<li>Cancel Button</li>
|
||||
<li>Apply Button</li>
|
||||
<li>XML TextArea</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p>Shows error message if the xml-parsing or object creation failed on XML Editor Panel Apply Button applied.</p>
|
||||
<h2 id="wpf-application-source-code-path">WPF Application Source Code Path</h2>
|
||||
<ul>
|
||||
<li>Common/ObjectManagementMenuButton</li>
|
||||
</ul>
|
||||
<p>see <a href="../index.html">this page</a> for git repository.</p>
|
||||
<h2 id="web-page-application-source-code-path">Web Page Application Source Code Path</h2>
|
||||
<p>HiNC-2025-webservice (Quasar CLI SPA):</p>
|
||||
<ul>
|
||||
<li><code>wwwroot-src/src/components/widgets/ObjectManagementMenuButton.vue</code> — Quasar dropdown + XML editor dialog. Emits <code>update:modelKey</code>, <code>objectLoaded</code>, <code>objectPasted</code>, <code>xmlApplied</code>, <code>error</code>. Supports Ctrl+C / Ctrl+V.</li>
|
||||
<li><code>wwwroot-src/src/api/objectManagement.ts</code> — typed wrapper over <code>/api/ObjectManagement/*</code>.</li>
|
||||
<li><code>Widget/ObjectManagementController.cs</code> — REST endpoints: <code>Load</code>, <code>LoadResource</code>, <code>SaveAs</code>, <code>Copy</code>, <code>Paste</code>, <code>GetXml</code>, <code>ApplyXml</code>, <code>SupportsXml</code>, <code>GetSelectedItem</code>.</li>
|
||||
</ul>
|
||||
|
||||
</article>
|
||||
|
||||
<div class="contribution d-print-none">
|
||||
</div>
|
||||
|
||||
<div class="next-article d-print-none border-top" id="nextArticle"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="affix">
|
||||
<nav id="affix"></nav>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<div class="container-xxl search-results" id="search-results"></div>
|
||||
|
||||
<footer class="border-top text-secondary">
|
||||
<div class="container-xxl">
|
||||
<div class="flex-fill">
|
||||
<span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,152 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Polar Resolution 2D Panel | HiAPI-C# 2025 </title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="title" content="Polar Resolution 2D Panel | HiAPI-C# 2025 ">
|
||||
|
||||
|
||||
<link rel="icon" href="../../img/HiAPI.favicon.ico">
|
||||
<link rel="stylesheet" href="../../public/docfx.min.css">
|
||||
<link rel="stylesheet" href="../../public/main.css">
|
||||
<meta name="docfx:navrel" content="../../toc.html">
|
||||
<meta name="docfx:tocrel" content="../toc.html">
|
||||
|
||||
<meta name="docfx:rel" content="../../">
|
||||
|
||||
|
||||
|
||||
<meta name="loc:inThisArticle" content="In this article">
|
||||
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
||||
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
||||
<meta name="loc:tocFilter" content="Filter by title">
|
||||
<meta name="loc:nextArticle" content="Next">
|
||||
<meta name="loc:prevArticle" content="Previous">
|
||||
<meta name="loc:themeLight" content="Light">
|
||||
<meta name="loc:themeDark" content="Dark">
|
||||
<meta name="loc:themeAuto" content="Auto">
|
||||
<meta name="loc:changeTheme" content="Change theme">
|
||||
<meta name="loc:copy" content="Copy">
|
||||
<meta name="loc:downloadPdf" content="Download PDF">
|
||||
|
||||
<script type="module" src="./../../public/docfx.min.js"></script>
|
||||
|
||||
<script>
|
||||
const theme = localStorage.getItem('theme') || 'auto'
|
||||
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
|
||||
<header class="bg-body border-bottom">
|
||||
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
||||
<div class="container-xxl flex-nowrap">
|
||||
<a class="navbar-brand" href="../../index.html">
|
||||
<img id="logo" class="svg" src="../../img/HiAPI.logo.png" alt="">
|
||||
|
||||
</a>
|
||||
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<i class="bi bi-three-dots"></i>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navpanel">
|
||||
<div id="navbar">
|
||||
<form class="search" role="search" id="search">
|
||||
<i class="bi bi-search"></i>
|
||||
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container-xxl">
|
||||
<div class="toc-offcanvas">
|
||||
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<nav class="toc" id="toc"></nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="actionbar">
|
||||
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
|
||||
<i class="bi bi-list"></i>
|
||||
</button>
|
||||
|
||||
<nav id="breadcrumb"></nav>
|
||||
</div>
|
||||
|
||||
<article data-uid="">
|
||||
<h1 id="polar-resolution-2d-panel">Polar Resolution 2D Panel</h1>
|
||||
|
||||
<p>The model is <a class="xref" href="../../api/Hi.Geom.Resolution.PolarResolution2d.html">PolarResolution2d</a>.</p>
|
||||
<h2 id="layout">Layout</h2>
|
||||
<ul>
|
||||
<li>Polar Resolution 2D Panel
|
||||
<ul>
|
||||
<li>Enable Custom Resolution CheckBox
|
||||
<ul>
|
||||
<li>enabled if host.model is not null.</li>
|
||||
<li>set host.model to null if not enabled.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Linear Resolution (mm) Input Field
|
||||
<ul>
|
||||
<li>enabled if model not null</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Angle Resolution (deg) Input Field
|
||||
<ul>
|
||||
<li>enabled if model not null</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<h2 id="feature">Feature</h2>
|
||||
<p>There is a code-behind property to set visibility of Enable CheckBox.</p>
|
||||
<p>If the host.model is null, it may mean the resolution applied the default value.</p>
|
||||
<h2 id="source-code-path">Source Code Path</h2>
|
||||
<p>See <a href="../index.html">this page</a> for git repository.</p>
|
||||
<h3 id="wpf-application-source-code-path">WPF Application Source Code Path</h3>
|
||||
<ul>
|
||||
<li>Geom/PolarResolution2dPanel</li>
|
||||
</ul>
|
||||
<h3 id="web-service-application-source-code-path">Web Service Application Source Code Path</h3>
|
||||
<ul>
|
||||
<li>wwwroot/widget/polar-resolution-2d-panel.js</li>
|
||||
</ul>
|
||||
|
||||
</article>
|
||||
|
||||
<div class="contribution d-print-none">
|
||||
</div>
|
||||
|
||||
<div class="next-article d-print-none border-top" id="nextArticle"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="affix">
|
||||
<nav id="affix"></nav>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<div class="container-xxl search-results" id="search-results"></div>
|
||||
|
||||
<footer class="border-top text-secondary">
|
||||
<div class="container-xxl">
|
||||
<div class="flex-fill">
|
||||
<span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,142 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Resizable Bar Component | HiAPI-C# 2025 </title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="title" content="Resizable Bar Component | HiAPI-C# 2025 ">
|
||||
|
||||
|
||||
<link rel="icon" href="../../img/HiAPI.favicon.ico">
|
||||
<link rel="stylesheet" href="../../public/docfx.min.css">
|
||||
<link rel="stylesheet" href="../../public/main.css">
|
||||
<meta name="docfx:navrel" content="../../toc.html">
|
||||
<meta name="docfx:tocrel" content="../toc.html">
|
||||
|
||||
<meta name="docfx:rel" content="../../">
|
||||
|
||||
|
||||
|
||||
<meta name="loc:inThisArticle" content="In this article">
|
||||
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
||||
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
||||
<meta name="loc:tocFilter" content="Filter by title">
|
||||
<meta name="loc:nextArticle" content="Next">
|
||||
<meta name="loc:prevArticle" content="Previous">
|
||||
<meta name="loc:themeLight" content="Light">
|
||||
<meta name="loc:themeDark" content="Dark">
|
||||
<meta name="loc:themeAuto" content="Auto">
|
||||
<meta name="loc:changeTheme" content="Change theme">
|
||||
<meta name="loc:copy" content="Copy">
|
||||
<meta name="loc:downloadPdf" content="Download PDF">
|
||||
|
||||
<script type="module" src="./../../public/docfx.min.js"></script>
|
||||
|
||||
<script>
|
||||
const theme = localStorage.getItem('theme') || 'auto'
|
||||
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
|
||||
<header class="bg-body border-bottom">
|
||||
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
||||
<div class="container-xxl flex-nowrap">
|
||||
<a class="navbar-brand" href="../../index.html">
|
||||
<img id="logo" class="svg" src="../../img/HiAPI.logo.png" alt="">
|
||||
|
||||
</a>
|
||||
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<i class="bi bi-three-dots"></i>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navpanel">
|
||||
<div id="navbar">
|
||||
<form class="search" role="search" id="search">
|
||||
<i class="bi bi-search"></i>
|
||||
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container-xxl">
|
||||
<div class="toc-offcanvas">
|
||||
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<nav class="toc" id="toc"></nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="actionbar">
|
||||
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
|
||||
<i class="bi bi-list"></i>
|
||||
</button>
|
||||
|
||||
<nav id="breadcrumb"></nav>
|
||||
</div>
|
||||
|
||||
<article data-uid="">
|
||||
<h1 id="resizable-bar-component">Resizable Bar Component</h1>
|
||||
|
||||
<p>A Vue component that provides draggable dividers for resizing adjacent panels in web applications.</p>
|
||||
<h2 id="overview">Overview</h2>
|
||||
<p>The ResizableBar component creates a draggable bar that allows users to resize panels by clicking and dragging. It supports both horizontal and vertical orientations.</p>
|
||||
<h2 id="key-features">Key Features</h2>
|
||||
<ul>
|
||||
<li><strong>Directional Support</strong>: Works in both horizontal (for width adjustment) and vertical (for height adjustment) orientations</li>
|
||||
<li><strong>Unit Flexibility</strong>: Supports pixel, percentage, and custom unit systems through converters</li>
|
||||
<li><strong>Visual Feedback</strong>: Changes appearance on hover and during drag operations</li>
|
||||
<li><strong>Constraint System</strong>: Enforces minimum and maximum size limits</li>
|
||||
</ul>
|
||||
<h2 id="usage-pattern">Usage Pattern</h2>
|
||||
<p>The component should be placed between two panels that need to be resizable. The resize events provide size information that parent components use to adjust panel dimensions.</p>
|
||||
<h2 id="unit-modes">Unit Modes</h2>
|
||||
<ol>
|
||||
<li><strong>Pixel Mode</strong> (default): Direct pixel value manipulation</li>
|
||||
<li><strong>Percentage Mode</strong>: Automatic calculation relative to parent container</li>
|
||||
<li><strong>Custom Mode</strong>: User-defined unit converters for specialized requirements</li>
|
||||
</ol>
|
||||
<h2 id="integration-example">Integration Example</h2>
|
||||
<p>See the player-panel.js implementation for a practical example of using ResizableBar to create adjustable layouts between rendering canvas and side panels.</p>
|
||||
<h2 id="web-application-source-code-path">Web Application Source Code Path</h2>
|
||||
<ul>
|
||||
<li>common/resizable-bar</li>
|
||||
<li>common/resizable-bar-example</li>
|
||||
<li>player/player-panel</li>
|
||||
</ul>
|
||||
<p>See this page <a href="../index.html">~/app-anatomy/index.md</a> for git repository.</p>
|
||||
|
||||
</article>
|
||||
|
||||
<div class="contribution d-print-none">
|
||||
</div>
|
||||
|
||||
<div class="next-article d-print-none border-top" id="nextArticle"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="affix">
|
||||
<nav id="affix"></nav>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<div class="container-xxl search-results" id="search-results"></div>
|
||||
|
||||
<footer class="border-top text-secondary">
|
||||
<div class="container-xxl">
|
||||
<div class="flex-fill">
|
||||
<span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,607 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Vec3dControl Component | HiAPI-C# 2025 </title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="title" content="Vec3dControl Component | HiAPI-C# 2025 ">
|
||||
|
||||
|
||||
<link rel="icon" href="../../../img/HiAPI.favicon.ico">
|
||||
<link rel="stylesheet" href="../../../public/docfx.min.css">
|
||||
<link rel="stylesheet" href="../../../public/main.css">
|
||||
<meta name="docfx:navrel" content="../../../toc.html">
|
||||
<meta name="docfx:tocrel" content="../../toc.html">
|
||||
|
||||
<meta name="docfx:rel" content="../../../">
|
||||
|
||||
|
||||
|
||||
<meta name="loc:inThisArticle" content="In this article">
|
||||
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
||||
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
||||
<meta name="loc:tocFilter" content="Filter by title">
|
||||
<meta name="loc:nextArticle" content="Next">
|
||||
<meta name="loc:prevArticle" content="Previous">
|
||||
<meta name="loc:themeLight" content="Light">
|
||||
<meta name="loc:themeDark" content="Dark">
|
||||
<meta name="loc:themeAuto" content="Auto">
|
||||
<meta name="loc:changeTheme" content="Change theme">
|
||||
<meta name="loc:copy" content="Copy">
|
||||
<meta name="loc:downloadPdf" content="Download PDF">
|
||||
|
||||
<script type="module" src="./../../../public/docfx.min.js"></script>
|
||||
|
||||
<script>
|
||||
const theme = localStorage.getItem('theme') || 'auto'
|
||||
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
|
||||
<header class="bg-body border-bottom">
|
||||
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
||||
<div class="container-xxl flex-nowrap">
|
||||
<a class="navbar-brand" href="../../../index.html">
|
||||
<img id="logo" class="svg" src="../../../img/HiAPI.logo.png" alt="">
|
||||
|
||||
</a>
|
||||
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<i class="bi bi-three-dots"></i>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navpanel">
|
||||
<div id="navbar">
|
||||
<form class="search" role="search" id="search">
|
||||
<i class="bi bi-search"></i>
|
||||
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container-xxl">
|
||||
<div class="toc-offcanvas">
|
||||
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<nav class="toc" id="toc"></nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="actionbar">
|
||||
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
|
||||
<i class="bi bi-list"></i>
|
||||
</button>
|
||||
|
||||
<nav id="breadcrumb"></nav>
|
||||
</div>
|
||||
|
||||
<article data-uid="">
|
||||
<h1 id="vec3dcontrol-component">Vec3dControl Component</h1>
|
||||
|
||||
<p>Vec3dControl is a user control for <a class="xref" href="../../../api/Hi.Geom.Vec3d.html">Vec3d</a> and display.</p>
|
||||
<h2 id="main-features">Main Features</h2>
|
||||
<ol>
|
||||
<li><p>Dual Input Modes</p>
|
||||
<ul>
|
||||
<li>Standard Mode: Input X, Y, Z components separately (formatted display with 4 significant digits)</li>
|
||||
<li>Text Mode: Input complete vector in text format (full precision, no information loss)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p>Vector Normalization</p>
|
||||
<ul>
|
||||
<li>Normalization button (optional)</li>
|
||||
<li>Button visibility controlled by <code>ShowNormalizeButton</code> property</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p>Special Value Handling (Web)</p>
|
||||
<ul>
|
||||
<li>Supports Infinity, -Infinity, and NaN values</li>
|
||||
<li>Uses <a href="../numeric-io-utilities.html">Numeric Input/Output Utilities</a> for display and parsing</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ol>
|
||||
<h2 id="refer-sample-code">Refer Sample Code</h2>
|
||||
<pre><code class="lang-csharp" name="SampleCode-xaml"><UserControl x:Class="HiNC_2025_win_desktop.Geom.Vec3dControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="30" d:DesignWidth="200">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Standard Mode Panel -->
|
||||
<StackPanel x:Name="StandardModePanel" Orientation="Horizontal" Grid.ColumnSpan="5">
|
||||
<TextBox x:Name="XTextBox" Width="60" Margin="0,0,2,0" TextChanged="XTextBox_TextChanged" IsReadOnly="{Binding IsReadOnly}"/>
|
||||
<TextBox x:Name="YTextBox" Width="60" Margin="0,0,2,0" TextChanged="YTextBox_TextChanged" IsReadOnly="{Binding IsReadOnly}"/>
|
||||
<TextBox x:Name="ZTextBox" Width="60" Margin="0,0,2,0" TextChanged="ZTextBox_TextChanged" IsReadOnly="{Binding IsReadOnly}"/>
|
||||
<Button Content="{DynamicResource Vec3d_TextMode_Toggle}" Width="20" Click="TextModeToggle_Click" Margin="0,0,2,0" ToolTip="{DynamicResource Vec3d_TextMode_Tooltip}"/>
|
||||
<Button Content="{DynamicResource Vec3d_Normalize}" Width="20" Click="NormalizeButton_Click" Visibility="{Binding ShowNormalizeButton, Converter={StaticResource BooleanToVisibilityConverter}}" ToolTip="{DynamicResource Vec3d_Normalize_Tooltip}"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Text Mode Panel -->
|
||||
<StackPanel x:Name="TextModePanel" Orientation="Horizontal" Grid.ColumnSpan="5" Visibility="Collapsed">
|
||||
<TextBox x:Name="VectorTextBox" Width="180" Margin="0,0,2,0" TextChanged="VectorTextBox_TextChanged" IsReadOnly="{Binding IsReadOnly}"
|
||||
ToolTip="{DynamicResource Vec3d_TextMode_Format_Tooltip}"/>
|
||||
<Button Content="{DynamicResource Vec3d_StandardMode_Toggle}" Width="20" Click="StandardModeToggle_Click" Margin="0,0,2,0" ToolTip="{DynamicResource Vec3d_StandardMode_Tooltip}"/>
|
||||
<Button Content="{DynamicResource Vec3d_Normalize}" Width="20" Click="NormalizeButton_Click" Visibility="{Binding ShowNormalizeButton, Converter={StaticResource BooleanToVisibilityConverter}}" ToolTip="{DynamicResource Vec3d_Normalize_Tooltip}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
</code></pre><pre><code class="lang-csharp" name="SampleCode-xaml.cs">using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows;
|
||||
using Hi.Geom;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.ComponentModel;
|
||||
using Hi.Common;
|
||||
using Hi.Common.Messages;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace HiNC_2025_win_desktop.Geom
|
||||
{
|
||||
/// <summary>
|
||||
/// Vec3dControl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class Vec3dControl : UserControl, INotifyPropertyChanged
|
||||
{
|
||||
private bool _isUpdating = false;
|
||||
private Func<Vec3d> _getterFunc;
|
||||
private Func<Task> _updateByContentFunc;
|
||||
private bool _showNormalizeButton = false;
|
||||
private bool _isTextMode = false;
|
||||
private bool _isReadOnly = false;
|
||||
private readonly ILogger<Vec3dControl> _logger = App.ServiceProvider.GetRequiredService<ILogger<Vec3dControl>>();
|
||||
|
||||
private static readonly Regex VectorRegex = new Regex(@"^\s*[\(\[\{]?\s*(-?\d*\.?\d+)\s*,\s*(-?\d*\.?\d+)\s*,\s*(-?\d*\.?\d+)\s*[\)\]\}]?\s*$", RegexOptions.Compiled);
|
||||
private static readonly Regex MatrixRegex = new Regex(@"\{(?:\s*\{?\s*(-?\d*\.?\d+)\s*,\s*(-?\d*\.?\d+)\s*,\s*(-?\d*\.?\d+)\s*,\s*(-?\d*\.?\d+)\s*\}?\s*,){3}\s*\{?\s*(-?\d*\.?\d+)\s*,\s*(-?\d*\.?\d+)\s*,\s*(-?\d*\.?\d+)\s*,\s*(-?\d*\.?\d+)\s*\}?\s*\}", RegexOptions.Compiled);
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public string ControlId { get; set; } = Guid.NewGuid().ToString();
|
||||
|
||||
public Func<Vec3d> GetterFunc
|
||||
{
|
||||
get => _getterFunc;
|
||||
set
|
||||
{
|
||||
_getterFunc = value;
|
||||
UpdateUI();
|
||||
}
|
||||
}
|
||||
|
||||
public Func<Task> UpdateByContentFunc
|
||||
{
|
||||
get => _updateByContentFunc;
|
||||
set => _updateByContentFunc = value;
|
||||
}
|
||||
|
||||
public bool ShowNormalizeButton
|
||||
{
|
||||
get => _showNormalizeButton;
|
||||
set
|
||||
{
|
||||
if (_showNormalizeButton != value)
|
||||
{
|
||||
_showNormalizeButton = value;
|
||||
OnPropertyChanged(nameof(ShowNormalizeButton));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsTextMode
|
||||
{
|
||||
get => _isTextMode;
|
||||
set
|
||||
{
|
||||
if (_isTextMode != value)
|
||||
{
|
||||
_isTextMode = value;
|
||||
UpdateModeVisibility();
|
||||
OnPropertyChanged(nameof(IsTextMode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get => _isReadOnly;
|
||||
set
|
||||
{
|
||||
if (_isReadOnly != value)
|
||||
{
|
||||
_isReadOnly = value;
|
||||
OnPropertyChanged(nameof(IsReadOnly));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public Vec3dControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
private void UpdateModeVisibility()
|
||||
{
|
||||
if (IsTextMode)
|
||||
{
|
||||
StandardModePanel.Visibility = Visibility.Collapsed;
|
||||
TextModePanel.Visibility = Visibility.Visible;
|
||||
UpdateVectorTextFromXYZ();
|
||||
}
|
||||
else
|
||||
{
|
||||
StandardModePanel.Visibility = Visibility.Visible;
|
||||
TextModePanel.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateVectorTextFromXYZ()
|
||||
{
|
||||
if (_isUpdating) return;
|
||||
|
||||
if (double.TryParse(XTextBox.Text, out double x) &&
|
||||
double.TryParse(YTextBox.Text, out double y) &&
|
||||
double.TryParse(ZTextBox.Text, out double z))
|
||||
{
|
||||
VectorTextBox.Text = $"{x},{y},{z}";
|
||||
}
|
||||
}
|
||||
|
||||
private void TextModeToggle_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IsTextMode = true;
|
||||
}
|
||||
|
||||
private void StandardModeToggle_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IsTextMode = false;
|
||||
}
|
||||
|
||||
private async void NormalizeButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_isUpdating || _getterFunc == null || IsReadOnly)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
_isUpdating = true;
|
||||
|
||||
var vec = _getterFunc();
|
||||
if (vec != null)
|
||||
{
|
||||
vec.Normalize();
|
||||
|
||||
XTextBox.Text = vec.X.ToString("F3");
|
||||
YTextBox.Text = vec.Y.ToString("F3");
|
||||
ZTextBox.Text = vec.Z.ToString("F3");
|
||||
|
||||
if (IsTextMode)
|
||||
{
|
||||
VectorTextBox.Text = $"{vec.X:F3},{vec.Y:F3},{vec.Z:F3}";
|
||||
}
|
||||
if(_updateByContentFunc != null)
|
||||
await _updateByContentFunc();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(string.Format(Application.Current.FindResource("Vec3d_Update_Error").ToString(), ex.Message));
|
||||
_logger.LogError(ex, "{Message}", ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isUpdating = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateUI()
|
||||
{
|
||||
if (_isUpdating || _getterFunc == null)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
_isUpdating = true;
|
||||
var vec = _getterFunc();
|
||||
if (vec != null)
|
||||
{
|
||||
XTextBox.Text = vec.X.ToString("F3");
|
||||
YTextBox.Text = vec.Y.ToString("F3");
|
||||
ZTextBox.Text = vec.Z.ToString("F3");
|
||||
|
||||
if (IsTextMode)
|
||||
{
|
||||
VectorTextBox.Text = $"{vec.X},{vec.Y},{vec.Z}";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
XTextBox.Text = "";
|
||||
YTextBox.Text = "";
|
||||
ZTextBox.Text = "";
|
||||
VectorTextBox.Text = "";
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isUpdating = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async void XTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
await HandleTextChanged();
|
||||
}
|
||||
|
||||
private async void YTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
await HandleTextChanged();
|
||||
}
|
||||
|
||||
private async void ZTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
await HandleTextChanged();
|
||||
}
|
||||
|
||||
private async void VectorTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (_isUpdating || _getterFunc == null || IsReadOnly)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
string text = VectorTextBox.Text.Trim();
|
||||
|
||||
// 如果文本为空或太短,不做处理
|
||||
if (string.IsNullOrWhiteSpace(text) || text.Length < 3)
|
||||
return;
|
||||
|
||||
_isUpdating = true;
|
||||
|
||||
// 尝试解析为向量格式
|
||||
if (TryParseVector(text, out double x, out double y, out double z))
|
||||
{
|
||||
await UpdateVectorValues(x, y, z);
|
||||
}
|
||||
// 尝试解析为变换矩阵格式(仅提取位移分量)
|
||||
else if (TryParseTransformMatrix(text, out double tx, out double ty, out double tz))
|
||||
{
|
||||
await UpdateVectorValues(tx, ty, tz);
|
||||
}
|
||||
// 尝试作为单值解析每个字段(宽松模式)
|
||||
else if (TryParseLooseVector(text, out double lx, out double ly, out double lz))
|
||||
{
|
||||
await UpdateVectorValues(lx, ly, lz);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(string.Format(Application.Current.FindResource("Vec3d_Update_Error").ToString(), ex.Message));
|
||||
_logger.LogError(ex, "{Message}", ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isUpdating = false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryParseVector(string text, out double x, out double y, out double z)
|
||||
{
|
||||
x = y = z = 0;
|
||||
|
||||
// 使用正则表达式匹配向量格式
|
||||
Match match = VectorRegex.Match(text);
|
||||
if (match.Success && match.Groups.Count >= 4)
|
||||
{
|
||||
if (double.TryParse(match.Groups[1].Value, out x) &&
|
||||
double.TryParse(match.Groups[2].Value, out y) &&
|
||||
double.TryParse(match.Groups[3].Value, out z))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool TryParseTransformMatrix(string text, out double tx, out double ty, out double tz)
|
||||
{
|
||||
tx = ty = tz = 0;
|
||||
|
||||
// 移除所有换行和多余空格,便于匹配
|
||||
text = Regex.Replace(text, @"\s+", " ");
|
||||
|
||||
// 尝试匹配变换矩阵格式
|
||||
Match match = MatrixRegex.Match(text);
|
||||
if (match.Success && match.Groups.Count >= 8)
|
||||
{
|
||||
// 变换矩阵的第4列通常是位移分量
|
||||
if (double.TryParse(match.Groups[4].Value, out tx) &&
|
||||
double.TryParse(match.Groups[8].Value, out ty) &&
|
||||
double.TryParse(match.Groups[12].Value, out tz))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 尝试匹配更宽松的变换矩阵表示(例如从界面复制的数据)
|
||||
var numbers = Regex.Matches(text, @"(-?\d*\.?\d+)");
|
||||
if (numbers.Count >= 16)
|
||||
{
|
||||
// 假设这是一个4x4矩阵,提取位移分量(第4、8、12个数字)
|
||||
if (double.TryParse(numbers[3].Value, out tx) &&
|
||||
double.TryParse(numbers[7].Value, out ty) &&
|
||||
double.TryParse(numbers[11].Value, out tz))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool TryParseLooseVector(string text, out double x, out double y, out double z)
|
||||
{
|
||||
x = y = z = 0;
|
||||
|
||||
// 移除所有非数字和小数点以外的字符,然后按空白分割
|
||||
string cleanText = Regex.Replace(text, @"[^\d\.\-\s,;]+", " ");
|
||||
string[] parts = Regex.Split(cleanText, @"[\s,;]+");
|
||||
|
||||
// 尝试从分割后的部分获取三个数字
|
||||
var numbers = new System.Collections.Generic.List<double>();
|
||||
foreach (var part in parts)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(part) && double.TryParse(part, out double value))
|
||||
{
|
||||
numbers.Add(value);
|
||||
if (numbers.Count >= 3) break; // 最多取3个数字
|
||||
}
|
||||
}
|
||||
|
||||
// 如果获取到了三个数字,就认为解析成功
|
||||
if (numbers.Count >= 3)
|
||||
{
|
||||
x = numbers[0];
|
||||
y = numbers[1];
|
||||
z = numbers[2];
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private async Task UpdateVectorValues(double x, double y, double z)
|
||||
{
|
||||
XTextBox.Text = x.ToString("F3");
|
||||
YTextBox.Text = y.ToString("F3");
|
||||
ZTextBox.Text = z.ToString("F3");
|
||||
|
||||
var vec = _getterFunc?.Invoke();
|
||||
if (vec != null)
|
||||
{
|
||||
vec.X = x;
|
||||
vec.Y = y;
|
||||
vec.Z = z;
|
||||
|
||||
if (_updateByContentFunc != null)
|
||||
{
|
||||
await _updateByContentFunc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleTextChanged()
|
||||
{
|
||||
if (_isUpdating || _getterFunc == null || IsReadOnly)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
_isUpdating = true;
|
||||
|
||||
// 尝试解析每个文本框的值
|
||||
bool allValid = true;
|
||||
|
||||
allValid &= double.TryParse(XTextBox.Text, out double x);
|
||||
allValid &= double.TryParse(YTextBox.Text, out double y);
|
||||
allValid &= double.TryParse(ZTextBox.Text, out double z);
|
||||
|
||||
if (allValid)
|
||||
{
|
||||
if (IsTextMode)
|
||||
{
|
||||
VectorTextBox.Text = $"{x},{y},{z}";
|
||||
}
|
||||
|
||||
var vec = _getterFunc();
|
||||
if (vec != null)
|
||||
{
|
||||
vec.X = x;
|
||||
vec.Y = y;
|
||||
vec.Z = z;
|
||||
|
||||
if(_updateByContentFunc != null)
|
||||
await _updateByContentFunc();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果有无效输入,不进行更新但也不显示错误
|
||||
// 这允许用户在输入过程中有不完整的状态
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 记录异常但不中断用户操作
|
||||
_logger.LogWarning(string.Format(Application.Current.FindResource("Vec3d_Update_Error").ToString(), ex.Message));
|
||||
_logger.LogError(ex, "{Message}", ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isUpdating = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</code></pre><h2 id="source-code-path">Source Code Path</h2>
|
||||
<p>See <a href="../../index.html">this page</a> for git repository.</p>
|
||||
<h3 id="wpf-application-source-code-path">WPF Application Source Code Path</h3>
|
||||
<ul>
|
||||
<li>Geom/Vec3dControl</li>
|
||||
</ul>
|
||||
<h3 id="web-service-application-source-code-path">Web Service Application Source Code Path</h3>
|
||||
<ul>
|
||||
<li>wwwroot/widget/vec3d-control.js</li>
|
||||
<li>Widget/Vec3dHub.cs</li>
|
||||
</ul>
|
||||
|
||||
</article>
|
||||
|
||||
<div class="contribution d-print-none">
|
||||
</div>
|
||||
|
||||
<div class="next-article d-print-none border-top" id="nextArticle"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="affix">
|
||||
<nav id="affix"></nav>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<div class="container-xxl search-results" id="search-results"></div>
|
||||
|
||||
<footer class="border-top text-secondary">
|
||||
<div class="container-xxl">
|
||||
<div class="flex-fill">
|
||||
<span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user