Exemple #1
0
        void itemsControl_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (IsInDock(mouseX, mouseY))
            {
                // Replace placeholder with icon.
                var index = VMLocator.Main.Icons.IndexOf(placeholder);
                VMLocator.Main.Icons.Remove(placeholder);
                VMLocator.Main.Icons.Insert(index, icon);
                icon.Pinned = true;
            }
            else
            {
                VMLocator.Main.Icons.Remove(placeholder);
                if (icon.IsActive)
                {
                    VMLocator.Main.Icons.Add(icon);
                }
            }
            // Clean up events and variables.
            isMouseDown = false;
            MouseManager.Manager.MouseMoved -= Manager_MouseMoved;
            itemsControl.ReleaseMouseCapture();
            itemsControl.MouseUp   -= itemsControl_MouseUp;
            itemsControl.MouseMove -= itemsControl_MouseMove;
            var window = draggedIconWindow;

            AnimationTools.FadeOut(0.2, window, 0, () =>
            {
                window.Close();
                window = null;
            });
            icon        = null;
            placeholder = null;
        }
        protected override void OnAttached()
        {
            base.OnAttached();
            IconViewModel icon = (IconViewModel)AssociatedObject.DataContext;

            icon.Element = AssociatedObject;
        }
Exemple #3
0
        public RenderingOptions()
        {
            this.InitializeComponent();
            this.ViewModel = new ViewModels.IconViewModel();

            this.DataContext = this.ViewModel;
        }
        public IActionResult Icons()
        {
            var iconlevel = 0;

            var currentLevel = HttpContext.Session.GetString("IconLevel");

            if (string.IsNullOrEmpty(currentLevel))
            {
                HttpContext.Session.SetString("IconLevel", "1");
                iconlevel = 1;
            }
            else
            {
                iconlevel = Convert.ToInt32(currentLevel);
            }

            int numberOfAnswers = iconlevel + 3;
            int numberOfIcons   = numberOfAnswers * 2;

            IconViewModel model = new IconViewModel {
                AllIcons = _iconHelper.GetIcons(numberOfIcons)
            };

            model.InitIcons = model.AllIcons.Take(numberOfAnswers).ToList();

            var str = JsonConvert.SerializeObject(model.InitIcons);

            HttpContext.Session.SetString("Answers", str);

            var rnd = new Random();

            model.AllIcons = model.AllIcons.OrderBy(item => rnd.Next()).ToList();

            return(View(model));
        }
 /// <summary>
 /// Load the personalization (color of the software) from the session file
 /// </summary>
 public void loadPerso()
 {
     foreach (KeyValuePair <string, byte[]> pair in personalization)
     {
         App.Current.Resources[pair.Key] = (Color.FromArgb(pair.Value[3], pair.Value[0], pair.Value[1], pair.Value[2]));
         if (pair.Key == "FeedbackStreamColor")
         {
             DrawingSheetStreamViewModel.Get().changeColorFeedbacks();
         }
     }
     IconViewModel.get().setFFT((Color)App.Current.Resources["GeneralTextColor"], (Color)App.Current.Resources["UnselectedTabColor"]);
 }
        public Icon GetIcon(IconViewModel iconFromViewModel, bool withId = false)
        {
            Icon icon;

            icon = new Icon
            {
                GameId   = iconFromViewModel.GameId,
                Value    = iconFromViewModel.Value,
                IconName = GetFileName(iconFromViewModel.IconFile)
            };
            if (withId)
            {
                icon.Id = iconFromViewModel.Id;
            }
            return(icon);
        }
Exemple #7
0
 void DetachIcon()
 {
     if (isMouseDown)
     {
         AssociatedObject.MouseMove  -= AssociatedObject_MouseMove;
         AssociatedObject.MouseLeave -= AssociatedObject_MouseLeave;
         itemsControl = FrameworkHelper.GetParent <ItemsControl>(AssociatedObject);
         MouseManager.Manager.MouseMoved += Manager_MouseMoved;
         icon = (IconViewModel)AssociatedObject.DataContext;
         VMLocator.Main.Icons.Remove(icon);
         if (draggedIconWindow == null)
         {
             draggedIconWindow = new DraggedIconWindow();
         }
         draggedIconWindow.DataContext = icon;
         itemsControl.CaptureMouse();
         itemsControl.MouseUp   += itemsControl_MouseUp;
         itemsControl.MouseMove += itemsControl_MouseMove;
     }
 }
        public void ContextualCommandViewModel_Icon()
        {
            // Arrange
            var context     = new object();
            var command     = new RelayCommand(() => { });
            var testSubject = new ContextualCommandViewModel(context, command);

            using (var tracker = new PropertyChangedTracker(testSubject))
            {
                // Case 1: null
                // Act + Assert
                testSubject.Icon.Should().BeNull("Expected icon to return null when not set");

                // Case 2: static
                var staticIcon = new IconViewModel(null);
                testSubject.Icon = staticIcon;
                // Act + Assert
                testSubject.Icon.Should().Be(staticIcon, "Unexpected static icon");
                tracker.AssertPropertyChangedRaised(nameof(testSubject.Icon), 1);

                // Case 3: dynamic
                var dynamicIcon = new IconViewModel(null);
                var funcInvoked = false;
                Func <object, IconViewModel> func = x =>
                {
                    funcInvoked = true;
                    return(dynamicIcon);
                };
                testSubject.SetDynamicIcon(func);
                // Act + Assert
                testSubject.Icon.Should().Be(dynamicIcon, "Unexpected dynamic icon");
                funcInvoked.Should().BeTrue("Dynamic icon function  was not invoked");
                tracker.AssertPropertyChangedRaised(nameof(testSubject.Icon), 2);
            }

            // Case 4: dynamic - null exception
            Exceptions.Expect <ArgumentNullException>(() => testSubject.SetDynamicIcon(null));
        }
Exemple #9
0
 void WindowManager_WindowAdded(object sender, WindowEventArgs e)
 {
     Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
     {
         var foundItems           = VMLocator.Main.Icons.Where(i => PathTools.SamePath(i.Path, e.Window.FileName));
         IconViewModel windowIcon = null;
         if (foundItems.Any())
         {
             windowIcon = foundItems.First();
         }
         if (!foundItems.Any() || (windowIcon != null && windowIcon.Windows.Count > 0))
         {
             windowIcon = new IconViewModel()
             {
                 Name   = Path.GetFileName(e.Window.FileName),
                 Path   = e.Window.FileName,
                 Pinned = false
             };
             VMLocator.Main.Icons.Add(windowIcon);
         }
         windowIcon.Windows.Add(e.Window);
     }));
 }
Exemple #10
0
 void itemsControl_MouseMove(object sender, MouseEventArgs e)
 {
     mouseY = e.GetPosition(itemsControl).Y;
     mouseX = e.GetPosition(itemsControl).X;
     if (IsInDock(mouseX, mouseY))
     {
         var index = GetDropIndex(mouseX);
         if (placeholder == null)
         {
             placeholder = new IconViewModel();
         }
         if (VMLocator.Main.Icons.IndexOf(placeholder) != index)
         {
             VMLocator.Main.Icons.Remove(placeholder);
             VMLocator.Main.Icons.Insert(index, placeholder);
         }
     }
     else
     {
         VMLocator.Main.Icons.Remove(placeholder);
         placeholder = null;
     }
 }
        public async Task <IActionResult> Create(IconViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (model.Icons == null)
                    {
                        model.Icons = new List <Icon>();
                    }
                    if (_iconService.Get(x => x.GameId == model.GameId && x.Value == model.Value) != null)
                    {
                        ModelState.AddModelError("Value", "Value must be unique");
                        model.Icons.AddRange(_iconService.List(x => x.GameId == model.GameId));
                        return(View(model));
                    }
                    _iconService.BeginTransaction();
                    var icon = helper.GetIcon(model);
                    icon.Id = _iconService.Add(icon);
                    if (icon.Id < 0)
                    {
                        throw new Exception("database error");
                    }
                    await helper.FileUploadAsync(model.IconFile, icon.IconName, "Icon");

                    model.Icons.AddRange(_iconService.List(x => x.GameId == model.GameId));
                    _iconService.CommitTransaction();
                    return(View(nameof(Create), model));
                }
                catch (Exception ex)
                {
                    _iconService.RollbackTransaction();
                }
            }
            return(View(model));
        }
#pragma warning disable CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable. The icon field is actually initialized when setting the Icon property
        public IconTabViewModel(IconViewModel icon, MainWindowViewModel mainWindow)
        {
            this.Icon             = icon;
            this.MainWindow       = mainWindow;
            this.ResetGridCommand = new RelayCommand(ResetGridSettings);
        }
#pragma warning disable CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable. The icon field is actually initialized when setting the Icon property
        public IconTabViewModel(IconViewModel icon, MainWindowViewModel mainWindow)
        {
            this.Icon       = icon;
            this.MainWindow = mainWindow;
        }
Exemple #14
0
 private void LeftMouseUpAction(IconViewModel icon)
 {
     icon.Run();
 }
Exemple #15
0
 protected override void OnAttached()
 {
     base.OnAttached();
     icon = (IconViewModel)AssociatedObject.DataContext;
     icon.OnAnimateIconBounce += icon_OnAnimateIconBounce;
 }
Exemple #16
0
 /// <summary>
 /// 转换为实体
 /// </summary>
 /// <param name="dto">数据传输对象</param>
 private Icons ToEntity(IconViewModel dto)
 {
     return(dto.ToEntity());
 }
 public IconView()
 {
     InitializeComponent();
     this.DataContext = IconViewModel.get();
 }
Exemple #18
0
 public FrameworkElement FindFrameworkElement(IconViewModel icon)
 {
     return(Panel.Children.OfType <FrameworkElement>().FirstOrDefault(c => c.DataContext == icon));
 }
Exemple #19
0
        /// <summary>
        /// 查看详细
        /// </summary>
        /// <param name="id">实体编号</param>
        public PartialViewResult Detail(string id)
        {
            IconViewModel model = IconRepository.Find(id.ToGuidList(), "Id")[0].ToDto();

            return(PartialView("Parts/Icon.Detail", model));
        }
Exemple #20
0
#pragma warning disable CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable. The icon field is actually initialized when setting the Icon property
        public IconTabViewModel(IconViewModel icon, MainWindowViewModel mainWindow)
        {
            Icon       = icon;
            MainWindow = mainWindow;
        }
Exemple #21
0
 private void LeftMouseDownAction(IconViewModel icon)
 {
 }