public static void saveAssemblyZoneLayoutToFile(AssemblyZoneLayout pLayout) { // check if scnes dir exists if (!Directory.Exists(ProjectConstants.ASSEMBLYZONES_DIR)) { // if not create it Directory.CreateDirectory(ProjectConstants.ASSEMBLYZONES_DIR); } System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog(); dlg.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + ProjectConstants.ASSEMBLYZONES_DIR; dlg.Filter = "zone files (*.zone)|*.zone"; if (dlg.ShowDialog() != DialogResult.OK) { return; } string filename = dlg.FileName; if (!filename.EndsWith(ProjectConstants.ASSEMBLYZONE_FILE_ENDING)) { filename = filename + ProjectConstants.ASSEMBLYZONE_FILE_ENDING; } UtilitiesIO.SaveObjectToJson(pLayout, filename); }
public void loadAssemblyZoneLayoutFromFile() { SetNewLayout(AssemblyZoneLayout.loadAssemblyZoneLayoutFromFile()); BackendControl.Instance.refreshGUI(); AdminView.Instance.refreshDataContext(); }
public void SetNewLayout(AssemblyZoneLayout pLayout) { if (pLayout != null) { int highestID = 0; // workaround for databinding bug m_CurrentLayout.AssemblyZones.Clear(); foreach (AssemblyZone zone in pLayout.AssemblyZones) { m_CurrentLayout.AssemblyZones.Add(zone); if (zone.Id > highestID) { highestID = zone.Id; } } m_CurrentLayout.LayoutName = pLayout.LayoutName; m_IdCounter = highestID + 1; } }
public static AssemblyZoneLayout loadAssemblyZoneLayoutFromFile() { AssemblyZoneLayout ret = null; // filechooser System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog(); dlg.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + ProjectConstants.ASSEMBLYZONES_DIR; dlg.Filter = "zone files (*.zone)|*.zone"; dlg.FilterIndex = 2; dlg.RestoreDirectory = true; DialogResult res = dlg.ShowDialog(); if (res == DialogResult.OK) { bool isOkay = UtilitiesIO.GetObjectFromJson(ref ret, dlg.FileName); if (!isOkay) { return(null); } } return(ret); }
public void saveAssemblyZoneLayoutToFile() { AssemblyZoneLayout.saveAssemblyZoneLayoutToFile(m_CurrentLayout); }