/// <summary>
        /// Populates the list of logs contained in the field notes file
        /// </summary>
        /// <param name="logs">
        /// A list of cache logs<see cref="List<CacheLog>"/>
        /// </param>
        public void PopulateLogs(List <CacheLog> logs)
        {
            this.GdkWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Watch);
            this.Sensitive        = false;
            OCMApp.UpdateGUIThread();
            m_logList.Clear();
            m_caches.Clear();
            fieldNotesDescPane.Sensitive = false;
            viewCacheButton.Sensitive    = false;
            deleteButton.Sensitive       = false;
            m_Logs = logs;
            listSort.SetSortColumnId(0, SortType.Descending);
            List <String> caches = new List <String> ();

            foreach (CacheLog log in logs)
            {
                m_logList.AppendValues(log);
                caches.Add(log.CacheCode);
            }
            List <Geocache> cachesInDb = m_Win.App.CacheStore.GetCachesByName(caches.ToArray());

            foreach (Geocache cache in cachesInDb)
            {
                m_caches[cache.Name] = cache;
            }
            this.Sensitive        = true;
            this.GdkWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Arrow);
        }
 /// <summary>
 /// Sends Geocaches to a device
 /// </summary>
 /// <param name="caches">
 /// A list of geocaches <see cref="List<Geocache>"/>
 /// </param>
 /// <param name="profile">
 /// A gps profiles <see cref="GPSProfile"/>
 /// </param>
 /// <param name="includeChildren">
 /// If true, include child waypoints<see cref="System.Boolean"/>
 /// </param>
 /// <param name="store">
 /// The source cache store <see cref="ACacheStore"/>
 /// </param>
 public void Start(List <Geocache> caches, GPSProfile profile, bool includeChildren, ACacheStore store)
 {
     try {
         total = caches.Count + 1;
         if (profile.CacheLimit != -1 && profile.CacheLimit < caches.Count)
         {
             total = profile.CacheLimit + 1;
         }
         writer.Limit             = profile.CacheLimit;
         writer.BabelFile         = profile.OutputFile;
         writer.BabelFormat       = profile.BabelFormat;
         writer.DescMode          = profile.DescMode;
         writer.NameMode          = profile.NameMode;
         writer.LogLimit          = profile.LogLimit;
         writer.IncludeAttributes = profile.IncludeAttributes;
         writer.OtherBabelParams  = profile.OtherProperties;
         writer.IncludeChildren   = includeChildren;
         writer.ForcePlainText    = profile.ForcePlainText;
         OCMApp.UpdateGUIThread();
         writer.WriteToGPS(caches, profile.WaypointMappings, store);
         this.Show();
     } catch (Exception e) {
         this.Hide();
         OCMApp.ShowException(e);
     }
 }
 /// <summary>
 /// Starts downloading a list of files
 /// </summary>
 /// <param name="files">
 /// A list of file urls<see cref="List<System.String>"/>
 /// </param>
 /// <param name="destFolder">
 /// The destination directory <see cref="System.String"/>
 /// </param>
 public void Start(List <string> files, string destFolder)
 {
     try
     {
         int iCount = 1;
         int total  = files.Count;
         this.Show();
         OCMApp.UpdateGUIThread();
         foreach (string url in files)
         {
             if (m_cancel)
             {
                 break;
             }
             DownloadFile(url, destFolder, total, ref iCount);
         }
         if (m_cancel)
         {
             progBar.Text = Catalog.GetString("Cancelled");
         }
         else
         {
             progBar.Text = Catalog.GetString("Complete");
         }
         buttonOk.Show();
         buttonCancel.Hide();
     }
     catch (Exception e)
     {
         this.Hide();
         OCMApp.ShowException(e);
     }
 }
Exemple #4
0
        void HandleAppCacheStoreReadCache(object sender, ocmengine.ReadCacheArgs args)
        {
            m_Model.Add(args.Cache);
            if (!args.Cache.Available)
            {
                m_disabledOrArchivedCount++;
            }
            else if (args.Cache.Archived)
            {
                m_disabledOrArchivedCount++;
            }
            if (args.Cache.Found)
            {
                m_foundCount++;
            }
            if (m_App.OwnerIDs.Contains(args.Cache.OwnerID) || m_App.OwnerIDs.Contains(args.Cache.PlacedBy))
            {
                m_mineCount++;
            }
            m_visibleCount++;

            m_Count++;
            if (m_Count == 50)
            {
                loadProgress.Pulse();
                OCMApp.UpdateGUIThread();
                m_Count = 0;
            }
        }
Exemple #5
0
 void HandleHandlePrepare(object o, PrepareArgs args)
 {
     if (args.Page == confirm)
     {
         this.GdkWindow.Cursor = new Cursor(CursorType.Watch);
         OCMApp.UpdateGUIThread();
         confirm.Prepare();
         this.GdkWindow.Cursor = new Cursor(CursorType.Arrow);
     }
 }
Exemple #6
0
        void UpdateBG()
        {
            int idx = animPos;

            this.GdkWindow.SetBackPixmap(backgrounds[idx], false);
            this.GdkWindow.InvalidateRect(new Rectangle(0, 0, 744, 600), true);
            OCMApp.UpdateGUIThread();
            animPos++;
            if (animPos >= backgrounds.Length)
            {
                animPos = 0;
            }
        }
        private void DownloadFile(string url, string destFolder, int total, ref int iCount)
        {
            WebRequest  req   = WebRequest.Create(url);
            WebResponse resp  = req.GetResponse();
            string      fName = Utilities.GetShortFileNameNoExtension(url);

            if (fName == null)
            {
                // Skip this file
                iCount++;
                return;
            }

            System.IO.FileStream fs        = new FileStream(destFolder + "/" + fName, FileMode.Create);
            System.IO.Stream     webstream = resp.GetResponseStream();
            fileLabel.Markup = String.Format(Catalog.GetString("File {0} of {1}"), iCount, total);
            long totalKB    = resp.ContentLength / 8;
            long totalBytes = resp.ContentLength;
            long currProg   = 0;

            byte[] buff = new byte[4096];
            for (;;)
            {
                OCMApp.UpdateGUIThread();
                long currKB = currProg / 8;
                progBar.Text = String.Format(Catalog.GetString("Received {0} bytes of {1} bytes"), currKB, totalKB);
                double progress = (((double)currProg / (double)totalBytes) + (double)iCount) / (double)total;
                if (progress > 1)
                {
                    progress = 1;
                }
                if (progBar.Fraction >= 0)
                {
                    progBar.Fraction = progress;
                }
                int read = webstream.Read(buff, 0, 4096);
                currProg = currProg + read;
                if (read > 0 && !m_cancel)
                {
                    fs.Write(buff, 0, read);
                }
                else
                {
                    break;
                }
            }
            fs.Close();
            webstream.Close();
            iCount++;
            return;
        }
        public void Start(Dictionary <string, string[]> files)
        {
            int iCount  = 1;
            int iFailed = 0;
            int total   = files.Count;

            this.Show();
            OCMApp.UpdateGUIThread();
            foreach (string url in files.Keys)
            {
                if (m_cancel)
                {
                    break;
                }
                try
                {
                    DownloadFile(files[url][0], files[url][1], total, ref iCount);
                }
                catch (Exception e)
                {
                    System.Console.WriteLine("FAILED:" + files[url][0]);
                    progBar.Text = String.Format(Catalog.GetString("Download Failed for {0}"), files[url][0]);
                    iCount++;
                    iFailed++;
                }
            }
            if (m_cancel)
            {
                progBar.Text = Catalog.GetString("Cancelled");
            }
            else
            {
                progBar.Text = String.Format(Catalog.GetString("Complete, {0} files failed to download"), iFailed);
            }
            buttonOk.Show();
            buttonCancel.Hide();
        }
Exemple #9
0
 void HandleViewLoadStarted(object o, LoadStartedArgs args)
 {
     mapProgress.Fraction = 0.15;
     mapProgress.Visible  = true;
     OCMApp.UpdateGUIThread();
 }
Exemple #10
0
 void HandleViewLoadProgressChanged(object o, LoadProgressChangedArgs args)
 {
     mapProgress.Fraction = ((double)args.Progress / 100d);
     OCMApp.UpdateGUIThread();
 }
Exemple #11
0
 void HandleM_ViewLoadCommitted(object o, LoadCommittedArgs args)
 {
     mapProgress.Fraction = 0.10;
     mapProgress.Visible  = true;
     OCMApp.UpdateGUIThread();
 }
Exemple #12
0
 /// <summary>
 /// Connect to the specified profile and download all field notes
 /// </summary>
 /// <param name="profile">
 /// The GPS Profile to use <see cref="GPSProfile"/>
 /// </param>
 /// <param name="latestScan">
 /// Logs older then this date will be ignored <see cref="DateTime"/>
 /// </param>
 /// <param name="ownerId">
 /// The owner ID to use for marking the logs in the OCM DB <see cref="String"/>
 /// </param>
 /// <returns>
 /// The new datetime of the latest scan <see cref="DateTime"/>
 /// </returns>
 public DateTime ProcessFieldNotes(GPSProfile profile, DateTime latestScan, String ownerId)
 {
     try
     {
         statusLabel.Markup = Catalog.GetString("<i>Receiving from device...</i>");
         OCMApp.UpdateGUIThread();
         List <CacheLog> logs       = FieldNotesHandler.GetLogs(profile.FieldNotesFile, ownerId);
         int             iCount     = 0;
         int             iProgCount = 0;
         int             iTotal     = logs.Count;
         statusLabel.Markup = Catalog.GetString("<i>Processing Field Notes...</i>");
         m_Win.App.CacheStore.StartUpdate();
         DateTime newLatest = DateTime.MinValue;
         foreach (CacheLog log in logs)
         {
             if (m_cancel)
             {
                 m_Win.App.CacheStore.CancelUpdate();
                 return(DateTime.MinValue);
             }
             double prog = (double)((double)iProgCount / (double)iTotal);
             loadProgress.Fraction = prog;
             loadProgress.Text     = prog.ToString("0%");
             iProgCount++;
             OCMApp.UpdateGUIThread();
             if (log.LogDate <= latestScan)
             {
                 System.Console.WriteLine("Skipping" + latestScan);
                 continue;
             }
             List <Geocache> cache = m_Win.App.CacheStore.GetCachesByName(new string[] { log.CacheCode });
             if (cache.Count > 0)
             {
                 UpdateCache(cache[0], log);
             }
             if (newLatest < log.LogDate)
             {
                 newLatest = log.LogDate;
             }
             iCount++;
         }
         if (!m_cancel)
         {
             UpdateFNFile(logs);
             m_Win.App.CacheStore.CompleteUpdate();
         }
         else
         {
             m_Win.App.CacheStore.CancelUpdate();
         }
         buttonCancel.Visible  = false;
         buttonClose.Visible   = true;
         buttonView.Visible    = true;
         loadProgress.Fraction = 1;
         statusLabel.Markup    = String.Format(Catalog.GetString("<i>Scanned {0} Field Notes, {1} new.</i>"), iProgCount, iCount);
         loadProgress.Text     = Catalog.GetString("Complete");
         return(newLatest);
     }
     catch (Exception e)
     {
         m_Win.App.CacheStore.CancelUpdate();
         this.Hide();
         OCMApp.ShowException(e);
         return(DateTime.MinValue);
     }
 }