| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 | using System;using System.IO;using System.Linq;using Comal.Classes;using InABox.Core;using InABox.DynamicGrid;using InABox.WPF;using ScriptEditor = InABox.DynamicGrid.ScriptEditorWindow;namespace PRSServer.Forms.WebStyles{    public class WebStyleGrid : DynamicDataGrid<WebStyle>    {        public WebStyleGrid()        {            ActionColumns.Add(new DynamicImageColumn(Properties.Resources.css.AsBitmapImage(), EditStyleAction));            OnAfterSave += (sender, items) =>            {                foreach (var style in items.Cast<WebStyle>()) SaveToLocalFolder(style);            };            OnDoubleClick += (sender, args) =>            {                if (SelectedRows.Length == 1) EditWebStyle(SelectedRows[0]);                args.Handled = true;            };        }        protected override void DoReconfigure(FluentList<DynamicGridOption> options)        {            base.DoReconfigure(options);            options.AddRange(DynamicGridOption.AddRows, DynamicGridOption.EditRows, DynamicGridOption.DeleteRows);        }        private bool EditStyleAction(CoreRow arg)        {            if (arg != null) EditWebStyle(arg);            return false;        }        private static void SaveToLocalFolder(WebStyle style)        {            if (CoreUtils.GetVersion() == "???")                File.WriteAllText(                    string.Format("{0}/WebBackup/Styles/{1}_{2}.css",                        Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),                        style.Code,                        style.ID                    ),                    style.Style                );        }        private void EditWebStyle(CoreRow arg)        {            var style = LoadItem(arg);            var editor = new ScriptEditor(style.Style, SyntaxLanguage.CSS, $"Style: {style}");            editor.OnSave += (e, args) =>            {                style.Style = editor.Script;                SaveToLocalFolder(style);                SaveItem(style);            };            editor.Show();        }    }}
 |