예제 #1
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            //creates kml file if selected.
            String path = txtFileName.Text;

            if ((path != null) &&(path != "" ))
            if (Directory.Exists(Path.GetDirectoryName(path)))
                //diretorul exista. Si acum fisierul are extensie kml?
                if (Path.GetFileName(path).EndsWith(".kml"))
                       //si e fisier kml. BUn...
                {
                    KMLGenerator generator = new KMLGenerator(layers);
                    //create style in generator
                    #region Create kml style

                    geStyle style = new geStyle("Shape2KMLGeneratedStyle");
                    //style.ID = "Shape2KMLGeneratedStyle";

                    //should use booleans for these, but for now checking the controls is ok...

                    if (grpIcon.Visible)
                    {
                        //icon style
                        style.IconStyle = new geIconStyle();
                        style.IconStyle.Color.SysColor = pbIcon.BackColor;
                        //style.IconStyle.ColorMode =
                        style.IconStyle.Icon = new geIcon(pbSelectedIcon.ImageLocation);
                    }

                    if (grpLine.Visible)
                    {
                        //line style, if we have lines
                        style.LineStyle = new geLineStyle();
                        style.LineStyle.Color.SysColor = pbLine.BackColor;
                        style.LineStyle.Width = (float)numLineWidth.Value;
                    }

                    //polygon style, only if we have polygons
                    if (grpPoly.Visible)
                    {
                        style.PolyStyle = new gePolyStyle();
                        style.PolyStyle.Color.SysColor = pbFill.BackColor;

                    }

                    generator.DefaultStyle = style;
                    #endregion

                    pnlMain.Visible = false;
                    pnlProgress.Visible = true;
                    //IMxDocument activeDoc = m_application.Document as IMxDocument;
                    //MessageBox.Show (activeDoc.ToString);

                    //get active document name
                    String docPath = GetActiveDocumentPath(m_application);
                    generator.KmlDocument.Name = Path.GetFileName(docPath);
                    generator.KmlDocument.Description = docPath;
                    generator.Generate(path,pbarDone);

                    MessageBox.Show("Creat document "+ path);
                    pnlMain.Visible = true;
                    pnlProgress.Visible = false;

                }
               // MessageBox.Show("not ok");
        }
예제 #2
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            //creates kml file if selected.
            String path = txtFileName.Text;

            if ((path != null) && (path != ""))
            {
                if (Directory.Exists(Path.GetDirectoryName(path)))
                {
                    //diretorul exista. Si acum fisierul are extensie kml?
                    if (Path.GetFileName(path).EndsWith(".kml"))
                    //si e fisier kml. BUn...
                    {
                        KMLGenerator generator = new KMLGenerator(layers);
                        //create style in generator
                        #region Create kml style

                        geStyle style = new geStyle("Shape2KMLGeneratedStyle");
                        //style.ID = "Shape2KMLGeneratedStyle";

                        //should use booleans for these, but for now checking the controls is ok...

                        if (grpIcon.Visible)
                        {
                            //icon style
                            style.IconStyle = new geIconStyle();
                            style.IconStyle.Color.SysColor = pbIcon.BackColor;
                            //style.IconStyle.ColorMode =
                            style.IconStyle.Icon = new geIcon(pbSelectedIcon.ImageLocation);
                        }

                        if (grpLine.Visible)
                        {
                            //line style, if we have lines
                            style.LineStyle = new geLineStyle();
                            style.LineStyle.Color.SysColor = pbLine.BackColor;
                            style.LineStyle.Width          = (float)numLineWidth.Value;
                        }

                        //polygon style, only if we have polygons
                        if (grpPoly.Visible)
                        {
                            style.PolyStyle = new gePolyStyle();
                            style.PolyStyle.Color.SysColor = pbFill.BackColor;
                        }

                        generator.DefaultStyle = style;
                        #endregion

                        pnlMain.Visible     = false;
                        pnlProgress.Visible = true;
                        //IMxDocument activeDoc = m_application.Document as IMxDocument;
                        //MessageBox.Show (activeDoc.ToString);

                        //get active document name
                        String docPath = GetActiveDocumentPath(m_application);
                        generator.KmlDocument.Name        = Path.GetFileName(docPath);
                        generator.KmlDocument.Description = docPath;
                        generator.Generate(path, pbarDone);

                        MessageBox.Show("Creat document " + path);
                        pnlMain.Visible     = true;
                        pnlProgress.Visible = false;
                    }
                }
            }
            // MessageBox.Show("not ok");
        }