This repository has been archived on 2026-10-11. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
HiNC-2025-win-desktop-Deploy/App/wwwroot/HiAPI-docsite/anatomy/shell/preference-menu.html
T
2026-09-09 18:06:21 +08:00

193 lines
13 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Preference Menu Dropdown | HiAPI-C# 2025 </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="title" content="Preference Menu Dropdown | 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 &quot;{query}&quot;">
<meta name="loc:searchNoResults" content="No results for &quot;{query}&quot;">
<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="Anatomy-PreferenceMenu">
<h1 id="preference-menu-dropdown">Preference Menu Dropdown</h1>
<p>The Preference dropdown holds the application's display settings, and it is on the <a class="xref" href="main-panel.html">Main Panel</a>. The server-backed ones are service-wide rather than per-account: one <code>UserService</code> singleton holds one <code>UserConfig</code>, saved to a single <code>UserConfig.xml</code> resolved against the process working directory, so every browser signed in to that service reads and writes the same values. The sign-in cookie carries a user-name claim that nothing outside the authentication endpoints reads, and no preference endpoint is keyed on an account.</p>
<p>The dropdown has two models: Language and Show Physics Options bind the <code>appState</code> store, hydrated from and written back through <code>/api/preference/*</code>, where the server keeps them on <code>UserConfig</code>; the CSV / CL Controller checkboxes bind the device-local <code>useViewPrefs</code> singleton, persisted in the browser's <code>localStorage</code> and never sent to the server.</p>
<h2 id="layout">Layout</h2>
<ul>
<li>Preference Menu Dropdown
<ul>
<li><a class="xref" href="../execution/step-present-dialog.html">Step Present Preference</a> Button
<ul>
<li>Web application: the editor belongs to the Execution page's Step Info column, where a small icon button in the Step Properties panel header opens it as a modal next to the list it configures.</li>
</ul>
</li>
<li><a class="xref" href="../execution/graphic-cache-menu.html">Graphic-Cache Dropdown</a>
<ul>
<li>Web application: an entry of the Execution page's <a class="xref" href="../execution/execution-extended-renderingcanvas-tool-bar.html">extended tool bar</a>, under <code>Meshed Geom ▾</code>, which gathers the workpiece rendering-cache settings.</li>
<li>Its write is the one preference write that does not persist. <code>POST /api/preference/graphic-cache</code> clamps the requested size between the stored limits, assigns the three fields on the live <code>UserConfig</code> and returns, without calling <code>UserService.SaveUserConfig()</code>. The new value is service-wide and takes effect at once, but it reaches the file only when some later preference save writes the config out.</li>
</ul>
</li>
<li><a class="xref" href="language-selection-submenu.html">Language Selection SubMenu</a>
<ul>
<li>The persisted value is <code>UserConfig.LanguageCode</code>; the web application reaches it through <code>GET/POST /api/preference/language</code>, whose response also names the language codes the server supports.</li>
<li>In the web application the parent row captions the current language and the sub-menu marks the active code. A successful switch flips the interface text at once, so the confirmation toast already reads in the just-picked language.</li>
</ul>
</li>
<li>CSV Controller CheckBox
<ul>
<li>Web application only. The model is <code>useViewPrefs().showCsvController</code> — device-local, stored in the browser's <code>localStorage</code>, not in <code>UserConfig</code>. It is off by default.</li>
<li>Checking it adds the <code>CSV Controller</code> node to the General Setup page's Control Tree; unchecking removes it, moving the selection away first when that node is the selected one.</li>
<li>The caption under the box says whether the loaded project plays CSV — <code>This project plays CSV</code>, or <code>Not used by this project</code> — read from the <code>referenced</code> flag of <code>GET /api/mech/csv-runner</code>. Opening the dropdown fetches both runner snapshots in parallel, but the fetch is guarded on a loaded project: with none, neither request is made and both captions are cleared to blank. A snapshot that fails to arrive leaves its caption blank as well, so a blank caption states nothing about the project. The guard reaches the captions only — neither checkbox is disabled by it.</li>
</ul>
</li>
<li>CL Controller CheckBox
<ul>
<li>The same, for <code>useViewPrefs().showClController</code>, the <code>CL Controller</code> Control Tree node and <code>GET /api/mech/cl-runner</code>.</li>
</ul>
</li>
<li>Show Physics Options CheckBox
<ul>
<li>The model is <code>UserConfig.ShowPhysicsOptions</code>, reached in the web application through <code>GET/POST /api/preference/show-physics-options</code>.</li>
<li>The checkbox is disabled and unchecked if <code>UserService.IsPhysicsLicensed</code> is false: the GET returns the flag ANDed with the licence and the POST forces <code>false</code> without it.</li>
</ul>
</li>
<li>Show Log Button
<ul>
<li>See <a class="xref" href="bottom-message-bar.html">Message Section</a>.</li>
<li>It is not a Preference-dropdown entry: it sits on the menu bar's right side as an always-visible button that opens the Log Viewer page.</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>So the web application's Preference dropdown carries the Language submenu, the CSV Controller and CL Controller visibility checkboxes, and the Show Physics Options checkbox.</p>
<p>A server write that fails raises a negative toast and rolls the item back in <code>appState</code>, so the dropdown never shows a language or a physics flag the server did not take.</p>
<h2 id="source-code-path">Source Code Path</h2>
<p>See <a class="xref" href="../index.html">HiNC App Anatomy</a> for git repository links.</p>
<ul>
<li><code>wwwroot-src/src/components/AppMenuBar.vue</code> — the <code>Preference ▾</code> dropdown itself and the menu bar's <code>Show Log</code> button.</li>
<li><code>wwwroot-src/src/stores/appState.ts</code> — the model of the two server-backed items, with the boot-time hydration and the write-back actions.</li>
<li><code>wwwroot-src/src/composables/useViewPrefs.ts</code> — the device-local <code>localStorage</code> singleton behind the two controller checkboxes.</li>
<li><code>wwwroot-src/src/api/preference.ts</code> — typed wrapper over <code>/api/preference/language</code> and <code>/api/preference/show-physics-options</code>.</li>
<li><code>wwwroot-src/src/api/csvRunner.ts</code>, <code>wwwroot-src/src/api/clRunner.ts</code> — the <code>referenced</code> flag each controller caption reports.</li>
<li><code>wwwroot-src/src/components/controlTree/useControlTreeHost.ts</code> — builds or omits the two controller nodes and rebuilds the tree when either checkbox flips.</li>
<li><code>wwwroot-src/src/i18n/en/menu.ts</code> — the dropdown's labels and captions.</li>
<li><code>wwwroot-src/src/pages/LogViewerPage.vue</code> — the page the <code>Show Log</code> button routes to.</li>
<li><code>Environments/PreferenceController.cs</code> — the endpoints. The step-present, show-physics-options, language and execution-layout writes persist through <code>UserService.SaveUserConfig()</code>; the graphic-cache write is the exception, and returns without one.</li>
<li><code>Environments/UserConfig.cs</code> — the persisted <code>LanguageCode</code> and <code>ShowPhysicsOptions</code> properties.</li>
<li><code>Environments/UserService.cs</code> — owns the single <code>UserConfig</code> the service holds, writes it to <code>UserConfigPath</code>, and answers the physics licence check.</li>
<li><code>Program.cs</code> — the one <code>UserService</code> registration behind every server-backed item here, and the configuration path it resolves against the process working directory.</li>
</ul>
<h2 id="see-also">See Also</h2>
<ul>
<li><a class="xref" href="main-panel.html">Main Panel</a> — the menu bar this dropdown sits on</li>
<li><a class="xref" href="language-selection-submenu.html">Language Selection SubMenu</a> — the only sub-menu this dropdown nests</li>
<li><a class="xref" href="../execution/graphic-cache-menu.html">Graphic-Cache SubMenu</a> — one of the two entries the web client hosts elsewhere</li>
<li><a class="xref" href="../execution/step-present-dialog.html">Step Present Preference Page</a> — the other entry the web client hosts elsewhere</li>
<li><a class="xref" href="../platform/log-viewer.html">Log Viewer Page</a> — the log screen this menu's namesake route serves</li>
<li><a class="xref" href="../general-setup/hidden-controllers.html">Hidden Controller Branches</a> — the two equipment nodes the CSV and CL entries reveal, and what a link to one does while its box is off</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>