コード例 #1
0
        private void loadButton_Click(object sender, EventArgs e)
        {
            // Confirm stuff is defined
            string ntxFile         = ntxFileTextBox.Text.Trim();
            string translationFile = translationTextBox.Text.Trim();

            if (ntxFile.Length == 0)
            {
                MessageBox.Show("You must first specify the name of the input file.");
                return;
            }

            // Load any translation file that's been specified
            if (translationFile.Length > 0)
            {
                m_Translator = new TranslationFile();
                m_Translator.Load(translationFile);
            }

            ForwardingTraceListener trace = new ForwardingTraceListener(ShowLoadProgress);

            try
            {
                statusStrip.Visible = true;
                loadButton.Enabled  = false;
                closeButton.Enabled = false;
                Trace.Listeners.Add(trace);
                LoadNtx(ntxFile);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace, ex.Message);
            }

            finally
            {
                Trace.Listeners.Remove(trace);
                statusStrip.Visible = false;
                closeButton.Enabled = true;
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: steve-stanton/backsight
        internal Project OpenProject(string projectName)
        {
            if (String.IsNullOrEmpty(projectName))
                return null;

            ProjectDatabase pd = new ProjectDatabase();
            ProjectSettings ps = pd.GetProjectSettings(projectName);
            if (ps == null)
                return null;

            // Close any currently open project or dialog.
            OnProjectOpening();

            ForwardingTraceListener trace = new ForwardingTraceListener(ShowLoadProgress);
            Stopwatch sw = Stopwatch.StartNew();

            try
            {
                string increment = ps.SplashIncrement;
                string percents = ps.SplashPercents;

                // Don't show splash screen if it's a brand new file
                //if (percents.Length > 0)
                SplashScreen.ShowSplashScreen(increment, percents);

                Trace.Listeners.Add(trace);
                Trace.Write("Loading " + projectName);

                // Display the map name in the dialog title (nice to see what's loading
                // rather than the default "Map Title" text)
                this.Text = projectName;
                Project p = pd.OpenProject(projectName);

                // Remember the project the user is now working with
                //EditingController.Current.SetProject(p);

                // Update splashscreen metrics. This is perhaps a little premature, since
                // the original splash screen implementation waited until the screen had
                // completely faded away. The drawback with that is that the project settings would
                // then be rewritten on another thread, which could trample on things that
                // are happening here.
                SplashScreen ss = SplashScreen.SplashForm;
                p.Settings.SplashIncrement = ss.GetIncrement();
                p.Settings.SplashPercents = ss.GetPercents();
                p.SaveSettings();

                sw.Stop();
                ShowLoadProgress(String.Format("Load time: {0:0.00} seconds", sw.ElapsedMilliseconds / 1000.0));

                // If the splash screen has been displayed for less than two seconds, WAIT (block
                // this thread!)
                int waitTime = (int)(2000 - sw.ElapsedMilliseconds);
                if (waitTime > 0)
                    System.Threading.Thread.Sleep(waitTime);

                // Need to first initialize overview extent before defining center and scale
                // ...but first pick up the last draw info before defining the overview extent (really,
                // should modify SetMapModel so it accepts the DrawInfo rather than an extent).
                // ...I think initialization of the overview extent will adjust the last draw
                // data that's saved in the project settings

                //DrawInfo drawInfo = p.Settings.LastDraw;
                DrawInfo drawInfo = ps.LastDraw;
                //EditingController.Current.SetMapModel(p.Model, null);

                if (drawInfo.MapScale > 0)
                {
                    double cx = drawInfo.CenterX;
                    double cy = drawInfo.CenterY;
                    double mapScale = drawInfo.MapScale;
                    (EditingController.Current.ActiveDisplay as MapControl).SetCenterAndScale(cx, cy, mapScale, true);
                }

                return p;
            }

            catch (Exception ex)
            {
                SplashScreen.CloseForm();
                ShowMessageBox(ex);
                Trace.Write(ex.StackTrace);
            }

            finally
            {
                SplashScreen.CloseForm();
                Trace.Listeners.Remove(trace);
            }

            return null;
        }
コード例 #3
0
        private void loadButton_Click(object sender, EventArgs e)
        {
            // Confirm stuff is defined
            string ntxFile = ntxFileTextBox.Text.Trim();
            string translationFile = translationTextBox.Text.Trim();

            if (ntxFile.Length==0)
            {
                MessageBox.Show("You must first specify the name of the input file.");
                return;
            }

            // Load any translation file that's been specified
            if (translationFile.Length>0)
            {
                m_Translator = new TranslationFile();
                m_Translator.Load(translationFile);
            }

            ForwardingTraceListener trace = new ForwardingTraceListener(ShowLoadProgress);

            try
            {
                statusStrip.Visible = true;
                loadButton.Enabled = false;
                closeButton.Enabled = false;
                Trace.Listeners.Add(trace);
                LoadNtx(ntxFile);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace, ex.Message);
            }

            finally
            {
                Trace.Listeners.Remove(trace);
                statusStrip.Visible = false;
                closeButton.Enabled = true;
            }
        }