コード例 #1
0
        protected override void OnPointerMoved(PointerRoutedEventArgs e)
        {
            e.Handled = true;

            if (_ignorePointerMoved)
            {
                _ignorePointerMoved = false; return;
            }

            _rootRef.Point2 = _rootDelta.Point2 = GridPoint(e);
            _drawRef.Point2 = _drawDelta.Point2 = DrawPoint(e);


            if (_isPointerPressed && _eventAction.TryGetValue(EventId.Drag, out Action drag))
            {
                drag?.Invoke();
                if (_enableHitTest)
                {
                    HitTest(_drawRef.Point2);
                }

                EditorCanvas.Invalidate();
            }
            else if (_eventAction.TryGetValue(EventId.Hover, out Action hover))
            {
                HitTest(_drawRef.Point2);
                if (_selector.IsChanged)
                {
                    Debug.WriteLine($"- - - - - - - - - Hit { _selector.HitLocation}");
                    hover?.Invoke();
                }
            }
        }
コード例 #2
0
 private void EditContactComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (EditContact == Edit_Contact.Edit)
     {
         AutoFlipGrid.Visibility    = Windows.UI.Xaml.Visibility.Collapsed;
         ContactGrid.Visibility     = Windows.UI.Xaml.Visibility.Collapsed;
         SelectorCanvas.Visibility  = Windows.UI.Xaml.Visibility.Visible;
         PickerCanvas.Visibility    = Windows.UI.Xaml.Visibility.Visible;
         PropertyGrid.Visibility    = Windows.UI.Xaml.Visibility.Visible;
         ColorPickerGrid.Visibility = Windows.UI.Xaml.Visibility.Visible;
         SetIdleOnVoid();
     }
     else if (EditContact == Edit_Contact.Contacts)
     {
         PropertyGrid.Visibility    = Windows.UI.Xaml.Visibility.Collapsed;
         ColorPickerGrid.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
         SelectorCanvas.Visibility  = Windows.UI.Xaml.Visibility.Collapsed;
         PickerCanvas.Visibility    = Windows.UI.Xaml.Visibility.Collapsed;
         AutoFlipGrid.Visibility    = Windows.UI.Xaml.Visibility.Collapsed;
         ContactGrid.Visibility     = Windows.UI.Xaml.Visibility.Visible;
         SetContactsOnVoid();
     }
     else
     {
         PropertyGrid.Visibility    = Windows.UI.Xaml.Visibility.Collapsed;
         ColorPickerGrid.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
         SelectorCanvas.Visibility  = Windows.UI.Xaml.Visibility.Collapsed;
         PickerCanvas.Visibility    = Windows.UI.Xaml.Visibility.Collapsed;
         ContactGrid.Visibility     = Windows.UI.Xaml.Visibility.Collapsed;
         AutoFlipGrid.Visibility    = Windows.UI.Xaml.Visibility.Visible;
         SetContactsOnVoid();
     }
     EditorCanvas.Invalidate();
 }
コード例 #3
0
 private void OnEditorComparePointerReleased()
 {
     EditorCompareTop.IsChecked    = false;
     EditorCompareBottom.IsChecked = false;
     if (EditorCanvas.Visibility == Visibility.Visible)
     {
         cbm   = CanvasBitmap.CreateFromBytes(EditorCanvas, lastDecodeResult.Bytes, lastDecodeResult.Width, lastDecodeResult.Height, DirectXPixelFormat.B8G8R8A8UIntNormalized);
         brush = new CanvasImageBrush(EditorCanvas, cbm)
         {
             Interpolation = CanvasImageInterpolation.NearestNeighbor
         };
         EditorCanvas.Width  = lastDecodeResult.Width;
         EditorCanvas.Height = lastDecodeResult.Height;
         EditorCanvas.Invalidate();
     }
     else
     {
         if (EditorText.Visibility == Visibility.Visible)
         {
             EditorText.Text = currentStrAll;
         }
         else if (EditorHex.Visibility == Visibility.Visible)
         {
             EditorHex.Bytes = new byte[currentBytes.Length];
             currentBytes.CopyTo(EditorHex.Bytes, 0);
             EditorHex.Invalidate();
         }
     }
 }
コード例 #4
0
 private void OnEditorComparePointerPressed()
 {
     EditorCompareTop.IsChecked    = true;
     EditorCompareBottom.IsChecked = true;
     if (EditorCanvas.Visibility == Visibility.Visible)
     {
         cbm   = CanvasBitmap.CreateFromBytes(EditorCanvas, editFileParams.Bytes, editFileParams.Width, editFileParams.Height, DirectXPixelFormat.B8G8R8A8UIntNormalized);
         brush = new CanvasImageBrush(EditorCanvas, cbm)
         {
             Interpolation = CanvasImageInterpolation.NearestNeighbor
         };
         EditorCanvas.Width  = editFileParams.Width;
         EditorCanvas.Height = editFileParams.Height;
         EditorCanvas.Invalidate();
     }
     else
     {
         if (EditorText.Visibility == Visibility.Visible)
         {
             currentStrAll   = EditorText.Text;
             EditorText.Text = initialStrAll;
         }
         else if (EditorHex.Visibility == Visibility.Visible)
         {
             currentBytes = new Byte[EditorHex.Bytes.Length];
             EditorHex.Bytes.CopyTo(currentBytes, 0);
             EditorHex.Bytes = new Byte[initialBytes.Length];
             initialBytes.CopyTo(EditorHex.Bytes, 0);
             EditorHex.Invalidate();
         }
     }
 }
コード例 #5
0
        private void DragNewShape()
        {
            Shape.MoveCenter(DragShapes, ShapeDelta);
            RawPoint1   = RawPoint2;
            ShapePoint1 = ShapePoint(RawPoint2);

            EditorCanvas.Invalidate();
        }
コード例 #6
0
 private void TryInvokeEventAction(PointerEvent e)
 {
     if (_eventAction.TryGetValue(EventKey(e), out Action action))
     {
         action.Invoke();
         EditorCanvas.Invalidate();
     }
 }
コード例 #7
0
 private void RecenterButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
 {
     if (SelectedShapes.Count > 0)
     {
         Shape.SetCenter(SelectedShapes, Vector2.Zero);
         EditorCanvas.Invalidate();
     }
 }
コード例 #8
0
        private void DragCenterPoint()
        {
            Shape.MoveCenter(SelectedShapes, ShapeDelta);
            Shape.LockSliders(SelectedShapes, true);
            SetSizeSliders();

            EditorCanvas.Invalidate();
        }
コード例 #9
0
 private void DragContact_SEC()
 {
     if (Target_Contacts.TryGetValue(Target.SEC, out (Contact con, (sbyte dx, sbyte dy)pnt, byte siz)val))
     {
         var p = ClampPoint(ShapePoint2, TargetIndex.SEC);
         Target_Contacts[Target.SEC] = (val.con, Shape.ToSByte(p), val.siz);
     }
     EditorCanvas.Invalidate();
 }
コード例 #10
0
        private async void EditorPreview_Checked(object sender, RoutedEventArgs e)
        {
            if (EditorText.Visibility == Visibility.Visible)
            {
                try
                {
                    lastDecodeResult = await decoder.decode(ASCIIEncoding.ASCII.GetBytes(EditorText.Text));
                }
                catch
                {
                    var           loader             = new ResourceLoader();
                    var           warningTilte       = loader.GetString("DecodeFailureTitle");
                    var           warningMesage      = loader.GetString("DecodeFailureMessage");
                    var           ok                 = loader.GetString("Ok");
                    MessageDialog decodeFailedDialog = new MessageDialog(warningMesage, warningTilte);
                    decodeFailedDialog.Commands.Add(new UICommand(ok));
                    decodeFailedDialog.DefaultCommandIndex = 0;
                    await decodeFailedDialog.ShowAsync();

                    return;
                }
            }
            else if (EditorHex.Visibility == Visibility.Visible)
            {
                try
                {
                    lastDecodeResult = await decoder.decode(EditorHex.Bytes);
                }
                catch (Exception)
                {
                    var           loader             = new ResourceLoader();
                    var           warningTilte       = loader.GetString("DecodeFailureTitle");
                    var           warningMesage      = loader.GetString("DecodeFailureMessage");
                    var           ok                 = loader.GetString("Ok");
                    MessageDialog decodeFailedDialog = new MessageDialog(warningMesage, warningTilte);
                    decodeFailedDialog.Commands.Add(new UICommand(ok));
                    decodeFailedDialog.DefaultCommandIndex = 0;
                    await decodeFailedDialog.ShowAsync();

                    return;
                }
            }
            cbm   = CanvasBitmap.CreateFromBytes(EditorCanvas, lastDecodeResult.Bytes, lastDecodeResult.Width, lastDecodeResult.Height, DirectXPixelFormat.B8G8R8A8UIntNormalized);
            brush = new CanvasImageBrush(EditorCanvas, cbm)
            {
                Interpolation = CanvasImageInterpolation.NearestNeighbor
            };
            EditorCanvas.Width  = lastDecodeResult.Width;
            EditorCanvas.Height = lastDecodeResult.Height;

            EditorCanvas.Visibility = Visibility.Visible;
            EditorEditGrid.RowDefinitions[editorRow].Height = new GridLength(0, GridUnitType.Pixel);
            EditorEditGrid.RowDefinitions[2].Height         = new GridLength(1, GridUnitType.Star);
            this.Keyboard.Visibility = Visibility.Collapsed;
            EditorCanvas.Invalidate();
        }
コード例 #11
0
        private void SetDragNewShape()
        {
            if (SetEditorState(EditorState.DragNewShape))
            {
                SetEventAction(PointerEvent.Drag, DragNewShape);
                SetEventAction(PointerEvent.End, EndDragNewShape);

                EditorCanvas.Invalidate();
            }
        }
コード例 #12
0
        public void Refresh()
        {
            if (EditorCanvas == null)
            {
                return;
            }

            CheckGraphSymbols();
            EditorCanvas.Invalidate();
        }
コード例 #13
0
        private void DimensionSlider_ValueChanged(object sender, Windows.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e)
        {
            var value = (float)DimensionSlider.Value;

            if (Changed(value, _polyDimension))
            {
                Shape.SetDimension(SelectedShapes, value);
                SetSizeSliders();
                EditorCanvas.Invalidate();
            }
        }
コード例 #14
0
        private void ChangeColorAtPoint(Point point)
        {
            // Change the color according to the current color
            int x = (int)point.X;
            int y = (int)point.Y;

            _colors[y, x] = _currentColor;

            // This forces us to redraw
            EditorCanvas.Invalidate();
        }
コード例 #15
0
        private void KeyboardAccelerator_Invoked(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args)
        {
            var k = args.KeyboardAccelerator.Key;
            var m = args.KeyboardAccelerator.Modifiers;

            if (_eventAction.TryGetValue(EventKey(k, m), out Action action))
            {
                action.Invoke();
                EditorCanvas.Invalidate();
            }
        }
コード例 #16
0
        private void TernarySizeSlider_ValueChanged(object sender, Windows.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e)
        {
            var value = (float)TernarySizeSlider.Value;

            if (Changed(value, _ternarySize))
            {
                Shape.ResizeTernaryAxis(SelectedShapes, value);
                SetSizeSliders();
                EditorCanvas.Invalidate();
            }
        }
コード例 #17
0
 private void SetNewContactSize(Target targ, double value)
 {
     if (_contactSizeChangeEnabled)
     {
         var d = (float)(value / 100);
         if (Target_Contacts.TryGetValue(targ, out (Contact c, (sbyte x, sbyte y)p, byte s)v))
         {
             Target_Contacts[targ] = (v.c, v.p, Shape.ToByte(d));
             EditorCanvas.Invalidate();
         }
     }
 }
コード例 #18
0
        private void SetIdleOnVoid()
        {
            if (SetEditorState(EditorState.IdleOnVoid))
            {
                PickerShape = null;
                SelectedShapes.Clear();
                SetSizeSliders();

                PickerCanvas.Invalidate();
                EditorCanvas.Invalidate();
            }
        }
コード例 #19
0
        private void HorizontalSizeSlider_ValueChanged(object sender, Windows.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e)
        {
            var value = (float)HorizontalSizeSlider.Value;

            if (Changed(value, _horizontalSize))
            {
                Shape.ResizeHorizontal(SelectedShapes, value);
                LockPolyline();
                SetSizeSliders();
                EditorCanvas.Invalidate();
            }
        }
コード例 #20
0
        private void SetShapesAreSelected()
        {
            if (SetEditorState(EditorState.ShapesAreSelected)) //enable hit test
            {
                SetEventAction(PointerEvent.Begin, TargetPointerDown);
                SetEventAction(PointerEvent.Hover, TargetPointerHover);

                PickerShape = null;
                PickerCanvas.Invalidate();
                EditorCanvas.Invalidate();
            }
        }
コード例 #21
0
        private void AddNewShape()
        {
            if (PickerShape != null)
            {
                var newShape = PickerShape.Clone(ShapePoint1);
                DragShapes[0] = newShape;
                SymbolShapes.Add(newShape);

                SetProperty(newShape, ProertyId.All);

                EditorCanvas.Invalidate();
            }
        }
コード例 #22
0
        private void CopyButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            if (SelectedShapes.Count > 0)
            {
                CutCopyShapes.Clear();
                foreach (var shape in SelectedShapes)
                {
                    CutCopyShapes.Add(shape.Clone());
                }
                SelectedShapes.Clear();

                EditorCanvas.Invalidate();
            }
        }
コード例 #23
0
        private void PickerCanvas_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            var index = GetPickerShapeIndex(e);

            if (index < 0 || (index != _pickerIndex))
            {
                return;
            }

            SetPicker(PickerShapes[index]);

            PickerCanvas.Invalidate();
            EditorCanvas.Invalidate();
        }
コード例 #24
0
 private void PasteButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
 {
     if (CutCopyShapes.Count > 0)
     {
         SelectedShapes.Clear();
         foreach (var template in CutCopyShapes)
         {
             var shape = template.Clone();
             SymbolShapes.Add(shape);
             SelectedShapes.Add(shape);
         }
         SetShapesAreSelected();
         EditorCanvas.Invalidate();
     }
 }
コード例 #25
0
        private void EndTargetDrag()
        {
            if (IsKillZone())
            {
                RestorePointerCursor();
                if (!_polylineTarget.TryDeletePoint(_linePointIndex))
                {
                    SymbolShapes.Remove(_polylineTarget);
                    _targetPoints.Clear();
                    SetIdleOnVoid();
                }
            }

            ClearEventAction(PointerEvent.Drag);
            EditorCanvas.Invalidate();
        }
コード例 #26
0
 private void SelectorCanvas_PointerMoved(object sender, PointerRoutedEventArgs e)
 {
     if (_selectPointerPressed && _selectorIndex >= 0 && SelectedShapes.Count == 0)
     {
         var index = GetSelectorIndex(e);
         if (index >= 0 && index != _selectorIndex && SelectedShapes.Count == 0)
         {
             var shape = SymbolShapes[_selectorIndex];
             SymbolShapes[_selectorIndex] = SymbolShapes[index];
             SymbolShapes[index]          = shape;
             _selectorIndex = index;
             _ignoreSelectPointerReleased = true;
             EditorCanvas.Invalidate();
         }
     }
 }
コード例 #27
0
        private void DragLinePoint()
        {
            _polylineTarget.MovePoint(_linePointIndex, ShapeDelta);
            Shape.LockSliders(SelectedShapes, true);
            SetSizeSliders();

            if (IsKillZone())
            {
                TrySetNewCursor(CoreCursorType.UniversalNo);
            }
            else
            {
                RestorePointerCursor();
            }

            EditorCanvas.Invalidate();
        }
コード例 #28
0
        private void DragContact_NEC()
        {
            if (Target_Contacts.TryGetValue(Target.NEC, out (Contact con, (sbyte dx, sbyte dy)pnt, byte siz)val))
            {
                var d = ShapePoint2.Y;
                if (d < -1f)
                {
                    d = -1f;
                }
                if (d > -0.1f)
                {
                    d = -0.1f;
                }
                var p = new Vector2(-d, d);

                Target_Contacts[Target.NEC] = (val.con, Shape.ToSByte(p), val.siz);
            }
            EditorCanvas.Invalidate();
        }
コード例 #29
0
        private void ShapeSelectorHit(int index)
        {
            var shape = SymbolShapes[index];

            if (IsSelectOneOrMoreShapeMode)
            {
                if (SelectedShapes.Contains(shape))
                {
                    SelectedShapes.Remove(shape);
                }
                else
                {
                    SelectedShapes.Add(shape);
                }
            }
            else
            {
                SelectedShapes.Clear();
                SelectedShapes.Add(shape);
            }

            GrtProperty(shape);
            PickerShape = null;

            if (SelectedShapes.Count > 0)
            {
                SetShapesAreSelected();
            }
            else
            {
                SetIdleOnVoid();
            }

            PickerShape = null;
            SetSizeSliders();
            PickerCanvas.Invalidate();
            EditorCanvas.Invalidate();
        }
コード例 #30
0
ファイル: HandTool.cs プロジェクト: rajeshwarn/MochaNote
        public override bool HandleDragMove(MouseEventArgs e)
        {
            if (e.Location == _prevLocation)
            {
                return(true);
            }

            var loc   = _canvas.TranslateToControlPoint(e.Location);
            var delta = (Size)loc - (Size)_prevLocation;

            if (_canvas.CanvasBackgroundImage != null)
            {
                _canvas.Invalidate();
            }
            _canvas.AutoScrollPosition =
                new Point(
                    -_canvas.AutoScrollPosition.X - delta.Width,
                    -_canvas.AutoScrollPosition.Y - delta.Height
                    );

            _prevLocation = loc;
            return(true);
        }