| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 | using Comal.Classes;using FastReport.Messaging.Xmpp;using InABox.Core;using InABox.DynamicGrid;using InABox.WPF;using PRS.Shared;using Syncfusion.DocIO.DLS;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Media.Imaging;using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;using ScriptEditor = InABox.DynamicGrid.ScriptEditorWindow;namespace PRSServer{    public class ScheduledScriptsGrid : DynamicDataGrid<ScheduledScript>    {        private const string DefaultScript = @"using System;using System.Collections.Generic;using System.Linq;using System.Runtime;using System.Windows;using InABox.Core;using InABox.Clients;using InABox.Logging;using Comal.Classes;public class Module{        public Object Data { get; set; }        public bool Execute()    {        return true;    }    }";        public ScheduledScriptsGrid()        {            Options.BeginUpdate().Clear().AddRange(                DynamicGridOption.AddRows,                DynamicGridOption.EditRows,                DynamicGridOption.DeleteRows).EndUpdate();            HiddenColumns.Add(x => x.Script);            ActionColumns.Add(new DynamicImageColumn(ScriptImage, ScriptAction));            ActionColumns.Add(new DynamicImageColumn(ScheduleImage, ScheduleAction));        }        protected override ScheduledScript CreateItem()        {            var item = base.CreateItem();            item.Script = DefaultScript;            return item;        }        private bool ScriptAction(CoreRow arg)        {            var script = LoadItem(arg);            var editor = new ScriptEditor(script.Script);            editor.OnSave += (e, args) =>            {                if (script.Script != editor.Script)                {                    script.Script = editor.Script;                    SaveItem(script);                }            };            if (editor.ShowDialog() == true)            {                if (script.Script != editor.Script)                {                    script.Script = editor.Script;                    SaveItem(script);                }            }            return false;        }        private bool ScheduleAction(CoreRow arg)        {            var script = LoadItem(arg);            var form = new ScheduleForm(script);            form.ShowDialog();            return false;        }        private BitmapImage ScriptImage(CoreRow arg)        {            return Properties.Resources.script.AsBitmapImage();        }        private BitmapImage ScheduleImage(CoreRow arg)        {            return Properties.Resources.schedule.AsBitmapImage();        }    }}
 |