Пример #1
0
        /// <summary>
        /// Appends the given training time for the specified character to the provided <see cref="StringBuilder"/>. *
        /// Format is : "1d, 5h, 32m John Doe (Eidetic Memory)"
        /// Used to update the window's title.
        /// </summary>
        /// <param name="character">The character.</param>
        /// <param name="time">The time.</param>
        /// <returns></returns>
        private static string AppendCharacterTrainingTime(Character character, TimeSpan time)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append($"{time.ToDescriptiveText(DescriptiveTextOptions.None)} {character.Name}");

            if (Settings.UI.MainWindow.ShowSkillNameInWindowTitle)
                builder.Append($" ({character.CurrentlyTrainingSkill.SkillName})");

            return builder.ToString();
        }
        /// <summary>
        /// Updates control contents.
        /// </summary>
        private void UpdateDisplay()
        {
            trainTime = TimeSpan.Zero;

            // Default all known flag to true. Will be set to false in UpdateNode() if a requirement is not met
            bool allCertsKnown = true;

            // Default unplanned certificates flag to false. Will be set to true in UpdateNode() if a requirement is neither met nor planned
            bool certsUnplanned = false;

            // Treeview update
            tvCertList.BeginUpdate();
            try
            {
                tvCertList.Nodes.Clear();
                if (m_object != null && m_plan != null)
                {
                    // Recursively create nodes
                    foreach (var cert in StaticCertificates.AllCertificates.Where(x=> x.Recommendations.Contains(m_object)))
                    {
                        tvCertList.Nodes.Add(GetCertNode(cert));
                    }
                }

                // Update the nodes
                foreach (TreeNode node in tvCertList.Nodes)
                {
                    UpdateNode(node, ref allCertsKnown, ref certsUnplanned);
                }
            }
            finally
            {
                tvCertList.EndUpdate();
            }

            // Set training time required label
            if (allCertsKnown)
            {
                lblTimeRequired.Text = "No training required";
            }
            else
            {
                lblTimeRequired.Text = trainTime.ToDescriptiveText(DescriptiveTextOptions.IncludeCommas);
            }

            // Set minimun control size
            Size timeRequiredTextSize = TextRenderer.MeasureText(lblTimeRequired.Text, Font);
            Size newMinimumSize = new Size(timeRequiredTextSize.Width + btnAddCerts.Width, 0);
            if (this.MinimumSize.Width < newMinimumSize.Width)
                this.MinimumSize = newMinimumSize;

            // Enable / disable button
            btnAddCerts.Enabled = certsUnplanned;
        }
Пример #3
0
 internal void UpdateTimeStatusLabel(bool selected, int skillCount, TimeSpan totalTime)
 {
     TimeStatusLabel.AutoToolTip = false;
     TimeStatusLabel.Text = String.Format(CultureConstants.DefaultCulture, "{0} to train {1}",
         totalTime.ToDescriptiveText(DescriptiveTextOptions.IncludeCommas),
         selected ?
         String.Format("selected skill{0}", skillCount == 1 ? String.Empty : "s")
         : "whole plan");
 }
Пример #4
0
        /// <summary>
        /// Returns a string representation for the time left to the given date, using the following formats : 
        /// <list type="bullet">
        /// <item>1d 3h 5m 6s</item>
        /// <item>3h 5m</item>
        /// <item>Done</item>
        /// </list>
        /// </summary>
        /// <param name="t">The time (in the future) for which you want a span.</param>
        /// <param name="dateTimeKind">The kind of the dateTime (UTC or Local) being converted.</param>
        /// <remarks>DateTimeKind.Unspecified will be treated as UTC</remarks>
        /// <returns></returns>
        public static string ToRemainingTimeShortDescription(this DateTime t, DateTimeKind dateTimeKind)
        {
            DateTime now = dateTimeKind == DateTimeKind.Local ? DateTime.Now : DateTime.UtcNow;
            if (t <= now)
                return "Done";

            // Fixing the small chance that the method could cross over the
            // second boundary, and have an inconsistent result.
            double factor = Math.Pow(10, 7);
            long roundedTicks = (long)Math.Round(t.Subtract(now).Ticks / factor) * (int)factor;
            TimeSpan ts = new TimeSpan(roundedTicks);

            return ts.ToDescriptiveText(DescriptiveTextOptions.SpaceBetween);
        }
 /// <summary>
 /// Transpose the timespan to text.
 /// </summary>
 /// <param name="time"></param>
 /// <param name="includeSeconds"></param>
 /// <returns></returns>
 private string TimeSpanToText(TimeSpan time, bool includeSeconds)
 {
     return time.ToDescriptiveText(
         DescriptiveTextOptions.FirstLetterUppercase
         | DescriptiveTextOptions.SpaceText
         | DescriptiveTextOptions.FullText
         | DescriptiveTextOptions.IncludeCommas,
         includeSeconds);
 }
Пример #6
0
 /// <summary>
 /// Transpose the timespan to text.
 /// </summary>
 /// <param name="time"></param>
 /// <param name="includeSeconds"></param>
 /// <returns></returns>
 private static string TimeSpanToText(TimeSpan time, bool includeSeconds)
     => time.ToDescriptiveText(DescriptiveTextOptions.IncludeCommas, includeSeconds);
Пример #7
0
        /// <summary>
        /// Appends the given training time for the specified character to the provided <see cref="StringBuilder"/>. *
        /// Format is : "1d, 5h, 32m John Doe (Eidetic Memory)"
        /// Used to update the window's title.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="character"></param>
        /// <param name="time"></param>
        private static string AppendCharacterTrainingTime(CCPCharacter character, TimeSpan time)
        {
            StringBuilder builder = new StringBuilder();

            string skillDescriptionText = time.ToDescriptiveText(DescriptiveTextOptions.Default);
            builder.AppendFormat(CultureConstants.DefaultCulture,"{0} {1}", skillDescriptionText, character.Name);

            if (Settings.UI.MainWindow.ShowSkillNameInWindowTitle)
                builder.AppendFormat(CultureConstants.DefaultCulture, " ({0})", character.CurrentlyTrainingSkill.SkillName);

            return builder.ToString();
        }