Ejemplo n.º 1
0
        /// <summary>
        /// Get the path where codes for a problem are saved
        /// </summary>
        /// <param name="pnum">Problem Number</param>
        /// <returns>
        /// Valid folder of codes for a given problem.
        /// Returns null if LocalDatabase is not ready or CodesPath doesn't exist
        /// </returns>
        public static string GetCodesPath(long pnum)
        {
            if (!LocalDatabase.IsReady)
            {
                return(null);
            }

            string path = RegistryAccess.CodesPath;

            if (string.IsNullOrEmpty(path) || !Directory.Exists(path))
            {
                return(null);
            }

            string title = LocalDatabase.GetTitle(pnum);

            title = ValidateFileName(title);

            char sep = Path.DirectorySeparatorChar;

            path += sep + string.Format("Volume {0:000}", pnum / 100);
            path += sep + string.Format("{0} - {1}", pnum, title);

            CreateDirectory(path);
            return(path);
        }
Ejemplo n.º 2
0
        void SetStatus(int percent, string status)
        {
            int tot      = LocalDatabase.problemList.Count;
            int finished = tot - remaining.Count;

            totalProgress.Value  = (int)(100.0 * finished / tot);
            totalPercentage.Text = totalProgress.Value.ToString() + "%";
            overallStatus.Text   = string.Format("{0} / {1} problems downloaded.", finished, tot);

            if (CurrentState == State.Running)
            {
                StatusLabel.Text       = status;
                currentProgress.Value  = percent;
                currentPercentage.Text = currentProgress.Value.ToString() + "%";
                currentProblem.Text    = string.Format("Downloading {0} - {1}... ",
                                                       current, LocalDatabase.GetTitle(current));
            }
            else
            {
                StatusLabel.Text       = "";
                currentProgress.Value  = 0;
                currentPercentage.Text = "";
                currentProblem.Text    = CurrentState.ToString();
            }
        }