using System;
|
using System.Diagnostics;
|
using System.Drawing;
|
using System.IO;
|
using System.Windows.Forms;
|
using DevExpress.LookAndFeel;
|
using DevExpress.Tutorials.Controls;
|
using DevExpress.Utils;
|
using DevExpress.XtraBars.Ribbon;
|
using DevExpress.XtraBars.Ribbon.Gallery;
|
using DevExpress.XtraEditors;
|
using DevExpress.XtraEditors.Controls;
|
using DevExpress.Utils.Taskbar;
|
using DevExpress.XtraSplashScreen;
|
using DevExpress.Skins;
|
using DevExpress.Utils.Colors;
|
using DevExpress.XtraEditors.ColorWheel;
|
using DevExpress.XtraEditors.Popup;
|
using System.Collections.Generic;
|
using DevExpress.Utils.Helpers;
|
using DevExpress.XtraPrinting;
|
using System.Drawing.Imaging;
|
using System.Drawing.Printing;
|
using DevExpress;
|
using DevExpress.XtraBars;
|
using DevExpress.XtraBars.Ribbon;
|
using Hydro.MapView;
|
|
|
namespace Hydro.WinfrmUI.Viewer
|
{
|
public partial class frmMain : DevExpress.XtraBars.Ribbon.RibbonForm
|
{
|
public frmMain()
|
{
|
InitializeComponent();
|
|
|
|
UserLookAndFeel.Default.SetSkinStyle("Office 2019 Colorful");
|
|
|
}
|
|
private void frmMain_Load(object sender, System.EventArgs e)
|
{
|
ribbonControl1.ForceInitialize();
|
//GalleryDropDown skins = new GalleryDropDown();
|
//skins.Ribbon = ribbonControl1;
|
//DevExpress.XtraBars.Helpers.SkinHelper.InitSkinGalleryDropDown(skins);
|
//iPaintStyle.DropDownControl = skins;
|
CreateNewDocument(@"D:\WorkData\YiWei\Hydro\Hydro.V1.1\out\xiaofang.inp");
|
}
|
|
protected override void OnLoad(EventArgs e)
|
{
|
base.OnLoad(e);
|
SplashScreenManager.CloseForm(false);
|
}
|
|
protected override void OnShown(EventArgs e)
|
{
|
base.OnShown(e);
|
}
|
|
|
|
|
int documentIndex = 0;
|
|
|
GalleryItem fCurrentFontItem, fCurrentColorItem;
|
|
void CreateNewDocument()
|
{
|
CreateNewDocument(null);
|
}
|
|
public void ShowHideFormatCategory()
|
{
|
RibbonPageCategory selectionCategory = Ribbon.PageCategories[0] as RibbonPageCategory;
|
if (selectionCategory == null) return;
|
|
if (selectionCategory.Visible) Ribbon.SelectedPage = selectionCategory.Pages[0];
|
}
|
void CreateNewDocument(string fileName)
|
{
|
if (string.IsNullOrEmpty(fileName))
|
{
|
return;
|
}
|
|
documentIndex++;
|
frmDoc pad = new frmDoc();
|
|
|
var viewer = pad.LoadDocument(fileName);
|
if (viewer == null)
|
{
|
return;
|
}
|
viewer.OnChangeMonseClickPostion += (x, y, posi) =>
|
{
|
label_mouse.Caption = $"X£º{x.ToString("0")} Y£º{y.ToString("0")} [Map]X£º{posi.X.ToString("0.00")} Y£º{posi.Y.ToString("0.00")}";
|
};
|
viewer.OnChangeViewCenter += (posi) =>
|
{
|
label_center.Caption = $"center£º({posi.X.ToString("0.00")} £¬{posi.Y.ToString("0.00")}£©";
|
};
|
viewer.OnChangeViewZoom += (zoom) =>
|
{
|
label_zoom.Caption = $"Zoom£º{zoom.ToString("0.000")}";
|
};
|
viewer.OnChangeViewOrtho += (bol) =>
|
{
|
label_ZZ.Checked = bol;
|
//if (mapOption.IsOrtho)
|
//{
|
// label_ZZ.Text = "Õý½»Ä£Ê½:¿ª";
|
//}
|
//else
|
//{
|
// label_ZZ.Text = "Õý½»Ä£Ê½:¹Ø";
|
//}
|
};
|
viewer.OnChangeViewRotation += (r1, r2) =>
|
{
|
label_rotation.Caption = $"Rotation£º({r1.ToString("0")}£¬{r2.ToString("0")})";
|
};
|
|
|
pad.MdiParent = this;
|
|
pad.Closed += new EventHandler(Pad_Closed);
|
|
pad.Show();
|
}
|
|
void pad_ShowMiniToolbar(object sender, EventArgs e)
|
{
|
if (string.IsNullOrEmpty(((RichTextBox)sender).SelectedText))
|
return;
|
ShowSelectionMiniToolbar();
|
}
|
|
void Pad_Closed(object sender, EventArgs e)
|
{
|
CloseFind();
|
}
|
void Pad_ShowPopupMenu(object sender, EventArgs e)
|
{
|
pmMain.RibbonToolbar = selectionMiniToolbar;
|
pmMain.ShowPopup(Control.MousePosition);
|
}
|
void CloseFind()
|
{
|
|
}
|
|
|
#region Init
|
private void frmMain_Activated(object sender, System.EventArgs e)
|
{
|
InitDocument();
|
}
|
|
void ChangeActiveForm()
|
{
|
CloseFind();
|
}
|
private void xtraTabbedMdiManager1_FloatMDIChildActivated(object sender, EventArgs e)
|
{
|
ChangeActiveForm();
|
}
|
private void xtraTabbedMdiManager1_FloatMDIChildDeactivated(object sender, EventArgs e)
|
{
|
BeginInvoke(new MethodInvoker(ChangeActiveForm));
|
}
|
private void frmMain_MdiChildActivate(object sender, System.EventArgs e)
|
{
|
ChangeActiveForm();
|
}
|
|
private void InitDocument()
|
{
|
|
}
|
|
protected virtual void ShowSelectionMiniToolbar()
|
{
|
Point pt = Control.MousePosition;
|
pt.Offset(0, -11);
|
selectionMiniToolbar.Alignment = ContentAlignment.TopRight;
|
selectionMiniToolbar.PopupMenu = null;
|
selectionMiniToolbar.Show(pt);
|
}
|
|
|
|
|
|
|
|
|
|
void InitCurrentDocument(RichTextBox rtbControl)
|
{
|
bool _enabled = rtbControl != null;
|
iSaveAs.Enabled = _enabled;
|
iOpenByEpa.Enabled = _enabled;
|
|
sbiSave.Enabled = _enabled;
|
iFind.Enabled = _enabled;
|
}
|
|
|
#endregion
|
#region Properties
|
frmDoc CurrentForm
|
{
|
get
|
{
|
if (this.ActiveMdiChild == null) return null;
|
if (xtraTabbedMdiManager1.ActiveFloatForm != null)
|
return xtraTabbedMdiManager1.ActiveFloatForm as frmDoc;
|
return this.ActiveMdiChild as frmDoc;
|
}
|
}
|
|
|
|
|
#endregion
|
#region File
|
void idNew_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
CreateNewDocument();
|
}
|
|
void iOpenByEpa_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
// Process.Start(@"epanetH\Epanet2wH.exe", _filePath);
|
}
|
private void iClear_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
if (CurrentForm != null) CurrentForm.Close();
|
}
|
|
|
public void OpenFile(string name)
|
{
|
CreateNewDocument(name);
|
}
|
|
|
bool CheckForOverlap(RecentPinItem pinItem, RecentItemCollection recentItemCollection)
|
{
|
foreach (RecentItemBase item in recentItemCollection)
|
{
|
RecentPinItem pItem = item as RecentPinItem;
|
if (pItem != null && pinItem.Caption == pItem.Caption && pinItem.Description == pItem.Description)
|
return true;
|
}
|
return false;
|
}
|
|
|
void iOpen_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
openFileDialog.Filter = "INP Files (*.inp)|*.inp|All Files (*.*)|*.*";
|
if (this.CurrentForm == null)
|
return;
|
this.CurrentForm.GetBrowser().OpenFile(openFileDialog.FileName);
|
}
|
|
|
|
void iSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
Save();
|
}
|
void iSaveAs_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
SaveAs();
|
}
|
void Save()
|
{
|
if (CurrentForm == null)
|
return;
|
CurrentForm.GetBrowser().Save ( );
|
}
|
|
void SaveAs()
|
{
|
if (CurrentForm == null)
|
return;
|
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
saveFileDialog.Filter = "Inp Files (*.inp)|*.inp";
|
saveFileDialog.InitialDirectory = Directory.GetCurrentDirectory() + $@"\template\";
|
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
{
|
string filePath = saveFileDialog.FileName;
|
CurrentForm.GetBrowser().SaveAs(filePath);
|
}
|
|
}
|
private void bbiÒÔµ±Ç°ÊÓ½ÇÁí´æ_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
saveFileDialog.Filter = "Inp Files (*.inp)|*.inp";
|
saveFileDialog.InitialDirectory = Directory.GetCurrentDirectory() + $@"\template\";
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
{
|
string filePath = saveFileDialog.FileName;
|
CurrentForm.GetBrowser().SaveAsByView(filePath);
|
}
|
}
|
|
private void iExit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
Close();
|
}
|
private void frmMain_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
{
|
}
|
private void ribbonPageGroup1_CaptionButtonClick(object sender, DevExpress.XtraBars.Ribbon.RibbonPageGroupEventArgs e)
|
{
|
|
}
|
|
private void ribbonPageGroup9_CaptionButtonClick(object sender, DevExpress.XtraBars.Ribbon.RibbonPageGroupEventArgs e)
|
{
|
SaveAs();
|
}
|
#endregion
|
|
#region Ë¢ÐÂ, ÉÏÒ»²½, ÏÂÒ»²½
|
private void iUndo_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
CurrentForm.GetBrowser().Undo();
|
}
|
|
private void iRedo_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
CurrentForm.GetBrowser().Redo();
|
}
|
|
private void bbiË¢ÐÂ_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
CurrentForm.GetBrowser().Redo();
|
}
|
|
private void ribbonPageGroup2_CaptionButtonClick(object sender, DevExpress.XtraBars.Ribbon.RibbonPageGroupEventArgs e)
|
{
|
pmMain.ShowPopup(ribbonControl1.Manager, MousePosition);
|
}
|
#endregion
|
|
|
|
|
private void iAbout_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
BarManager.About();
|
}
|
|
|
|
|
|
private void ribbonControl1_ApplicationButtonDoubleClick(object sender, EventArgs e)
|
{
|
if (ribbonControl1.RibbonStyle == RibbonControlStyle.Office2007)
|
this.Close();
|
}
|
|
|
|
|
|
private void sbExit_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
|
|
private void label_ZZ_CheckedChanged(object sender, ItemClickEventArgs e)
|
{
|
CurrentForm.GetBrowser().IsOrtho = label_ZZ.Checked;
|
}
|
|
|
|
|
private void bvItemSave_ItemClick(object sender, BackstageViewItemEventArgs e)
|
{
|
Save();
|
}
|
|
private void bvItemSaveAs_ItemClick(object sender, BackstageViewItemEventArgs e)
|
{
|
SaveAs();
|
}
|
|
private void bvItemOpen_ItemClick(object sender, BackstageViewItemEventArgs e)
|
{
|
|
}
|
|
private void bvItemClose_ItemClick(object sender, BackstageViewItemEventArgs e)
|
{
|
if (xtraTabbedMdiManager1.SelectedPage != null)
|
xtraTabbedMdiManager1.SelectedPage.MdiChild.Close();
|
}
|
|
private void bvItemExit_ItemClick(object sender, BackstageViewItemEventArgs e)
|
{
|
Close();
|
}
|
|
void ribbonControl1_ResetLayout(object sender, ResetLayoutEventArgs e)
|
{
|
ShowHideFormatCategory();
|
}
|
void OnNewDocThumbButtonClick(object sender, ThumbButtonClickEventArgs e)
|
{
|
CreateNewDocument();
|
}
|
void OnPrevThumbButtonClick(object sender, ThumbButtonClickEventArgs e)
|
{
|
Form mdiChild = GetPrevMdiChild();
|
if (mdiChild != null)
|
ActivateMdiChild(mdiChild);
|
}
|
void OnNextDocThumbButtonClick(object sender, ThumbButtonClickEventArgs e)
|
{
|
Form mdiChild = GetNextMdiChild();
|
if (mdiChild != null)
|
ActivateMdiChild(mdiChild);
|
}
|
void OnExitThumbButtonClick(object sender, ThumbButtonClickEventArgs e)
|
{
|
Close();
|
}
|
Form GetNextMdiChild()
|
{
|
if (ActiveMdiChild == null || MdiChildren.Length < 2)
|
return null;
|
int pos = Array.IndexOf(MdiChildren, ActiveMdiChild);
|
return pos == MdiChildren.Length - 1 ? MdiChildren[0] : MdiChildren[pos + 1];
|
}
|
Form GetPrevMdiChild()
|
{
|
if (ActiveMdiChild == null || MdiChildren.Length < 2)
|
return null;
|
int pos = Array.IndexOf(MdiChildren, ActiveMdiChild);
|
return pos == 0 ? MdiChildren[MdiChildren.Length - 1] : MdiChildren[pos - 1];
|
}
|
void OnTabbedMdiManagerPageCollectionChanged(object sender, DevExpress.XtraTabbedMdi.MdiTabPageEventArgs e)
|
{
|
UpdateThumbnailButtons();
|
}
|
void UpdateThumbnailButtons()
|
{
|
thumbButtonNext.Enabled = thumbButtonPrev.Enabled = MdiChildren.Length > 1;
|
}
|
|
|
|
|
private void bbiÆÕͨ״̬_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
CurrentForm.GetBrowser().ResetOperateStatus();
|
}
|
|
|
private void bbiNewLink_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
CurrentForm.GetBrowser().NewLink();
|
}
|
|
private void bbiÐÂÔö¹ÜÏß_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
CurrentForm.GetBrowser().NewLink();
|
}
|
|
private void bbiÐÂÔöÁ¢¹Ü_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
CurrentForm.GetBrowser().NewVerticalLink();
|
}
|
|
private void bbiÌí¼ÓË®³Ø_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
CurrentForm.GetBrowser().NewPool();
|
}
|
|
private void bbiÌí¼ÓË®±Ã_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
CurrentForm.GetBrowser().NewPump();
|
}
|
|
private void bbiÌí¼ÓË®¿â_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
CurrentForm.GetBrowser().NewTask();
|
}
|
|
private void bbiÌí¼Ó·§ÃÅ_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
CurrentForm.GetBrowser().NewValve();
|
}
|
|
private void bbiÌí¼ÓË®±í_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
CurrentForm.GetBrowser().NewWaterMeter();
|
}
|
|
private void bbiÌí¼ÓÖØ¸´Æ÷_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
CurrentForm.GetBrowser().NewRepeater();
|
}
|
|
private void bbiÇå¿Õ¾Ö²¿Ëðʧ_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
CurrentForm.GetBrowser().ClearMinorLoss();
|
}
|
|
private void bbi¼ÆËã_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
CurrentForm.GetBrowser().Calc();
|
}
|
|
private void bbiCalcMiniLoss_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
CurrentForm.GetBrowser().CalcLinkMinorLoss();
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|