예제 #1
0
        private bool OnWindowCreated(byte[] newVal)
        {
            if (ElementWdwPtr.Read <int>() == 0)
            {
                return(false);
            }

            ElementIdPtr             = SMProcess[Core.Natives.ElWind.ElementIdPtr];
            LimitChildrenCountPtr    = SMProcess[Core.Natives.Globals.LimitChildrenCountPtr];
            CurrentConceptIdPtr      = SMProcess[Core.Natives.Globals.CurrentConceptIdPtr];
            CurrentConceptGroupIdPtr = SMProcess[Core.Natives.Globals.CurrentConceptGroupIdPtr];
            CurrentRootIdPtr         = SMProcess[Core.Natives.Globals.CurrentRootIdPtr];
            CurrentHookIdPtr         = SMProcess[Core.Natives.Globals.CurrentHookIdPtr];
            LearningModePtr          = SMProcess[Core.Natives.ElWind.LearningModePtr];

            ElementIdPtr.RegisterValueChangedEventHandler <int>(OnElementChangedInternal);

            LastElementId = CurrentElementId;

            // TODO: ??? This somehow gets delayed and causes all sorts of troubles
            //OnElementChanged?.Invoke(new SMDisplayedElementChangedEventArgs(SMA.Instance,
            //                                                   CurrentElement,
            //                                                   null));

            IsAvailable = true;

            OnAvailableInternal?.Invoke();

            OnAvailable?.InvokeRemote(
                nameof(OnAvailable),
                h => OnAvailable -= h
                );

            return(true);
        }
예제 #2
0
        /// <inheritdoc />
        public void Dispose()
        {
            LogTo.Debug("Cleaning up {Name}", GetType().Name);

            _controlGroup?.Dispose();
            SMMainWdwPtr?.Dispose();
            ElementWdwPtr?.Dispose();
            ElementIdPtr?.Dispose();
            CurrentConceptIdPtr?.Dispose();
            CurrentConceptGroupIdPtr?.Dispose();
            CurrentRootIdPtr?.Dispose();
            CurrentHookIdPtr?.Dispose();
            LearningModePtr?.Dispose();

            SMMainWdwPtr             = null;
            ElementWdwPtr            = null;
            ElementIdPtr             = null;
            CurrentConceptIdPtr      = null;
            CurrentConceptGroupIdPtr = null;
            CurrentRootIdPtr         = null;
            CurrentHookIdPtr         = null;
            LearningModePtr          = null;

            LogTo.Debug("Cleaning up {Name}... Done", GetType().Name);
        }
예제 #3
0
        void IUserInteractive.OnPointerPress(IPointer cursor, uint button, InputEventModifier modifiers)
        {
            // We become focused.
            if (parent is IContainer)
            {
                (parent as IContainer).Focused = this;
            }
            else
            {
                FocusChange(true);
            }

            if (this is IContainer)
            {
                // We make sure no child is focused.
                (this as IContainer).Focused = null;
            }

            OnPointerPressInternal(cursor, button, modifiers);


            Action4 <Area, IPointer, uint, InputEventModifier> t = onMousePressed;

            if (t != null)
            {
                t(this, cursor, button, modifiers);
            }
        }
예제 #4
0
 void IUserInteractive.OnWheel(IPointer cursor, float deltaMove)
 {
     if (rootObjectInteractive != null)
     {
         rootObjectInteractive.OnWheel(cursor, deltaMove);
     }
 }
예제 #5
0
        public void Begin(IPointer pointer, Point point)
        {
            pointer.Capture(element);
            var tone = vm.NotesViewModel.PointToTone(point);

            sineGen = PlaybackManager.Inst.PlayTone(MusicMath.ToneToFreq(tone));
        }
예제 #6
0
        /// <inheritdoc />
        public override HitResult Hit(IPointer pointer, out HitData hit)
        {
            if (base.Hit(pointer, out hit) != HitResult.Hit)
            {
                return(HitResult.Miss);
            }

            if (_camera != null)
            {
                if (!_camera.pixelRect.Contains(pointer.Position))
                {
                    return(HitResult.Miss);
                }
            }

            hit = new HitData(transform, this);
            var result = checkHitFilters(pointer, hit);

            if (result != HitResult.Hit)
            {
                hit = default(HitData);
                return(result);
            }
            return(HitResult.Hit);
        }
예제 #7
0
        public override void Update(IPointer pointer, Point point)
        {
            var notesVm = vm.NotesViewModel;
            var hitInfo = notesVm.HitTest.HitTestPhoneme(point);

            if (hitInfo.hit)
            {
                var phoneme     = hitInfo.phoneme;
                var parent      = phoneme.Parent;
                var leadingNote = parent.Extends ?? parent;
                int index       = parent.PhonemeOffset + phoneme.Index;
                if (hitInfo.hitPosition)
                {
                    DocManager.Inst.ExecuteCmd(new PhonemeOffsetCommand(notesVm.Part, leadingNote, index, 0));
                }
                else if (hitInfo.hitPreutter)
                {
                    DocManager.Inst.ExecuteCmd(new PhonemePreutterCommand(notesVm.Part, leadingNote, index, 1));
                }
                else if (hitInfo.hitOverlap)
                {
                    DocManager.Inst.ExecuteCmd(new PhonemeOverlapCommand(notesVm.Part, leadingNote, index, 1));
                }
            }
        }
예제 #8
0
        protected override void OnPointerPressInternal(IPointer cursor, uint button,
                                                       SharpMedia.Input.InputEventModifier modifiers)
        {
            base.OnPointerPressInternal(cursor, button, modifiers);

            // 1) If clicked somewhere, text is deselect.
            if (!enabled)
            {
                return;
            }

            TextDeselect();

            // We only allow primary button.
            if (button != 0)
            {
                return;
            }

            if ((modifiers & InputEventModifier.DoubleClick) != 0)
            {
                // Double click starts a word selection.
                WordSelection(cursor.CanvasPosition);
            }
            else
            {
                // Pointer pressed starts drag event.
                dragController.Start(cursor);
            }
        }
예제 #9
0
        public override void End(IPointer pointer, Point point)
        {
            base.End(pointer, point);
            var notesVm = vm.NotesViewModel;

            notesVm.ShowExpValueTip = false;
        }
예제 #10
0
 public override void End(IPointer pointer, Point point)
 {
     if (note.pitch.data.Count > 2)
     {
         var  notesVm = vm.NotesViewModel;
         bool removed = false;
         if (index > 0)
         {
             var prev = note.pitch.data[index - 1];
             var size = notesVm.TickToneToSize(prev.X - pitchPoint.X, (prev.Y - pitchPoint.Y) * 0.1);
             if (size.Width * size.Width + size.Height * size.Height < 64)
             {
                 DocManager.Inst.ExecuteCmd(new DeletePitchPointCommand(notesVm.Part, note, index));
                 removed = true;
             }
         }
         if (!removed && index < note.pitch.data.Count - 1)
         {
             var next = note.pitch.data[index + 1];
             var size = notesVm.TickToneToSize(next.X - pitchPoint.X, (next.Y - pitchPoint.Y) * 0.1);
             if (size.Width * size.Width + size.Height * size.Height < 64)
             {
                 DocManager.Inst.ExecuteCmd(new DeletePitchPointCommand(notesVm.Part, note, index));
             }
         }
     }
     base.End(pointer, point);
 }
예제 #11
0
        public override void Update(IPointer pointer, Point point)
        {
            var    notesVm = vm.NotesViewModel;
            int    tick    = notesVm.PointToTick(point) - note.position;
            double deltaX  = notesVm.Project.TickToMillisecond(tick) - pitchPoint.X;
            bool   isFirst = index == 0;
            bool   isLast  = index == note.pitch.data.Count - 1;

            if (!isFirst)
            {
                deltaX = Math.Max(deltaX, note.pitch.data[index - 1].X - pitchPoint.X);
            }
            if (!isLast)
            {
                deltaX = Math.Min(deltaX, note.pitch.data[index + 1].X - pitchPoint.X);
            }
            double deltaY = 0;

            if (!(isFirst && note.pitch.snapFirst) && !isLast)
            {
                deltaY = (notesVm.PointToToneDouble(point) - note.tone) * 10 - pitchPoint.Y;
            }
            if (deltaX == 0 && deltaY == 0)
            {
                return;
            }
            DocManager.Inst.ExecuteCmd(new MovePitchPointCommand(pitchPoint, (float)deltaX, (float)deltaY));
        }
예제 #12
0
        public override void Begin(IPointer pointer, Point point)
        {
            base.Begin(pointer, point);
            var notesVm = vm.NotesViewModel;

            xOffset = point.X - notesVm.TickToneToPoint(note.position, 0).X;
        }
예제 #13
0
 void IUserInteractive.OnPointerRelease(IPointer cursor, uint button)
 {
     if (rootObjectInteractive != null)
     {
         rootObjectInteractive.OnPointerRelease(cursor, button);
     }
 }
        public virtual void Dispose()
        {
            _ignoreUserConfirmationPtr = null;

            SMProcess.Native.Exited -= OnSMExited;

            try
            {
                SMHookEngine.Instance.CleanupHooks();
            }
            catch (Exception ex)
            {
                LogTo.Error(ex,
                            "Failed to cleanup SMHookEngine");
            }

            try
            {
                SMA.SMA.Instance.OnSMStopped().Wait();
            }
            catch (Exception ex)
            {
                LogTo.Error(ex,
                            "An exception occured in one of OnSMStoppedEvent handlers");
            }
        }
예제 #15
0
        public override void Update(IPointer pointer, Point point)
        {
            var notesVm = vm.NotesViewModel;
            int x0      = notesVm.PointToSnappedTick(point);
            int x1      = notesVm.PointToSnappedTick(startPoint);
            int y0      = notesVm.PointToTone(point);
            int y1      = notesVm.PointToTone(startPoint);

            if (x0 > x1)
            {
                Swap(ref x0, ref x1);
            }
            if (y0 > y1)
            {
                Swap(ref y0, ref y1);
            }
            x1 += notesVm.SnapUnit;
            y0--;
            var leftTop = notesVm.TickToneToPoint(x0, y1);
            var Size    = notesVm.TickToneToSize(x1 - x0, y1 - y0);

            Canvas.SetLeft(selectionBox, leftTop.X);
            Canvas.SetTop(selectionBox, leftTop.Y);
            selectionBox.Width  = Size.Width + 1;
            selectionBox.Height = Size.Height;
            notesVm.TempSelectNotes(x0, x1, y0, y1);
        }
예제 #16
0
 protected override void OnPointerEnterInternal(IPointer cursor)
 {
     if (animationState.CurrentState != CommonStyleStates.Focused)
     {
         base.OnPointerEnterInternal(cursor);
     }
 }
예제 #17
0
 protected override void OnPointerLeaveInternal(IPointer cursor)
 {
     if (!animationState.IsOrTransistingTo(CommonStyleStates.Focused))
     {
         base.OnPointerLeaveInternal(cursor);
     }
 }
예제 #18
0
        protected override void OnKeyPressInternal(IPointer cursor, KeyCodes code,
                                                   KeyboardModifiers modifiers, InputEventModifier eventModifiers)
        {
            base.OnKeyPressInternal(cursor, code, modifiers, eventModifiers);

            // We are focused.
            animationState.TransistTo(CommonStyleStates.Focused);

            if (code == KeyCodes.C && (modifiers & KeyboardModifiers.LCtrl) != 0)
            {
                if (selectedRange.Y < selectedRange.X)
                {
                    return;
                }

                // We have a copy event.
                Action3 <Label, Vector2i, StringBuilder> t = onTextCopy;
                StringBuilder b = new StringBuilder(SelectedText);

                // Events may alter copy or react on it.
                if (t != null)
                {
                    t(this, selectedRange, b);
                }

                // We add copy to cursor.
                AttachedData attachedData = new AttachedData();
                attachedData.ApplicationID  = Guid.Empty; //< FIXME
                attachedData.Data           = b.ToString();
                attachedData.Representation = null;

                // We attach data.
                cursor.AttachData(attachedData);
            }
        }
예제 #19
0
        protected override void OnPointerMoveInternal(IPointer cursor, Vector2f deltaMove)
        {
            base.OnPointerMoveInternal(cursor, deltaMove);

            dragController.Update(cursor);
            UpdateDrag();
        }
예제 #20
0
        protected override void OnPointerReleaseInternal(IPointer cursor, uint button)
        {
            base.OnPointerReleaseInternal(cursor, button);

            if (button != 0 || !enabled)
            {
                return;
            }

            dragController.End(cursor);

            // No need for event if nothing dragged.
            if (selectedRange.Y < selectedRange.X)
            {
                return;
            }

            // We also fire selection event.
            Action2 <Label, Vector2i> t = onTextSelected;

            if (t != null)
            {
                t(this, this.selectedRange);
            }
        }
예제 #21
0
 public static void ReleasePointerCapture(this IInputElement element, IPointer device)
 {
     if (element == device.Captured)
     {
         device.Capture(null);
     }
 }
예제 #22
0
        public override void Begin(IPointer pointer, Point point)
        {
            base.Begin(pointer, point);
            var notesVm = vm.NotesViewModel;

            notesVm.ShowExpValueTip = true;
        }
예제 #23
0
 void IUserInteractive.OnPointerPress(IPointer cursor, uint button, InputEventModifier modifiers)
 {
     if (rootObjectInteractive != null)
     {
         rootObjectInteractive.OnPointerPress(cursor, button, modifiers);
     }
 }
예제 #24
0
 public PointerWheelEventArgs(IInteractive source, IPointer pointer, IVisual rootVisual,
                              Point rootVisualPosition,
                              PointerPointProperties properties, InputModifiers modifiers, Vector delta)
     : base(InputElement.PointerWheelChangedEvent, source, pointer, rootVisual, rootVisualPosition, properties, modifiers)
 {
     Delta = delta;
 }
예제 #25
0
        protected override void OnPointerMoveInternal(IPointer cursor, Vector2f deltaMove)
        {
            base.OnPointerMoveInternal(cursor, deltaMove);

            // We check two position to see if enter/leave event should be fired.
            IWidget child1 = InputRouting.GetChildAtPosition(this, manager, cursor.CanvasPosition - deltaMove);
            IWidget child2 = InputRouting.GetChildAtPosition(this, manager, cursor.CanvasPosition);

            // If child was not changed.
            if (child1 == child2)
            {
                if (child1 != null)
                {
                    child1.OnPointerMove(cursor, deltaMove);
                }
            }
            else
            {
                // TODO: maybe should adjust deltaMove to the move inside the child

                if (child1 != null)
                {
                    // We first fire move event.
                    child1.OnPointerMove(cursor, deltaMove);
                    child1.OnPointerLeave(cursor);
                }

                if (child2 != null)
                {
                    child2.OnPointerEnter(cursor);
                    child2.OnPointerMove(cursor, deltaMove);
                }
            }
        }
예제 #26
0
        public virtual void Dispose()
        {
            _ignoreUserConfirmationPtr = null;

            if (SMProcess?.Native != null)
            {
                SMProcess.Native.Exited -= OnSMExited;
            }

            try
            {
                Hook.CleanupHooks();
            }
            catch (Exception ex)
            {
                LogTo.Error(ex, "Failed to cleanup SMHookEngine");
            }

            try
            {
                Core.SMA.OnSMStopped();
            }
            catch (Exception ex)
            {
                LogTo.Error(ex, "An exception occurred in one of OnSMStoppedEvent handlers");
            }
        }
예제 #27
0
        /// <inheritdoc />
        protected override void updateOnce(IPointer pointer)
        {
            switch (state)
            {
            case CursorState.Released:
            case CursorState.Over:
                if (DefaultCursor != null)
                {
                    DefaultCursor.Show();
                }
                if (PressedCursor != null)
                {
                    PressedCursor.Hide();
                }
                break;

            case CursorState.Pressed:
            case CursorState.OverPressed:
                if (DefaultCursor != null)
                {
                    DefaultCursor.Hide();
                }
                if (PressedCursor != null)
                {
                    PressedCursor.Show();
                }
                break;
            }

            base.updateOnce(pointer);
        }
예제 #28
0
        /// <summary>
        /// Checks the hit filters.
        /// </summary>
        /// <param name="pointer">The pointer.</param>
        /// <param name="hit">HitData for the pointer.</param>
        /// <returns></returns>
        protected HitResult checkHitFilters(IPointer pointer, HitData hit)
        {
            hit.Target.GetComponents(tmpHitTestList);
            var count = tmpHitTestList.Count;

            if (count == 0)
            {
                return(HitResult.Hit);
            }

            var hitResult = HitResult.Hit;

            for (var i = 0; i < count; i++)
            {
                var test = tmpHitTestList[i];
                if (!test.enabled)
                {
                    continue;
                }
                hitResult = test.IsHit(pointer, hit);
                if (hitResult != HitResult.Hit)
                {
                    break;
                }
            }

            return(hitResult);
        }
예제 #29
0
        private bool OnWindowCreated(byte[] newVal)
        {
            if (ElementWdwPtr.Read <int>() == 0)
            {
                return(false);
            }

            ElementIdPtr        = SMProcess[SM17Natives.TElWind.ElementIdPtr];
            CurrentConceptIdPtr = SMProcess[SM17Natives.Globals.CurrentConceptIdPtr];
            CurrentRootIdPtr    = SMProcess[SM17Natives.Globals.CurrentRootIdPtr];
            CurrentHookIdPtr    = SMProcess[SM17Natives.Globals.CurrentHookIdPtr];

            ElementIdPtr.RegisterValueChangedEventHandler <int>(OnElementChangedInternal);

            LastElementId = CurrentElementId;

            // TODO: ??? This somehow gets delayed and causes all sorts of troubles
            //OnElementChanged?.Invoke(new SMDisplayedElementChangedArgs(SMA.Instance,
            //                                                   CurrentElement,
            //                                                   null));

            OnAvailable?.Invoke();

            return(true);
        }
예제 #30
0
        public bool Render(ICanvas canvas, IDisplayObject displayObject)
        {
            IPointer pointer  = displayObject as IPointer;
            Vector3f position = pointer.CanvasPosition;

            // A pointer style object.
            GuiPointer.GuiPointerStyle style =
                displayObject.Style.GetStyle <GuiPointer.GuiPointerStyle>(CommonStyleStates.Normal);
            if (style == null)
            {
                return(false);
            }

            // For now create dot of size in pixels.
            Metrics.GuiVector2 vector = new SharpMedia.Graphics.GUI.Metrics.GuiVector2(new Vector2f(4, 4),
                                                                                       Vector2f.Zero, Vector2f.Zero);

            Vector2f v     = vector.ToConvasSize(canvas, null);
            Rectf    shape = new Rectf(position - v, position + new Vector2f(v.X, -v.Y),
                                       position + v);

            // We now render pointer
            AreaRenderer.RenderBorderAndArea(canvas, shape, shape, style, null, 0.0f);

            return(true);
        }
예제 #31
0
 public void LoadModules(IAcquisition AcquisitionModule, IPointer PointerModule, IOutput OutputModule)
 {
     this.AcquisitionModule = AcquisitionModule;
     this.PointerModule = PointerModule;
     this.OutputType = OutputModule.GetType();
     this.Outputs = new IOutput[yRes];
     this.Ready = true;
 }
예제 #32
0
 public abstract void LoadModules(IAcquisition Acquisition, IPointer Pointer, IOutput Output);