示例#1
0
        private bool ConfirmSave(XEditNetCtrl editor, FileInfo fi)
        {
            if (editor == null || !editor.IsModified)
            {
                return(true);
            }

            string       msg = string.Format("Do you want to save the changes to {0}", fi.Name);
            DialogResult dr  = MessageBox.Show(this, msg, "XEditNet Author", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);

            if (dr == DialogResult.Cancel)
            {
                return(false);
            }

            if (dr == DialogResult.Yes)
            {
                if (fi == null)
                {
                    fi = GetSaveAsFileInfo();
                }

                if (fi == null)
                {
                    return(false);
                }

                SaveFile(editor, fi);
            }
            return(true);
        }
示例#2
0
        public void OpenDocument(FileInfo fi)
        {
            string title = fi == null ? "New Document" : fi.Name;

            try
            {
                bool        valid;
                XmlDocument doc = XEditNetCtrl.LoadDocument(fi.FullName, true, out valid);
                if (doc == null)
                {
                    return;
                }

                Form f = GetMdiForm(doc, valid);
                f.Text        = title;
                f.Closing    += new CancelEventHandler(ChildClosing);
                f.MdiParent   = this;
                f.WindowState = FormWindowState.Maximized;
                f.Show();
                f.Tag = fi;
            }
            catch (XmlException e)
            {
                // TODO: M: lots of things can cause this error, eg. trying to run xpath anywhere
                MessageBox.Show(this, "XML error reading document\n" + e.Message, "Open File", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception e)
            {
                MessageBox.Show(this, e.Message);
            }
        }
示例#3
0
        public FindPopup(XEditNetCtrl context)
        {
            this.context = context;

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
        }
示例#4
0
        private void menuFileSaveAs_Click(object sender, EventArgs e)
        {
            XEditNetCtrl editor = CurrentEditor;

            if (editor == null)
            {
                return;
            }

            FileSaveAs();
        }
示例#5
0
 public void FontProblems()
 {
     Form frm=new Form();
     XEditNetCtrl ctrl=new XEditNetCtrl();
     XmlDocument doc=new XmlDocument();
     doc.LoadXml("<doc>x</doc>");
     ctrl.Attach(doc, true);
     frm.Controls.Add(ctrl);
     frm.ShowDialog();
     //			frm.Update();
 }
示例#6
0
        public void FontProblems()
        {
            Form         frm  = new Form();
            XEditNetCtrl ctrl = new XEditNetCtrl();
            XmlDocument  doc  = new XmlDocument();

            doc.LoadXml("<doc>x</doc>");
            ctrl.Attach(doc, true);
            frm.Controls.Add(ctrl);
            frm.ShowDialog();
//			frm.Update();
        }
        private void SaveFile(XEditNetCtrl editor, FileInfo fi)
        {
            // TODO: M: show wait cursor
            XmlTextWriter xtw = new XmlTextWriter(fi.FullName, Encoding.UTF8);

            try
            {
                editor.Document.Save(xtw);
                editor.IsModified = false;
            }
            finally
            {
                xtw.Close();
            }
        }
        private void OpenFile(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.AddExtension    = true;
            dlg.CheckFileExists = true;
            dlg.CheckPathExists = true;
            dlg.DefaultExt      = "xml";
            dlg.Filter          = DEFAULT_FILE_FILTER;
            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                string   fileName = dlg.FileName;
                FileInfo fi       = new FileInfo(fileName);
                string   title    = fi == null ? "New Document" : fi.Name;

                try
                {
                    bool        valid;
                    XmlDocument doc = XEditNetCtrl.LoadDocument(fi.FullName, true, out valid);
                    if (doc == null)
                    {
                        return;
                    }

                    DockContent childForm = GetMdiForm(doc, valid);
                    childForm.Text = title;
                    //f.Closing += new CancelEventHandler(ChildClosing);
                    childForm.MdiParent  = this;
                    childForm.DockAreas  = DockAreas.Document | DockAreas.Float;
                    childForm.ShowHint   = DockState.Document;
                    childForm.Activated += new EventHandler(childForm_Activated);
                    childForm.Show(this.dockPanel1);
                    childForm.Show();
                    childForm.Tag = fi;
                }
                catch (XmlException ex)
                {
                    // TODO: M: lots of things can cause this error, eg. trying to run xpath anywhere
                    MessageBox.Show(this, "XML error reading document\n" + ex.Message, "Open File", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.Message);
                }
            }
        }