Beispiel #1
0
        /*protected override CreateParams CreateParams {
         *  get {
         *      var parms = base.CreateParams;
         *      //parms.ExStyle |= 0x02000000;  // Turn on WS_EX_COMPOSITED
         *      //parms.Style &= ~0x02000000;  // Turn off WS_CLIPCHILDREN
         *      return parms;
         *  }
         * }*/

        public FormEdit(EnvValue value = null)
        {
            InitializeComponent();
            this.value                        = value;
            name.TextTransformer             += validateName;
            text.TextChanged                 += textChanged;
            listEditorExEdit.InputTextReq    += listEditorExEdit_InputTextReq;
            listEditorExEdit.SizeHint        += listEditorExEdit_SizeHint;
            listEditorExEdit.SplitterHintReq += listEditorExEdit_SplitterHintReq;
            listEditorExEdit.SaveUrgent      += toRawText;
            listEditorExEdit.LengthSignal    += showLength;
            diffW = (Width - listEditorExEdit.Width) + 20;
            diffH = (Height - listEditorExEdit.Height) + 100;
            setTitle();
            load();
        }
Beispiel #2
0
        public static int ImportValues(string filepath)
        {
            var stream = new StreamReader(File.Open(filepath, FileMode.Open, FileAccess.Read, FileShare.None));
            int errors = 0;

            while (!stream.EndOfStream)
            {
                var line  = stream.ReadLine();
                var match = Regex.Match(line, @"^(\w+?)(\*?)\\([A-Za-z0-9#$'()*+,\-.?@[\]_`{}~ ]+?)=(.+)$");
                if (!match.Success)
                {
                    errors++;
                    continue;
                }
                var grps = match.Groups;
                var env  = new EnvValue()
                {
                    Target     = (EVT)Enum.Parse(TYPE_EVT, grps[1].Value),
                    Expandable = grps[2].Length > 0,
                    Name       = grps[3].Value,
                    Value      = Encoding.Unicode.GetString(Convert.FromBase64String(grps[4].Value))
                };
                var existing = Data.FindIndex(e => env > e);
                if (existing != -1)
                {
                    Data[existing] = env;
                }
            }
            stream.Close();
            stream.Dispose();
            if (errors == 0)
            {
                SystemSounds.Asterisk.Play();
            }
            return(errors);
        }
Beispiel #3
0
 public EnvValue(EnvValue from)
 {
     Name   = from.Name;
     Target = from.Target;
     Value  = from.Value;
 }
Beispiel #4
0
        bool save(bool askFirst = false)   //returns true if a choice is made
        {
            if (tabs.SelectedIndex == 1)
            {
                toRawText();
            }
            var t = ((EnumItem <EVT>)category.SelectedItem).value;
            var n = name.Text;
            var e = chkExpand.Checked;
            var v = chkShowExp.Checked ? original : text.Text;

            if (value != null
             ? (value.Target == t && value.Name == n && (value.Expandable == null || value.Expandable == e) && value.Value == v)
             : (t == NEW_INDEX && n == NEW_NAME && !e && v.Length == 0))
            {
                Saved?.Invoke(this, false);
                return(true);
            }
            DialogResult r;

            if (askFirst)
            {
                r = MessageBox.Show(
                    "This value has been modified. Save the changes?",
                    Program.NAME,
                    MessageBoxButtons.YesNoCancel,
                    MessageBoxIcon.Warning
                    );
                if (r != DialogResult.Yes)
                {
                    return(r == DialogResult.No);
                }
            }
            string err     = "";
            bool?  canSave = CanSave?.Invoke(this, t, n, out err);

            if (canSave == null)
            {
                r = MessageBox.Show(
                    "Before-save check not assigned! Save anyways?",
                    Program.NAME,
                    MessageBoxButtons.OKCancel,
                    MessageBoxIcon.Warning);
            }
            else if (!canSave.Value)
            {
                r = MessageBox.Show(
                    err + ". Save anyways?",
                    Program.NAME,
                    MessageBoxButtons.OKCancel,
                    MessageBoxIcon.Error);
            }
            else
            {
                r = DialogResult.OK;
            }
            if (r != DialogResult.OK)
            {
                return(false);
            }
            value            = value ?? new EnvValue();
            Tag              = value;
            value.Target     = t;
            value.Name       = n;
            value.Expandable = e;
            value.Value      = v;
            setTitle();
            showProblem();
            value.Changed = true;
            Saved?.Invoke(this, true);
            return(true);
        }