diff --git a/Timelapse.Pack/Program.cs b/Timelapse.Pack/Program.cs index 53bbf90..282b505 100644 --- a/Timelapse.Pack/Program.cs +++ b/Timelapse.Pack/Program.cs @@ -82,12 +82,12 @@ public class TimelapsePack { //build the library Process p = new Process(); - p.StartInfo = new ProcessStartInfo("dotnet","build --configuration Release"); + p.StartInfo = new ProcessStartInfo("dotnet","publish --configuration Release"); p.StartInfo.UseShellExecute=false; if(p.Start()) { p.WaitForExit(); - return Path.Combine(Environment.CurrentDirectory,"bin","Release","net6.0",$"{curDirName}.dll"); + return Path.Combine(Environment.CurrentDirectory,"bin","Release","net6.0","publish",$"{curDirName}.dll"); }else{ Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ERROR: process not started"); diff --git a/Timelapse.Pack/Timelapse.Pack.csproj b/Timelapse.Pack/Timelapse.Pack.csproj index e66f543..4b06c59 100644 --- a/Timelapse.Pack/Timelapse.Pack.csproj +++ b/Timelapse.Pack/Timelapse.Pack.csproj @@ -17,9 +17,9 @@ Tesses.TimelapsePack Mike Nolan Tesses - 1.0.2 - 1.0.2 - 1.0.2 + 1.0.3 + 1.0.3 + 1.0.3 Extension Packaging tool for TimelapseNow GPL-3.0-only true diff --git a/Timelapse/Program.cs b/Timelapse/Program.cs index cc2d041..3c36188 100644 --- a/Timelapse/Program.cs +++ b/Timelapse/Program.cs @@ -324,11 +324,21 @@ public class MainForm : Form svr.Listen(); }); t.Start(); - + Instance.HasCamera=c !=null; if(c == null) { - MessageBox.Show("You will need to restart app to record"); - return; + + Thread t2=new Thread(async()=>{ + while(true) + { + Image rgb=new Image(Instance.Model.blankCameraWidth,Instance.Model.blankCameraHeight,new Rgb24(0,0,0)); + await FrameChanged(rgb); + + Thread.Sleep(50); + } + }); + t2.Start(); + return; } //////////////////////////////////////////////// diff --git a/TimelapseApi/Api.cs b/TimelapseApi/Api.cs index 97655e0..030f7ce 100644 --- a/TimelapseApi/Api.cs +++ b/TimelapseApi/Api.cs @@ -27,7 +27,9 @@ public class GuiData Instance.Extensions.Add(ext); await ext._Create(); } + Instance.SetPriority(); } + public void FSChanged() { if(Instance != null) @@ -52,8 +54,22 @@ public class GuiData public IEnumerable<(Func ShareActionAsync,string Text,TimelapseExtension extension)>? Share {get {if(Instance==null) return null;return Instance._share;}} public int CurrentFSIndex {get;set;} } +internal class PriorityCompare : IComparer<(Func, Task> Handler, string HandlerName, TimelapseExtension Extension, int Priority)> +{ + public int Compare((Func, Task> Handler, string HandlerName, TimelapseExtension Extension, int Priority) x, (Func, Task> Handler, string HandlerName, TimelapseExtension Extension, int Priority) y) + { + + return y.Priority.CompareTo(x.Priority); + } +} public class Api { + internal void SetPriority() + { + _frameHandlers.Sort(new PriorityCompare()); + } + + public bool HasCamera {get;set;} public TimelapseSettingsModel Model = LoadModel(); internal static string ModelLocation = GetInternalFile("config.json"); private static TimelapseSettingsModel LoadModel() @@ -193,7 +209,7 @@ public class Api return fs; } - internal List<(Func,Task> Handler,string HandlerName, TimelapseExtension Extension)> _frameHandlers=new List<(Func, Task> Handler,string HandlerName, TimelapseExtension Extension)>(); + internal List<(Func,Task> Handler,string HandlerName, TimelapseExtension Extension,int Priority)> _frameHandlers=new List<(Func, Task> Handler,string HandlerName, TimelapseExtension Extension,int Priority)>(); internal List<(Func Dialog,string Text,TimelapseExtension Extension)> _extSettings= new List<(Func Dialog,string Text,TimelapseExtension Extension)>(); diff --git a/TimelapseApi/ExtensionFeatures.cs b/TimelapseApi/ExtensionFeatures.cs index 05c8b78..db9af37 100644 --- a/TimelapseApi/ExtensionFeatures.cs +++ b/TimelapseApi/ExtensionFeatures.cs @@ -22,9 +22,7 @@ public sealed class ExtensionFeatures } public ExtensionFeatures RegisterAsyncFrameHandler(Func,Task> handler,string handlerName) { - if(!Valid || Instance == null) return this; - Instance._frameHandlers.Add((handler,handlerName,Extension)); - return this; + return RegisterAsyncFrameHandler(handler,handlerName,10000); } public ExtensionFeatures RegisterFileSystem(TimelapseFileSystem fs,string name) { @@ -32,6 +30,12 @@ public sealed class ExtensionFeatures Instance._fs.Add((fs,name,Extension)); return this; } + public ExtensionFeatures RegisterAsyncFrameHandler(Func,Task> handler,string handlerName,int priority) + { + if(!Valid || Instance == null) return this; + Instance._frameHandlers.Add((handler,handlerName,Extension,priority)); + return this; + } public ExtensionFeatures RegisterFrameHandler(Func,bool> handler,string handlerName) { if(!Valid) return this; @@ -46,6 +50,20 @@ public sealed class ExtensionFeatures },handlerName); return this; } + public ExtensionFeatures RegisterFrameHandler(Func,bool> handler,string handlerName,int priority) + { + if(!Valid) return this; + RegisterAsyncFrameHandler(async(e)=>{ + if(handler !=null) + { + return await Task.Run(()=>{ + return handler(e); + }); + } + return true; + },handlerName,priority); + return this; + } public ExtensionFeatures RegisterExport(Func>,string,CancellationToken,Task> export,FileFilter[] filter,string text) { if(!Valid || Instance == null) return this; diff --git a/TimelapseApi/ExtensionLoader.cs b/TimelapseApi/ExtensionLoader.cs index 692dcfa..99c8891 100644 --- a/TimelapseApi/ExtensionLoader.cs +++ b/TimelapseApi/ExtensionLoader.cs @@ -56,6 +56,7 @@ public class ExtensionLoader ext2.Instance=instance; instance.Extensions.Add(ext2); await ext2._Create(); + instance.SetPriority(); } } } diff --git a/TimelapseApi/TimelapseSettings.cs b/TimelapseApi/TimelapseSettings.cs index 7eb367c..eb23af4 100644 --- a/TimelapseApi/TimelapseSettings.cs +++ b/TimelapseApi/TimelapseSettings.cs @@ -187,7 +187,18 @@ internal class TimelapseSettings : Dialog }; DynamicLayout lyt1=new DynamicLayout(); Scrollable scrollable=new Scrollable(); - + GroupBox szRow=new GroupBox {Text="Blank camera size"}; + NumericStepper blankWidth=new NumericStepper{Value=api.Model.blankCameraWidth,MinValue=120,MaxValue=65535}; + NumericStepper blankHeight =new NumericStepper{Value=api.Model.blankCameraHeight,MinValue=90,MaxValue=65535}; + + DynamicLayout lyt3=new DynamicLayout(); + lyt3.BeginVertical(); + lyt3.BeginHorizontal(); + lyt3.Add(blankWidth,true); + lyt3.Add(blankHeight,true); + lyt3.EndHorizontal(); + lyt3.EndVertical(); + szRow.Content=lyt3; DynamicLayout lyt2=new DynamicLayout(); scrollable.Content=lyt2; lyt2.BeginVertical(); @@ -206,6 +217,7 @@ internal class TimelapseSettings : Dialog lyt2.AddRow(installExtension); lyt2.AddRow(enableExt); lyt2.AddRow(useCustomFilePickerForNativeFS); + lyt2.AddRow(szRow); lyt2.AddRow(null); lyt2.EndVertical(); @@ -218,7 +230,8 @@ internal class TimelapseSettings : Dialog saveBtn.Click += (sender,e)=>{ api.Model.canBlockFrames=blockBoxState; api.Model.canOverlayVideo=overLayBoxState; - + api.Model.blankCameraWidth=(int)blankWidth.Value; + api.Model.blankCameraHeight=(int)blankHeight.Value; api.Model.deniedBlockExtensions.Clear(); api.Model.deniedOverlayExtensions.Clear(); api.Model.enableWebServer=enableServer.Checked.GetValueOrDefault(); diff --git a/TimelapseApi/TimelapseSettingsModel.cs b/TimelapseApi/TimelapseSettingsModel.cs index e5c8866..3b786dc 100644 --- a/TimelapseApi/TimelapseSettingsModel.cs +++ b/TimelapseApi/TimelapseSettingsModel.cs @@ -11,8 +11,12 @@ public class TimelapseSettingsModel timelapsePort=49290; canBlockFrames=true; addExtensionOnInstall=true; + blankCameraHeight=720; + blankCameraWidth=1280; } + public int blankCameraWidth {get;set;} + public int blankCameraHeight {get;set;} public bool useCustomFilePickerForNativeFS {get;set;} public bool addExtensionOnInstall {get;set;} public bool canOverlayVideo {get;set;}