| | |
| | | using System.Linq; |
| | | using System.Runtime.InteropServices; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Windows.Forms; |
| | | using TerraExplorerX; |
| | | using TETree; |
| | |
| | | { |
| | | InitializeComponent(); |
| | | //this.KeyPreview = true; |
| | | this.Load += FrmWeb_Load; |
| | | //this.KeyDown += FrmWin_KeyDown; |
| | | this.FormClosed += FrmWin_FormClosed; |
| | | this.Load += FrmWeb_Load; |
| | | this.FormClosing += FrmWin_FormClosing; |
| | | |
| | | timer = new System.Timers.Timer(1500); |
| | | timer = new System.Timers.Timer(1000); |
| | | timer.Elapsed += timer_Elapsed; |
| | | } |
| | | |
| | |
| | | this.SG.OnLoadFinished -= SG_OnLoadFinished; |
| | | } |
| | | |
| | | void FrmWin_FormClosed(object sender, FormClosedEventArgs e) |
| | | void FrmWin_FormClosing(object sender, FormClosingEventArgs e) |
| | | { |
| | | ExecCmd(new List<string> { "taskkill /f /t /im OSGBLab.exe" }); |
| | | LogOut.Info("关闭程序."); |
| | | } |
| | | #endregion |
| | | |
| | | #region invoke |
| | | protected override void DefWndProc(ref Message m) |
| | | { |
| | | switch (m.Msg) |
| | |
| | | DisplayByAttribute(1, "按照属性设置颜色"); break; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region user32.dll |
| | | public const int SWP_NOSIZE = 0x0001; |
| | |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | public static void Main() |
| | | #region OSGBLab |
| | | const int GCLP_HICON = -14; |
| | | const int ICON_SMALL = 0; |
| | | const int ICON_BIG = 1; |
| | | |
| | | [DllImport("user32.dll", SetLastError = true)] |
| | | static extern IntPtr FindWindow(string lpClassName, string lpWindowsName); |
| | | |
| | | [DllImport("user32.dll", SetLastError = true)] |
| | | public static extern IntPtr FindWindowEx(IntPtr hWndParent, IntPtr hWndChildAfter, string lpszClass, string lpszWindow); |
| | | |
| | | [DllImport("user32.dll", SetLastError = true)] |
| | | static extern bool SetWindowText(IntPtr hWnd, String lpString); |
| | | |
| | | [DllImport("user32.dll", SetLastError = true)] |
| | | public static extern IntPtr SetClassLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong); |
| | | |
| | | public void DealOsgbLab() |
| | | { |
| | | // 获取指定窗体的句柄 |
| | | //IntPtr hWnd = // 获取窗体句柄的方法,例如FindWindow或者通过进程名获取 |
| | | // 获取窗体的坐标 |
| | | //RECT rect; |
| | | //GetWindowRect(hWnd, out rect); |
| | | //Console.WriteLine("窗体坐标: 左上角({0}, {1}), 右下角({2}, {3})", rect.Left, rect.Top, rect.Right, rect.Bottom); |
| | | /*Process[] processes = Process.GetProcessesByName("OSGBLab"); |
| | | if (processes.Length > 0) |
| | | { |
| | | IntPtr hWnd = processes[0].MainWindowHandle; |
| | | SetWindowText(hWnd, "OSGB数据处理工具"); |
| | | }*/ |
| | | |
| | | IntPtr hWnd = FindWindow(null, "OSGBLab(倾斜伴侣) (Windows) 免费版"); |
| | | if (hWnd == IntPtr.Zero) return; |
| | | |
| | | DealOsgbLab(hWnd); |
| | | } |
| | | |
| | | public void DealOsgbLab(Process p) |
| | | { |
| | | do |
| | | { |
| | | if (p.MainWindowHandle != IntPtr.Zero) |
| | | { |
| | | DealOsgbLab(p.MainWindowHandle); |
| | | break; |
| | | } |
| | | |
| | | Thread.Sleep(50); |
| | | } while (true); |
| | | } |
| | | |
| | | public void DealOsgbLab(IntPtr hWnd) |
| | | { |
| | | SetWindowText(hWnd, "OSGB数据处理工具"); |
| | | |
| | | Icon icon = new Icon(Path.Combine(mainUrl, @"Resources\favicon.ico")); |
| | | SetClassLongPtr(hWnd, GCLP_HICON + ICON_SMALL, icon.Handle); |
| | | SetClassLongPtr(hWnd, GCLP_HICON + ICON_BIG, icon.Handle); |
| | | } |
| | | #endregion |
| | | |
| | | #region ShowHtml+RunExe |
| | | public void ShowHtmlByid(int id, int arg) |
| | | { |
| | | switch (id) |
| | |
| | | SG.Window.ShowPopup(popup); |
| | | } |
| | | |
| | | public void RunExe(string path, string args, bool noWindow = true) |
| | | public Process RunExe(string path, string args, bool noWindow = true) |
| | | { |
| | | Process p = new Process(); |
| | | p.StartInfo.FileName = path; |
| | |
| | | p.StartInfo.CreateNoWindow = noWindow; |
| | | p.StartInfo.UseShellExecute = false; |
| | | p.Start(); |
| | | |
| | | return p; |
| | | } |
| | | |
| | | public static string ExecCmd(List<string> list) |
| | |
| | | |
| | | return str; |
| | | } |
| | | #endregion |
| | | |
| | | #region 角量算 |
| | | private void AngleMeasurement() |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region 调用Html |
| | | private string GetAbsolutePath(string key) |
| | | { |
| | | string str = ConfigurationManager.AppSettings[key]; |
| | |
| | | private void InvokeOsgbLab() |
| | | { |
| | | ExecCmd(new List<string> { "taskkill /f /t /im OSGBLab.exe" }); |
| | | RunExe(GetAbsolutePath("osgblabPath"), null, false); |
| | | osgbProc = RunExe(GetAbsolutePath("osgblabPath"), null, false); |
| | | DealOsgbLab(osgbProc); |
| | | } |
| | | |
| | | private void DisplayByAttribute(int type, String name) |
| | | { |
| | | this.ShowHtml(name, mainUrl + @"\Resources\DisplayByAttribute\DisplayByAttribute.html?Type=" + type + "&lang=2052", 20, 20, 365, 355); |
| | | } |
| | | #endregion |
| | | |
| | | #region 加载shp + 读取shp |
| | | private void LoadShp() |