OSDN Git Service

Fixes for Automatic startup
[automap/automap.git] / Automap / Subsystems / AutomapGUIDialog.cs
index a325263..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)
@@ -75,6 +75,10 @@ namespace Automap
                        txtNoteArea.fixedHeight = 24;
                        txtNoteArea.fixedWidth = 256;
 
+                       ElementBounds btnSnapshotArea = btnNoteArea.CopyOffsetedSibling(0, 64, 2, 5);
+                       btnNoteArea.fixedHeight = 24;
+                       btnNoteArea.fixedWidth = 28;
+
 
                        this.SingleComposer = capi.Gui.CreateCompo("automapControlPanel", dialogBounds)
                                .AddShadedDialogBG(bgBounds)
@@ -86,6 +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( ), key: _btnSnapKey)
                                .Compose();
 
                        //Controls for ALL Block & Entity Designators (Enable/Disable) <-- block edits while in 'Run' state
@@ -93,8 +98,8 @@ namespace Automap
                        //_automapSystem.Entity_Designators
                        //Renderer selection
                        //Message verbosity? Speed?
-
-
+                       var swAutostart = this.SingleComposer.GetSwitch(_swAutostart);
+                       swAutostart.On = this.configuration.Autostart;
 
                }
 
@@ -139,7 +144,7 @@ namespace Automap
                        var txtNote = this.SingleComposer.GetTextInput(_noteTextKey);
                        if (!String.IsNullOrWhiteSpace(txtNote.GetText()))
                        {
-                               noteCmd.Notation = txtNote.GetText();
+                               noteCmd.Notation = txtNote.GetText().Replace("\n", " ");
                                txtNote.SetValue(string.Empty);
 
                                capi.Event.PushEvent(AutomapSystem.AutomapCommandEventKey, noteCmd);
@@ -147,6 +152,15 @@ namespace Automap
                        return true;//FINDOUT: What does this DO?
                }
 
+               private bool TriggerSnapshot( )
+               {
+               var snappyCmd = new CommandData(CommandType.Snapshot);
+               
+               capi.Event.PushEvent(AutomapSystem.AutomapCommandEventKey, snappyCmd);
+               
+               return true;//FINDOUT: What does this DO?
+               }
+
                private void AutostartChange(bool startValue)
                {
                configuration.Autostart = startValue;           
@@ -172,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;
 
-               }
 
        }
 }