Exemple #1
0
        public void Format_Double_FormatsAccordingToSpecifiedPattern()
        {
            var pctFormatter = new PercentageFormatter("{0}%", new NumberFormatInfo());

            Assert.AreEqual("55%", pctFormatter.Format(.552));

            pctFormatter = new PercentageFormatter("{0} %", new NumberFormatInfo());
            Assert.AreEqual("55 %", pctFormatter.Format(.552));
        }
        /// ------------------------------------------------------------------------------------
        private void LoadPlaybackSpeedCombo()
        {
            var pctFormatter = new PercentageFormatter();

            for (int i = 10; i > 0; i--)
            {
                _comboPlaybackSpeed.Items.Add(pctFormatter.Format(i * 10));
            }
        }
Exemple #3
0
        public void Format_InvalidNumbers_ReturnsNull()
        {
            var    pctFormatter = new PercentageFormatter("{0}%", new NumberFormatInfo());
            double value;

            Assert.IsNull(pctFormatter.Format("55.A%", out value));
            Assert.AreEqual(0, value);
            Assert.IsNull(pctFormatter.Format("ABC45", out value));
            Assert.AreEqual(0, value);
        }
Exemple #4
0
        public void Format_ValidNumberWithoutPercentSign_ParsesAndFormatsCorrectly()
        {
            var    pctFormatter = new PercentageFormatter("{0}%", new NumberFormatInfo());
            double value;

            Assert.AreEqual("55%", pctFormatter.Format("55", out value));
            Assert.AreEqual(55, value);
            Assert.AreEqual("56%", pctFormatter.Format("55.6", out value));
            Assert.AreEqual(55.6, value);
        }
        public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode)
        {
            string textPercentage = (tracker.IsRunning) ? PercentageFormatter.Format(progress.Percentage, Settings.Accuracy) : "-";

            if (invalidator != null && this.InternalComponent.InformationValue != textPercentage)
            {
                this.InternalComponent.InformationValue = textPercentage;
                invalidator.Invalidate(0f, 0f, width, height);
                InternalComponent.Update(invalidator, state, width, height, mode);
            }
        }
Exemple #6
0
        private void UpdateDataGridView(GameProgress progress)
        {
            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            if (this.TrackerDataGrid.InvokeRequired)
            {
                UpdateGridView d = new UpdateGridView(UpdateDataGridView);
                this.Invoke(d, new object[] { progress });
            }
            else
            {
                // Style
                if (darkTheme)
                {
                    TrackerDataGrid.RowTemplate.DefaultCellStyle.SelectionForeColor =
                        TrackerDataGrid.RowTemplate.DefaultCellStyle.ForeColor      = Color.White;
                    TrackerDataGrid.RowTemplate.DefaultCellStyle.SelectionBackColor =
                        TrackerDataGrid.RowTemplate.DefaultCellStyle.BackColor      =
                            TrackerDataGrid.BackgroundColor = Color.Black;
                }
                else
                {
                    TrackerDataGrid.RowTemplate.DefaultCellStyle.SelectionForeColor =
                        TrackerDataGrid.RowTemplate.DefaultCellStyle.ForeColor      = Color.Black;
                    TrackerDataGrid.RowTemplate.DefaultCellStyle.SelectionBackColor =
                        TrackerDataGrid.RowTemplate.DefaultCellStyle.BackColor      =
                            TrackerDataGrid.BackgroundColor = Color.White;
                }

                // Content
                this.TrackerDataGrid.Rows.Clear();
                foreach (Requirement r in progress.Requirements)
                {
                    TrackerDataGrid.Rows.Add(new string[] { r.Name, FormatString(r.Progression) });
                }

                if (showPercentage)
                {
                    string[] row8 = { "Progression", PercentageFormatter.Format(progress.Percentage, accuracy) };
                    TrackerDataGrid.Rows.Add(row8);
                }

                if (TrackerDataGrid.Rows.Count >= 2)
                {
                    TrackerDataGrid.Height = (TrackerDataGrid.Rows[0].Height * (TrackerDataGrid.Rows.Count + 1));
                    this.Height            = TrackerDataGrid.Size.Height + WindowHeaderHeight + 5;
                }

                // refresh
                TrackerDataGrid.Invalidate();
            }
        }
Exemple #7
0
        public void Format_ValidNumberWithPercentSign_ParsesAndFormatsCorrectly()
        {
            var    pctFormatter = new PercentageFormatter("{0}%", new NumberFormatInfo());
            double value;

            Assert.AreEqual("55%", pctFormatter.Format("55 %", out value));
            Assert.AreEqual(55, value);
            Assert.AreEqual("55%", pctFormatter.Format("55.2%", out value));
            Assert.AreEqual(55.2, value);
            Assert.AreEqual("51%", pctFormatter.Format("% 51", out value));
            Assert.AreEqual(51, value);

            pctFormatter = new PercentageFormatter("{0} %", new NumberFormatInfo());
            Assert.AreEqual("56 %", pctFormatter.Format("55.9 %", out value));
            Assert.AreEqual(55.9, value);
            Assert.AreEqual("55 %", pctFormatter.Format("55%", out value));
            Assert.AreEqual(55, value);
            Assert.AreEqual("54 %", pctFormatter.Format("%53.9", out value));
            Assert.AreEqual(53.9, value);
        }
Exemple #8
0
        public void Format_OneThousand_FormatsWithoutComma()
        {
            var pctFormatter = new PercentageFormatter("{0}%", new NumberFormatInfo());

            Assert.AreEqual("1000%", pctFormatter.Format(1000));
        }