コード例 #1
0
        public void TestThatCopyToClipboardWithSelectionSavesCorrectBitmap()
        {
            Clipboard.Clear();

            Layer testLayer  = new Layer("test layer", 10, 10);
            Layer testLayer2 = new Layer("test layer", 10, 10);

            testLayer.SetPixel(new Coordinates(4, 4), testColor);
            testLayer2.SetPixel(new Coordinates(5, 5), testColor);

            ClipboardController.CopyToClipboard(new [] { testLayer, testLayer2 },
                                                new [] { new Coordinates(4, 4), new Coordinates(5, 5) }, 10, 10);

            var img = Clipboard.GetImage(); // Using default Clipboard get image to avoid false positives from faulty ClipboardController GetImage

            Assert.True(ClipboardController.IsImageInClipboard());
            Assert.NotNull(img);
            Assert.Equal(2, img.PixelWidth);
            Assert.Equal(2, img.PixelHeight);

            var bmp = new WriteableBitmap(img);

            Assert.Equal(testColor, bmp.GetPixel(0, 0));
            Assert.Equal(testColor, bmp.GetPixel(1, 1));
        }
コード例 #2
0
        public void TestThatClipboardControllerSavesImageToClipboard()
        {
            Layer testLayer = new Layer("test layer", 10, 10);

            ClipboardController.CopyToClipboard(new [] { testLayer }, CoordinatesCalculator.RectangleToCoordinates(0, 0, 9, 9), 10, 10);
            Assert.True(ClipboardController.IsImageInClipboard());
        }
コード例 #3
0
 private void Copy(object parameter)
 {
     ClipboardController.CopyToClipboard(
         Owner.BitmapManager.ActiveDocument.Layers.Where(x => x.IsActive && x.IsVisible).ToArray(),
         Owner.BitmapManager.ActiveDocument.ActiveSelection.SelectedPoints.ToArray(),
         Owner.BitmapManager.ActiveDocument.Width,
         Owner.BitmapManager.ActiveDocument.Height);
 }
コード例 #4
0
        public void TestThatClipboardControllerIgnoresNonImageDataInClipboard()
        {
            Clipboard.Clear();
            Clipboard.SetText(Text);
            WriteableBitmap img = ClipboardController.GetImageFromClipboard();

            Assert.Null(img);
        }
コード例 #5
0
 private void Copy(object parameter)
 {
     ClipboardController.CopyToClipboard(
         new[] { Owner.BitmapManager.ActiveDocument.ActiveLayer },
         Owner.BitmapManager.ActiveDocument.ActiveSelection.SelectedPoints.ToArray(),
         Owner.BitmapManager.ActiveDocument.Width,
         Owner.BitmapManager.ActiveDocument.Height);
 }
コード例 #6
0
 public void Paste(object parameter)
 {
     if (Owner.BitmapManager.ActiveDocument == null)
     {
         return;
     }
     ClipboardController.PasteFromClipboard(Owner.BitmapManager.ActiveDocument);
 }
コード例 #7
0
 void Start()
 {
     sprite             = GetComponent <Image>();
     sprite.enabled     = false;
     instance           = this;
     anim               = GetComponent <Animator>();
     clipboardText.text = "";
 }
コード例 #8
0
        public void TestThatClipboardControllerIgnoresNonImageDataInClipboard()
        {
            Clipboard.Clear();
            Clipboard.SetText("Text data");
            var img = ClipboardController.GetImageFromClipboard();

            Assert.Null(img);
        }
コード例 #9
0
        private void Copy(object parameter)
        {
            var doc = Owner.BitmapManager.ActiveDocument;

            ClipboardController.CopyToClipboard(
                doc.Layers.Where(x => x.IsActive && doc.GetFinalLayerIsVisible(x)).ToArray(),
                doc.ActiveSelection.SelectedPoints.ToArray(),
                doc.Width,
                doc.Height);
        }
コード例 #10
0
 // Use this for initialization
 void Start()
 {
     pictureFolderMap["Pictures Main Room Left"] = "Main Room North Left";
     leftHandPoint         = leftHand.transform.GetChild(0).gameObject;
     rightHandPoint        = rightHand.transform.GetChild(0).gameObject;
     rightHandModelPoint   = rightHandModel.transform.GetChild(1).gameObject;
     clipboard             = clipboardContainer.transform.GetChild(0).gameObject;
     clipboardController   = clipboard.GetComponent <ClipboardController>();
     clipboardHoldingPoint = clipboardContainer.transform.GetChild(1).gameObject;
     clipboardBottomPoint  = clipboardContainer.transform.GetChild(2).gameObject;
     clipboardTopPoint     = clipboardContainer.transform.GetChild(3).gameObject;
     vrControllerCheck     = GetComponent <VRControllerCheck>();
 }
コード例 #11
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var clipboardIcon = new System.Windows.Forms.NotifyIcon()
            {
                Icon        = new System.Drawing.Icon((Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), @"Resources\ApplicationIcon.ico"))),
                ContextMenu = new ContextMenuController().ContextMenu,
                Visible     = true
            };

            HotkeyController.Hotkey = new HotkeyController.HotKey(Key.V, ModifierKeys.Shift | ModifierKeys.Control, OnHotKeyPressed);
            clipboardController     = new ClipboardController(this);
            btnCurrentItems.Tag     = true;
            clipboardController.ClipboardChanged += ClipboardController_ClipboardChanged;
            this.Deactivated += ClipboardView_Deactivated;
        }
コード例 #12
0
        public void TestThatClipboardControllerGetsCorrectImageInDibFormatFromClipboard()
        {
            Clipboard.Clear();
            var bmp = BitmapFactory.New(10, 10);

            bmp.SetPixel(4, 4, testColor);
            Clipboard.SetImage(bmp);

            var img = ClipboardController.GetImageFromClipboard();

            Assert.NotNull(img);
            Assert.Equal(10, img.PixelWidth);
            Assert.Equal(10, img.PixelHeight);
            Assert.Equal(testColor, bmp.GetPixel(4, 4));
        }
コード例 #13
0
ファイル: UIController.cs プロジェクト: Iggyyy/horrorUnity
    public void createRay()
    {
        Vector3 point = new Vector3(_camera.pixelWidth / 2, _camera.pixelHeight / 2);
        // Debug.Log("casting: " + _camera.pixelWidth / 2 + ", " + _camera.pixelHeight / 2);
        Ray        ray = _camera.ScreenPointToRay(point);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            GameObject          hitObject = hit.transform.gameObject;
            ClipboardController target    = hitObject.GetComponent <ClipboardController>();
            DoorOpenDevice      hitDoor   = hitObject.GetComponent <DoorOpenDevice>();

            float distance = Vector3.Distance(player.transform.position, hitObject.transform.position);

            if (target != null && distance <= maxRayDistance)
            {
                if (Input.GetKeyDown(KeyCode.E))
                {
                    target.reactToHit();          //Reaction to hit
                    collectingSystem.setScore();
                    StartCoroutine(collectNot()); //Notification collected
                    Debug.Log("Collected");
                }
                else
                {
                    collectNotification.text = "Press 'E' to collect clipboard";
                }
            }
            else if (hitDoor != null && distance <= maxRayDistance)
            {
                if (Input.GetKeyDown(KeyCode.E))
                {
                    hitDoor.Operate();
                }
                else
                {
                    collectNotification.text = "Press 'E' to open";
                }
            }
            else
            {
                collectNotification.text = "";
            }
        }
    }
コード例 #14
0
        public void TestThatClipboardControllerGetsCorrectImageInBitmapFormatFromClipboard()
        {
            Clipboard.Clear();
            var bmp = BitmapFactory.New(10, 10);

            bmp.SetPixel(4, 4, testColor);

            DataObject data = new DataObject();

            data.SetData(DataFormats.Bitmap, bmp, false); //PNG, supports transparency
            Clipboard.SetDataObject(data, true);

            var img = ClipboardController.GetImageFromClipboard();

            Assert.NotNull(img);
            Assert.Equal(10, img.PixelWidth);
            Assert.Equal(10, img.PixelHeight);
            Assert.Equal(testColor, bmp.GetPixel(4, 4));
        }
コード例 #15
0
        public void TestThatClipboardControllerGetsCorrectImageInPngFormatFromClipboard()
        {
            Clipboard.Clear();
            var bmp = BitmapFactory.New(10, 10);

            bmp.SetPixel(4, 4, testColor);
            using (var pngStream = new MemoryStream())
            {
                DataObject data = new DataObject();

                PngBitmapEncoder encoder = new PngBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(bmp));
                encoder.Save(pngStream);
                data.SetData("PNG", pngStream, false); //PNG, supports transparency
                Clipboard.SetDataObject(data, true);
            }

            var img = ClipboardController.GetImageFromClipboard();

            Assert.NotNull(img);
            Assert.Equal(10, img.PixelWidth);
            Assert.Equal(10, img.PixelHeight);
            Assert.Equal(testColor, bmp.GetPixel(4, 4));
        }
コード例 #16
0
 private bool CanPaste(object property)
 {
     return(Owner.DocumentIsNotNull(null) && ClipboardController.IsImageInClipboard());
 }
コード例 #17
0
 public void Paste(object parameter)
 {
     ClipboardController.PasteFromClipboard();
 }
コード例 #18
0
 private void Copy(object parameter)
 {
     ClipboardController.CopyToClipboard(Owner.BitmapManager.ActiveDocument);
 }
コード例 #19
0
 public void TestThatIsImageInClipboardWorksForDib()
 {
     Clipboard.Clear();
     Clipboard.SetImage(BitmapFactory.New(10, 10));
     Assert.True(ClipboardController.IsImageInClipboard());
 }