コード例 #1
0
        private void exportButton_Click(object sender, System.EventArgs e)
        {
            exportButton.Enabled = false;
            Cursor.Current       = Cursors.WaitCursor;

            if (Project.exportDestFolder.Length == 0)
            {
                setExportDestFolder();
            }

            if (Project.exportDestFolder.Length > 0 && Directory.Exists(Project.exportDestFolder))
            {
                Hashtable listOfTiles = new Hashtable();

                int scaleIndex = 10 + (m_scaleShift == 0 ? Project.preloadScale1 : (Project.preloadScale2 + m_scaleShift));

                int levels = TileSetTerraLayout.listTilesAtLevels(listOfTiles,
                                                                  PictureManager.This.CameraManager.CoverageTopLeft,
                                                                  PictureManager.This.CameraManager.CoverageBottomRight,
                                                                  scaleIndex, scaleUpCheckBox.Checked);

                int countLoaded = 0;
                int countTotal  = 0;

                // save selected tiles:
                foreach (string tileName in listOfTiles.Keys)
                {
                    string fileNameJpg = tileName + ".jpg";
                    string srcPath     = Project.GetTerraserverPath(fileNameJpg);

                    if (File.Exists(srcPath))
                    {
                        try
                        {
                            PdaHelper.exportSingleFile(tileName, srcPath, true);
                            countLoaded++;
                        }
                        catch (Exception ee)
                        {
#if DEBUG
                            // some files may be broken/missing, not a big deal
                            LibSys.StatusBar.Error("PreloadTiles:export " + ee.Message);
#endif
                        }
                    }
                    countTotal++;
                }
                this.messageLabel.Text = "OK: " + countLoaded + " downloaded tiles out of "
                                         + countTotal + " covering whole view on " + levels + " levels\n  exported to folder: " + Project.exportDestFolder;
            }
            else
            {
                this.messageLabel.Text = "Error: folder '" + Project.exportDestFolder + "' not valid.";
                setExportDestFolder();
            }
            exportButton.Enabled = true;
            Cursor.Current       = Cursors.Default;
        }
コード例 #2
0
        private void exportByList(Hashtable listOfTiles, out int countExported, out int countTotal)
        {
            countExported = 0;
            countTotal    = 0;

            int      toExport      = listOfTiles.Count;
            DateTime lastDisplayed = DateTime.Now;
            DateTime started       = DateTime.Now;

            // save selected tiles. This loop takes time, if BMP conversion is performed.
            foreach (string tileName in listOfTiles.Keys)
            {
                if (m_canceling)
                {
                    break;
                }

                string fileNameJpg = tileName + ".jpg";
                string srcPath     = Project.GetTerraserverPath(fileNameJpg);

                int percentComplete = (int)(countTotal * 100.0d / toExport);

                if (File.Exists(srcPath))
                {
                    try
                    {
                        string dstPath = PdaHelper.exportSingleFile(tileName, srcPath, true);

                        if ((DateTime.Now - lastDisplayed).TotalMilliseconds > 500)
                        {
                            string timeLeftStr = "";
                            if (percentComplete > 1.0d)
                            {
                                TimeSpan elapsed   = DateTime.Now - started;
                                TimeSpan projected = new TimeSpan((long)(((double)elapsed.Ticks) / ((double)percentComplete) * 100.0d));
                                TimeSpan left      = projected - elapsed;
                                timeLeftStr = "    (" + left.Minutes + " min. " + left.Seconds + " sec. left)";
                            }

                            this.estimateLabel.Text = "" + countTotal + " of " + toExport + "  -  " + percentComplete + "%" + timeLeftStr + "\r\n" + dstPath;
                            this.estimateLabel.Refresh();
                            progressBar1.Value = Math.Min(percentComplete, 100);
                            progressBar1.Refresh();
                            Application.DoEvents();
                            lastDisplayed = DateTime.Now;
                        }
                        countExported++;
                    }
                    catch (Exception ee)
                    {
#if DEBUG
                        // some files may be broken/missing, not a big deal
                        LibSys.StatusBar.Error("PreloadTiles:export " + ee.Message);
#endif
                    }
                }
                countTotal++;
            }

            this.estimateLabel.Text = "100% complete";
            this.estimateLabel.Refresh();
            progressBar1.Value = 100;
            progressBar1.Refresh();
            Application.DoEvents();
        }