From 51b0c2b92b35ba17290c27993492dc1b39384f60 Mon Sep 17 00:00:00 2001 From: fcs Date: Sun, 12 Oct 2025 18:46:39 +0400 Subject: [PATCH] add endpoint letter tag reset --- readme.md | 2 ++ src/APIRest.cs | 49 +++++++++++++++++++++++++++++++++++++++++++ src/FormCollection.cs | 6 +++++- 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index d0e18d4..cfdf7f1 100644 --- a/readme.md +++ b/readme.md @@ -148,6 +148,8 @@ Le port (ci-dessus 1234) est fourni dans le menu_option. - /LetterTag
Description : Ajout de lettres (A, B, C, ...)
"http://localhost:7999/LetterTag" +
Remettre à zéro (lettre A) +
"http://localhost:7999/ResetLetterTag" - /SquareTag
Description : Ajout de carrés diff --git a/src/APIRest.cs b/src/APIRest.cs index 7b2183d..05adc4c 100644 --- a/src/APIRest.cs +++ b/src/APIRest.cs @@ -1317,6 +1317,55 @@ Dictionary ParseQuery(string query) ret = string.Format("{{ \"OK\": true, \"Tool\": \"{0}\" }}", Tools.Names[Array.IndexOf(Tools.All, tool)]); } } + + else if (req.Url.AbsolutePath == "/ResetLetterTag" || req.Url.AbsolutePath == "/LetterTag_Reset") + { + if (!(Root.FormDisplay.Visible || Root.FormCollection.Visible)) + { + resp.StatusCode = 409; + ret = "!!!!! Not in Inking mode"; + } + else + { + try + { + // Mettre le compteur à 0 => la prochaine incrémentation produira la lettre 'A' + Root.TagNumbering = 0; + Root.FormCollection.LetterTag_Counter_Public = 0; + + // Sélectionner l’outil LetterTag (conserve le remplissage courant) + Root.FormCollection.SelectTool(Tools.LetterTag, Root.FilledSelected); + + // Rafraîchir l’UI + Root.UponButtonsUpdate |= 0x2; + Root.UponAllDrawingUpdate = true; + + // Prévisualisation de la prochaine valeur ("A") + int nextN = 1; + string tagStr = string.Format( + Root.TagFormatting, + nextN, + (char)(64 + nextN), // 'A' + (char)(96 + nextN) // 'a' + ); + + ret = string.Format( + "{{ \"OK\": true, \"Tool\": \"{0}\", \"NextTag\": \"{1}\" }}", + Tools.Names[Array.IndexOf(Tools.All, Tools.LetterTag)], + tagStr + ); + } + catch (Exception e) + { + resp.StatusCode = 500; + ret = string.Format("!!!! Exception: {0}", e.Message); + } + } + } + + + + // --- FIN nouveaux endpoints --- else if (req.Url.AbsolutePath == "/ChangePage") diff --git a/src/FormCollection.cs b/src/FormCollection.cs index a0be316..940efed 100644 --- a/src/FormCollection.cs +++ b/src/FormCollection.cs @@ -116,7 +116,11 @@ public static System.Windows.Forms.Cursor LoadCustomCursor(string path) public bool SnapWithoutClosing = false; - + public int LetterTag_Counter_Public + { + get => LetterTag_Counter; + set => LetterTag_Counter = value; + }