add patch for stretching issue on AutoSize of RadTextBoxControl
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Pilz.UI.Telerik.Patches;
|
namespace Pilz.UI.Telerik.Patches;
|
||||||
|
|
||||||
@@ -6,6 +7,6 @@ public static class Patches
|
|||||||
{
|
{
|
||||||
public static void Initialize(Harmony harmony)
|
public static void Initialize(Harmony harmony)
|
||||||
{
|
{
|
||||||
harmony.PatchAll();
|
harmony.PatchAll(Assembly.GetExecutingAssembly());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using System.Reflection;
|
||||||
|
using Telerik.WinControls;
|
||||||
|
using Telerik.WinControls.UI;
|
||||||
|
|
||||||
|
namespace Pilz.UI.Telerik.Patches.TelerikUiForWinForms;
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(RadTextBoxControl))]
|
||||||
|
[HarmonyPatch("ProcessAutoSizeChanged")]
|
||||||
|
internal class RadTextBoxControl_PreventAutoStretchOnAutoSize
|
||||||
|
{
|
||||||
|
private static readonly MethodInfo m_get_RootElement = AccessTools.PropertyGetter(typeof(RadControl), nameof(RadControl.RootElement));
|
||||||
|
|
||||||
|
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
|
||||||
|
{
|
||||||
|
var ignored = 0;
|
||||||
|
var ignoring = false;
|
||||||
|
int getRootelementCallcount = 0;
|
||||||
|
|
||||||
|
foreach (var instruction in instructions)
|
||||||
|
{
|
||||||
|
if (instruction.Calls(m_get_RootElement))
|
||||||
|
{
|
||||||
|
getRootelementCallcount += 1;
|
||||||
|
if (getRootelementCallcount == 2)
|
||||||
|
ignoring = true;
|
||||||
|
}
|
||||||
|
if (ignoring)
|
||||||
|
{
|
||||||
|
if (ignored >= 4)
|
||||||
|
ignoring = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ignored += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
yield return instruction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user