Ejemplo n.º 1
0
        public EditScriptWindow(Script script, Dictionary <string, Script> scripts)
        {
            InitializeComponent();
            DataContext = this;
            SearchPanel.Install(scriptView);

            this._scripts = scripts;
            this.script   = script;

            if (script == null)
            {
                // This is a new script
                editorScript = new Script("New script", null, false, null);
            }
            else
            {
                // This is an existing script
                editorScript = script.Copy();
            }

            // See if there is the default value for this script is empty
            if (string.IsNullOrWhiteSpace(editorScript.defaultValue))
            {
                // No default; disable reset and show
                showDiffButton.IsEnabled       = false;
                resetToDefaultButton.IsEnabled = false;
            }

            scriptView.Text       = editorScript.Value;
            ScriptRecoveryService = new ScriptRecoveryService(this);
            ScriptRecoveryService.BeginScriptRecovery();
            scriptView.TextChanged += ScriptView_TextChanged;
        }
Ejemplo n.º 2
0
        public EditScriptWindow(Dictionary <string, Script> scripts, string name)
        {
            InitializeComponent();
            DataContext = this;
            SearchPanel.Install(scriptView);

            this._scripts     = scripts;
            this.originalName = name;

            scripts.TryGetValue(name, out _script);
            if (_script == null)
            {
                // This is a new script
                ScriptName        = "New script";
                ScriptDescription = null;
                ScriptValue       = null;
                Responder         = false;
                Priority          = 3;
            }
            else
            {
                // This is an existing script
                ScriptName         = _script.Name;
                ScriptDescription  = _script.Description;
                ScriptValue        = _script.Value;
                ScriptDefaultValue = _script.defaultValue;
                Responder          = _script.Responder;
                Priority           = _script.Priority;
            }

            // See if there is the default value for this script is empty
            if (string.IsNullOrWhiteSpace(ScriptDefaultValue))
            {
                // No default; disable reset and show
                showDiffButton.IsEnabled       = false;
                resetToDefaultButton.IsEnabled = false;
            }

            scriptView.Text       = scriptValue;
            ScriptRecoveryService = new ScriptRecoveryService(this);
            ScriptRecoveryService.BeginScriptRecovery();
            scriptView.TextChanged += ScriptView_TextChanged;
        }