diff --git a/program/Logger.cs b/program/Logger.cs new file mode 100644 index 0000000..85b0efe --- /dev/null +++ b/program/Logger.cs @@ -0,0 +1,69 @@ +using System; +using System.IO; +using System.Text; + +/// Append-only text log next to the .exe: logs/ears-YYYYMMDD.log +public static class Logger +{ + private static readonly object _gate = new object(); + private static string _path; + private static bool _failed; + + public static void Write(string message) + { + Write(null, message); + } + + public static void Write(string tag, string message) + { + if (_failed) return; + + string line = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + + (string.IsNullOrEmpty(tag) ? " " : " [" + tag + "] ") + + message; + + lock (_gate) + { + try + { + if (_path == null) _path = Init(); + File.AppendAllText(_path, line + Environment.NewLine, Encoding.UTF8); + } + catch (Exception ex) + { + _failed = true; // never let logging crash the app + Console.WriteLine("[Logger] disabled: " + ex.Message); + } + } + } + + public static void Write(string tag, string format, params object[] args) + { + Write(tag, string.Format(format, args)); + } + + public static void Exception(string tag, Exception ex) + { + Write(tag, ex.GetType().Name + ": " + ex.Message); + Write(tag, ex.StackTrace ?? "(no stack)"); + } + + private static string Init() + { + string dir = Path.Combine( + Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), + "logs"); + + Directory.CreateDirectory(dir); + + string path = Path.Combine(dir, "ears-" + DateTime.Now.ToString("yyyyMMdd") + ".log"); + + File.AppendAllText(path, + Environment.NewLine + + "=== session start " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + + " (" + Environment.OSVersion.Platform + ") ===" + Environment.NewLine, + Encoding.UTF8); + + return path; + } +} \ No newline at end of file diff --git a/program/MainWindow.cs b/program/MainWindow.cs index 083aa67..2455c89 100644 --- a/program/MainWindow.cs +++ b/program/MainWindow.cs @@ -55,7 +55,7 @@ private static Builder CreateBuilder() { var builder = new Builder(); - builder.AddFromFile("homepageallv5.glade"); + builder.AddFromFile("homepageallv6.glade"); return builder; } diff --git a/program/MapWindow.cs b/program/MapWindow.cs index 5c74aa9..e18eb72 100644 --- a/program/MapWindow.cs +++ b/program/MapWindow.cs @@ -9,6 +9,20 @@ [UI] private Label MapTitleLabel = null; [UI] private Button MapBackButton = null; + [UI] private Label MapCaseLabel = null; + [UI] private RadioButton BodySkeletonRadio = null; + [UI] private RadioButton BodyJacketRadio = null; + [UI] private ComboBoxText JacketSizeCombo = null; + [UI] private RadioButton ViewFrontRadio = null; + [UI] private RadioButton ViewBackRadio = null; + [UI] private RadioButton ViewRightRadio = null; + [UI] private RadioButton ViewLeftRadio = null; + [UI] private CheckButton HideCircleCheck = null; + [UI] private CheckButton BlackAudioCheck = null; + [UI] private Button SoundTestButton = null; + [UI] private TextView MapLogView = null; + [UI] private Box MapControlSlots = null; + private readonly Language _lang; private readonly SoundLooper _sound = new SoundLooper(); @@ -29,6 +43,7 @@ _lang.Register("MapBackButton", MapBackButton); _lang.RegisterDynamic("MapTitleLabel", MapTitleLabel); + _sound.Log += msg => Logger.Write("sound", msg); } /// Called when a disease is picked. Loads images, starts the loop. @@ -40,6 +55,8 @@ _body = LoadPixbuf(bodyPath, false); _map = LoadPixbuf(mapPath, true); // true = key out black + Logger.Write("case", "open: " + title + " | map=" + mapPath + " | sound=" + soundPath); + MapArea.QueueDraw(); _sound.Start(soundPath); } @@ -48,6 +65,7 @@ public void StopSession() { _sound.Stop(); + Logger.Write("case", "closed"); } private void OnBackClicked(object sender, EventArgs e) @@ -86,7 +104,9 @@ { if (string.IsNullOrEmpty(path) || !File.Exists(path)) { - Console.WriteLine("[MapWindow] image not found: " + path); + // Console.WriteLine("[MapWindow] image not found: " + path); + Logger.Write("map", "image not found: " + path); + return null; } @@ -101,7 +121,9 @@ } catch (Exception ex) { - Console.WriteLine("[MapWindow] load failed " + path + ": " + ex.Message); + // Console.WriteLine("[MapWindow] load failed " + path + ": " + ex.Message); + Logger.Write("map", "image not found: " + path); + return null; } } diff --git a/program/homepageallv6.glade b/program/homepageallv6.glade new file mode 100644 index 0000000..4630bf4 --- /dev/null +++ b/program/homepageallv6.glade @@ -0,0 +1,828 @@ + + + + + + False + + + True + True + False + False + + + + True + False + 3 + 5 + + + Normal Session + True + True + True + 50 + 50 + 50 + 50 + True + True + + + 1 + 1 + + + + + Position Recording Mode + True + True + True + 50 + 50 + 50 + 50 + True + True + + + 1 + 2 + + + + + Exam Mode + True + True + True + 50 + 50 + 50 + 50 + True + True + + + 1 + 3 + + + + + A / あ + True + True + True + True + + + 3 + 0 + + + + + True + False + Language + + + 2 + 0 + + + + + Close + True + True + True + True + + + 4 + 4 + + + + + Settings + True + True + True + + + 4 + 3 + + + + + True + False + network-offline + 6 + + + 4 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + False + 3 + 3 + True + + + True + False + center + True + True + COM Port + + + 0 + 0 + + + + + True + False + center + True + True + + + 1 + 0 + + + + + Connect + True + True + True + start + center + True + True + + + 2 + 0 + + + + + Auto Connect + True + True + True + center + start + True + True + + + 1 + 1 + + + + + Back + True + True + True + end + end + True + True + + + 2 + 2 + + + + + True + False + Log + + + 0 + 2 + + + + + True + True + True + True + in + + + True + True + False + True + + + + + 1 + 2 + + + + + True + False + vertical + + + Refresh Ports + True + True + True + center + start + + + False + True + 0 + + + + + True + False + Disconnected + + + False + True + 1 + + + + + 2 + 1 + + + + + + + + 1 + + + + + True + False + vertical + + + True + False + label + + + + + + False + True + 0 + + + + + True + True + False + False + never + in + + + True + False + + + + True + False + 6 + 6 + True + + + + + + + + + + + + + + + + + + + + + + + + + True + True + 1 + + + + + Back + True + True + True + end + True + right + + + False + True + 4 + + + + + 2 + + + + + True + False + horizontal + 12 + + + True + True + 340 + never + none + + + True + False + + + True + False + vertical + 10 + 12 + 12 + 12 + 12 + + + True + False + 0 + in + + + True + False + - + True + 0 + 8 + 8 + 6 + 6 + + + + + True + False + 選択中の症例 + + + + + False + True + 0 + + + + + True + False + 0 + in + + + True + False + vertical + 8 + 8 + 6 + 6 + + + スケルトン + True + True + False + True + True + + + False + True + 0 + + + + + ジャケット + True + True + False + True + BodySkeletonRadio + + + False + True + 1 + + + + + + + True + False + 体の画像選択 + + + + + False + True + 1 + + + + + True + False + 8 + + + True + False + サイズ: + + + False + True + 0 + + + + + True + False + 0 + + L + XL + + + + False + True + 1 + + + + + False + True + 2 + + + + + True + False + 0 + in + + + True + False + True + 8 + 8 + 6 + 6 + + + + True + True + False + True + False + + + True + True + 0 + + + + + + True + True + False + False + ViewFrontRadio + + + True + True + 1 + + + + + + True + True + False + False + ViewFrontRadio + + + True + True + 2 + + + + + + True + True + False + False + ViewFrontRadio + + + True + True + 3 + + + + + + + True + False + 視点 + + + + + False + True + 3 + + + + + 番号を隠す + True + True + False + True + True + + + False + True + 4 + + + + + 黒画素でも再生 + True + True + False + True + + + False + True + 5 + + + + + 再生テスト + True + True + True + + + False + True + 6 + + + + + True + False + vertical + 8 + True + + + True + True + 7 + + + + + 戻る + True + True + True + end + + + False + True + 8 + + + + + + + + + False + True + 0 + + + + + True + False + vertical + 6 + True + 12 + 12 + 12 + + + True + False + label + + + + + + False + True + 0 + + + + + True + False + True + True + + + True + True + 1 + + + + + True + True + 1 + + + + + 3 + + + + + + + + +