internal static MethodInfo SearchExtMethod (Type t, string methodName)
{
string key = t.Name + "." + methodName;
- if (knownExtMethods.ContainsKey (key))
- return knownExtMethods [key];
-
- //System.Diagnostics.Console.WriteLine ($"*** search extension method: {t};{methodName} => key={key}");
-
- MethodInfo mi = null;
- if (!TryGetExtensionMethods (Assembly.GetEntryAssembly (), t, methodName, out mi)) {
- if (!TryGetExtensionMethods (t.Module.Assembly, t, methodName, out mi)) {
- foreach (Assembly a in Interface.crowAssemblies) {
- if (TryGetExtensionMethods (a, t, methodName, out mi))
- break;
+ lock (knownExtMethods) {
+ if (knownExtMethods.ContainsKey (key))
+ return knownExtMethods [key];
+
+ //System.Diagnostics.Console.WriteLine ($"*** search extension method: {t};{methodName} => key={key}");
+
+ MethodInfo mi = null;
+ if (!TryGetExtensionMethods (Assembly.GetEntryAssembly (), t, methodName, out mi)) {
+ if (!TryGetExtensionMethods (t.Module.Assembly, t, methodName, out mi)) {
+ foreach (Assembly a in Interface.crowAssemblies) {
+ if (TryGetExtensionMethods (a, t, methodName, out mi))
+ break;
+ }
+ if (mi == null)
+ TryGetExtensionMethods (Assembly.GetExecutingAssembly (), t, methodName, out mi);//crow Assembly
}
- if (mi == null)
- TryGetExtensionMethods (Assembly.GetExecutingAssembly (), t, methodName, out mi);//crow Assembly
}
- }
- //add key even if mi is null to prevent searching again and again for propertyless bindings
- knownExtMethods.Add (key, mi);
- return mi;
+ //add key even if mi is null to prevent searching again and again for propertyless bindings
+ knownExtMethods.Add (key, mi);
+ return mi;
+ }
}
public static bool TryGetExtensionMethods (Assembly assembly, Type extendedType, string methodName, out MethodInfo foundMI)
}
}
- public void SetDash (double [] dashes, double offset)
+ public void SetDash (double [] dashes, double offset = 0)
{
NativeMethods.cairo_set_dash (handle, dashes, dashes.Length, offset);
}
/// query a repaint, if control is cached, cache will not be updated and simply repainted.
/// if not cached, repaint will trigger the onDraw method.
/// </summary>
+ /// <remark>
+ /// This could be usefull in widget with complex drawing, that need some markers on top: the main part
+ /// of the drawing could take place in the onDraw method, and the markers (single line, rectangle, ...)
+ /// could be drawn in the Paint method. Such widget must have 'CacheEnabled=true' and to simply update the
+ /// markers without a full redraw, just call 'RegisterForRepaint'.
+ ///
+ /// </remark>
public void RegisterForRepaint () {
if (RegisteredLayoutings == LayoutingType.None && !IsDirty)
IFace.EnqueueForRepaint (this);
+++ /dev/null
-<Project Sdk="Microsoft.NET.Sdk">
- <PropertyGroup>
- <OutputType>Library</OutputType>
- <TargetFrameworks>netstandard2.1</TargetFrameworks>
- <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
- </PropertyGroup>
- <ItemGroup>
- <PackageReference Include="glfw-sharp" Version="$(GlfwSharpVersion)" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="src\**\*.cs"/>
- </ItemGroup>
-</Project>
+++ /dev/null
-// Copyright (c) 2013-2021 Bruyère Jean-Philippe jp_bruyere@hotmail.com
-//
-// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
-
-using System;
-using System.IO;
-using System.Diagnostics;
-using System.Collections.Generic;
-using System.Linq;
-using Glfw;
-
-namespace CrowDbgShared
-{
- public delegate void InterfaceResizeDelegate(int a, int b);
- public delegate bool InterfaceMouseMoveDelegate(int a, int b);
- public delegate bool InterfaceMouseButtonDelegate(MouseButton button);
- public delegate void VoidDelegate();
- public delegate IntPtr IntPtrGetterDelegate();
-}
-
DbgWidgetRecord curWidget, hoverWidget;
DbgEvent curEvent, hoverEvent;
- List<DbgEvent> events = new List<DbgEvent> ();
- List<DbgWidgetRecord> widgets = new List<DbgWidgetRecord> ();
+ IList<DbgEvent> events = new List<DbgEvent> ();
+ IList<DbgWidgetRecord> widgets = new List<DbgWidgetRecord> ();
public DbgEvtType Filter {
RegisterForGraphicUpdate();
}
}
- public List<DbgEvent> Events {
+ public IList<DbgEvent> Events {
get => events;
set {
if (events == value)
RegisterForGraphicUpdate ();
}
}
- public List<DbgWidgetRecord> Widgets {
+ public IList<DbgWidgetRecord> Widgets {
get => widgets;
set {
if (widgets == value)
return;
hoverEvent = value;
NotifyValueChanged (nameof (HoverEvent), hoverEvent);
+ RegisterForRepaint ();
}
}
updateMargins ();
}
}
-
- void drawEvents (Context ctx, List<DbgEvent> evts)
+ RectangleD getWidgetEvtBounds (DbgEvent evt, ref Rectangle cb, double penY) {
+ double x = xScale * (evt.begin - minTicks - ScrollX);
+ double w = Math.Max (Math.Max (2.0, 2.0 * xScale), (double)(evt.end - evt.begin) * xScale);
+ if (x < 0.0) {
+ w += x;
+ x = 0.0;
+ }
+ x += leftMargin + cb.Left;
+ double rightDiff = x + w - cb.Right;
+ if (rightDiff > 0)
+ w -= rightDiff;
+ return new RectangleD(x, penY, w, fe.Height);
+ }
+ void drawEvents (Context ctx, IList<DbgEvent> evts)
{
if (evts == null || evts.Count == 0)
return;
penY += (lIdx) * fe.Height;
ctx.SetSource (evt.Color);
-
- double x = xScale * (evt.begin - minTicks - ScrollX);
- double w = Math.Max (Math.Max (2.0, 2.0 * xScale), (double)(evt.end - evt.begin) * xScale);
- if (x < 0.0) {
- w += x;
- x = 0.0;
- }
- x += leftMargin + cb.Left;
- double rightDiff = x + w - cb.Right;
- if (rightDiff > 0)
- w -= rightDiff;
- RectangleD r = new RectangleD(x, penY, w, fe.Height);
- ctx.Rectangle (r);
+ ctx.Rectangle (getWidgetEvtBounds (evt, ref cb, penY));
ctx.Fill ();
- /*if (evt == CurrentEvent) {
- r.Inflate(2,2);
- ctx.SetSource(Colors.White);
- ctx.Rectangle(r);
- ctx.Stroke();
- }*/
}
} else if (evt.type.HasFlag (DbgEvtType.IFace)) {
double x = xScale * (evt.begin - minTicks - ScrollX);
ctx.SetSource (0.1, 0.1, 0.1, 0.4);
ctx.Rectangle (ContextCoordinates (r));
ctx.Fill ();
+
+ if (hoverEvent is DbgWidgetEvent wevt) {
+ ctx.SetSource (1.0,1.0,1.0,0.7);
+ ctx.SetDash (new double[] {1, 2});
+ ctx.Rectangle ((Rectangle)getWidgetEvtBounds (wevt, ref cb, y).Inflated (1), 1);
+ }
}
if (currentLine >= ScrollY && currentLine < scrollY + visibleLines) {
ctx.SetSource (Colors.Black);
ctx.ShowText (str);
+
+
}
public override void OnLayoutChanges (LayoutingType layoutType)
{
if (lastLine >= 0 && hoverLine >= 0)
ScrollY += lastLine - hoverLine;
updateMouseLocalPos (e.Position);
- } else {
+ } else if (widgets != null) {
HoverWidget = (hoverLine < 0 || hoverLine >= widgets.Count) ? null : widgets [hoverLine];
//HoverEvent = hoverWidget?.Events.FirstOrDefault (ev => ev.begin <= hoverTick && ev.end >= hoverTick);
double tickPerPixel = (double)visibleTicks / ClientRectangle.Width;
static DebugInterface() {
DbgLogger.IncludeEvents = DbgEvtType.None;
DbgLogger.DiscardEvents = DbgEvtType.None;
- DbgLogger.ConsoleOutput = true;
+ DbgLogger.ConsoleOutput = false;
}
public DebugInterface (IntPtr hWin) : base (hWin)
{
NotifyValueChangedAuto (discardedEvents);
}
}
- public bool DebugLogToFile {
- get => initialized ? !(bool)fiDbg_ConsoleOutput.GetValue (dbgIFace) : false;
- set {
- if (!initialized || DebugLogToFile == value)
- return;
- fiDbg_ConsoleOutput.SetValue (dbgIFace, !value);
- NotifyValueChangedAuto (DebugLogToFile);
- }
- }
public string DebugLogFilePath {
get => Configuration.Global.Get<string> ("DebugLogFilePath");
set {
MouseWheelSpeed="3";
Font="mono, 8";
Background="Onyx";
+ CacheEnabled = "true";
}
DbgEventView {
Height="Fit";
Margin="0";
Width="24";
TextAlignment="Right";
+}
+
+DbgEventWidget {
+ CacheEnabled = "true";
}
\ No newline at end of file
</HorizontalStack>
<Label Background="Red" Foreground="White" Margin="5" Width="Stretched" Text="{../../../dbgIfaceWidget.CrowDebuggerErrorMessage}"
IsVisible="{../../../dbgIfaceWidget.CrowDebuggerNOK}"/>
- <HorizontalStack Height="Fit" Width="Stretched" IsEnabled="{../cbFile.IsChecked}" Background="Onyx" Margin="5">
+ <HorizontalStack Height="Fit" Width="Stretched" Background="Onyx" Margin="5">
<Label Text="Debug log output file:" Fit="true"/>
<TextBox Text="{²../../../../dbgIfaceWidget.DebugLogFilePath}" />
</HorizontalStack>
- <CheckBox Name="cbFile" Caption="Record to file" IsChecked="{²../../../dbgIfaceWidget.DebugLogToFile}" Background="Onyx"/>
<EnumSelector RadioButtonStyle="CheckBox2" Template="#Dbg.EnumSelector.template"
Background="Grey"
Caption="Recorded Events" EnumValue="{²RecordedEvents}" BitFieldExcludeMask="255" />
Recording="{²DebugLogRecording}"
IMLSource="{Source}"
CurrentException="{²CurrentException}"
- DiscardedEvents="{DiscardedEvents}" RecordedEvents="{RecordedEvents}" DebugLogToFile="{DebugLogToFile}"/>
+ DiscardedEvents="{DiscardedEvents}" RecordedEvents="{RecordedEvents}"/>
<Splitter/>
<!--<TabView>-->
<VerticalStack Name="Editor" Spacing="0">