using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using DevExpress.XtraEditors; namespace Hydro.WinfrmUI.Viewer { /// /// Summary description for frmPad. /// public partial class frmPad : DevExpress.XtraEditors.XtraForm { public frmPad() { // // Required for Windows Form Designer support // InitializeComponent(); Icon = DevExpress.Utils.ResourceImageHelper.CreateIconFromResourcesEx("Hydro.WinfrmUI.Viewer.AppIcon.ico", typeof(frmMain).Assembly); // // TODO: Add any constructor code after InitializeComponent call // } bool modifiedCore = false; bool newDocumentCore = true; string docNameCore = ""; public string DocName { get { return docNameCore; } set { this.docNameCore = value; this.Text = DocName; } } public bool Modified { get { return modifiedCore; } set { if(value != modifiedCore) { modifiedCore = value; this.Text = DocName + (Modified ? "*" : ""); if(MdiParent != null) ((frmMain)MdiParent).UpdateText(); } } } public bool NewDocument { get { return this.newDocumentCore; } } public void LoadDocument(string fileName) { this.newDocumentCore = false; try { Hydro.WinfrmUI.ViewBrowser mapViewer1 = new Hydro.WinfrmUI.ViewBrowser(); mapViewer1._IsEditMode = true; mapViewer1._newTemplate = null; mapViewer1._ShowJunction = true; mapViewer1._ShowValve = true; mapViewer1.BackColor = System.Drawing.Color.Transparent; mapViewer1.Dock = System.Windows.Forms.DockStyle.Fill; mapViewer1.junction_multiply = 1F; mapViewer1.Link_multiply = 1F; mapViewer1.Location = new System.Drawing.Point(0, 0); mapViewer1.Name = "mapViewer1"; mapViewer1.Rotation = 0D; mapViewer1.RotationF = 90D; mapViewer1.showToolBar = true; mapViewer1.Size = new System.Drawing.Size(1000, 666); mapViewer1.TabIndex = 0; mapViewer1.zoom = 1F; mapViewer1.showToolBar = true; if (MapView.TemplateList.Inited == false) { MapView.TemplateList.Init(); } mapViewer1.OpenFile(fileName); this.Controls.Add(mapViewer1); } catch { XtraMessageBox.Show("Sorry, this file cannot be opened.", "Ribbon Simple Pad"); } this.DocName = fileName; } public string SaveAs(string path) { //SaveFileDialog dlg = new SaveFileDialog(); //dlg.Filter = "Rich Text Files (*.rtf)|*.rtf"; //dlg.Title = "Save As"; //if(path != string.Empty) dlg.InitialDirectory = path; //if(dlg.ShowDialog(this) == DialogResult.OK) { // RTBMain.SaveFile(dlg.FileName, RichTextBoxStreamType.RichText); // this.DocName = dlg.FileName; // this.newDocumentCore = false; // this.Modified = false; // return this.DocName; //} return string.Empty; } bool SaveQuestion() { //if(Modified) { // switch(DevExpress.XtraEditors.XtraMessageBox.Show("Do you want to save the changes you made to " + DocName + "?", "SimplePad Question", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)) { // case DialogResult.Cancel: // return false; // case DialogResult.Yes: // SaveAs(string.Empty); // break; // } //} return true; } private void frmPad_Closing(object sender, System.ComponentModel.CancelEventArgs e) { e.Cancel = !SaveQuestion(); } private void frmPad_Load(object sender, EventArgs e) { } } }