]> O.S.I.I.S - jp/crowedit.git/commitdiff
debug run mode, fixed log name option
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 17 Jul 2025 17:07:28 +0000 (19:07 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 17 Jul 2025 17:07:28 +0000 (19:07 +0200)
plugins/CECrowPlugin/src/CrowService.cs
plugins/CECrowPlugin/src/DebugInterface.cs
plugins/CECrowPlugin/src/DebugInterfaceWidget.cs
plugins/CECrowPlugin/ui/winConfiguration.crow

index 22902049d5385f5a2b738c2bf7f50ccf7f5171c7..b47295e67270b0f443db1ce4fe5bfc0430448345 100644 (file)
@@ -119,8 +119,10 @@ namespace CECrowPlugin
                        CMDOptions_SelectDebugLogDirectory = new ActionCommand ("...", () =>
                        {
                                FileDialog dlg = App.LoadIMLFragment<FileDialog> (@"
-                               <FileDialog Caption='Select Logs directory ' CurrentDirectory='{²DebugLogFileDirectory}'
-                                                       ShowFiles='false' ShowHidden='false' />");
+                               <FileDialog Caption='Select Logs directory '
+                                                       CurrentDirectory='{²DebugLogFileDirectory}'
+                                                       SelectedFile='{²DebugLogFileName}'
+                                                       ShowFiles='true' ShowHidden='false' />");
                                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<ForeignWidgetContainer>([new ForeignWidgetContainer(widgetType, instance)]);
                }
-               void getMouseScreenCoordinates (out int x, out int y) {
-                       x = mouseScreenPos.X;
-                       y = mouseScreenPos.Y;
-               }
                IEnumerable<object> 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<DbgEvent> events;
                IList<DbgWidgetRecord> widgets;
-               IList<DbgEvtType> recordedEvents = new ObservableList<DbgEvtType>(new DbgEvtType[] { DbgEvtType.Widget } );
+               IList<DbgEvtType> recordedEvents = new ObservableList<DbgEvtType>(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<string> ("DebugLogFileName", "crow.log");
+                       set {
+                               if (DebugLogFileName == value)
+                                       return;
+                               Configuration.Global.Set ("DebugLogFileName", value);
+                               NotifyValueChanged (value);
+                       }
+               }
                public bool DebugLogToFile {
                        get => Configuration.Global.Get<bool> (nameof(DebugLogToFile));
                        set {
@@ -847,6 +858,15 @@ namespace CECrowPlugin
                                DbgLogger.ConsoleOutput = !value;
                        }
                }
+               public bool ManualDebugLogFileName {
+                       get => Configuration.Global.Get<bool> (nameof(ManualDebugLogFileName));
+                       set {
+                               if (ManualDebugLogFileName == value)
+                                       return;
+                               Configuration.Global.Set (nameof(ManualDebugLogFileName), value);
+                               NotifyValueChanged(ManualDebugLogFileName);
+                       }
+               }
 
                public IList<DbgEvent> 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 {
index e8f86c77b182f2863373f301791872d99b2b2d80..a021908ee5bcb3535bd466acf3025e259d304062 100644 (file)
@@ -132,10 +132,10 @@ namespace CECrowPlugin
                Action<Exception> delCrowServiceSetCurrentException;
                Action<Type,object> delCrowServiceUpdateRootWidget;
                Action<string> delCrowServiceSetCurrentDesignId, delCrowServiceSetHoverDesignId;
-
+               Action delCrowServiceForceMousePosition;
 
                delegate void GetScreenCoordinateDelegateType(out int x, out int y);
-               GetScreenCoordinateDelegateType delCrowServiceGetScreenCoordinate;
+               //GetScreenCoordinateDelegateType delCrowServiceGetScreenCoordinate;
                Func<IEnumerable<object>> delCrowServiceGetStyling;
                Func<string, Stream> 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<Exception>)Delegate.CreateDelegate(typeof(Action<Exception>), crowService,
                                t.GetProperty("CurrentException").GetSetMethod(true));
                        delCrowServiceSetCurrentDesignId = (Action<string>)Delegate.CreateDelegate(typeof(Action<string>), crowService,
@@ -154,8 +155,8 @@ namespace CECrowPlugin
                        delCrowServiceUpdateRootWidget = (Action<Type,object>)Delegate.CreateDelegate(typeof(Action<Type,object>), 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<IEnumerable<object>>)Delegate.CreateDelegate (typeof (Func<IEnumerable<object>>), crowService,
                                t.GetMethod ("getStyling", BindingFlags.Instance | BindingFlags.NonPublic));
                        delCrowServiceGetStreamFromPath = (Func<string, Stream>)Delegate.CreateDelegate (typeof (Func<string, Stream>), 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
index e6ee64af594463fb03417622324bec6c768bf713..7fbaf5b4e93856855149553b282a6072558090c1 100644 (file)
@@ -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 ();
index 42f7c2796b1a0e34058661f7bfe98ede068142e2..966bd89ac802fb1f781412472b8c0bad2e26f72b 100644 (file)
@@ -1,44 +1,48 @@
 <?xml version="1.0"?>
-<DockWindow Caption="Crow Preview Configuration"  Width="400" Height="400">
+<DockWindow Caption="Crow Preview Configuration"  Width="800" Height="800">
        <VerticalStack RootDataLevel="true" Margin="5">
-               <HorizontalStack Height="Fit" Margin="5">
-                       <Label Text="Crow Service" Width="Stretched"/>
-                       <ListBox Data="{Commands}" Fit="true">
-                               <Template>
-                                       <HorizontalStack Name="ItemsContainer" />
-                               </Template>
-                               <ItemTemplate Path="#ui.IconCommand.itmp"/>
-                       </ListBox>
-               </HorizontalStack>
-               <GroupBox Caption="In design Crow Assembly" Height="Fit">
-                       <VerticalStack>
-                               <HorizontalStack Height="Fit" Spacing="5">
-                                       <Label Fit="true" Text="Assembly Path:"/>
-                                       <TextBox Height="Fit" Text="{²CrowDbgAssemblyLocation}" Margin="2"/>
-                                       <Image Width="30" Height="20" Path="#Crow.Icons.IconAlerte.svg" Visible="{ServiceIsInError}"/>
-                                       <Button Command="{CMDOptions_SelectCrowAssemblyLocation}" MinimumSize="0,0"/>
-                               </HorizontalStack>
-                               <HorizontalStack Height="Fit" Spacing="5">
-                                       <Label Fit="true" Text="Assembly Name:"/>
-                                       <Label Fit="true" Text="{CrowAssemblyName}"/>
-                               </HorizontalStack>
-                               <HorizontalStack Height="Fit" Spacing="5">
-                                       <CheckBox Style="StateBox" Caption="Design mode is enabled" IsChecked="{DesignModeEnabled}"/>
-                                       <CheckBox Style="StateBox" Caption="Debug logger is enabled" IsChecked="{DebugLogIsEnabled}"/>
-                               </HorizontalStack>
-                       </VerticalStack>
-               </GroupBox>
-               <Label Background="Red" Foreground="White" Margin="5" Width="Stretched" Text="{ServiceErrorMessage}"
-                       IsVisible="{ServiceIsInError}"/>
-               <ListBox Style="ScrollingListBox" Data="{CrowAssemblies}" MinimumSize="100,200" SelectedItem="{²SelectedCrowAssembly}"/>
-               <HorizontalStack Height="Fit" Width="Fit" HorizontalAlignment="Right">
-                       <Button Command="{CMDOptions_AddCrowAssembly}"/>
-                       <Button Command="{CMDOptions_RemoveCrowAssembly}"/>
-               </HorizontalStack>
-               <Spinner Caption="Zoom Factor" Value="{²ZoomFactor}" Minimum="0.2" Maximum="4.0" SmallIncrement="0.1" LargeIncrement="0.2"/>
-               <Spinner Caption="Refresh Rate (ms)" Value="{²RefreshRate}" Maximum="1000"/>
-               <Spinner Caption="Max Layout Try" Value="{²MaxLayoutingTries}" Maximum="1000"/>
-               <Spinner Caption="Max Layout Discard" Value="{²MaxDiscardCount}" Maximum="1000"/>
+               <!--<Expandable Caption="Crow Service Configuration" Width="Stretched">-->
+                       <HorizontalStack Height="Fit" Margin="5">
+                               <Label Text="Crow Service" Width="Stretched"/>
+                               <ListBox Data="{Commands}" Fit="true">
+                                       <Template>
+                                               <HorizontalStack Name="ItemsContainer" />
+                                       </Template>
+                                       <ItemTemplate Path="#ui.IconCommand.itmp"/>
+                               </ListBox>
+                       </HorizontalStack>
+                       <GroupBox Caption="In design Crow Assembly" Height="Fit">
+                               <VerticalStack>
+                                       <HorizontalStack Height="Fit" Spacing="5">
+                                               <Label Fit="true" Text="Assembly Path:"/>
+                                               <TextBox Height="Fit" Text="{²CrowDbgAssemblyLocation}" Margin="2"/>
+                                               <Image Width="30" Height="20" Path="#Crow.Icons.IconAlerte.svg" Visible="{ServiceIsInError}"/>
+                                               <Button Command="{CMDOptions_SelectCrowAssemblyLocation}" MinimumSize="0,0"/>
+                                       </HorizontalStack>
+                                       <HorizontalStack Height="Fit" Spacing="5">
+                                               <Label Fit="true" Text="Assembly Name:"/>
+                                               <Label Fit="true" Text="{CrowAssemblyName}"/>
+                                       </HorizontalStack>
+                                       <HorizontalStack Height="Fit" Spacing="5">
+                                               <CheckBox Style="StateBox" Caption="Design mode is enabled" IsChecked="{DesignModeEnabled}"/>
+                                               <CheckBox Style="StateBox" Caption="Debug logger is enabled" IsChecked="{DebugLogIsEnabled}"/>
+                                       </HorizontalStack>
+                               </VerticalStack>
+                       </GroupBox>
+                       <Label Background="Red" Foreground="White" Margin="5" Width="Stretched" Text="{ServiceErrorMessage}"
+                               IsVisible="{ServiceIsInError}"/>
+                       <ListBox Style="ScrollingListBox" Data="{CrowAssemblies}" MinimumSize="100,200" SelectedItem="{²SelectedCrowAssembly}" Height="100"/>
+                       <HorizontalStack Height="Fit" Width="Fit" HorizontalAlignment="Right">
+                               <Button Command="{CMDOptions_AddCrowAssembly}"/>
+                               <Button Command="{CMDOptions_RemoveCrowAssembly}"/>
+                       </HorizontalStack>
+               <!--</Expandable>
+               <Expandable Caption="Debug Interface Options" Width="Stretched">-->
+                       <Spinner Caption="Zoom Factor" Value="{²ZoomFactor}" Minimum="0.2" Maximum="4.0" SmallIncrement="0.1" LargeIncrement="0.2"/>
+                       <Spinner Caption="Refresh Rate (ms)" Value="{²RefreshRate}" Maximum="1000"/>
+                       <Spinner Caption="Max Layout Try" Value="{²MaxLayoutingTries}" Maximum="1000"/>
+                       <Spinner Caption="Max Layout Discard" Value="{²MaxDiscardCount}" Maximum="1000"/>
+               <!--</Expandable>-->
                <GroupBox Caption="Debug Logger" IsEnabled="{DebugLogIsEnabled}" Height="40%">
                        <HorizontalStack Margin="4">
                                <ListBox Data="{RecordedEvents}" SelectedItem="{²CurrentRecordedEvent}"/>
                                                <TextBox Text="{²DebugLogFileDirectory}"  />
                                                <Button Command="{CMDOptions_SelectDebugLogDirectory}" MinimumSize="0,0"/>
                                        </HorizontalStack>
+                                       <CheckBox Name="cbFileName" Caption="Fixed Log Name" IsChecked="{²ManualDebugLogFileName}" Background="Onyx"/>
+                                       <HorizontalStack Height="Fit" Width="Stretched" IsEnabled="{../cbFileName.IsChecked}" Background="Onyx" Margin="5">
+                                               <Label Text="Debug log file name:" Fit="true"/>
+                                               <TextBox Text="{²DebugLogFileName}"  />
+                                       </HorizontalStack>
                                        <Label Text="{CurrentRecordedEvent}"/>
                                        <EnumSelector RadioButtonStyle="CheckBoxEvtType" Template="#CECrowPlugin.ui.EnumSelector.template" Width="Stretched"
                                                Caption="Event Type to add for recording:" EnumValue="{²EvtTypeToAddForRecording}"  />