internal void SetNewLayout(BoxLayout pBoxLayout) { if (pBoxLayout != null) { int highestID = 0; // workaround for databinding bug m_CurrentLayout.Boxes.Clear(); foreach (Box b in pBoxLayout.Boxes) { m_CurrentLayout.Boxes.Add(b); if (b.Id > highestID) { highestID = b.Id; } } m_CurrentLayout.LayoutName = pBoxLayout.LayoutName; m_IdCounter = highestID + 1; } }
public static BoxLayout loadBoxLayoutFromFile() { BoxLayout ret = null; // filechooser System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog(); dlg.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + ProjectConstants.BOXES_DIR; dlg.Filter = "box files (*.box)|*.box"; dlg.FilterIndex = 2; dlg.RestoreDirectory = true; DialogResult res = dlg.ShowDialog(); //Nullable<bool> result = dlg.ShowDialog(); if (res == DialogResult.OK) { UtilitiesIO.GetObjectFromJson(ref ret, dlg.FileName); } return(ret); }
public static void saveBoxLayoutToFile(BoxLayout pCurrentLayout) { // check if scnes dir exists if (!Directory.Exists(ProjectConstants.BOXES_DIR)) { // if not create it Directory.CreateDirectory(ProjectConstants.BOXES_DIR); } System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog(); dlg.Filter = "Box files (*" + ProjectConstants.BOX_FILE_ENDING + ")|*" + ProjectConstants.BOX_FILE_ENDING + "|All files (*.*)|*.*"; dlg.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + ProjectConstants.BOXES_DIR; dlg.ShowDialog(); string filename = dlg.FileName; if (!filename.EndsWith(ProjectConstants.BOX_FILE_ENDING)) { filename = filename + ProjectConstants.BOX_FILE_ENDING; } UtilitiesIO.SaveObjectToJson(pCurrentLayout, filename); }
internal void saveBoxLayoutToFile() { BoxLayout.saveBoxLayoutToFile(m_CurrentLayout); }
public void loadBoxLayoutFromFile() { SetNewLayout(BoxLayout.loadBoxLayoutFromFile()); }