/nx09SitingTool/frmNewMain.cs
C# | 286 lines | 247 code | 37 blank | 2 comment | 23 complexity | 55c0f03ecd61bd6a13da9a6d8728fd32 MD5 | raw file
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using DotSpatial.Controls;
- using DotSpatial.Controls.Docking;
- using DotSpatial.Data;
- using DotSpatial.Symbology;
- using DotSpatial.Topology;
- using System.Reflection;
- using System.ComponentModel.Composition;
- using System.Deployment.Application;
- using DevExpress.XtraBars;
- using System.IO;
-
- namespace nx09SitingTool
- {
- public partial class frmNewMain : Form
- {
- [Export("Shell", typeof(ContainerControl))]
-
- private static ContainerControl Shell;
-
- public frmNewMain()
- {
- InitializeComponent();
- Shell = this;
- appManager1.LoadExtensions();
- mpMain.GeoMouseMove += mpMain_GeoMouseMove;
- }
-
- bool mouseUPBool = false;
- int seInt = 1;
- double startP = 0;
- double endP = 0;
- int endR = 0;
- int endC = 0;
- int startR = 0;
- int startC = 0;
- clsLCPCoords lc = new clsLCPCoords();
- string projSaveFile = null;
-
- private void qButAddLayer_ItemActivated(object sender, Qios.DevSuite.Components.QCompositeEventArgs e)
- {
- mpMain.AddLayer();
- }
-
- private void qButZoomIn_ItemActivated(object sender, Qios.DevSuite.Components.QCompositeEventArgs e)
- {
- mpMain.FunctionMode = DotSpatial.Controls.FunctionMode.ZoomIn;
- }
-
- private void qButZoomOut_ItemActivated(object sender, Qios.DevSuite.Components.QCompositeEventArgs e)
- {
- mpMain.FunctionMode = DotSpatial.Controls.FunctionMode.ZoomOut;
- }
-
- private void qButFixedZoomIn_ItemActivated(object sender, Qios.DevSuite.Components.QCompositeEventArgs e)
- {
- mpMain.ZoomIn();
- }
-
- private void qButFixedZoomOut_ItemActivated(object sender, Qios.DevSuite.Components.QCompositeEventArgs e)
- {
- mpMain.ZoomOut();
- }
-
- private void qButPan_ItemActivated(object sender, Qios.DevSuite.Components.QCompositeEventArgs e)
- {
- mpMain.FunctionMode = DotSpatial.Controls.FunctionMode.Pan;
- }
-
- private void qButMaxExtent_ItemActivated(object sender, Qios.DevSuite.Components.QCompositeEventArgs e)
- {
- mpMain.ZoomToMaxExtent();
- mpMain.FunctionMode = DotSpatial.Controls.FunctionMode.None;
- }
-
- private void qButInfo_ItemActivated(object sender, Qios.DevSuite.Components.QCompositeEventArgs e)
- {
- mpMain.FunctionMode = DotSpatial.Controls.FunctionMode.Info;
- }
-
- private void qButSelect_ItemActivated(object sender, Qios.DevSuite.Components.QCompositeEventArgs e)
- {
- mpMain.FunctionMode = DotSpatial.Controls.FunctionMode.Select;
- }
-
- private void qButLoadAtts_ItemActivated(object sender, Qios.DevSuite.Components.QCompositeEventArgs e)
- {
- if (mpMain.Layers.SelectedLayer as MapPolygonLayer == null)
- {
- MessageBox.Show("Please select a polygon layer for attributes.", "Improper Layer Selected", MessageBoxButtons.OK);
- return;
- }
- IMapPolygonLayer currentLayer = (IMapPolygonLayer)mpMain.Layers.SelectedLayer;
-
- DataTable curLay = null;
- curLay = currentLayer.DataSet.DataTable;
- dgAttributes.DataSource = curLay;
- }
-
- private void mpMain_GeoMouseMove(object sender, GeoMouseArgs e)
- {
- tsslXCoord.Text = "X: " + Math.Round(e.GeographicLocation.X, 4);
- tsslYCoord.Text = " Y: " + Math.Round(e.GeographicLocation.Y, 4);
- }
-
- private void frmNewMain_Load(object sender, EventArgs e)
- {
- this.Text = "Line Siter " + Assembly.GetExecutingAssembly().GetName().Version.ToString();
- }
-
- private void qRbPgTools_Activated(object sender, EventArgs e)
- {
-
- }
-
- private void qButLCP_ItemActivated(object sender, Qios.DevSuite.Components.QCompositeEventArgs e)
- {
- if (!Directory.Exists(@"c:\temp\LineSiter"))
- {
- Directory.CreateDirectory(@"c:\temp\LineSiter");
- }
- frmToolExecute newExecute = new frmToolExecute(mpMain, lc);
- newExecute.ShowDialog();
- }
-
- private void qButReclass_ItemActivated(object sender, Qios.DevSuite.Components.QCompositeEventArgs e)
- {
- frmReclass rcls = new frmReclass();
- rcls.ShowDialog();
- }
-
- public void mpMain_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
- {
-
-
- Coordinate xy = null;
- int seRow = 0;
- int seCol = 0;
- double seCellValue = 0;
-
- if (mouseUPBool == true)
- {
-
- if (mpMain.Layers.SelectedLayer as MapRasterLayer == null)
- {
- MessageBox.Show("Please select a raster layer to select start and end points.", "Wrong Layer Selected", MessageBoxButtons.OK);
- return;
- }
-
- IMapRasterLayer seLayer = (IMapRasterLayer)mpMain.Layers.SelectedLayer;
-
- if (seLayer == null)
- {
- MessageBox.Show("Please select a layer to set start and end points.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- return;
- }
- else
- {
- IRaster seRaster = seLayer.DataSet;
- xy = mpMain.PixelToProj(e.Location);
- RcIndex rasterXY = DotSpatial.Data.RasterExt.ProjToCell(seRaster, xy);
- seRow = rasterXY.Row;
- seCol = rasterXY.Column;
- int numCols = seRaster.NumColumns;
- int numRows = seRaster.NumRows;
- if (seCol > 0 & seCol < seRaster.NumColumns & seRow > 0 & seRow < seRaster.NumRows)
- {
- if (seInt == 1)
- {
- startR = seRow;
- startC = seCol;
- startP = seRaster.Value[seRow, seCol];
- tsslStart.Text = "Start- Row: " + Convert.ToString(seRow) + " Column: " + Convert.ToString(seCol);
- lc.startRow = rasterXY.Row;
- lc.startCol = rasterXY.Column;
- seInt++;
- }
- else if (seInt == 2)
- {
- endR = seRow;
- endC = seCol;
- endP = seRaster.Value[seRow, seCol];
- tsslEnd.Text = "End- Row: " + Convert.ToString(seRow) + " Column: " + Convert.ToString(seCol);
- seInt = 1;
- lc.EndRow = rasterXY.Row;
- lc.EndCol = rasterXY.Column;
- mouseUPBool = false;
- }
- //seCellValue= seRaster.Value[seRow,seCol];
- }
- else
- {
- MessageBox.Show("Value is outside raster bounds. Please select an area on the map.", "Error 120: Selection Out of Bounds", MessageBoxButtons.OK);
- }
-
- }
-
- //MessageBox.Show("Point \r\n X: " + seRow +" Y: " + seCol+ " with a value of: " + seCellValue +" was clicked.", "Info", MessageBoxButtons.OK);
- }
-
- }
-
- private void qButStartEnd_ItemActivated(object sender, Qios.DevSuite.Components.QCompositeEventArgs e)
- {
- mouseUPBool = true;
- mpMain.MouseUp += new MouseEventHandler(mpMain_MouseUp);
- }
-
- private void qRbPgFile_Activated(object sender, EventArgs e)
- {
- }
-
- private void qButOpen_ItemActivated(object sender, Qios.DevSuite.Components.QCompositeEventArgs e)
- {
- tsslOpen.Visible = true;
- tsslProjName.Text = "Project Loading Please Wait...";
- OpenFileDialog opProjFile = new OpenFileDialog();
- opProjFile.Filter = "DotSpatial Project Files (*.dspx)|*.dspx";
- if (opProjFile.ShowDialog() == DialogResult.OK)
- {
- appManager1.SerializationManager.OpenProject(opProjFile.FileName);
- projSaveFile = opProjFile.FileName;
- }
- else
- {
- tsslOpen.Visible = false;
- tsslProjName.Text = "No Project Loaded";
- return;
- }
- tsslProjName.Text = projSaveFile;
- mpMain.Refresh();
- mpMain.ZoomToMaxExtent();
- tsslOpen.Visible = false;
- }
-
- private void qButSave_ItemActivated(object sender, Qios.DevSuite.Components.QCompositeEventArgs e)
- {
- tsslSave.Visible = true;
- if (projSaveFile != null)
- {
- appManager1.SerializationManager.SaveProject(projSaveFile);
- }
- else
- {
- SaveFileDialog svProjFile = new SaveFileDialog();
- svProjFile.Filter = "DotSpatial Project Files (*.dspx)|*.dspx";
- if (svProjFile.ShowDialog() == DialogResult.OK)
- {
- appManager1.SerializationManager.SaveProject(svProjFile.FileName);
- projSaveFile = svProjFile.FileName;
- }
- tsslProjName.Text = projSaveFile;
- }
- tsslSave.Visible = false;
- }
-
- private void qButSaveAs_ItemActivated(object sender, Qios.DevSuite.Components.QCompositeEventArgs e)
- {
- tsslSave.Visible = true;
- SaveFileDialog svProjFile = new SaveFileDialog();
- svProjFile.Filter = "DotSpatial Project Files (*.dspx)|*.dspx";
- svProjFile.Title = "Save LineSiter Project File";
- svProjFile.CreatePrompt = true;
- svProjFile.OverwritePrompt = true;
- if (svProjFile.ShowDialog() == DialogResult.OK)
- {
- appManager1.SerializationManager.SaveProject(svProjFile.FileName);
- projSaveFile = svProjFile.FileName;
- }
- tsslProjName.Text = projSaveFile;
- tsslSave.Visible = false;
- }
-
- private void qButExit_ItemActivated(object sender, Qios.DevSuite.Components.QCompositeEventArgs e)
- {
- Application.Exit();
- }
- }
- }