Beispiel #1
0
        public void Initialize(MapWindow.Interfaces.IMapWin MapWin, int ParentHandle)
        {
            try
            {
                m_MapWin       = MapWin;
                m_ParentHandle = ParentHandle;

                m_shpFilePropfrm = new mwIdentifier.Forms.frmShapeFileProp(this);
                m_GridPropfrm    = new mwIdentifier.Forms.frmGridProp(this);
                m_WMSPropfrm     = new mwIdentifier.Forms.frmWMSProp(this);

                System.Drawing.Icon icon;
                System.Drawing.Icon icon2;
                icon  = m_shpFilePropfrm.Icon;
                icon2 = new System.Drawing.Icon(this.GetType(), "IdentByShape.ico");
                MapWindow.Interfaces.ToolbarButton button;

                //Add the tool bar
                if (m_ToolbarName.Length > 0)
                {
                    m_MapWin.Toolbar.AddToolbar(m_ToolbarName);
                }

                //add buttons and the tool tip
                // button = m_MapWin.Toolbar.AddButton("Identifier", m_ToolbarName, null, null);
                button = m_MapWin.Toolbar.AddButton("ddIdentifier", m_ToolbarName, true);
                if (button == null)
                {
                    throw new Exception("Failed to add Identifier Button (" + m_MapWin.LastError + ")");
                }
                button.Tooltip     = "Identifier";
                button.Text        = "";
                m_IdentBtn         = button;
                m_IdentBtn.Picture = icon;

                button = m_MapWin.Toolbar.AddButton("Identify", m_ToolbarName, "ddIdentifier", "");
                if (button == null)
                {
                    throw new Exception("Failed to add Identifier Button (" + m_MapWin.LastError + ")");
                }
                button.Text         = "Identifier";
                m_IdentBtn2         = button;
                m_IdentBtn2.Picture = icon;

                button = m_MapWin.Toolbar.AddButton("Identify by Shape(s)", m_ToolbarName, "ddIdentifier", "");
                if (button == null)
                {
                    throw new Exception("Failed to add Identifier Button (" + m_MapWin.LastError + ")");
                }
                button.Text            = "Identify by Shape(s)";
                m_IdentByShape         = button;
                m_IdentByShape.Picture = icon2;
            }
            catch (System.Exception ex)
            {
                ShowErrorBox("Initialize()", ex.Message);
            }
        }
Beispiel #2
0
        private void LoadLayer()
        {
            try
            {
                //exit if their is no layers to load
                if (m_MapWin.Layers.NumLayers <= 0)
                {
                    return;
                }

                // Always try to create the panel; if it doesn't exist,
                // it will be created, and if it does exist, a handle will be returned.
                m_UIPanel = m_MapWin.UIPanel.CreatePanel("Identifier", DockStyle.None);
                // Not intuitive -- m_UIPanel = m_MapWin.UIPanel.CreatePanel("Identifier", MapWindow.Interfaces.MapWindowDockStyle.RightAutoHide);
                if (m_UIPanel != null)
                {
                    m_MapWin.UIPanel.AddOnCloseHandler("Identifier", OnPanelClose);
                    m_HavePanel = true;
                }

                if (m_OnWMSLayer)
                {
                    if (m_GridPropfrm.Visible || m_shpFilePropfrm.Visible)
                    {
                        m_shpFilePropfrm.Hide();
                        m_GridPropfrm.Hide();
                    }

                    if (m_WMSLayerIDReturn != "")
                    {
                        m_WMSPropfrm.PopulateForm(!m_HavePanel, m_WMSLayerIDReturn, m_MapWin.Layers[m_MapWin.Layers.CurrentLayer].Name, false);
                    }

                    if (m_HavePanel && m_UIPanel != null)
                    {
                        if (m_WMSPropfrm.panel1 == null || m_WMSPropfrm.panel1.IsDisposed)
                        {
                            m_WMSPropfrm = new mwIdentifier.Forms.frmWMSProp(this);
                        }

                        if (m_UIPanel_LastType != "WMS" && m_UIPanel_LastType != "")
                        {
                            while (m_UIPanel.Controls.Count > 0)
                            {
                                m_UIPanel.Controls.RemoveAt(0);
                            }
                        }

                        if (m_UIPanel.Controls.Count == 0)
                        {
                            m_UIPanel.Controls.Add(m_WMSPropfrm.panel1);
                            m_UIPanel_LastType = "WMS";
                        }
                        else
                        {
                            m_MapWin.UIPanel.SetPanelVisible("Identifier", true);
                        }

                        m_WMSPropfrm.Hide();
                    }
                }
                else
                {
                    //get the object from mapwindow
                    object obj       = m_MapWin.Layers[m_MapWin.Layers.CurrentLayer].GetObject();
                    string layerName = m_MapWin.Layers[m_MapWin.Layers.CurrentLayer].Name;
                    MapWindow.Interfaces.eLayerType LayerType = m_MapWin.Layers[m_MapWin.Layers.CurrentLayer].LayerType;


                    //if the layer is a shapefile
                    if (LayerType == MapWindow.Interfaces.eLayerType.LineShapefile ||
                        LayerType == MapWindow.Interfaces.eLayerType.PointShapefile ||
                        LayerType == MapWindow.Interfaces.eLayerType.PolygonShapefile)
                    {
                        if (m_GridPropfrm.Visible || m_WMSPropfrm.Visible)
                        {
                            m_WMSPropfrm.Hide();
                            m_GridPropfrm.Hide();
                        }

                        //check to see if there is any previously selected shapes
                        if (m_MapWin.View.SelectedShapes.NumSelected > 0)
                        {
                            int   numSel   = m_MapWin.View.SelectedShapes.NumSelected;
                            int[] shpIndex = new int[numSel];

                            for (int i = 0; i < numSel; i++)
                            {
                                shpIndex[i] = m_MapWin.View.SelectedShapes[i].ShapeIndex;
                            }
                            m_shpFilePropfrm.PopulateForm(!m_HavePanel, (Shapefile)obj, shpIndex, m_MapWin.Layers[m_MapWin.Layers.CurrentLayer].Name, false);
                        }
                        else
                        {
                            m_shpFilePropfrm.PopulateForm(!m_HavePanel, (Shapefile)obj, m_MapWin.Layers[m_MapWin.Layers.CurrentLayer].Name, false);
                        }
                    }
                    //if the layer is a grid
                    else if (LayerType == MapWindow.Interfaces.eLayerType.Grid)
                    {
                        if (m_shpFilePropfrm.Visible || m_WMSPropfrm.Visible)
                        {
                            m_WMSPropfrm.Hide();
                            m_shpFilePropfrm.Hide();
                        }

                        //get the grid object
                        Grid grid = m_MapWin.Layers[m_MapWin.Layers.CurrentLayer].GetGridObject;

                        if (grid != null)
                        {
                            m_GridPropfrm.PopulateForm(!m_HavePanel, grid, layerName, null, m_MapWin.Layers.CurrentLayer);
                        }
                        else
                        {
                            m_GridPropfrm.Hide();
                        }
                    }
                    //if the layer is a image
                    else if (LayerType == MapWindow.Interfaces.eLayerType.Image)
                    {
                        // Chris Michaelis - 5-17-2007 - Allow identification of image values (the color values), better than nothing.
                        // Do this when no associated grid is found of course.

                        if (m_shpFilePropfrm.Visible || m_WMSPropfrm.Visible)
                        {
                            m_WMSPropfrm.Hide();
                            m_shpFilePropfrm.Hide();
                        }

                        Grid grid = FindAssociatedGrid(((MapWinGIS.Image)obj).Filename);

                        if (grid != null)
                        {
                            m_GridPropfrm.PopulateForm(!m_HavePanel, grid, layerName, null, m_MapWin.Layers.CurrentLayer);
                        }
                        else
                        {
                            // Identify by values -- so just open the first band of the image.
                            // This only works for greyscale of course in this version (one band grids only)

                            Grid tmpGrid = new Grid();
                            try
                            {
                                // Open as a grid to get values
                                if (tmpGrid.Open(((MapWinGIS.Image)obj).Filename, GridDataType.UnknownDataType, false, GridFileType.UseExtension, null))
                                {
                                    m_GridPropfrm.PopulateForm(!m_HavePanel, tmpGrid, layerName, null, m_MapWin.Layers.CurrentLayer);
                                }
                                else
                                {
                                    MapWinUtility.Logger.Message("No information on this image can be displayed.", "Identifier", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information, DialogResult.OK);
                                    m_GridPropfrm.Hide();
                                }
                            }
                            catch
                            {
                                m_GridPropfrm.Hide();
                            }
                        }
                    }

                    if (m_HavePanel && m_UIPanel != null)
                    {
                        //if the layer is a shapefile
                        if (LayerType == MapWindow.Interfaces.eLayerType.LineShapefile ||
                            LayerType == MapWindow.Interfaces.eLayerType.PointShapefile ||
                            LayerType == MapWindow.Interfaces.eLayerType.PolygonShapefile)
                        {
                            if (m_shpFilePropfrm.panel1 == null || m_shpFilePropfrm.panel1.IsDisposed)
                            {
                                m_shpFilePropfrm = new mwIdentifier.Forms.frmShapeFileProp(this);
                            }

                            if (m_UIPanel_LastType != "shapefile" && m_UIPanel_LastType != "")
                            {
                                while (m_UIPanel.Controls.Count > 0)
                                {
                                    m_UIPanel.Controls.RemoveAt(0);
                                }
                            }

                            if (m_UIPanel.Controls.Count == 0)
                            {
                                m_UIPanel.Controls.Add(m_shpFilePropfrm.panel1);
                                m_UIPanel_LastType = "shapefile";
                            }
                            else
                            {
                                m_MapWin.UIPanel.SetPanelVisible("Identifier", true);
                            }

                            m_shpFilePropfrm.Hide();
                        }
                        //if the layer is a grid or image
                        else if (LayerType == MapWindow.Interfaces.eLayerType.Grid || LayerType == MapWindow.Interfaces.eLayerType.Image)
                        {
                            if (m_GridPropfrm.panel1 == null || m_GridPropfrm.panel1.IsDisposed)
                            {
                                m_GridPropfrm = new mwIdentifier.Forms.frmGridProp(this);
                            }

                            if (m_UIPanel_LastType != "grid" && m_UIPanel_LastType != "")
                            {
                                while (m_UIPanel.Controls.Count > 0)
                                {
                                    m_UIPanel.Controls.RemoveAt(0);
                                }
                            }

                            if (m_UIPanel.Controls.Count == 0)
                            {
                                m_UIPanel.Controls.Add(m_GridPropfrm.panel1);
                                m_UIPanel_LastType = "grid";
                            }
                            else
                            {
                                m_MapWin.UIPanel.SetPanelVisible("Identifier", true);
                            }

                            m_GridPropfrm.Hide();
                        }
                    }
                    // else Normal identifier with a separate window
                }
            }
            catch (System.Exception ex)
            {
                ShowErrorBox("LoadLayer()", ex.Message);
            }
        }
Beispiel #3
0
        public void LoadLayerAlternate(MapWindow.Interfaces.eLayerType LayerType, string layerName)
        {
            try
            {
                //exit if their is no layers to load
                if (m_MapWin.Layers.NumLayers <= 0)
                {
                    return;
                }

                // Always try to create the panel; if it doesn't exist,
                // it will be created, and if it does exist, a handle will be returned.
                m_UIPanel = m_MapWin.UIPanel.CreatePanel("Identifier", DockStyle.None);
                // Not intuitive -- m_UIPanel = m_MapWin.UIPanel.CreatePanel("Identifier", MapWindow.Interfaces.MapWindowDockStyle.RightAutoHide);
                if (m_UIPanel != null)
                {
                    m_MapWin.UIPanel.AddOnCloseHandler("Identifier", OnPanelClose);
                    m_HavePanel = true;
                }

                //if the layer is a shapefile
                if (LayerType == MapWindow.Interfaces.eLayerType.LineShapefile ||
                    LayerType == MapWindow.Interfaces.eLayerType.PointShapefile ||
                    LayerType == MapWindow.Interfaces.eLayerType.PolygonShapefile)
                {
                    if (m_GridPropfrm.Visible)
                    {
                        m_GridPropfrm.Hide();
                    }
                }
                //if the layer is a grid
                else if (LayerType == MapWindow.Interfaces.eLayerType.Grid)
                {
                    if (m_shpFilePropfrm.Visible)
                    {
                        m_shpFilePropfrm.Hide();
                        m_WMSPropfrm.Hide();
                    }
                }
                //if the layer is a image
                else if (LayerType == MapWindow.Interfaces.eLayerType.Image)
                {
                    if (m_shpFilePropfrm.Visible)
                    {
                        m_shpFilePropfrm.Hide();
                        m_WMSPropfrm.Hide();
                    }
                }

                if (m_HavePanel && m_UIPanel != null)
                {
                    //if the layer is a shapefile
                    if (LayerType == MapWindow.Interfaces.eLayerType.LineShapefile ||
                        LayerType == MapWindow.Interfaces.eLayerType.PointShapefile ||
                        LayerType == MapWindow.Interfaces.eLayerType.PolygonShapefile)
                    {
                        if (m_shpFilePropfrm.panel1 == null || m_shpFilePropfrm.panel1.IsDisposed)
                        {
                            m_shpFilePropfrm = new mwIdentifier.Forms.frmShapeFileProp(this);
                        }

                        if (m_UIPanel_LastType != "shapefile" && m_UIPanel_LastType != "")
                        {
                            while (m_UIPanel.Controls.Count > 0)
                            {
                                m_UIPanel.Controls.RemoveAt(0);
                            }
                        }

                        if (m_UIPanel.Controls.Count == 0)
                        {
                            m_UIPanel.Controls.Add(m_shpFilePropfrm.panel1);
                            m_UIPanel_LastType = "shapefile";
                        }
                        else
                        {
                            m_MapWin.UIPanel.SetPanelVisible("Identifier", true);
                        }

                        m_shpFilePropfrm.Hide();
                    }
                    //if the layer is a grid or image
                    else if (LayerType == MapWindow.Interfaces.eLayerType.Grid || LayerType == MapWindow.Interfaces.eLayerType.Image)
                    {
                        if (m_GridPropfrm.panel1 == null || m_GridPropfrm.panel1.IsDisposed)
                        {
                            m_GridPropfrm = new mwIdentifier.Forms.frmGridProp(this);
                        }

                        if (m_UIPanel_LastType != "grid" && m_UIPanel_LastType != "")
                        {
                            while (m_UIPanel.Controls.Count > 0)
                            {
                                m_UIPanel.Controls.RemoveAt(0);
                            }
                        }

                        if (m_UIPanel.Controls.Count == 0)
                        {
                            m_UIPanel.Controls.Add(m_GridPropfrm.panel1);
                            m_UIPanel_LastType = "grid";
                        }
                        else
                        {
                            m_MapWin.UIPanel.SetPanelVisible("Identifier", true);
                        }

                        m_GridPropfrm.Hide();
                    }
                }
                // else Normal identifier with a separate window
            }
            catch (System.Exception ex)
            {
                ShowErrorBox("LoadLayer()", ex.Message);
            }
        }