Beispiel #1
0
        private void panSharpenFunctionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                XmlElement   xelKey  = doc.CreateElement("Function");
                XmlAttribute xelName = doc.CreateAttribute("name");
                xelName.InnerText = "Pansharpening";
                xelKey.SetAttributeNode(xelName);

                XmlAttribute xelDesp = doc.CreateAttribute("description");
                xelDesp.InnerText = "Enhances the spatial resolution of a multiband image by fusing it with a higher-resolution panchromatic image.";
                xelKey.SetAttributeNode(xelDesp);

                XmlElement xelPanImage = doc.CreateElement("PanImage");
                xelPanImage.InnerText = "default";
                xelKey.AppendChild(xelPanImage);

                XmlElement xelType = doc.CreateElement("PansharpeningType");
                xelType.InnerText = "0";
                xelKey.AppendChild(xelType);

                XmlElement xelRed = doc.CreateElement("Red");
                xelRed.InnerText = "0.166";
                xelKey.AppendChild(xelRed);

                XmlElement xelGreen = doc.CreateElement("Green");
                xelGreen.InnerText = "0.166";
                xelKey.AppendChild(xelGreen);

                XmlElement xelBlue = doc.CreateElement("Blue");
                xelBlue.InnerText = "0.166";
                xelKey.AppendChild(xelBlue);

                XmlElement xelIR = doc.CreateElement("Infra");
                xelIR.InnerText = "0.5";
                xelKey.AppendChild(xelIR);

                XmlElement xelOutput = doc.CreateElement("Output");
                xelOutput.InnerText = "_pansharpen";
                xelKey.AppendChild(xelOutput);

                //窗口打开
                panSharpenFunction panSharpenFunction = new panSharpenFunction(xelKey);
                panSharpenFunction.ShowDialog();
                //得到XML中的Element
                XmlNode node = panSharpenFunction.GetXMLNode();

                XmlElement temp    = node as XmlElement;
                DataRow    dataRow = dataTable.NewRow();
                //dataRow[0] = dataTable.Columns.Count;

                dataRow[0]    = temp.GetAttribute("name");
                dataRow[1]    = temp.GetAttribute("description");
                m_hitRowindex = (m_hitRowindex < 0) ? dataTable.Rows.Count : m_hitRowindex;
                dataTable.Rows.InsertAt(dataRow, m_hitRowindex);
                //对doc进行修改
                InsertDoc(doc, node, m_hitRowindex);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        //对于doc进行loop,依次进行Init()函数
        private void miFinish_Click(object sender, EventArgs e)
        {
            if (dataTable.Rows.Count == 0)
            {
                MessageBox.Show("编辑器不能为空");
            }
            else
            {
                if (m_checkedindex == -1)
                {
                    m_checkedindex = dataTable.Rows.Count - 1;
                }
                XmlNode     xn  = doc.SelectSingleNode("XmlRasterFunctionTemplate");
                XmlNodeList xnl = xn.ChildNodes;
                int         i   = 0;
                foreach (XmlNode xn1 in xnl)
                {
                    if (xn1 is XmlComment)
                    {
                        continue;
                    }
                    //else if (xn1.
                    if (i == (m_checkedindex + 1))
                    {
                        break;
                    }
                    XmlElement xe = (XmlElement)xn1;
                    if (xe.Name == "Function")
                    {
                        switch (xe.GetAttribute("name"))
                        {
                        case "Pansharpening":
                        {
                            panSharpenFunction panSharpenFunction = new panSharpenFunction(m_raster, xn1);
                            panSharpenFunction.Init();
                            m_raster = panSharpenFunction.GetRaster();
                            break;
                        }

                        case "Convolution":
                        {
                            convolutionFunction convolutionFunction = new convolutionFunction(m_raster, xn1);
                            convolutionFunction.underInit();
                            m_raster = convolutionFunction.GetRaster();
                            break;
                        }

                        case "Slope":
                        {
                            slopeFunction slopeFunction = new slopeFunction(m_raster, xn1);
                            slopeFunction.Init();
                            m_raster = slopeFunction.GetRaster();
                            break;
                        }

                        case "Aspect":
                        {
                            aspectFunction aspectFunction = new aspectFunction(m_raster, xn1);
                            aspectFunction.Init();
                            m_raster = aspectFunction.GetRaster();
                            break;
                        }

                        case "stretchFunction":
                        {
                            stretchFunction stretchFunction = new stretchFunction(m_raster, xn1);
                            stretchFunction.Init();
                            m_raster = stretchFunction.GetRaster();
                            break;
                        }

                        case "ndviFunction":
                        {
                            ndviFunction ndviFunction = new ndviFunction(m_raster, xn1);
                            ndviFunction.Init();
                            //ndviFunction.UnderInit();
                            m_raster = ndviFunction.GetRaster();
                            break;
                        }

                        case "clipFunction":
                        {
                            clipFunction clipFunction = new clipFunction(m_raster, xn1);
                            clipFunction.Init();
                            m_raster = clipFunction.GetRaster();
                            break;
                        }

                        case "hillshadeFunction":
                        {
                            hillshadeFunction hillshadeFunction = new hillshadeFunction(m_raster, xn1);
                            hillshadeFunction.Init();
                            m_raster = hillshadeFunction.GetRaster();
                            break;
                        }

                        default:
                            break;
                        }
                        i++;
                    }
                }
            }
            IsFinished = true;
        }
Beispiel #3
0
        private void dataGridView1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            try
            {
                DataGridView.HitTestInfo hit = dataGridView1.HitTest(e.X, e.Y);
                if (hit.ColumnIndex != 0)
                {
                    if (hit.Type == DataGridViewHitTestType.Cell)
                    {
                        m_doublehitRowindex = hit.RowIndex;
                        XmlNode     xn  = doc.SelectSingleNode("XmlRasterFunctionTemplate");
                        XmlNodeList xnl = xn.ChildNodes;
                        int         i   = 0;
                        foreach (XmlNode xn1 in xnl)
                        {
                            if (xn1 is XmlComment)
                            {
                                continue;
                            }
                            //else if (xn1.
                            XmlElement xe = (XmlElement)xn1;
                            if (xe.Name == "Function")
                            {
                                if (i == m_doublehitRowindex)
                                {
                                    switch (xe.GetAttribute("name"))
                                    {
                                    case "Pansharpening":
                                    {
                                        panSharpenFunction panSharpenFunction = new panSharpenFunction(xn1);
                                        panSharpenFunction.ShowDialog();
                                        EditDoc(doc, panSharpenFunction.GetXMLNode(), m_doublehitRowindex);
                                        break;
                                    }

                                    case "Convolution":
                                    {
                                        convolutionFunction convolutionFunction = new convolutionFunction(xn1);
                                        convolutionFunction.ShowDialog();
                                        EditDoc(doc, convolutionFunction.GetXMLNode(), m_doublehitRowindex);
                                        break;
                                    }

                                    case "Slope":
                                    {
                                        slopeFunction slopeFunction = new slopeFunction(xn1);
                                        slopeFunction.ShowDialog();
                                        EditDoc(doc, slopeFunction.GetXMLNode(), m_doublehitRowindex);
                                        break;
                                    }

                                    case "Aspect":
                                    {
                                        break;
                                    }

                                    case "stretchFunction":
                                    {
                                        stretchFunction stretchFunction = new stretchFunction(xn1);
                                        stretchFunction.ShowDialog();
                                        EditDoc(doc, stretchFunction.GetXMLNode(), m_doublehitRowindex);
                                        break;
                                    }

                                    case "ndviFunction":
                                    {
                                        ndviFunction ndviFunction = new ndviFunction(m_raster, xn1);
                                        ndviFunction.ShowDialog();
                                        EditDoc(doc, ndviFunction.GetXMLNode(), m_doublehitRowindex);
                                        break;
                                    }

                                    case "clipFunction":
                                    {
                                        clipFunction clipFunction = new clipFunction(xn1);
                                        clipFunction.ShowDialog();
                                        EditDoc(doc, clipFunction.GetXMLNode(), m_doublehitRowindex);
                                        break;
                                    }

                                    case "hillshadeFunction":
                                    {
                                        hillshadeFunction hillshadeFunction = new hillshadeFunction(xn1);
                                        hillshadeFunction.ShowDialog();
                                        EditDoc(doc, hillshadeFunction.GetXMLNode(), m_doublehitRowindex);
                                        break;
                                    }

                                    default:
                                        break;
                                    }
                                }
                                i++;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }