From: Jean-Philippe Bruyère Date: Thu, 17 Jul 2025 17:07:28 +0000 (+0200) Subject: debug run mode, fixed log name option X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=0386b8b7860cbd68d069cea48ad2805fad9b8926;p=jp%2Fcrowedit.git debug run mode, fixed log name option --- diff --git a/plugins/CECrowPlugin/src/CrowService.cs b/plugins/CECrowPlugin/src/CrowService.cs index 2290204..b47295e 100644 --- a/plugins/CECrowPlugin/src/CrowService.cs +++ b/plugins/CECrowPlugin/src/CrowService.cs @@ -119,8 +119,10 @@ namespace CECrowPlugin CMDOptions_SelectDebugLogDirectory = new ActionCommand ("...", () => { FileDialog dlg = App.LoadIMLFragment (@" - "); + "); dlg.DataSource = this; }); @@ -381,13 +383,13 @@ namespace CECrowPlugin #region DesignInterface callbacks //those methods are called by designed interface + public void ForceMousePosition() { + //todo: looks like having no effect + App.ForceMousePosition(); + } public void UpdateRootWidget(Type widgetType, object instance) { GraphicTree = new List([new ForeignWidgetContainer(widgetType, instance)]); } - void getMouseScreenCoordinates (out int x, out int y) { - x = mouseScreenPos.X; - y = mouseScreenPos.Y; - } IEnumerable getStyling () { if (App.CurrentProject is CERoslynPlugin.SolutionProject sol) { if (sol.StartupProject is CERoslynPlugin.MSBuildProject csprj) { @@ -700,7 +702,7 @@ namespace CECrowPlugin if (CurrentState == Status.Running) { try { - mouseScreenPos = _mouseScreenPos;//absolute on screen position. + mouseScreenPos = _mouseScreenPos; //e.Handled = delMouseMove ((int)(e.X / ZoomFactor), (int)(e.Y / ZoomFactor));//DebugInterface local coordinate for mouse. e.Handled = delMouseMove (e.X, e.Y);//DebugInterface local coordinate for mouse. } @@ -768,7 +770,7 @@ namespace CECrowPlugin public object LogMutex = new object (); IList events; IList widgets; - IList recordedEvents = new ObservableList(new DbgEvtType[] { DbgEvtType.Widget } ); + IList recordedEvents = new ObservableList(new DbgEvtType[] { DbgEvtType.Widget, DbgEvtType.IFace } ); DbgEvtType evtTypeToAddForRecording = DbgEvtType.None, currentRecordedEvent = DbgEvtType.None; public bool DebugLogIsEnabled { get => debugLogIsEnabled; @@ -837,6 +839,15 @@ namespace CECrowPlugin NotifyValueChanged (value); } } + public string DebugLogFileName { + get => Configuration.Global.Get ("DebugLogFileName", "crow.log"); + set { + if (DebugLogFileName == value) + return; + Configuration.Global.Set ("DebugLogFileName", value); + NotifyValueChanged (value); + } + } public bool DebugLogToFile { get => Configuration.Global.Get (nameof(DebugLogToFile)); set { @@ -847,6 +858,15 @@ namespace CECrowPlugin DbgLogger.ConsoleOutput = !value; } } + public bool ManualDebugLogFileName { + get => Configuration.Global.Get (nameof(ManualDebugLogFileName)); + set { + if (ManualDebugLogFileName == value) + return; + Configuration.Global.Set (nameof(ManualDebugLogFileName), value); + NotifyValueChanged(ManualDebugLogFileName); + } + } public IList Events { get => events; @@ -872,9 +892,11 @@ namespace CECrowPlugin return; Recording = false; if (DebugLogToFile) { - string logfilepath = Path.Combine(DebugLogFileDirectory, $"crow-{DateTime.Now:yyyy-MM-dd_hh-mm}.log"); - using (FileStream stream = new FileStream(logfilepath, FileMode.CreateNew, FileAccess.Write)) { + string logfilepath = Path.Combine(DebugLogFileDirectory, + ManualDebugLogFileName ? DebugLogFileName : $"crow-{DateTime.Now:yyyy-MM-dd_hh-mm}.log"); + using (FileStream stream = new FileStream(logfilepath, FileMode.Create, FileAccess.Write)) { writeLog(stream); + //todo: should be notified in crowedit logs MessageBox.ShowModal(App, MessageBox.Type.Information, $"Debug log saved to: {logfilepath}"); } } else { diff --git a/plugins/CECrowPlugin/src/DebugInterface.cs b/plugins/CECrowPlugin/src/DebugInterface.cs index e8f86c7..a021908 100644 --- a/plugins/CECrowPlugin/src/DebugInterface.cs +++ b/plugins/CECrowPlugin/src/DebugInterface.cs @@ -132,10 +132,10 @@ namespace CECrowPlugin Action delCrowServiceSetCurrentException; Action delCrowServiceUpdateRootWidget; Action delCrowServiceSetCurrentDesignId, delCrowServiceSetHoverDesignId; - + Action delCrowServiceForceMousePosition; delegate void GetScreenCoordinateDelegateType(out int x, out int y); - GetScreenCoordinateDelegateType delCrowServiceGetScreenCoordinate; + //GetScreenCoordinateDelegateType delCrowServiceGetScreenCoordinate; Func> delCrowServiceGetStyling; Func delCrowServiceGetStreamFromPath; FieldInfo fiWidget_design_id, fiPrivateContainer_child; @@ -143,7 +143,8 @@ namespace CECrowPlugin public void RegisterDebugInterfaceCallback (object crowService){ Type t = crowService.GetType(); - //delRegisterForRepaint = (Action)Delegate.CreateDelegate(typeof(Action), w, t.GetMethod("RegisterForRepaint")); + delCrowServiceForceMousePosition = (Action)Delegate.CreateDelegate(typeof(Action), crowService, + t.GetMethod("ForceMousePosition")); delCrowServiceSetCurrentException = (Action)Delegate.CreateDelegate(typeof(Action), crowService, t.GetProperty("CurrentException").GetSetMethod(true)); delCrowServiceSetCurrentDesignId = (Action)Delegate.CreateDelegate(typeof(Action), crowService, @@ -154,8 +155,8 @@ namespace CECrowPlugin delCrowServiceUpdateRootWidget = (Action)Delegate.CreateDelegate(typeof(Action), crowService, t.GetMethod("UpdateRootWidget")); - delCrowServiceGetScreenCoordinate = (GetScreenCoordinateDelegateType)Delegate.CreateDelegate(typeof(GetScreenCoordinateDelegateType), crowService, - t.GetMethod("getMouseScreenCoordinates", BindingFlags.Instance | BindingFlags.NonPublic)); + /*delCrowServiceGetScreenCoordinate = (GetScreenCoordinateDelegateType)Delegate.CreateDelegate(typeof(GetScreenCoordinateDelegateType), crowService, + t.GetMethod("getMouseScreenCoordinates", BindingFlags.Instance | BindingFlags.NonPublic));*/ delCrowServiceGetStyling = (Func>)Delegate.CreateDelegate (typeof (Func>), crowService, t.GetMethod ("getStyling", BindingFlags.Instance | BindingFlags.NonPublic)); delCrowServiceGetStreamFromPath = (Func)Delegate.CreateDelegate (typeof (Func), crowService, @@ -265,13 +266,13 @@ namespace CECrowPlugin } public override bool OnMouseMove(int x, int y) { - int deltaX = x - base.MousePosition.X; - int deltaY = y - base.MousePosition.Y; - - MousePosition = new Point(x,y); - MouseMoveEventArgs e = new MouseMoveEventArgs (x, y, deltaX, deltaY); - if (Edition) { + int deltaX = x - base.MousePosition.X; + int deltaY = y - base.MousePosition.Y; + + MousePosition = new Point(x,y); + MouseMoveEventArgs e = new MouseMoveEventArgs (x, y, deltaX, deltaY); + if (editHoverWidget != null) { //check topmost graphicobject first Widget topContainer = editHoverWidget; @@ -316,8 +317,8 @@ namespace CECrowPlugin } editHoverWidget = null; return false; - } else - return base.OnMouseMove(x, y); + } + return base.OnMouseMove(x, y); } public override bool OnMouseButtonDown(MouseButton button) { @@ -335,8 +336,10 @@ namespace CECrowPlugin public override void ForceMousePosition() { - delCrowServiceGetScreenCoordinate(out int x, out int y); - Glfw.Glfw3.SetCursorPosition (WindowHandle, x, y); + //delCrowServiceGetScreenCoordinate(out int x, out int y); + //Debug.WriteLine($"force mouse position: {x},{y}"); + //Glfw.Glfw3.SetCursorPosition (WindowHandle, x, y); + delCrowServiceForceMousePosition(); } public bool OnKeyDown (Glfw.Key key, int scancode, Glfw.Modifier modifiers) { @@ -438,5 +441,15 @@ namespace CECrowPlugin public void LockRenderMutex() => Monitor.Enter(this.UpdateMutex); public void UnlockRenderMutex() => Monitor.Exit(this.UpdateMutex); + + + /*protected override void processDrawing(IContext ctx) + { + base.processDrawing(ctx); + + ctx.Arc(MousePosition, 2, 0, Math.PI * 2.0); + ctx.SetSource(Colors.DarkRed); + ctx.Fill(); + }*/ } } \ No newline at end of file diff --git a/plugins/CECrowPlugin/src/DebugInterfaceWidget.cs b/plugins/CECrowPlugin/src/DebugInterfaceWidget.cs index e6ee64a..7fbaf5b 100644 --- a/plugins/CECrowPlugin/src/DebugInterfaceWidget.cs +++ b/plugins/CECrowPlugin/src/DebugInterfaceWidget.cs @@ -193,9 +193,12 @@ namespace CECrowPlugin public override void onKeyDown(object sender, KeyEventArgs e) => crowIFaceService?.onKeyDown(e); public override void onKeyUp(object sender, KeyEventArgs e) => crowIFaceService?.onKeyUp(e); public override void onKeyPress(object sender, KeyPressEventArgs e) => crowIFaceService?.onKeyPress(e); + Point localMousePos; public override void onMouseMove(object sender, MouseMoveEventArgs e) { Point m = ScreenPointToLocal (e.Position); - crowIFaceService?.onMouseMove(e.Position, new MouseMoveEventArgs(m.X,m.Y, e.XDelta, e.YDelta)); + localMousePos = m; + //Debug.WriteLine($"local mouse position: {m}"); + crowIFaceService?.onMouseMove(e.Position, new MouseMoveEventArgs (m.X, m.Y, e.XDelta, e.YDelta)); } public override void onMouseDown(object sender, MouseButtonEventArgs e) => crowIFaceService?.onMouseDown(e); public override void onMouseUp(object sender, MouseButtonEventArgs e) => crowIFaceService?.onMouseUp(e); @@ -215,6 +218,7 @@ namespace CECrowPlugin if (crowIFaceService != null && crowIFaceService.IsRunning && bmp != null) { //crowIFaceService.LockRenderMutex(); paintCache (ctx, Slot + Parent.ClientRectangle.Position); + if (crowIFaceService.EditMode) { if (hoverWidget != null && hoverWidget != currentWidget) { //currentWidget. @@ -234,7 +238,12 @@ namespace CECrowPlugin // ctx.Stroke(); //ctx.SetDash([0]); } + /*ctx.LineWidth = 1; + ctx.Arc(localMousePos, 3, 0, Math.PI * 2.0); + ctx.SetSource(Colors.Yellow); + ctx.Stroke();*/ } + //crowIFaceService.UnlockRenderMutex(); crowIFaceService.ResetDirtyState (); } @@ -255,6 +264,12 @@ namespace CECrowPlugin } } + public override MouseCursor MouseCursor { + get => base.MouseCursor; + set { + Console.WriteLine("set mouse cursor"); + } + } protected override void Dispose(bool disposing) { CMDRefresh?.Dispose (); diff --git a/plugins/CECrowPlugin/ui/winConfiguration.crow b/plugins/CECrowPlugin/ui/winConfiguration.crow index 42f7c27..966bd89 100644 --- a/plugins/CECrowPlugin/ui/winConfiguration.crow +++ b/plugins/CECrowPlugin/ui/winConfiguration.crow @@ -1,44 +1,48 @@  - + - - - - - -