Beispiel #1
0
        /// <summary>
        /// Save to .emm files
        /// </summary>
        /// <param name="actionGroups"></param>
        /// <param name="folderPath">save to this folder</param>
        public string SaveAsToFile(MacroTemplate macroTemplate, string fullPath)
        {
            //Open the file save dialog
            SaveFileDialog saveFileDialog = new SaveFileDialog
            {
                AddExtension     = true,
                CheckPathExists  = true,
                DefaultExt       = ".emm",
                InitialDirectory = (fullPath.Equals(string.Empty)) ? savedTemplateDirectory : Path.GetDirectoryName(fullPath),
                Filter           = @"Easy Macro Maker (.emm)|*.emm",
                FileName         = (fullPath.Equals(string.Empty)) ? macroTemplate.MacroName.Replace(" ", "_") : Path.GetFileNameWithoutExtension(fullPath)
            };

            var result = saveFileDialog.ShowDialog();

            if (result == false)
            {
                return(fullPath);
            }

            //Serialize the macro then save it
            File.WriteAllText(saveFileDialog.FileName, JsonConvert.SerializeObject(macroTemplate, Formatting.Indented));

            return(saveFileDialog.FileName);
        }
Beispiel #2
0
        /// <summary>
        /// Save the <see cref="MacroTemplate"/> if the path is already existed, otherwise call the save as method
        /// </summary>
        /// <param name="macroTemplate">The <see cref="MacroTemplate"/> to save</param>
        /// <param name="fullPath">The path the <see cref="MacroTemplate"/></param>
        public string SaveToFile(MacroTemplate macroTemplate, string fullPath)
        {
            if (fullPath.Equals(string.Empty))
            {
                return(this.SaveAsToFile(macroTemplate, string.Empty));
            }
            else
            {
                //Serialize the macro then save it
                File.WriteAllText(fullPath, JsonConvert.SerializeObject(macroTemplate, Formatting.Indented));
            }

            return(fullPath);
        }
Beispiel #3
0
        /// <summary>
        /// Save the <see cref="MacroTemplate"/> if the path is already existed, otherwise call the save as method
        /// </summary>
        /// <param name="macroTemplate">The <see cref="MacroTemplate"/> to save</param>
        /// <param name="fullPath">The path the <see cref="MacroTemplate"/></param>
        public string SaveToFile(MacroTemplate macroTemplate, string fullPath)
        {
            if (string.IsNullOrWhiteSpace(fullPath))
            {
                return(this.SaveAsToFile(macroTemplate, string.Empty));
            }
            else
            {
                Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
                //Serialize the macro then save it
                File.WriteAllText(fullPath, JsonConvert.SerializeObject(macroTemplate, Formatting.Indented));
            }

            return(fullPath);
        }