Ejemplo n.º 1
0
        public DialogResult ShowPreImportDialogs()
        {
            if (BeginWork != null)
            {
                BeginWork(this, new EventArgs());
            }

            DialogResult result;
            var          showProgressIndicator = false;

            if (!garminUSBReader.CachedSessionsExists && !garminUSBReader.ReadingNow)
            {
                garminUSBReader.BeginReadData();
                showProgressIndicator = true;
            }
            else
            {
                showProgressIndicator = garminUSBReader.ReadingNow;
            }

            if (showProgressIndicator)
            {
                var progressIndicator = new ProgressIndicator(garminUSBReader);
                result = progressIndicator.ShowDialog();
                if (result != DialogResult.OK)
                {
                    if (EndWork != null)
                    {
                        EndWork(this, new EventArgs());
                    }
                    return(result);
                }
            }

            var sessionHeaders = new List <GarminSessionHeader>(garminUSBReader.GetSessionHeadersFromCache());

            sessionHeaders.Sort();
            sessionHeaders.Reverse();

            using (var dlg = new GarminSessionSelector(sessionHeaders))
            {
                result = dlg.ShowDialog();
                if (result == DialogResult.OK)
                {
                    sessionToImport = garminUSBReader.GetSessionFromCache(dlg.SelectedSessionHeader);
                }
                dlg.Dispose();
            }

            if (EndWork != null)
            {
                EndWork(this, new EventArgs());
            }

            return(result);
        }
        public DialogResult ShowPreImportDialogs()
        {
            if (BeginWork != null) BeginWork(this, new EventArgs());

              DialogResult result;
              var showProgressIndicator = false;

              if (/*!garminUSBReader.CachedSessionsExists && */ !garminUSBReader.ReadingNow)
              {
            garminUSBReader.BeginReadData();
            showProgressIndicator = true;
              }
              else
              {
            showProgressIndicator = garminUSBReader.ReadingNow;
              }

              if (showProgressIndicator)
              {
            var progressIndicator = new ProgressIndicator(garminUSBReader);
            result = progressIndicator.ShowDialog();
            if (result != DialogResult.OK)
            {
              if (EndWork != null) EndWork(this, new EventArgs());
              return result;
            }
              }

              var sessionHeaders = new List<GarminSessionHeader>(garminUSBReader.GetSessionHeadersFromCache());
              sessionHeaders.Sort();
              sessionHeaders.Reverse();

              using (var dlg = new GarminSessionSelector(sessionHeaders))
              {
            result = dlg.ShowDialog();
            if (result == DialogResult.OK)
            {
              sessionToImport = garminUSBReader.GetSessionFromCache(dlg.SelectedSessionHeader);
            }
            dlg.Dispose();
              }

              if (EndWork != null) EndWork(this, new EventArgs());

              return result;
        }