]> O.S.I.I.S - jp/crow.git/commitdiff
Merge branch 'master' of github.com:jpbruyere/Crow
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 30 Oct 2021 17:42:13 +0000 (19:42 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 30 Oct 2021 17:42:13 +0000 (19:42 +0200)
1  2 
Samples/common/src/SampleBase.cs

index ce043b37b24d5a33d585467e5c75cb968f458064,eee98f9a02e0346722227961e1bd9cc1b7642700..91b787fb1127c69222855644ac2f8fd3db180aab
@@@ -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) :
                        }
                        return base.OnKeyDown(e);
                }
 +              public IEnumerable<RandomProgress> 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<ValueChangeEventArgs> 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;
 +                      }
 +              }
        }
--}
++}