Esempio n. 1
0
        public static FlowMap Open(Form mdiparent)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                String       loc    = dlg.FileName;
                FlowDocument olddoc = FlowDocument.FindDocument(loc);
                if (olddoc != null)
                {
                    IList windows = FlowMap.FindWindows(mdiparent, olddoc);
                    if (windows.Count > 0)
                    {
                        FlowMap w = windows[0] as FlowMap;



                        if (w.Reload())
                        {
                            w.Show();
                            w.Activate();
                        }
                        return(w);
                    }
                }
                else
                {
                    Stream file = dlg.OpenFile();
                    if (file != null)
                    {
                        FlowDocument doc = null;
                        try
                        {
                            doc = FlowDocument.Load(file, loc);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(mdiparent, ex.Message, "Error reading design from a file");
                        }
                        finally
                        {
                            file.Close();
                        }
                        if (doc != null)
                        {
                            FlowMap w = new FlowMap();


                            w.View.Document = doc;
                            w.MdiParent     = mdiparent;
                            w.Show();
                            w.Activate();
                            return(w);
                        }
                    }
                }
            }
            return(null);
        }
Esempio n. 2
0
        private void btnNew_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FlowMap canvas = new FlowMap();

            canvas.MdiParent = this;
            canvas.Show();
            canvas.WindowState = FormWindowState.Maximized;
            canvas.View.UpdateFormInfo();
            FlowDocument doc = canvas.View.Doc;

            doc.UndoManager.Clear();
            doc.IsModified = false;

            frmInfo dlg = new frmInfo();

            dlg.Doc = doc;
            dlg.ShowDialog();
        }