public static void ImportFromFile(GridClient client)
        {
            WindowWrapper mainWindow = new WindowWrapper(frmMain.ActiveForm.Handle);

            System.Windows.Forms.OpenFileDialog dlg = new OpenFileDialog();
            dlg.Title       = "Open object file";
            dlg.Filter      = "XML file (*.xml)|*.xml";
            dlg.Multiselect = false;
            DialogResult res = dlg.ShowDialog();

            if (res == DialogResult.OK)
            {
                Thread t = new Thread(new System.Threading.ThreadStart(delegate()
                {
                    try
                    {
                        PrimDeserializer d = new PrimDeserializer(client);
                        string primsXmls   = System.IO.File.ReadAllText(dlg.FileName);
                        d.CreateObjectFromXml(primsXmls);
                        d.CleanUp();
                        d = null;
                        MessageBox.Show(mainWindow, "Successfully imported " + dlg.FileName, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (Exception excp)
                    {
                        MessageBox.Show(mainWindow, excp.Message, "Saving failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }));

                t.IsBackground = true;
                t.Start();
            }
        }
Beispiel #2
0
 private void loadBtn_Click(object sender, EventArgs e)
 {
     PrimDeserializer.ImportFromFile(client);
 }