using FlashCap.Devices; using FlashCap.Utilities; using FlashCap; using Eto.Forms; using TimelapseApi; using System.Collections.ObjectModel; namespace Timelapse.Desktop { public class TimeSpanControl : StackLayout { private NumericStepper[] steppers=new NumericStepper[] { new NumericStepper {MinValue=0,MaxValue=int.MaxValue}, new NumericStepper {MinValue=0,MaxValue=23}, new NumericStepper {MinValue=0,MaxValue=60}, new NumericStepper {MinValue=0,MaxValue=60} }; private Label[] lbls=new Label[] { new Label {Text="Days: "}, new Label {Text="Hours: "}, new Label {Text="Minutes: "}, new Label {Text="Seconds: " } }; public TimeSpanControl() { foreach(var stepper in steppers) { stepper.ValueChanged += (sender,e)=>{ ValueChanged?.Invoke(this,EventArgs.Empty); }; } Orientation=Orientation.Vertical; StackLayout lyt=new StackLayout {Orientation = Orientation.Horizontal}; lyt.Items.Add(lbls[0]); lyt.Items.Add(steppers[0]); lyt.Items.Add(lbls[1]); lyt.Items.Add(steppers[1]); Items.Add(lyt); lyt=new StackLayout {Orientation=Orientation.Horizontal}; lyt.Items.Add(lbls[2]); lyt.Items.Add(steppers[2]); lyt.Items.Add(lbls[3]); lyt.Items.Add(steppers[3]); Items.Add(lyt); } public event EventHandler? ValueChanged; public TimeSpan Value {get {return new TimeSpan((int)steppers[0].Value,(int)steppers[1].Value,(int)steppers[2].Value,(int)steppers[3].Value);} set { steppers[0].Value=value.Days; steppers[1].Value = value.Hours; steppers[2].Value=value.Minutes; steppers[3].Value = value.Seconds; }} } public class TimelapseProjectSettings : Dialog { public TimelapseProjectSettings(TimelapseProject proj) { Title="Project Settings"; Button saveBtn=new Button {Text="Save"}; ComboBox cbox=new ComboBox(); if(proj.ProjectLocation!= null && proj.ProjectLocation.DirectoryExists("Sections")) foreach(var f in proj.ProjectLocation.GetDirectories("Sections")) { cbox.Items.Add(f); } cbox.Text = proj.SectionName; cbox.TextChanged += (sender,e)=>{ proj.SectionName =cbox.Text; }; DynamicLayout lyt=new DynamicLayout(); lyt.BeginVertical(); lyt.BeginHorizontal(); lyt.Add(new Label {Text="Section name:"}); lyt.EndBeginHorizontal(); lyt.Add(cbox,true); lyt.EndBeginHorizontal(); TabControl control = new TabControl(); TimeSpanControl ctl=new TimeSpanControl(); ctl.Value = proj.Interval; ctl.ValueChanged += (sender,e)=>{ proj.Interval = ctl.Value; }; StackLayout lyt0=new StackLayout(); lyt0.Orientation = Orientation.Vertical; lyt0.Items.Add(new Label {Text="Estimated Project Length:"}); TimeSpanControl estProjLen = new TimeSpanControl(); estProjLen.Value=proj.Interval.EstimatedProjectLength; estProjLen.ValueChanged += (sender,e)=>{ proj.Interval.EstimatedProjectLength = estProjLen.Value; }; lyt0.Items.Add(estProjLen); lyt0.Items.Add(new Label {Text="Estimated Video Length:"}); TimeSpanControl estVidLen = new TimeSpanControl(); estVidLen.Value=proj.Interval.EstimatedVideoLength; estVidLen.ValueChanged += (sender,e)=>{ proj.Interval.EstimatedVideoLength = estVidLen.Value; }; lyt0.Items.Add(estVidLen); control.Pages.Add(new TabPage {Content=lyt0,Text="Estimated"}); control.Pages.Add(new TabPage {Content=ctl,Text="Interval"}); control.SelectedIndex = proj.Interval.UseEstimated ? 0 : 1; control.SelectedIndexChanged += (sender,e)=>{ proj.Interval.UseEstimated = control.SelectedIndex == 1; }; lyt.Add(control,true); lyt.EndHorizontal(); lyt.EndBeginVertical(); lyt.BeginHorizontal(); lyt.AddSpace(true); lyt.Add(saveBtn); lyt.EndHorizontal(); lyt.EndVertical(); saveBtn.Click += (sender,e)=>{ this.Close(); }; Content=lyt; Resizable=true; } } }