Exemplo n.º 1
0
        private void OnAddMgElemExecute()
        {
            if (additionMgElem != null)
            {
                string filename = dialogManager.GetImageFilepath();

                if (filename != "")
                {
                    BitmapImage image = new BitmapImage(new Uri(filename));
                    if (image.PixelWidth != image.PixelHeight && dialogManager.PictureNot1to1() == System.Windows.Forms.DialogResult.No)
                    {
                        return;
                    }

                    MgElemControl control = controlCreator.CreateMgElemControl(50, image, SelectImage);
                    mgElemsStack.Children.Add(control);
                    imagesSelect.Add(control);
                    additionMgElem.Invoke(control.ViewModel.GetModel());

                    if (imagesSelect.Count == 1)
                    {
                        control.ViewModel.SelectVisibility = Visibility.Visible;
                        SelectedMgElem = control;
                    }
                }
            }
        }
Exemplo n.º 2
0
 public void CreateLoadedLevel(List <MgElem> elems)
 {
     foreach (MgElem elem in elems)
     {
         MgElemControl control = controlCreator.CreateMgElemControl(50, elem.Image, SelectImage);
         control.ViewModel.TextIndex = elem.Id;
         imagesSelect.Add(control);
     }
 }
Exemplo n.º 3
0
        public MgElemControl CreateMgElemControl(int size, BitmapImage imageSource, MouseButtonEventHandler onBtDown)
        {
            MgElemControl control = new MgElemControl();

            control.ViewModel.ImageSource = imageSource;
            control.ViewModel.ImageSize   = size;
            control.ImgControl.MouseDown += onBtDown;
            return(control);
        }
Exemplo n.º 4
0
        private void SelectImage(object sender, MouseButtonEventArgs e)
        {
            if (sender != null && sender is Image snd)
            {
                MgElemControl sndr = null;

                foreach (MgElemControl img in imagesSelect)
                {
                    img.ViewModel.SelectVisibility = Visibility.Hidden;
                    if (snd == img.ImgControl && sndr == null)
                    {
                        sndr = img;
                    }
                }

                if (sndr != null)
                {
                    sndr.ViewModel.SelectVisibility = Visibility.Visible;
                    SelectedMgElem = sndr;
                }
            }
        }