Esempio n. 1
0
        public static MacroManager Load(string fileName)
        {
            Console.WriteLine("Deserializing {0}.", fileName);
            FileStream             fs     = new FileStream(fileName, FileMode.Open);
            XmlDictionaryReader    reader = XmlDictionaryReader.CreateTextReader(fs, new XmlDictionaryReaderQuotas());
            DataContractSerializer ser    = new DataContractSerializer(typeof(MacroManager));

            MacroManager macroManager = (MacroManager)ser.ReadObject(reader, true);

            reader.Close();
            fs.Close();

            return(macroManager);
        }
Esempio n. 2
0
        public static void Save(string fileName, MacroManager controls)
        {
            Console.WriteLine("Serializing {0}.", fileName);
            DataContractSerializer ser = new DataContractSerializer(typeof(MacroManager));

            var settings = new XmlWriterSettings {
                Indent = true
            };

            using (var writer = XmlWriter.Create(fileName, settings))
            {
                ser.WriteObject(writer, controls);
                writer.Flush();
            }
        }
Esempio n. 3
0
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            saveFileDialogMacro.RestoreDirectory = true;
            saveFileDialogMacro.InitialDirectory = Environment.CurrentDirectory + @"\Saves";
            saveFileDialogMacro.Filter           = "R20CPCMG Macro (*.macro)|*.macro";
            saveFileDialogMacro.DefaultExt       = ".macro";
            DialogResult result = saveFileDialogMacro.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                Console.WriteLine(saveFileDialogMacro.FileName);
                MacroManager manager = new MacroManager();
                manager.Populate(flowLayoutPanelMacros);
                MacroManager.Save(saveFileDialogMacro.FileName, manager);
            }
        }
Esempio n. 4
0
        private void loadMacroToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialogMacro.RestoreDirectory = true;
            openFileDialogMacro.InitialDirectory = Environment.CurrentDirectory + @"\Saves";
            openFileDialogMacro.Filter           = "R20CPCMG Macro (*.macro)|*.macro";
            openFileDialogMacro.DefaultExt       = ".macro";
            openFileDialogMacro.FileName         = "";
            DialogResult result = openFileDialogMacro.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                Console.WriteLine(openFileDialogMacro.FileName);
                MacroManager manager = MacroManager.Load(openFileDialogMacro.FileName);
                manager.ExtractControls(flowLayoutPanelMacros);
                RefreshMacro();
            }
        }