예제 #1
0
        private void clipFunctionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                XmlNode xn = doc.SelectSingleNode("XmlRasterFunctionTemplate");

                XmlElement xmlnode1 = doc.CreateElement("Function");
                //xn.AppendChild(xmlnode1);
                xmlnode1.SetAttribute("name", "clipFunction");
                xmlnode1.SetAttribute("description", "A raster clip function.");
                //doc.AppendChild(xmlnode1);

                xmlnode1.AppendChild(doc.CreateElement("inputSHPPath", ""));

                //窗口打开
                clipFunction clipFunction = new clipFunction(xmlnode1);
                clipFunction.ShowDialog();

                //得到XML中的Element
                XmlNode    node    = clipFunction.GetXMLNode();
                XmlElement temp    = node as XmlElement;
                DataRow    dataRow = dataTable.NewRow();
                //dataRow[0] = dataTable.Columns.Count;
                //现在是会报错 因为没有传出来temp
                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);
            }
        }
예제 #2
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);
            }
        }