/// <summary> /// OpenFileDialog를 호출하는 Method /// </summary> /// <param name="structureType"></param> /// <returns></returns> private bool OpenMacroFile(SavedContainerType structureType) { OpenFileDialog openFileDialig = new OpenFileDialog(); openFileDialig.Filter = string.Format("{0} {1}|{2}", PROGRAM_KEY_WORD, structureType.ToString(), GstStructureExtension[structureType]); openFileDialig.Title = string.Format("{0} 열기", structureType.ToString()); if (openFileDialig.ShowDialog() != DialogResult.OK) { return(false); } Stream stream = File.Open(openFileDialig.FileName, FileMode.Open); BinaryFormatter formatter = new BinaryFormatter(); switch (structureType) { case SavedContainerType.이벤트집합: PrefabsSaveFormat openedData = (PrefabsSaveFormat)formatter.Deserialize(stream); Prefabs = openedData.Prefabs; PrefabsDupCheckSet = openedData.PrefabsDupCheckSet; SetNodeList(listView_Prefabs, Prefabs, true); break; case SavedContainerType.워크플로우: List <MacroNode> openedWorkflow = (List <MacroNode>)formatter.Deserialize(stream); Nodes = openedWorkflow; SetNodeList(listView_Main, Nodes, false); WorkFlowPath = openFileDialig.FileName; break; } stream.Close(); isModified = false; return(true); }
/// <summary> /// SaveFileDialog를 호출하는 Method /// </summary> /// <param name="saveType"></param> /// <param name="structureType"></param> /// <returns></returns> private bool SaveMacroFile(SaveType saveType, SavedContainerType structureType) { string saveFilePath = ""; if (saveType == SaveType.저장 && !WorkFlowName.Equals("")) { saveFilePath = WorkFlowPath; } else { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = string.Format("{0} {1}|{2}", PROGRAM_KEY_WORD, structureType.ToString(), GstStructureExtension[structureType]); saveFileDialog.Title = string.Format("{0} {1}", structureType.ToString(), saveType.ToString()); if (saveFileDialog.ShowDialog() != DialogResult.OK || saveFileDialog.FileName.Equals("")) { return(false); // Cancle } saveFilePath = saveFileDialog.FileName; } BinaryFormatter serializer = new BinaryFormatter(); Stream stream = File.Open(saveFilePath, FileMode.Create); switch (structureType) { case SavedContainerType.워크플로우: serializer.Serialize(stream, Nodes); WorkFlowPath = saveFilePath; break; case SavedContainerType.이벤트집합: SerializePrefabs.PrefabsDupCheckSet = PrefabsDupCheckSet; serializer.Serialize(stream, SerializePrefabs); break; } stream.Close(); isModified = false; return(true); }