public void UpdateServicePropertiesOnWindowTaskbarButtonInfoChanged()
        {
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            taskbarServiceImpl.Description   = "new desc";
            taskbarServiceImpl.ProgressValue = 0.5;
            RealWindow.TaskbarItemInfo       = null;
            Assert.IsTrue(string.IsNullOrEmpty(taskbarServiceImpl.Description));
        }
        public void AttachServiceToWindowWithTaskbarButtonInfo()
        {
            ImageSource icon_1 = ApplicationJumpListServiceTestsImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(TaskbarButtonServiceTests).Assembly, "Icons/icon1.ico"));
            ImageSource icon_2 = ApplicationJumpListServiceTestsImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(TaskbarButtonServiceTests).Assembly, "Icons/icon2.png"));

            RealWindow.TaskbarItemInfo = new TaskbarItemInfo()
            {
                ProgressState    = TaskbarItemProgressState.Paused,
                ProgressValue    = 0.1,
                Description      = "desc",
                Overlay          = icon_1,
                ThumbButtonInfos = new ThumbButtonInfoCollection {
                    new ThumbButtonInfo()
                    {
                        Description = "thumbButton1"
                    }
                },
                ThumbnailClipMargin = new Thickness {
                    Left = 100, Top = 105, Right = 130, Bottom = 110
                }
            };
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService()
            {
                ProgressState    = TaskbarItemProgressState.Error,
                ProgressValue    = 0.2,
                Description      = "desc2",
                OverlayIcon      = icon_2,
                ThumbButtonInfos = new TaskbarThumbButtonInfoCollection {
                    new TaskbarThumbButtonInfo()
                    {
                        Description = "thumbButton2"
                    }
                },
                ThumbnailClipMargin = new Thickness {
                    Left = 50, Top = 555, Right = 135, Bottom = 90
                }
            };

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            Assert.AreEqual(TaskbarItemProgressState.Error, RealWindow.TaskbarItemInfo.ProgressState);
            Assert.AreEqual(0.2, RealWindow.TaskbarItemInfo.ProgressValue);
            Assert.AreEqual("desc2", RealWindow.TaskbarItemInfo.Description);
            AssertHelper.AssertEnumerablesAreEqual(new ThumbButtonInfo[] {
                new ThumbButtonInfo()
                {
                    Description = "thumbButton2"
                },
            }, RealWindow.TaskbarItemInfo.ThumbButtonInfos, true, new string[] { "Command" });

            Assert.AreEqual(new Thickness {
                Left = 50, Top = 555, Right = 135, Bottom = 90
            }, RealWindow.TaskbarItemInfo.ThumbnailClipMargin);
        }
        public void TryUsingServiceWithoutWindow()
        {
            Grid grid = new Grid();
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(grid).Add(taskbarServiceImpl);
            ITaskbarButtonService taskbarService = taskbarServiceImpl;

            taskbarService.ProgressState = TaskbarItemProgressState.Paused;
            taskbarService.ProgressValue = 0.81;
        }
        public void SetDescription()
        {
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            ITaskbarButtonService taskbarService = taskbarServiceImpl;

            taskbarService.Description = "test1";
            Assert.AreEqual("test1", RealWindow.TaskbarItemInfo.Description);
            taskbarService.Description = "test2";
            Assert.AreEqual("test2", RealWindow.TaskbarItemInfo.Description);
        }
        public void SetThumbnailClipMarginCallback_LateBinding()
        {
            clipMarginShift = 0;
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            ITaskbarButtonService taskbarService = taskbarServiceImpl;

            taskbarService.ThumbnailClipMarginCallback = GetThumbnailClipMargin;
            Assert.IsTrue(RealWindow.Height > 100 && RealWindow.Width > 100);
            Assert.AreEqual(CorrectThickness(RealWindow), RealWindow.TaskbarItemInfo.ThumbnailClipMargin);
        }
        public void RemoveAssociatedObjectFromTree_CheckWindowIsNull()
        {
            Grid grid = new Grid();

            RealWindow.Content = grid;
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(grid).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            Assert.AreEqual(RealWindow, taskbarServiceImpl.ActualWindow);
            RealWindow.Content = null;
            DispatcherHelper.UpdateLayoutAndDoEvents(RealWindow);
            Assert.IsNull(taskbarServiceImpl.ActualWindow);
        }
        public void ExplicitWindow()
        {
            var testWindow = new Window();
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            taskbarServiceImpl.Window = testWindow;
            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            ITaskbarButtonService taskbarService = taskbarServiceImpl;

            taskbarService.ProgressValue = 0.5;
            Assert.IsNull(RealWindow.TaskbarItemInfo);
            Assert.AreEqual(0.5, testWindow.TaskbarItemInfo.ProgressValue);
        }
        public void BindTaskbarThumbButtonInfoCommand()
        {
            VM vm = VM.Create();

            RealWindow.DataContext = vm;
            TaskbarButtonService   taskbarServiceImpl = new TaskbarButtonService();
            TaskbarThumbButtonInfo bt = new TaskbarThumbButtonInfo();

            BindingOperations.SetBinding(bt, TaskbarThumbButtonInfo.CommandProperty, new Binding("DoCommand"));
            taskbarServiceImpl.ThumbButtonInfos.Add(bt);
            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            Assert.AreEqual(POCOViewModelExtensions.GetCommand(vm, x => x.Do()), bt.Command);
        }
        public void SetOverlayIcon()
        {
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            ITaskbarButtonService taskbarService = taskbarServiceImpl;
            ImageSource           icon_1         = ApplicationJumpListServiceTestsImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(TaskbarButtonServiceTests).Assembly, "Icons/icon1.ico"));
            ImageSource           icon_2         = ApplicationJumpListServiceTestsImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(TaskbarButtonServiceTests).Assembly, "Icons/icon2.ico"));

            taskbarService.OverlayIcon = icon_1;
            Assert.AreEqual(icon_1, RealWindow.TaskbarItemInfo.Overlay);
            taskbarService.OverlayIcon = icon_2;
            Assert.AreEqual(icon_2, RealWindow.TaskbarItemInfo.Overlay);
        }
        public void SetThumbnailClipMargin()
        {
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            ITaskbarButtonService taskbarService = taskbarServiceImpl;

            taskbarService.ThumbnailClipMargin = new Thickness {
                Bottom = 10, Left = 5, Right = 100, Top = 1
            };
            Assert.AreEqual(new Thickness {
                Bottom = 10, Left = 5, Right = 100, Top = 1
            }, RealWindow.TaskbarItemInfo.ThumbnailClipMargin);
        }
        public void SetProgressIndicatorValue()
        {
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            ITaskbarButtonService taskbarService = taskbarServiceImpl;

            taskbarService.ProgressValue = 0.0;
            Assert.AreEqual(0, RealWindow.TaskbarItemInfo.ProgressValue);
            taskbarService.ProgressValue = 0.5;
            Assert.AreEqual(0.5, RealWindow.TaskbarItemInfo.ProgressValue);
            taskbarService.ProgressValue = 1.0;
            Assert.AreEqual(1, RealWindow.TaskbarItemInfo.ProgressValue);
        }
        public void LateBoundWindow()
        {
            Grid grid = new Grid();
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(grid).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            ITaskbarButtonService taskbarService = taskbarServiceImpl;

            taskbarService.ProgressState = TaskbarItemProgressState.Paused;
            taskbarService.ProgressValue = 0.81;
            RealWindow.Content           = grid;
            DispatcherHelper.UpdateLayoutAndDoEvents(RealWindow);
            Assert.AreEqual(TaskbarItemProgressState.Paused, RealWindow.TaskbarItemInfo.ProgressState);
            Assert.AreEqual(0.81, RealWindow.TaskbarItemInfo.ProgressValue);
        }
        public void AttachToWindowChild()
        {
            Grid grid = new Grid();

            RealWindow.Content = grid;
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(grid).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            ITaskbarButtonService taskbarService = taskbarServiceImpl;

            taskbarService.ProgressState = TaskbarItemProgressState.Paused;
            taskbarService.ProgressValue = 0.81;
            Assert.AreEqual(TaskbarItemProgressState.Paused, RealWindow.TaskbarItemInfo.ProgressState);
            Assert.AreEqual(0.81, RealWindow.TaskbarItemInfo.ProgressValue);
        }
        public void SeveralServices()
        {
            TaskbarButtonService taskbarService_1 = new TaskbarButtonService();
            TaskbarButtonService taskbarService_2 = new TaskbarButtonService();

            taskbarService_1.Window = RealWindow;
            taskbarService_2.Window = RealWindow;
            EnqueueShowRealWindow();
            taskbarService_1.ProgressValue = 0.5;
            Assert.AreEqual(0.5, taskbarService_2.ProgressValue);
            taskbarService_2.ProgressValue = 0.8;
            Assert.AreEqual(0.8, taskbarService_1.ProgressValue);
            taskbarService_1.ProgressState = TaskbarItemProgressState.Normal;
            Assert.AreEqual(TaskbarItemProgressState.Normal, taskbarService_2.ProgressState);
            taskbarService_2.ProgressState = TaskbarItemProgressState.Paused;
            Assert.AreEqual(TaskbarItemProgressState.Paused, taskbarService_1.ProgressState);
        }
        public void BindDescription()
        {
            VM vm = VM.Create();

            RealWindow.DataContext = vm;
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            BindingOperations.SetBinding(taskbarServiceImpl, TaskbarButtonService.DescriptionProperty, new Binding("Description"));
            EnqueueShowRealWindow();
            ITaskbarButtonService taskbarService = taskbarServiceImpl;

            vm.Description = "test1";
            Assert.AreEqual("test1", RealWindow.TaskbarItemInfo.Description);
            vm.Description = "test2";
            Assert.AreEqual("test2", RealWindow.TaskbarItemInfo.Description);
        }
        public void DoNotResetTaskBarItemInfoProperties()
        {
            RealWindow.TaskbarItemInfo = new TaskbarItemInfo()
            {
                Description = "desc"
            };
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            ITaskbarButtonService taskbarService = taskbarServiceImpl;

            taskbarService.ProgressValue = 0.5;
            taskbarService.Description   = "desc2";
            Assert.AreEqual("desc2", RealWindow.TaskbarItemInfo.Description);
            Assert.AreEqual(0.5, RealWindow.TaskbarItemInfo.ProgressValue);
        }
        public void SetProgressIndicatorState()
        {
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            ITaskbarButtonService taskbarService = taskbarServiceImpl;

            taskbarService.ProgressState = TaskbarItemProgressState.Indeterminate;
            Assert.AreEqual(TaskbarItemProgressState.Indeterminate, RealWindow.TaskbarItemInfo.ProgressState);
            taskbarService.ProgressState = TaskbarItemProgressState.None;
            Assert.AreEqual(TaskbarItemProgressState.None, RealWindow.TaskbarItemInfo.ProgressState);
            taskbarService.ProgressState = TaskbarItemProgressState.Normal;
            Assert.AreEqual(TaskbarItemProgressState.Normal, RealWindow.TaskbarItemInfo.ProgressState);
            taskbarService.ProgressState = TaskbarItemProgressState.Paused;
            Assert.AreEqual(TaskbarItemProgressState.Paused, RealWindow.TaskbarItemInfo.ProgressState);
            taskbarService.ProgressState = TaskbarItemProgressState.Error;
            Assert.AreEqual(TaskbarItemProgressState.Error, RealWindow.TaskbarItemInfo.ProgressState);
        }
        public void BindProgressIndicatorValue()
        {
            VM vm = VM.Create();

            RealWindow.DataContext = vm;
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            BindingOperations.SetBinding(taskbarServiceImpl, TaskbarButtonService.ProgressValueProperty, new Binding("ProgressValue"));
            EnqueueShowRealWindow();
            ITaskbarButtonService taskbarService = taskbarServiceImpl;

            vm.ProgressValue = 0.0;
            Assert.AreEqual(0, RealWindow.TaskbarItemInfo.ProgressValue);
            vm.ProgressValue = 0.5;
            Assert.AreEqual(0.5, RealWindow.TaskbarItemInfo.ProgressValue);
            vm.ProgressValue = 1.0;
            Assert.AreEqual(1, RealWindow.TaskbarItemInfo.ProgressValue);
        }
        public void BindOverlayIcon()
        {
            VM vm = VM.Create();

            RealWindow.DataContext = vm;
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            BindingOperations.SetBinding(taskbarServiceImpl, TaskbarButtonService.OverlayIconProperty, new Binding("OverlayIcon"));
            EnqueueShowRealWindow();
            ITaskbarButtonService taskbarService = taskbarServiceImpl;
            ImageSource           icon_1         = ApplicationJumpListServiceTestsImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(TaskbarButtonServiceTests).Assembly, "Icons/icon1.ico"));
            ImageSource           icon_2         = ApplicationJumpListServiceTestsImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(TaskbarButtonServiceTests).Assembly, "Icons/icon2.ico"));

            vm.OverlayIcon = icon_1;
            Assert.AreEqual(icon_1, RealWindow.TaskbarItemInfo.Overlay);
            vm.OverlayIcon = icon_2;
            Assert.AreEqual(icon_2, RealWindow.TaskbarItemInfo.Overlay);
        }
        public void BindThumbnailClipMargin()
        {
            VM vm = VM.Create();

            RealWindow.DataContext = vm;
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            BindingOperations.SetBinding(taskbarServiceImpl, TaskbarButtonService.ThumbnailClipMarginProperty, new Binding("ThumbnailClipMargin"));
            EnqueueShowRealWindow();
            ITaskbarButtonService taskbarService = taskbarServiceImpl;

            vm.ThumbnailClipMargin = new Thickness {
                Bottom = 10, Left = 5, Right = 100, Top = 1
            };
            Assert.AreEqual(new Thickness {
                Bottom = 10, Left = 5, Right = 100, Top = 1
            }, RealWindow.TaskbarItemInfo.ThumbnailClipMargin);
        }
        public void ThumbButtonPropertiesChanged()
        {
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            ImageSource            imageSource1      = ApplicationJumpListServiceTestsImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(TaskbarButtonServiceTests).Assembly, "Icons/icon1.ico"));
            ImageSource            imageSource2      = ApplicationJumpListServiceTestsImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(TaskbarButtonServiceTests).Assembly, "Icons/icon2.ico"));
            ITaskbarButtonService  taskbarService    = taskbarServiceImpl;
            TaskbarThumbButtonInfo thumbButtonInfo_1 = new TaskbarThumbButtonInfo()
            {
                Description         = "thumbButton1",
                IsEnabled           = true,
                IsInteractive       = true,
                IsBackgroundVisible = false,
                DismissWhenClicked  = false,
                Visibility          = Visibility.Visible,
                ImageSource         = imageSource1
            };

            taskbarService.ThumbButtonInfos.Add(thumbButtonInfo_1);
            RealWindow.TaskbarItemInfo.ThumbButtonInfos[0].Description         = "thumbButton2";
            RealWindow.TaskbarItemInfo.ThumbButtonInfos[0].IsEnabled           = false;
            RealWindow.TaskbarItemInfo.ThumbButtonInfos[0].IsInteractive       = false;
            RealWindow.TaskbarItemInfo.ThumbButtonInfos[0].IsBackgroundVisible = true;
            RealWindow.TaskbarItemInfo.ThumbButtonInfos[0].DismissWhenClicked  = true;
            RealWindow.TaskbarItemInfo.ThumbButtonInfos[0].Visibility          = Visibility.Collapsed;
            RealWindow.TaskbarItemInfo.ThumbButtonInfos[0].ImageSource         = imageSource2;
            EnqueueShowRealWindow();
            AssertHelper.AssertEnumerablesAreEqual(new TaskbarThumbButtonInfo[] {
                new TaskbarThumbButtonInfo()
                {
                    Description         = "thumbButton2",
                    IsEnabled           = false,
                    IsInteractive       = false,
                    IsBackgroundVisible = true,
                    DismissWhenClicked  = true,
                    Visibility          = Visibility.Collapsed,
                    ImageSource         = imageSource2
                },
            }, taskbarService.ThumbButtonInfos, true, new string[] { "ItemInfo" });
        }
        public void DoNotThrowsExceptionIfUserIsNotLoggedIn()
        {
            var testWindow = new Window();
            var service    = new TaskbarButtonService();

            try {
                TaskbarListTestHelper.DoWithNotImplementedHrInit(() => {
                    testWindow.Show();
                    EnqueueConditional(() => testWindow.IsLoaded);
                    Assert.IsNull(testWindow.TaskbarItemInfo);
                    Assert.DoesNotThrow(() => {
                        Interaction.GetBehaviors(testWindow).Add(service);
                        service.Description = "descr";
                    });
                    TaskbarListTestHelper.SendTaskBarButtonCreated(testWindow);
                });
            } finally {
                testWindow.Close();
            }
        }
Exemple #23
0
        public void DoNotThrowsExceptionIfUserIsNotLoggedInAndThusThereIsNoAnyTaskbarButton()
        {
            var testWindow = new Window();
            var service    = new TaskbarButtonService();

            try {
                TaskbarListTestHelper.DoWithNotImplementedHrInit(() => {
                    testWindow.Show();
                    EnqueueConditional(() => testWindow.IsLoaded);
                    Assert.IsNull(testWindow.TaskbarItemInfo);
                    Assert.DoesNotThrow(() => {
                        Interaction.GetBehaviors(testWindow).Add(service);
                        service.Description = "descr";
                    });
                    Assert.IsNotNull(testWindow.TaskbarItemInfo);
                });
                Assert.IsNull(testWindow.GetType().GetField("_taskbarList", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(testWindow));
                TaskbarListTestHelper.SendTaskBarButtonCreated(testWindow);
                Assert.IsNotNull(testWindow.GetType().GetField("_taskbarList", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(testWindow));
            } finally {
                testWindow.Close();
            }
        }
        public void BindProgressIndicatorState()
        {
            VM vm = VM.Create();

            RealWindow.DataContext = vm;
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            BindingOperations.SetBinding(taskbarServiceImpl, TaskbarButtonService.ProgressStateProperty, new Binding("ProgressState"));
            EnqueueShowRealWindow();
            ITaskbarButtonService taskbarService = taskbarServiceImpl;

            vm.ProgressState = TaskbarItemProgressState.Indeterminate;
            Assert.AreEqual(TaskbarItemProgressState.Indeterminate, RealWindow.TaskbarItemInfo.ProgressState);
            vm.ProgressState = TaskbarItemProgressState.None;
            Assert.AreEqual(TaskbarItemProgressState.None, RealWindow.TaskbarItemInfo.ProgressState);
            vm.ProgressState = TaskbarItemProgressState.Normal;
            Assert.AreEqual(TaskbarItemProgressState.Normal, RealWindow.TaskbarItemInfo.ProgressState);
            vm.ProgressState = TaskbarItemProgressState.Paused;
            Assert.AreEqual(TaskbarItemProgressState.Paused, RealWindow.TaskbarItemInfo.ProgressState);
            vm.ProgressState = TaskbarItemProgressState.Error;
            Assert.AreEqual(TaskbarItemProgressState.Error, RealWindow.TaskbarItemInfo.ProgressState);
        }
        public void SetThumbButtonInfosClickAction()
        {
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            ITaskbarButtonService  taskbarService         = taskbarServiceImpl;
            TaskbarThumbButtonInfo taskbarThumbButtonInfo = new TaskbarThumbButtonInfo()
            {
                Description = "xxx"
            };
            bool actionExecuted = false;
            bool clickExecuted  = false;

            taskbarThumbButtonInfo.Action = () => { actionExecuted = true; };
            taskbarThumbButtonInfo.Click += (s, e) => clickExecuted = true;

            taskbarService.ThumbButtonInfos.Add(taskbarThumbButtonInfo);
            ThumbButtonInfo thumbButtonInfo = RealWindow.TaskbarItemInfo.ThumbButtonInfos[0];

            ClickThumbButton(thumbButtonInfo);
            Assert.IsTrue(actionExecuted);
            Assert.IsTrue(clickExecuted);
        }
Exemple #26
0
 protected virtual void OnThumbnailClipMarginMultipliyerChanged()
 {
     TaskbarButtonService.UpdateThumbnailClipMargin();
 }
Exemple #27
0
 bool IncreaseThumbnailClipMarginMultipliyer()
 {
     ThumbnailClipMarginMultipliyer = (ThumbnailClipMarginMultipliyer <= 90) ? (ThumbnailClipMarginMultipliyer + 10) : 100;
     TaskbarButtonService.UpdateThumbnailClipMargin();
     return(true);
 }
Exemple #28
0
 bool DecreaseThumbnailClipMarginMultipliyer()
 {
     ThumbnailClipMarginMultipliyer = (ThumbnailClipMarginMultipliyer >= 10) ? (ThumbnailClipMarginMultipliyer - 10) : 0;
     TaskbarButtonService.UpdateThumbnailClipMargin();
     return(true);
 }
        public void BindPropertyAndListenPropertyChanged()
        {
            VM vm = VM.Create();

            RealWindow.DataContext = vm;
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);

            int progressStateChangedCount       = 0;
            int progressValueChangedCount       = 0;
            int overlayIconChangedCount         = 0;
            int descriptionChangedCount         = 0;
            int thumbnailClipMarginChangedCount = 0;

            ((INotifyPropertyChanged)vm).PropertyChanged += (d, e) => {
                if (e.PropertyName == "ProgressState")
                {
                    progressStateChangedCount++;
                }
                if (e.PropertyName == "ProgressValue")
                {
                    progressValueChangedCount++;
                }
                if (e.PropertyName == "OverlayIcon")
                {
                    overlayIconChangedCount++;
                }
                if (e.PropertyName == "Description")
                {
                    descriptionChangedCount++;
                }
                if (e.PropertyName == "ThumbnailClipMargin")
                {
                    thumbnailClipMarginChangedCount++;
                }
            };

            BindingOperations.SetBinding(taskbarServiceImpl, TaskbarButtonService.ProgressStateProperty, new Binding("ProgressState"));
            BindingOperations.SetBinding(taskbarServiceImpl, TaskbarButtonService.ProgressValueProperty, new Binding("ProgressValue"));
            BindingOperations.SetBinding(taskbarServiceImpl, TaskbarButtonService.OverlayIconProperty, new Binding("OverlayIcon"));
            BindingOperations.SetBinding(taskbarServiceImpl, TaskbarButtonService.DescriptionProperty, new Binding("Description"));
            BindingOperations.SetBinding(taskbarServiceImpl, TaskbarButtonService.ThumbnailClipMarginProperty, new Binding("ThumbnailClipMargin"));

            EnqueueShowRealWindow();
            ITaskbarButtonService taskbarService = taskbarServiceImpl;

            vm.ProgressState = TaskbarItemProgressState.Indeterminate;
            Assert.AreEqual(TaskbarItemProgressState.Indeterminate, RealWindow.TaskbarItemInfo.ProgressState);
            Assert.AreEqual(1, progressStateChangedCount);

            vm.ProgressValue = 0.5d;
            Assert.AreEqual(0.5d, RealWindow.TaskbarItemInfo.ProgressValue);
            Assert.AreEqual(1, progressValueChangedCount);

            ImageSource icon_1 = ApplicationJumpListServiceTestsImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(TaskbarButtonServiceTests).Assembly, "Icons/icon1.ico"));

            vm.OverlayIcon = icon_1;
            Assert.AreEqual(icon_1, RealWindow.TaskbarItemInfo.Overlay);
            Assert.AreEqual(1, overlayIconChangedCount);

            vm.Description = "Test";
            Assert.AreEqual("Test", RealWindow.TaskbarItemInfo.Description);
            Assert.AreEqual(1, descriptionChangedCount);

            vm.ThumbnailClipMargin = new Thickness(45);
            Assert.AreEqual(new Thickness(45), RealWindow.TaskbarItemInfo.ThumbnailClipMargin);
            Assert.AreEqual(1, thumbnailClipMarginChangedCount);
        }