OSDN Git Service

Fixes for Automatic startup
[automap/automap.git] / Automap / Subsystems / AutomapGUIDialog.cs
index d5a22a1..72471f0 100644 (file)
@@ -14,6 +14,7 @@ namespace Automap
                private const string _noteTextKey = @"edtNote";
                private const string _swAutostart = @"swAutostart";
                private const string _btnRunKey = @"btnRun";
+               private const string _btnSnapKey = @"btnSnap";
 
                private ILogger Logger;
                private PersistedConfiguration configuration;
@@ -32,11 +33,10 @@ namespace Automap
 
                public AutomapGUIDialog(ICoreClientAPI capi, AutomapSystem ams, PersistedConfiguration cfg) : base(capi)
                {
-
+                       configuration = cfg;
                        Logger = capi.Logger;
                        SetupDialog();
                        capi.Event.RegisterEventBusListener(AutomapStatusMsg, 1.0D, AutomapSystem.AutomapStatusEventKey);
-                       configuration = cfg;
                }
 
                public AutomapGUIDialog(ICoreClientAPI capi) : base(capi)
@@ -90,7 +90,7 @@ namespace Automap
                                .AddDynamicText("Idle.", CairoFont.WhiteSmallText().WithFontSize(12), EnumTextOrientation.Left, txtStatusBounds, _statusTextKey)
                                .AddTextInput(txtNoteArea, null, CairoFont.WhiteMediumText().WithFontSize(16), _noteTextKey)
                                .AddButton("Note:", CreateNote, btnNoteArea, CairoFont.ButtonText())
-                               .AddButton("Snapshot!", TriggerSnapshot, btnSnapshotArea, CairoFont.ButtonText( ))
+                               .AddButton("Snapshot!", TriggerSnapshot, btnSnapshotArea, CairoFont.ButtonText( ), key: _btnSnapKey)
                                .Compose();
 
                        //Controls for ALL Block & Entity Designators (Enable/Disable) <-- block edits while in 'Run' state
@@ -98,8 +98,8 @@ namespace Automap
                        //_automapSystem.Entity_Designators
                        //Renderer selection
                        //Message verbosity? Speed?
-
-
+                       var swAutostart = this.SingleComposer.GetSwitch(_swAutostart);
+                       swAutostart.On = this.configuration.Autostart;
 
                }
 
@@ -186,25 +186,17 @@ namespace Automap
                        statusText.SetNewText($"State: {lastState}, Total: {totalShards}, Delta: ±{changesThisTick} Nulls: {voidShards} ");
                        
                        if (!btnRun.On) btnRun.SetValue(true);
-
-                       LockGUIElements(true);  
+                                                       
                        }
                        else if (lastState == CommandType.Stop && btnRun.Enabled) {
                        statusText.SetNewText($"State: {lastState}, Total: {totalShards}, Nulls: {voidShards} ");                       
                        
                        if (btnRun.On) btnRun.SetValue(false);
-
-                       LockGUIElements(true);
+                                                       
                        }
                }
 
-               private void LockGUIElements(bool state)
-               {
-               var swAutostart = this.SingleComposer.GetSwitch(_swAutostart);
 
-               swAutostart.Enabled = state;
-
-               }
 
        }
 }