public void LoadScript(ScriptEntry script)
        {
            var context = DataContext as ScriptData;

            context.Name        = script.Name;
            context.Code        = script.Code;
            context.WorkshopID  = script.WorkshopID;
            context.KeepUpdated = script.KeepUpdated;
            context.Id          = script.Id;
            if (context.WorkshopID == 0)
            {
                HideWorkshopSettings();
            }
            hasScriptBeenLoaded = true;
        }
        public async void AddScript(object sender, RoutedEventArgs e)
        {
            Status.StatusMessage = "";
            Status.IsInProgress  = true;
            var shouldClose = false;
            var delay       = 3000;

            string statusMsg = "";

            if (!ulong.TryParse(WorkshopIDEditor.Text, out ulong workshopId))
            {
                statusMsg = "Invalid input! The workshop ID must be a positive number.";
                Log.Warn(statusMsg);
            }
            else
            {
                var script = new ScriptEntry
                {
                    WorkshopID = workshopId
                };
                if (!await script.UpdateFromWorkshopAsync(msg => { Status.StatusMessage += "\n>" + msg; }))
                {
                    statusMsg = "Failed to add script from workshop id";
                    Log.Error(statusMsg);
                }
                else
                {
                    shouldClose = true;
                    delay       = 1000;
                    statusMsg   = "Successfully added Script from Workshop.";
                    Log.Info(statusMsg);
                    ScriptManagerPlugin.Instance.Config.Whitelist.Add(script);
                }
            }
            Status.StatusMessage += "\n>" + statusMsg;

            await Task.Delay(delay);

            Status.IsInProgress = false;
            if (shouldClose)
            {
                Close();
            }
        }
        public void OpenAddFromCodeDialog(object sender, RoutedEventArgs e)
        {
            var editor = new ScriptEditor();

            editor.SaveAndClose += (object s, ScriptEditor.ScriptSaveEventArgs scriptData) =>
            {
                var scriptCode = scriptData.Script.Code.Replace("\r", "");
                //var scriptHash = ScriptManagerPlugin.GetMD5Hash(scriptCode);
                var scriptEntry = new ScriptEntry()
                {
                    Name    = scriptData.Script.Name,
                    Enabled = false
                };
                scriptEntry.Code = scriptCode;
                (DataContext as ScriptManagerConfig).Whitelist.Add(scriptEntry);
            };

            editor.Show();
        }