From: Jean-Philippe Bruyère Date: Sat, 30 Oct 2021 17:42:13 +0000 (+0200) Subject: Merge branch 'master' of github.com:jpbruyere/Crow X-Git-Tag: v0.9.8-beta~13 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=08f31af885e04034aa16fa903a65b4ba84efbb2a;p=jp%2Fcrow.git Merge branch 'master' of github.com:jpbruyere/Crow --- 08f31af885e04034aa16fa903a65b4ba84efbb2a diff --cc Samples/common/src/SampleBase.cs index ce043b37,eee98f9a..91b787fb --- a/Samples/common/src/SampleBase.cs +++ b/Samples/common/src/SampleBase.cs @@@ -17,7 -16,29 +17,6 @@@ namespace Sample { public class SampleBase : Interface { -#if NETCOREAPP - static IntPtr resolveUnmanaged(Assembly assembly, String libraryName) - { -- - switch (libraryName) - { - case "cairo": - return NativeLibrary.Load("cairo-2", assembly, null); - case "glfw3": - return NativeLibrary.Load("glfw", assembly, null); - case "rsvg-2.40": - return NativeLibrary.Load("rsvg-2", assembly, null); - } - Console.WriteLine($"[UNRESOLVE] {assembly} {libraryName}"); - return IntPtr.Zero; - } - static SampleBase() - { - System.Runtime.Loader.AssemblyLoadContext ctx = - System.Runtime.Loader.AssemblyLoadContext.GetLoadContext(Assembly.GetExecutingAssembly()); - ctx.ResolvingUnmanagedDll += resolveUnmanaged; - } -#endif public SampleBase(IntPtr hWin) : base(800, 600, hWin) { } public SampleBase() : base(800, 600, true, true) { } public SampleBase(int width, int height, bool startUIThread, bool createSurface) : @@@ -418,63 -439,5 +417,63 @@@ } return base.OnKeyDown(e); } + public IEnumerable RandomProgressList { + get { + for (int i=0; i< RandomProgressItemCount; i++) + yield return new RandomProgress (); + } + } + int randomProgressItemCount = 10; + public int RandomProgressItemCount { + get => randomProgressItemCount; + set { + if (randomProgressItemCount == value) + return; + randomProgressItemCount = value; + NotifyValueChanged (randomProgressItemCount); + NotifyValueChanged ("RandomProgressList", RandomProgressList); + } + } + + public class RandomProgress : IValueChange { + static Random rnd = new Random(); + public event EventHandler ValueChanged; + public void NotifyValueChanged(object _value, [CallerMemberName] string caller = null) + => ValueChanged.Raise(this, new ValueChangeEventArgs(caller, _value)); + public void NotifyValueChanged(string membername, object _value) + => ValueChanged.Raise(this, new ValueChangeEventArgs(membername, _value)); + public RandomProgress () { + step = rnd.Next (10); + max = rnd.Next (100, 1000); + sleep = rnd.Next (2,200); + Thread t = new Thread(increment); + t.IsBackground = true; + t.Start (); + + NotifyValueChanged ("Maximum", max); + } + int val, step, max, sleep; + public int Value { + get => val; + set { + if (val == value) + return; + val = value; + NotifyValueChanged (val); + } + } + public int Maximum => max; + + void increment() { + Stopwatch sw = Stopwatch.StartNew(); + while (sw.ElapsedMilliseconds < 10000) { + Value += step; + if (Value > max) + Value = 0; + Thread.Sleep (sleep); + } + Value = max; + } + } } --} ++}