예제 #1
0
        private void scale()
        {
            new DpiScaler <FormZoom>(form =>
            {
                var hotSpot     = new Point(14, 8).ByDpi();
                var cursorImage = Runtime.IsMono
                                        ? Dpi.ScalePercent > 100
                                                ? Resources.rightclick_48_bw.HalfResizeDpi()
                                                : Resources.rightclick_24_bw.ResizeDpi()
                                        : Resources.rightclick_48.HalfResizeDpi();

                form.Cursor = CursorHelper.CreateCursor(cursorImage, hotSpot);

                bool useLargeIcon = Dpi.ScalePercent > 100;

                form._openFileButton.Image = useLargeIcon
                                        ? Resources.image_file_32.HalfResizeDpi()
                                        : Resources.image_file_16.ResizeDpi();

                form._showInExplorerButton.Image = useLargeIcon
                                        ? Resources.open_32.HalfResizeDpi()
                                        : Resources.open_16.ResizeDpi();

                form._showArtButton.Image = useLargeIcon
                                        ? Resources.art_64.HalfResizeDpi()
                                        : Resources.art_32.ResizeDpi();

                var cloneImg = Resources.clone_48.HalfResizeDpi();

                form._showDuplicatesButton.Image = cloneImg;
                form._showOtherSetsButton.Image  = cloneImg;
            }).Setup(this);
        }
예제 #2
0
        private void createDragCursor(Card card)
        {
            var cardIconSize = new Size(69, 96).ByDpi();
            int overlapY     = 28.ByDpiHeight();
            var handImage    = Resources.play_card_48.ResizeDpi();

            var cursorImage = new Bitmap(cardIconSize.Width, cardIconSize.Height + handImage.Height - overlapY);

            using (var g = Graphics.FromImage(cursorImage))
            {
                var bitmap = card?.Image(Ui);

                if (bitmap == null)
                {
                    using Pen pen = new Pen(SystemColors.WindowText, width: 2);
                    g.DrawRectangle(pen, new Rectangle(Point.Empty, cardIconSize));
                }
                else
                {
                    g.DrawImage(bitmap, new Rectangle(Point.Empty, cardIconSize));
                }

                g.DrawImage(handImage,
                            new Rectangle(
                                new Point((cardIconSize.Width - handImage.Width) / 2, cardIconSize.Height - overlapY - 1),
                                handImage.Size));
            }

            cursorImage = cursorImage.SetOpacity(0.65f);
            var hotSpot = new Point(cursorImage.Width / 2, cardIconSize.Height);

            _dragCursor = CursorHelper.CreateCursor(cursorImage, hotSpot);
        }
예제 #3
0
        public DeckEditorUi(
            MtgLayoutView layoutViewCards,
            MtgLayoutView layoutViewDeck,
            DeckEditorModel deckEditorModel,
            CollectionEditorModel collectionModel,
            DraggingSubsystem draggingSubsystem,
            Cursor cursor,
            FormZoom formZoom,
            Control parent)
        {
            _layoutViewCards   = layoutViewCards;
            _layoutViewDeck    = layoutViewDeck;
            _cursor            = cursor;
            _deckEditorModel   = deckEditorModel;
            _collectionModel   = collectionModel;
            _draggingSubsystem = draggingSubsystem;
            _draggingSubsystem.DraggedLikeClick += draggedLikeClick;
            _draggingSubsystem.DragRemoved      += dragRemoved;
            _draggingSubsystem.DragAdded        += dragAdded;
            _layoutViewCards.SelectionStarted   += selectionStarted;

            _formZoom = formZoom;
            _parent   = parent;

            var hotSpot = Size.Empty.ByDpi();

            _zoomCursor = CursorHelper.CreateCursor(Resources.zoom_48.HalfResizeDpi(), hotSpot);

            var iBeamIcon    = Resources.text_selection_24.ResizeDpi();
            var iBeamHotSpot = new Size(iBeamIcon.Width / 2, iBeamIcon.Height / 2);

            _textSelectionCursor = CursorHelper.CreateCursor(iBeamIcon, iBeamHotSpot);
        }
예제 #4
0
        public void Cursor_is_created()
        {
            var bmp     = new Bitmap(16, 16);
            var hotSpot = new Point(8, 0);

            var cursor = CursorHelper.CreateCursor(bmp, hotSpot);

            Assert.That(cursor.Size, Is.EqualTo(bmp.Size));
        }
예제 #5
0
        public void SetCursor()
        {
            DrawingBrush db         = this.FindResource("dPen") as DrawingBrush;
            Rectangle    exampleRec = new Rectangle();

            exampleRec.Width  = 28;
            exampleRec.Height = 32;
            exampleRec.Fill   = db;
            this.PenCursor    = CursorHelper.CreateCursor(exampleRec, 5, 5);
        }
예제 #6
0
		public void Scale()
		{
			new DpiScaler<DeckEditorSubsystem>(s =>
			{
				var hotSpot = Size.Empty.ByDpi();
				s._zoomCursor = CursorHelper.CreateCursor(Resources.zoom_48.HalfResizeDpi(), hotSpot);

				var iBeamIcon = Resources.text_selection_24.ResizeDpi();
				var iBeamHotSpot = new Size(iBeamIcon.Width / 2, iBeamIcon.Height / 2);
				s._textSelectionCursor = CursorHelper.CreateCursor(iBeamIcon, iBeamHotSpot);
			}).Setup(this);
		}
예제 #7
0
 public void Scale()
 {
     new DpiScaler <DeckEditorSubsystem>(s =>
     {
         var hotSpot = Point.Empty.ByDpi();
         var image   = Runtime.IsMono
                                 ? Dpi.ScalePercent > 100
                                         ? Resources.zoom_48_bw.HalfResizeDpi()
                                         : Resources.zoom_24_bw.ResizeDpi()
                                 : Resources.zoom_48.HalfResizeDpi();
         s._zoomCursor = CursorHelper.CreateCursor(image, hotSpot);
     }).Setup(this);
 }
예제 #8
0
        private static void Uielement_GiveFeedback(object sender, GiveFeedbackEventArgs e)
        {
            if (e.Effects == DragDropEffects.Move)
            {
                using Cursor customCursor = CursorHelper.CreateCursor(VisualTreeHelper.GetParent(e.Source as UIElement) as UIElement);
                if (customCursor != null)
                {
                    e.UseDefaultCursors = false;
                    Mouse.SetCursor(customCursor);
                }
            }
            else
            {
                e.UseDefaultCursors = true;
            }

            e.Handled = true;
        }
예제 #9
0
        public FormZoom(
            CardRepository cardRepository,
            ImageRepository imageRepository,
            ImageLoader imageLoader)
            : this()
        {
            _cardRepository  = cardRepository;
            _imageRepository = imageRepository;
            _imageLoader     = imageLoader;

            BackgroundImageLayout = ImageLayout.Zoom;
            TransparencyKey       = BackColor = _defaultBgColor;

            _pictureBox.MouseClick += click;
            MouseWheel             += mouseWheel;
            DoubleBuffered          = true;

            var hotSpot     = new Size(14, 8).ByDpi();
            var cursorImage = Resources.rightclick_48.HalfResizeDpi();

            Cursor = CursorHelper.CreateCursor(cursorImage, hotSpot);

            _openFileButton.Image = Dpi.ScalePercent > 100
                                ? Resources.image_file_32.HalfResizeDpi()
                                : Resources.image_file_16.ResizeDpi();

            _showInExplorerButton.Image = Dpi.ScalePercent > 100
                                ? Resources.open_32.HalfResizeDpi()
                                : Resources.open_16.ResizeDpi();

            _showArtButton.Image = Dpi.ScalePercent > 100
                                ? Resources.art_64.HalfResizeDpi()
                                : Resources.art_32.ResizeDpi();

            var cloneImg = Resources.clone_48.HalfResizeDpi();

            _showDuplicatesButton.Image = cloneImg;
            _showOtherSetsButton.Image  = cloneImg;

            _showArtButton.CheckedChanged += showArtChanged;
            updateShowArt();
        }
예제 #10
0
        private void dtGridActors_GiveFeedback(object sender, GiveFeedbackEventArgs e)
        {
            // TreeViewItem nd = (TreeViewItem)((TreeView)sender).SelectedItem;
            // StackPanel st = (StackPanel)nd.Header;
            Image im = null;

            if (_allOpsCursor == null)
            {
                //  TextBlock lbl = st.Children[1] as TextBlock;
                // if (lbl != null)  //  Unit font
                {
                    Label lblDrag = new Label();
                    lblDrag.Content = new string((char)150, 1);                              // lbl.Text;//  .Content;
                    //  lblDrag.Content = new string((char)86, 1);// lbl.Text;//  .Content;
                    lblDrag.Foreground = Brushes.Red;                                        //lbl.Foreground;
                    lblDrag.FontFamily = new System.Windows.Media.FontFamily("Wingdings 2"); //"Wingdings 2";// UserSession.KingsGameFontFamily;// new FontFamily("Simulation Font Environmental");
                    lblDrag.FontSize   = 40;                                                 // lbl.FontSize;
                    double fs = 20;                                                          // lbl.FontSize;
                    lblDrag.Height = 40;                                                     // lbl.Height;
                    lblDrag.Width  = 40;                                                     // lbl.Width;

                    lblDrag.FontWeight = System.Windows.FontWeights.Bold;

                    //new
                    // lblDrag.Foreground = System.Windows.Media.Brushes.Black;

                    try
                    {
                        _allOpsCursor = CursorHelper.CreateCursor(lblDrag, (int)8, (int)8, false);
                        Mouse.SetCursor(_allOpsCursor);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }

            e.UseDefaultCursors = false;
            e.Handled           = true;
        }
예제 #11
0
        private void Rectangle_MouseMove(object sender, MouseEventArgs e)
        {
            if (controlRectangles.Count == 0)
            {
                return;
            }

            Point p = e.GetPosition(cMain);

            {
                Rectangle r = (Rectangle)sender;
                if (e.GetPosition(cMain).X - Canvas.GetLeft(r) < r.Width / 4)
                {
                    Cursor = CursorHelper.CreateCursor(AppDomain.CurrentDomain.BaseDirectory + "\\Images\\toleft.png");//修改鼠标样式
                }
                else if (e.GetPosition(cMain).X - Canvas.GetLeft(r) > r.Width * 3 / 4)
                {
                    Cursor = CursorHelper.CreateCursor(AppDomain.CurrentDomain.BaseDirectory + "\\Images\\toright.png", 0, 0);//修改鼠标样式
                }
                else
                {
                    Cursor = CursorHelper.CreateCursor(AppDomain.CurrentDomain.BaseDirectory + "\\Images\\tomove.png");//修改鼠标样式
                }
            }
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                if (MoveOrChange == 0)
                {
                    Double chaX = p.X - pointX;
                    Double chaY = p.Y - pointY;

                    foreach (Rectangle r in controlRectangles)
                    {
                        Canvas.SetLeft(r, Canvas.GetLeft(r) + chaX);
                        Canvas.SetTop(r, Canvas.GetTop(r) + chaY);
                    }

                    pointX = p.X;
                    pointY = p.Y;
                }
                else if (MoveOrChange == 1)
                {
                    Double chaX = p.X - pointX;
                    Double chaY = p.Y - pointY;

                    foreach (Rectangle r in controlRectangles)
                    {
                        bool havaHinder = false;
                        foreach (Rectangle cr in controlRectangles)
                        {
                            if (Canvas.GetTop(r) == Canvas.GetTop(cr))
                            {
                                if (r == cr)
                                {
                                    continue;
                                }
                                //判断谁在前面
                                if (Canvas.GetLeft(r) < Canvas.GetLeft(cr))
                                {
                                    continue;
                                }
                                //Canvas.GetLeft(b) + -1 * chaX < Canvas.GetLeft(bc) + r.Width + 2
                                if (Canvas.GetLeft(cr) + cr.Width > Canvas.GetLeft(r) + chaX)
                                {
                                    havaHinder = true;
                                    break;
                                }
                            }
                        }
                        if (!havaHinder)
                        {
                            if (r.Width - chaX > 0)
                            {
                                r.Width -= chaX;
                                Canvas.SetLeft(r, Canvas.GetLeft(r) + chaX);
                            }
                        }
                        //Canvas.SetLeft(b, Canvas.GetLeft(b) + chaX);
                        //Canvas.SetTop(b, Canvas.GetTop(b) + chaY);
                    }

                    pointX = p.X;
                    pointY = p.Y;
                }
                else if (MoveOrChange == 2)
                {
                    Double chaX = p.X - pointX;
                    Double chaY = p.Y - pointY;

                    foreach (Rectangle r in controlRectangles)
                    {
                        bool havaHinder = false;
                        foreach (Rectangle cr in controlRectangles)
                        {
                            if (Canvas.GetTop(r) == Canvas.GetTop(cr))
                            {
                                if (r == cr)
                                {
                                    continue;
                                }

                                //判断谁在前面
                                if (Canvas.GetLeft(r) > Canvas.GetLeft(cr))
                                {
                                    continue;
                                }

                                if (Canvas.GetLeft(r) + r.Width + chaX > Canvas.GetLeft(cr))
                                {
                                    havaHinder = true;
                                    break;
                                }
                            }
                        }
                        if (!havaHinder)
                        {
                            if (r.Width + chaX > 0)
                            {
                                r.Width += chaX;
                            }
                        }
                        //Canvas.SetLeft(b, Canvas.GetLeft(b) + chaX);
                        //Canvas.SetTop(b, Canvas.GetTop(b) + chaY);
                    }

                    pointX = p.X;
                    pointY = p.Y;
                }
            }
            //e.Handled = true;
        }