Пример #1
0
        public void Parse_should_properly_interpret_values()
        {
            SizeUnit.Parse("*").ShouldBe(SizeUnit.Unlimited);
            SizeUnit.Parse("").ShouldBe(SizeUnit.NotSet);
            SizeUnit.Parse("-").ShouldBe(SizeUnit.NotSet);
            SizeUnit.Parse(null).ShouldBe(SizeUnit.NotSet);
            SizeUnit.Parse(" ").ShouldBe(SizeUnit.NotSet);
            SizeUnit.Parse("15").ShouldBe(SizeUnit.Absolute(15));

            Assert.Throws <ArgumentException>(() => SizeUnit.Parse("x")).Message.ShouldStartWith("Provided value is not a valid SizeUnit: x");
        }
Пример #2
0
        internal void OnStarted()
        {
            started = true;
            MiniProgressBar.IsIndeterminate = false;
            if (client.TransferEvent.IsUpload)
            {
                Title = AppLanguage.Get("LangTitleUploading_x").FormatC(0);
            }
            else
            {
                Title = AppLanguage.Get("LangTitleDownloading_x").FormatC(0);
            }

            GroupBoxCurrentX.Visibility = GroupBoxTotal.Visibility = Visibility.Visible;
            LabelETA.Visibility         = Visibility.Visible;
            TransferProgress.Roll(false);
            TextBlockCounts.Visibility = Visibility.Collapsed;

            ButtonPause.Visibility = Visibility.Visible;

            if (client.TransferEvent.TotalFiles > 0)
            {
                LabelFilesXY.Content    = AppLanguage.Get("LangLabelFiles_X_Y").FormatC(0, client.TransferEvent.TotalFiles);
                LabelFilesXY.Visibility = Visibility.Visible;
            }

            if (client.TransferEvent.TotalFolders > 0)
            {
                LabelFoldersXY.Content    = AppLanguage.Get("LangLabelFolders_X_Y").FormatC(0, client.TransferEvent.TotalFolders);
                LabelFoldersXY.Visibility = Visibility.Visible;
            }

            cacher.TotalSize           = SizeUnit.Parse(client.TransferEvent.TotalSize);
            LabelTotalSizeXY.Content   = AppLanguage.Get("LangLabelTransferredSize_X_FromTotal_Y").FormatC(0, cacher.TotalSize);
            LabelTotalRemainsX.Content = AppLanguage.Get("LangLabelRemains_X").FormatC(cacher.TotalSize);

            maximum = client.TransferEvent.TotalFolders + client.TransferEvent.TotalFiles + client.TransferEvent.TotalSize;
            if (maximum == 0)
            {
                maximum = 1;
            }

            LabelTransferSpeed.Content = AppLanguage.Get("LangLabelAverageTransferSpeed_X").FormatC(SizeUnit.Parse(0));
            ElapsedTimeLabel.Content   = AppLanguage.Get("LangLabelElapsedTime_X").FormatC(zeroTime);
            LabelETA.Content           = AppLanguage.Get("LangLabelETATime_X").FormatC(zeroTime);

            ButtonFished.Visibility = Visibility.Visible;
            TaskbarHelper.Add(ProgressBarTotal);

            timer200.Start();
            timer1000.Start();
        }
Пример #3
0
        public void Arrange_should_expand_component_if_Width_or_Height_is_unlimited(string width, string height, int expectedX, int expectedY, int expectedWidth, int expectedHeight)
        {
            var area      = new Rectangle(20, 30, 100, 100);
            var component = new TestableComponent
            {
                OnMeasureCallback = _ => new Size(10, 20),
                Width             = SizeUnit.Parse(width),
                Height            = SizeUnit.Parse(height)
            };

            component.Measure(area.Size, TestRendererContext.Instance);
            component.Arrange(area);
            component.Layout.ShouldBe(new Rectangle(expectedX, expectedY, expectedWidth, expectedHeight));
        }
Пример #4
0
        public void Measure_should_use_Width_and_Height_if_provided(string width, string height, int expectedWidth, int expectedHeight, int desiredWidth, int desiredHeight)
        {
            var inputSize         = new Size(15, 20);
            var fixedMeasureSize  = new Size(20, 30);
            var receivedInputSize = Size.Empty;

            var component = new TestableComponent
            {
                Width             = SizeUnit.Parse(width),
                Height            = SizeUnit.Parse(height),
                OnMeasureCallback = x =>
                {
                    receivedInputSize = x;
                    return(fixedMeasureSize);
                }
            };

            component.Measure(inputSize, TestRendererContext.Instance);

            component.DesiredSize.ShouldBe(new Size(desiredWidth, desiredHeight));
            receivedInputSize.ShouldBe(new Size(expectedWidth, expectedHeight));
        }
Пример #5
0
 private void TextBlockSession_ToolTipOpening(object sender, System.Windows.Controls.ToolTipEventArgs e)
 {
     TextBlockSession.ToolTip = AppLanguage.Get("LangLabelAverageTransferSpeed_X").FormatC(SizeUnit.Parse(speedy.Average()));
 }
Пример #6
0
        private void UpdateProgress()
        {
            SmartItem item = client.TransferEvent.Item;

            ProgressBarTotal.Value = (((client.TransferEvent.TotalTransferredFolders + client.TransferEvent.TotalTransferredFiles + client.TransferEvent.TotalSent) * 100) / maximum);

            if (!ended && (ProgressBarTotal.Value > 0))
            {
                if (client.TransferEvent.IsUpload)
                {
                    Title = AppLanguage.Get("LangTitleUploading_x").FormatC(ProgressBarTotal.Value);
                }
                else
                {
                    Title = AppLanguage.Get("LangTitleDownloading_x").FormatC(ProgressBarTotal.Value);
                }
            }

            if (!shrink.Shrinked)
            {
                ProgressBarCurrent.Value     = (item.Length == 0) ? 100 : client.TransferEvent.ItemSent * 100 / item.Length;
                GroupBoxCurrentX.Header      = AppLanguage.Get("LangGroupBoxCurrent_X").FormatC(ProgressBarCurrent.Value);
                LabelCurrentSizeXY.Content   = AppLanguage.Get("LangLabelTransferredSize_X_FromTotal_Y").FormatC(SizeUnit.Parse(client.TransferEvent.ItemSent), cacher.CurrentSize);
                LabelCurrentRemainsX.Content = AppLanguage.Get("LangLabelRemains_X").FormatC(SizeUnit.Parse(item.Length - client.TransferEvent.ItemSent));
                LabelTotalSizeXY.Content     = AppLanguage.Get("LangLabelTransferredSize_X_FromTotal_Y").FormatC(SizeUnit.Parse(client.TransferEvent.TotalSent), cacher.TotalSize);
                LabelTotalRemainsX.Content   = AppLanguage.Get("LangLabelRemains_X").FormatC(SizeUnit.Parse(client.TransferEvent.TotalSize - client.TransferEvent.TotalSent));
            }
        }
Пример #7
0
        private void timer1000_Tick(object sender, EventArgs e)
        {
            cacher.StartTime   = cacher.StartTime.AddSeconds(1.0);
            speedy.Transferred = client.TransferEvent.TotalSent;
            int average = speedy.Average() / 5;

            if (average > 0)
            {
                if ((average > NetworkClient.BUFFER_SIZE) && (average < 1043741824))
                {
                    client.BufferSize = average;
                }

                if (!shrink.Shrinked)
                {
                    average = average * 5;
                    ElapsedTimeLabel.Content   = AppLanguage.Get("LangLabelElapsedTime_X").FormatC(cacher.StartTime);
                    LabelTransferSpeed.Content = AppLanguage.Get("LangLabelAverageTransferSpeed_X").FormatC(SizeUnit.Parse(average));

                    LabelETA.Content = AppLanguage.Get("LangLabelETATime_X").FormatC(
                        zeroTime.AddSeconds((client.TransferEvent.TotalSize - client.TransferEvent.TotalSent) / average));
                }
            }
            else if (!shrink.Shrinked)
            {
                LabelETA.Content = AppLanguage.Get("LangLabelETATime_X").FormatC(zeroTime);
            }
        }
Пример #8
0
 public void GetValue_returns_proper_value(string value, int expected)
 {
     SizeUnit.Parse(value).GetValue(() => 2, -1).ShouldBe(expected);
     SizeUnit.Parse(value).GetValue(2, -1).ShouldBe(expected);
 }