コード例 #1
0
 void interactionManager_ButtonReleased(object sender, ButtonReleasedEventArgs e)
 {
     if (e != null)
     {
         sentButtonReleasedToRegisteredSpecifiedFunctionProxies(sender, e);
     }
 }
        protected override void im_ButtonCombinationReleased(object sender, ButtonReleasedEventArgs e)
        {
            if (sender != null && e != null)
            {
                fire_buttonCombinationReleased(e.ReleasedGenericKeys);

                // cancel button combos //

            }
        }
 protected virtual bool fireButtonCombinationReleasedEvent(ButtonReleasedEventArgs args)
 {
     bool cancel = false;
     if (ButtonCombinationReleased != null && args != null)
     {
         foreach (EventHandler<ButtonReleasedEventArgs> hndl in ButtonCombinationReleased.GetInvocationList())
         {
             try
             {
                 if (hndl != null) { hndl.DynamicInvoke(this, args); }
                 if (args.Cancel == true)
                 {
                     cancel = args.Cancel;
                     break;
                 }
             }
             catch (Exception) { }
         }
     }
     return cancel;
 }
        protected override void im_ButtonCombinationReleased(object sender, ButtonReleasedEventArgs e)
        {
            if (e != null && e.ReleasedGenericKeys != null)
            {
                BrailleIOScreen vs = GetVisibleScreen();

                #region General Commands

                switch (e.ReleasedGenericKeys.Count)
                {
                    case 1:
                        switch (e.ReleasedGenericKeys[0])
                        {
                            case "l": // abort speech output
                                AbortAudio();
                                e.Cancel = true;
                                return;

                            default:
                                break;
                        }
                        break;

                    case 3:
                        if (e.ReleasedGenericKeys.Contains("k1"))
                        {
                            // calibrate BrailleDis //
                            if (e.ReleasedGenericKeys.Intersect(new List<String> { "k1", "k3", "hbr" }).ToList().Count == 3)
                            {
                                if (io != null)
                                {
                                    this.ScreenObserver.Stop();
                                    audioRenderer.PlaySound(LL.GetTrans("tangram.lector.wm.recalibrate"));
                                    bool res = io.Recalibrate();
                                    this.ScreenObserver.Start();
                                    audioRenderer.PlaySound(LL.GetTrans("tangram.lector.wm.recalibrate.success", (res ? "" : LL.GetTrans("tangram.lector.not") + " ")));
                                }
                                Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] recalibrate the device");
                                e.Cancel = true;
                                return;
                            }
                        }
                        break;

                    case 4:
                        // follow GUI focus mode //
                        if (e.ReleasedGenericKeys.Intersect(new List<String> { "k1", "k2", "k4", "k7" }).ToList().Count == 4)
                        {
                            bool communicateSelection = false;
                            if (this.FocusMode == FollowFocusModes.FOLLOW_MOUSE_FOCUS)
                            {
                                this.FocusMode = FollowFocusModes.NONE;
                            }
                            else
                            {
                                this.FocusMode = FollowFocusModes.FOLLOW_MOUSE_FOCUS;

                                // jump to selected element
                                OoConnector ooc = OoConnector.Instance;
                                if (ooc != null && ooc.Observer != null)
                                {
                                    System.Drawing.Rectangle bb = ooc.Observer.SelectedBoundingBox;
                                    ooc.Observer.StartDrawSelectFocusHighlightingMode();
                                    if (bb.Width > 0 && bb.Height > 0) MoveToObject(bb);
                                    communicateSelection = true;
                                }
                            }
                            if (communicateSelection && OoConnector.Instance != null && OoConnector.Instance.Observer != null)
                            {
                                OoConnector.Instance.Observer.CommunicateLastSelection(false);
                            }
                            e.Cancel = true;
                            return;
                        }
                        break;
                    default:
                        break;
                }

                #endregion

                #region minimap commands
                if (vs != null && vs.Name.Equals(BS_MINIMAP_NAME))
                {
                    if (e.PressedGenericKeys == null || e.PressedGenericKeys.Count < 1)
                    {
                        if (e.ReleasedGenericKeys.Count == 1)
                        {
                            if (e.ReleasedGenericKeys[0].Equals("k2")) { } // exit minimap 
                            else if (e.ReleasedGenericKeys[0].Equals("lr")) { } // invert image
                            else
                            {
                                vs = screenBeforeMinimap; // operation has to be executed for normal screen, minimap is automatically synchronized to this
                                switch (e.ReleasedGenericKeys[0])
                                {
                                    // panning operations will be handled later
                                    case "nsll": break;
                                    case "nsl": break;
                                    case "nsr": break;
                                    case "nsrr": break;
                                    case "nsuu": break;
                                    case "nsu": break;
                                    case "nsd": break;
                                    case "nsdd": break;
                                    case "clu": break;
                                    case "cll": break;
                                    case "clr": break;
                                    case "cld": break;

                                    default: // all other operations lead to error sound
                                        audioRenderer.PlayWaveImmediately(StandardSounds.Error);
                                        e.Cancel = true;
                                        return;
                                }
                            }
                        }
                    }
                }
                #endregion

                #region global button commands

                if (e.PressedGenericKeys == null || e.PressedGenericKeys.Count < 1)
                {
                    BrailleIOViewRange center = GetActiveCenterView(vs);
                    BrailleIOViewRange detail = null;
                    if (vs != null) detail = vs.GetViewRange(VR_DETAIL_NAME);

                    if (e.ReleasedGenericKeys.Count == 1)
                    {
                        switch (e.ReleasedGenericKeys[0])
                        {
                            #region panning operations
                            case "nsll":// links blättern
                                if (vs != null && center != null)
                                    if (moveHorizontal(vs.Name, center.Name, center.ContentBox.Width))
                                    {
                                        audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.panning.left_big"));
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] big scroll left");
                                    }
                                e.Cancel = true;
                                return;
                            case "nsl":// links verschieben
                                if (vs != null && center != null)
                                    if (moveHorizontal(vs.Name, center.Name, 5))
                                    {
                                        audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.panning.left"));
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] small scroll left");
                                    }
                                e.Cancel = true;
                                return;
                            case "nsr":// rechts verschieben
                                if (vs != null && center != null)
                                    if (moveHorizontal(vs.Name, center.Name, -5))
                                    {
                                        audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.panning.right"));
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] small scroll right");
                                    }
                                e.Cancel = true;
                                return;
                            case "nsrr":// rechts blättern
                                if (vs != null && center != null)
                                    if (moveHorizontal(vs.Name, center.Name, -center.ContentBox.Width))
                                    {
                                        audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.panning.right_big"));
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] big scroll right");
                                    }
                                e.Cancel = true;
                                return;
                            case "nsuu":// hoch blättern
                                if (vs != null && center != null)
                                    if (moveVertical(vs.Name, center.Name, center.ContentBox.Height))
                                    {
                                        audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.panning.up_big"));
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] big scroll up");
                                    }
                                e.Cancel = true;
                                return;
                            case "nsu":// hoch verschieben
                                if (vs != null && center != null)
                                    if (moveVertical(vs.Name, center.Name, 5))
                                    {
                                        audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.panning.up"));
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] small scroll up");
                                    }
                                e.Cancel = true;
                                return;
                            case "nsd":// runter verschieben
                                if (vs != null && center != null)
                                    if (moveVertical(vs.Name, center.Name, -5))
                                    {
                                        audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.panning.down"));
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] small scroll down");
                                    }
                                e.Cancel = true;
                                return;
                            case "nsdd":// runter blättern
                                if (vs != null && center != null)
                                    if (moveVertical(vs.Name, center.Name, -center.ContentBox.Height))
                                    {
                                        audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.panning.down_big"));
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] big scroll down");
                                    }
                                e.Cancel = true;
                                return;
                            case "clu":// Sprung nach oben
                                jumpToTopBorder(center);
                                e.Cancel = true;
                                return;
                            case "cll":// Sprung nach links
                                jumpToLeftBorder(center);
                                e.Cancel = true;
                                return;
                            case "clr":// Sprung nach rechts
                                jumpToRightBorder(center);
                                e.Cancel = true;
                                return;
                            case "cld":// Sprung nach unten
                                jumpToBottomBorder(center);
                                e.Cancel = true;
                                return;

                            #endregion

                            #region zooming operations
                            case "rslu": // kleiner Zoom in
                                if (vs != null && center != null)
                                {
                                    if (zoomWithFactor(vs.Name, center.Name, 1.5))
                                    {
                                        audioRenderer.PlaySoundImmediately(
                                            LL.GetTrans("tangram.lector.wm.zooming.in",
                                            GetZoomPercentageBasedOnPrintZoom(vs.Name, center.Name)));
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] small zoom in");
                                    }
                                    else audioRenderer.PlayWaveImmediately(StandardSounds.End);
                                }
                                e.Cancel = true;
                                return;
                            case "rsld": // kleiner Zoom out
                                if (vs != null && center != null)
                                {
                                    if (zoomWithFactor(vs.Name, center.Name, 1 / 1.5))
                                    {
                                        audioRenderer.PlaySoundImmediately(
                                            LL.GetTrans("tangram.lector.wm.zooming.out",
                                            GetZoomPercentageBasedOnPrintZoom(vs.Name, center.Name)));
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] small zoom out");
                                    }
                                    else audioRenderer.PlayWaveImmediately(StandardSounds.End);
                                }
                                e.Cancel = true;
                                return;
                            case "rsru": // großer Zoom in
                                if (vs != null && center != null)
                                {
                                    if (zoomWithFactor(vs.Name, center.Name, 3))
                                    {
                                        audioRenderer.PlaySoundImmediately(
                                            LL.GetTrans("tangram.lector.wm.zooming.in_big",
                                            GetZoomPercentageBasedOnPrintZoom(vs.Name, center.Name)));
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] big zoom in");
                                    }
                                    else audioRenderer.PlayWaveImmediately(StandardSounds.End);
                                }
                                e.Cancel = true;
                                return;
                            case "rsrd": // großer Zoom out
                                if (vs != null && center != null)
                                {
                                    if (zoomWithFactor(vs.Name, center.Name, (double)1 / 3))
                                    {
                                        audioRenderer.PlaySoundImmediately(
                                            LL.GetTrans("tangram.lector.wm.zooming.out_big",
                                            GetZoomPercentageBasedOnPrintZoom(vs.Name, center.Name)));
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] big zoom out");
                                    }
                                    else audioRenderer.PlayWaveImmediately(StandardSounds.End);
                                }
                                e.Cancel = true;
                                return;
                            #endregion

                            #region detail area scrolling

                            case "cru": // scroll detail region up
                                if (detail != null)
                                {
                                    if (scrollViewRange(detail, 5))
                                    {
                                        e.Cancel = true;
                                        break;
                                    }
                                }
                                AudioRenderer.Instance.PlayWaveImmediately(StandardSounds.Error);
                                break;

                            case "crl": // no function yet
                                AudioRenderer.Instance.PlayWaveImmediately(StandardSounds.Error);
                                break;

                            case "crr": // no function yet
                                AudioRenderer.Instance.PlayWaveImmediately(StandardSounds.Error);
                                break;

                            case "crd": // scroll detail region down
                                if (detail != null)
                                {
                                    if (scrollViewRange(detail, -5))
                                    {
                                        e.Cancel = true;
                                        break;
                                    }
                                }
                                AudioRenderer.Instance.PlayWaveImmediately(StandardSounds.Error);
                                break;

                            #endregion

                            default:
                                break;
                        }
                    }

                    else if (e.ReleasedGenericKeys.Count == 2) // TODO: maybe bring this in one
                    {
                        #region panning operations
                        if (e.ReleasedGenericKeys.Intersect(new List<String> { "nsdd", "nsd" }).ToList().Count == 2)
                        {
                            if (vs != null && center != null)
                                if (moveVertical(vs.Name, center.Name, -center.ContentBox.Height))
                                {
                                    audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.panning.down_big"));
                                    Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] big scroll down");
                                }
                        }
                        else if (e.ReleasedGenericKeys.Intersect(new List<String> { "nsuu", "nsu" }).ToList().Count == 2)
                        {
                            if (vs != null && center != null)
                                if (moveVertical(vs.Name, center.Name, center.ContentBox.Height))
                                {
                                    audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.panning.up_big"));
                                    Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] big scroll up");
                                }
                        }
                        else if (e.ReleasedGenericKeys.Intersect(new List<String> { "nsll", "nsl" }).ToList().Count == 2)
                        {
                            if (vs != null && center != null)
                                if (moveHorizontal(vs.Name, center.Name, center.ContentBox.Width))
                                {
                                    audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.panning.left_big"));
                                    Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] big scroll left");
                                }
                        }
                        else if (e.ReleasedGenericKeys.Intersect(new List<String> { "nsrr", "nsr" }).ToList().Count == 2)
                        {
                            if (vs != null && center != null)
                                if (moveHorizontal(vs.Name, center.Name, -center.ContentBox.Width))
                                {
                                    audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.panning.right_big"));
                                    Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] big scroll right");
                                }
                        }
                        #endregion
                    }

                    else if (e.ReleasedGenericKeys.Count == 8)
                    {
                        // Ansichtswechsel
                        if (e.ReleasedGenericKeys.Intersect(new List<String> { "k1", "k2", "k3", "k4", "k5", "k6", "k7", "k8" }).ToList().Count == 8)
                        {
                            string message = "";
                            if (currentView.Equals(LectorView.Braille))
                            {
                                if (ChangeLectorView(LectorView.Drawing))
                                {
                                    changeActiveCenterView(vs, VR_CENTER_NAME);
                                    message = LL.GetTrans("tangram.lector.wm.views.draw_activated");
                                }
                            }
                            else if (currentView.Equals(LectorView.Drawing))
                            {
                                if (ChangeLectorView(LectorView.Braille))
                                {
                                    changeActiveCenterView(vs, VR_CENTER_2_NAME);
                                    message = LL.GetTrans("tangram.lector.wm.views.braille_activated");
                                }
                            }
                            audioRenderer.PlaySoundImmediately(message);
                            ShowTemporaryMessageInDetailRegion(message);
                            fillMainCenterContent();
                            Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] " + message);
                            e.Cancel = true;
                            return;
                        }
                    }
                }
                #endregion

                #region Drawing mode button commands

                // button commands that are not working in Braille mode
                if (!InteractionManager.Mode.Equals(InteractionMode.Braille))
                {
                    if (e.PressedGenericKeys == null || e.PressedGenericKeys.Count < 1)
                    {
                        #region 1 key

                        if (e.ReleasedGenericKeys.Count == 1)
                        {
                            switch (e.ReleasedGenericKeys[0])
                            {
                                case "k1": // Druck-Zoom

                                    if (vs != null && !vs.Name.Equals(BS_MINIMAP_NAME))
                                    {
                                        if (ZoomTo(vs.Name, VR_CENTER_NAME, GetPrintZoomLevel()))
                                        {
                                            audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.zooming.to_print"));
                                            Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] print zoom");
                                        }
                                        else audioRenderer.PlayWaveImmediately(StandardSounds.End);
                                    }
                                    e.Cancel = true;
                                    return;

                                case "k2": // Minimap
                                    toggleMinimap();
                                    BrailleIOScreen nvs = GetVisibleScreen();
                                    if (nvs != null && nvs.Name.Equals(BS_MINIMAP_NAME))
                                    {
                                        audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.views.minimap.show"));
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] start minimap");
                                    }
                                    else if (nvs != null)
                                    {
                                        audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.views.minimap.hide"));
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] stop minimap");
                                    }
                                    e.Cancel = true;
                                    return;

                                case "k3": // Breite/Höhe einpassen
                                    if (vs != null && !vs.Name.Equals(BS_MINIMAP_NAME))
                                    {
                                        if (ZoomTo(vs.Name, VR_CENTER_NAME, -1))
                                        {
                                            audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.zooming.fit_height"));
                                            Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] zoom fit to height");
                                        }
                                        else audioRenderer.PlayWaveImmediately(StandardSounds.End);
                                    }
                                    e.Cancel = true;
                                    return;

                                case "k7": // 1-zu-1 Zoom
                                    if (vs != null && !vs.Name.Equals(BS_MINIMAP_NAME))
                                    {
                                        if (ZoomTo(vs.Name, VR_CENTER_NAME, 1))
                                        {
                                            audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.zooming.1-1"));
                                            Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] zoom 1:1");
                                        }
                                        else audioRenderer.PlayWaveImmediately(StandardSounds.End);
                                    }
                                    e.Cancel = true;
                                    return;

                                case "lr": // Invertieren
                                    if (vs != null)
                                    {
                                        invertImage(vs.Name, VR_CENTER_NAME);
                                        BrailleIOViewRange vr = vs.GetViewRange(VR_CENTER_NAME);
                                        if (vr != null && !vr.InvertImage)
                                        {
                                            audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.views.non_invert"));
                                            Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] not invert output");
                                        }
                                        else
                                        {
                                            audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.views.invert"));
                                            Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] invert output");
                                        }
                                    }
                                    e.Cancel = true;
                                    return;

                                case "rl": // Schwellwert minus
                                    if (vs != null)
                                    {
                                        if (updateContrast(vs.Name, VR_CENTER_NAME, -THRESHOLD_STEP))
                                        {
                                            audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.views.threshold_down"));
                                            Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] reduce threshold");
                                        }
                                        else
                                        {
                                            audioRenderer.PlayWaveImmediately(StandardSounds.End);
                                            Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] already mininum threshold");
                                        }
                                    }
                                    e.Cancel = true;
                                    return;

                                case "r": // Schwellwert plus
                                    if (vs != null)
                                    {
                                        if (updateContrast(vs.Name, VR_CENTER_NAME, THRESHOLD_STEP))
                                        {
                                            audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.views.threshold_up"));
                                            Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] increase threshold");
                                        }
                                        else
                                        {
                                            audioRenderer.PlayWaveImmediately(StandardSounds.End);
                                            Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] already maximum threshold");
                                        }
                                    }
                                    e.Cancel = true;
                                    return;

                                default:
                                    break;
                            }
                        }
                        #endregion

                        #region 2 keys

                        else if (e.ReleasedGenericKeys.Count == 2)
                        {
                            // Standard-Schwellwert
                            if (e.ReleasedGenericKeys.Intersect(new List<String> { "rl", "r" }).ToList().Count == 2)
                            {
                                if (vs != null)
                                {
                                    setContrast(vs.Name, VR_CENTER_NAME, STANDARD_CONTRAST_THRESHOLD);
                                    audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.views.threshold_reset"));
                                    Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] reset threshold");
                                }
                            }
                        }

                        #endregion 

                        #region 3 keys

                        else if (e.ReleasedGenericKeys.Count == 3)
                        {
                            // Kopfbereich ein/aus
                            if (e.ReleasedGenericKeys.Intersect(new List<String> { "k1", "k3", "k8" }).ToList().Count == 3)
                            {
                                if (vs != null && vs.GetViewRange(VR_TOP_NAME) != null)
                                {
                                    if (vs.GetViewRange(VR_TOP_NAME).IsVisible())
                                    {
                                        if (changeViewVisibility(vs.Name, VR_TOP_NAME, false))
                                        {
                                            changeViewVisibility(vs.Name, VR_STATUS_NAME, false);
                                            audioRenderer.PlaySoundImmediately(
                                                LL.GetTrans("tangram.lector.wm.views.region.hide",
                                                LL.GetTrans("tangram.lector.wm.views.region.VR_TOP_NAME")
                                                ));
                                            Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] hide top region");
                                        }
                                    }
                                    else if (changeViewVisibility(vs.Name, VR_TOP_NAME, true))
                                    {
                                        changeViewVisibility(vs.Name, VR_STATUS_NAME, true);
                                        audioRenderer.PlaySoundImmediately(
                                            LL.GetTrans("tangram.lector.wm.views.region.show",
                                                LL.GetTrans("tangram.lector.wm.views.region.VR_TOP_NAME")
                                                ));
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] show top region");
                                    }
                                }
                                else if (vs != null && vs.Name.Equals(BS_FULLSCREEN_NAME))
                                {
                                    // exit fullscreen mode and show top region
                                    toggleFullscreen();
                                    BrailleIOScreen nvs = GetVisibleScreen();
                                    if (nvs != null)
                                    {
                                        BrailleIOViewRange top = nvs.GetViewRange(VR_TOP_NAME);
                                        if (top != null && !top.IsVisible())
                                        {
                                            changeViewVisibility(nvs.Name, VR_TOP_NAME, true);
                                        }
                                        audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.views.full_screen_exit"));
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] exit full screen");
                                    }
                                }
                                e.Cancel = true;
                                return;
                            }
                        }

                        #endregion

                        #region 4 keys
                        else if (e.ReleasedGenericKeys.Count == 4)
                        {
                            // Detailbereich ein/aus
                            if (e.ReleasedGenericKeys.Intersect(new List<String> { "k1", "k4", "k5", "k8" }).ToList().Count == 4)
                            {
                                if (vs != null && vs.GetViewRange(VR_DETAIL_NAME) != null)
                                {
                                    if (vs.GetViewRange(VR_DETAIL_NAME).IsVisible())
                                    {
                                        if (changeViewVisibility(vs.Name, VR_DETAIL_NAME, false))
                                        {
                                            audioRenderer.PlaySoundImmediately(
                                                LL.GetTrans("tangram.lector.wm.views.region.hide",
                                                LL.GetTrans("tangram.lector.wm.views.region.VR_DETAIL_NAME")
                                                ));
                                            Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] hide detail region");
                                        }
                                    }
                                    else if (changeViewVisibility(vs.Name, VR_DETAIL_NAME, true))
                                    {
                                        audioRenderer.PlaySoundImmediately(
                                            LL.GetTrans("tangram.lector.wm.views.region.show",
                                                LL.GetTrans("tangram.lector.wm.views.region.VR_DETAIL_NAME")
                                                ));
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] show detail region");
                                    }
                                }

                                else if (vs != null && vs.Name.Equals(BS_FULLSCREEN_NAME))
                                {
                                    // exit fullscreen mode and show detail region
                                    toggleFullscreen();
                                    BrailleIOScreen nvs = GetVisibleScreen();
                                    if (nvs != null)
                                    {
                                        BrailleIOViewRange detail = nvs.GetViewRange(VR_DETAIL_NAME);
                                        if (detail != null && !detail.IsVisible())
                                        {
                                            changeViewVisibility(nvs.Name, VR_DETAIL_NAME, true);
                                        }
                                        audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.views.full_screen_exit"));
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] exit full screen");
                                    }
                                }
                                e.Cancel = true;
                                return;
                            }
                        }

                        #endregion 

                        #region 5 keys

                        else if (e.ReleasedGenericKeys.Count == 5)
                        {
                            // Vollbildmodus
                            if (e.ReleasedGenericKeys.Intersect(new List<String> { "k1", "k3", "k4", "k6", "k8" }).ToList().Count == 5)
                            {
                                toggleFullscreen();
                                BrailleIOScreen nvs = GetVisibleScreen();
                                if (nvs != null && nvs.Name.Equals(BS_FULLSCREEN_NAME))
                                {
                                    audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.views.full_screen_start"));
                                    Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] start full screen");
                                }
                                else if (nvs != null)
                                {
                                    audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.views.full_screen_exit"));
                                    Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] exit full screen");
                                }
                                e.Cancel = true;
                                return;
                            }
                        }
                        #endregion 

                        #region 6 keys

                        else if (e.ReleasedGenericKeys.Count == 6)
                        {
                            // Zoomstufe abfragen
                            if (e.ReleasedGenericKeys.Intersect(new List<String> { "k1", "k3", "k5", "k6", "k7", "k8" }).ToList().Count == 6)
                            {
                                if (vs != null)
                                {
                                    BrailleIOViewRange vr = vs.GetViewRange(VR_CENTER_NAME);
                                    if (vr != null)
                                    {
                                        double zl = GetZoomPercentageBasedOnPrintZoom(vs.Name, vr.Name);
                                        string message = LL.GetTrans("tangram.lector.wm.zooming.current", zl.ToString());

                                        audioRenderer.PlaySoundImmediately(message);
                                        ShowTemporaryMessageInDetailRegion(message);
                                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] ask for current zoom level");
                                    }
                                }
                                e.Cancel = true;
                                return;
                            }
                        }
                        #endregion 
                    }
                }
                #endregion

                #region Braille input mode commands
                // button commands that only work in Braille writing mode
                if (InteractionManager.Mode.Equals(InteractionMode.Braille))
                {
                    if (e.PressedGenericKeys == null || e.PressedGenericKeys.Count < 1)
                    {
                        if (e.ReleasedGenericKeys.Count == 1)
                        {
                            switch (e.ReleasedGenericKeys[0])
                            {
                                case "r": // maximize detail area
                                    //toggleFullDetailScreen();
                                    audioRenderer.PlayWaveImmediately(StandardSounds.Error);
                                    e.Cancel = true;
                                    return;
                            }
                        }
                    }
                }
                #endregion
            }
        }
        internal bool fireButtonCombinationReleasedEvent(Object sender, ButtonReleasedEventArgs args)
        {
            bool cancel = false;
            if (ButtonCombinationReleased != null && args != null)
            {
                foreach (EventHandler<ButtonReleasedEventArgs> hndl in ButtonCombinationReleased.GetInvocationList())
                {
                    if (cancel) return cancel;

                    if (hndl != null && hndl.Target is IInteractionContextProxy)
                    {
                        if (!((IInteractionContextProxy)hndl.Target).Active) {
                            continue;
                        }
                    }

                    try
                    {
                        if (hndl != null) { hndl.Invoke(sender, args); }
                        if (args.Cancel == true)
                        {
                            cancel = args.Cancel;
                            break;
                        }
                    }
                    catch (Exception) { }
                }
            }
            return cancel;
        }
 private void sentButtonReleasedToRegisteredSpecifiedFunctionProxies(object sender, ButtonReleasedEventArgs e)
 {
     if (eventForwarder != null) { eventForwarder.fireButtonReleasedEvent(sender, e); }
 }
コード例 #7
0
        void interactionManager_ButtonCombinationReleased(object sender, ButtonReleasedEventArgs e)
        {
            if (e != null && e.ReleasedGenericKeys != null && e.ReleasedGenericKeys.Count > 0 && (e.PressedGenericKeys == null || e.PressedGenericKeys.Count < 1))
            {
                if (interactionManager.Mode == InteractionMode.Braille)
                {
                    interpretBrailleKeyboardCommand(e.ReleasedGenericKeys);
                }

                sentButtonCombinationReleasedToRegisteredSpecifiedFunctionProxies(sender, ref e);
            }
        }
 void interactionManager_ButtonReleased(object sender, ButtonReleasedEventArgs e)
 {
     if (monitor != null) monitor.MarkButtonAsPressed(e.PressedGenericKeys);
     if (monitor != null) monitor.UnmarkButtons(e.ReleasedGenericKeys);
 }
コード例 #9
0
 protected bool fireButtonCombinationReleasedEvent(BrailleIO.BrailleIODevice device, List<BrailleIO_DeviceButton> pressedGeneralKeys, List<String> pressedGenericKeys, List<BrailleIO_DeviceButton> releasedGeneralKeys, List<String> releasedGenericKeys)
 {
     var args = new ButtonReleasedEventArgs(device, pressedGeneralKeys, pressedGenericKeys, releasedGeneralKeys, releasedGenericKeys);
     Logger.Instance.Log(LogPriority.OFTEN, this, "Button combination released: " + String.Join(",", args.ReleasedGenericKeys) + " pressed: " + String.Join(",", args.PressedGenericKeys));
     bool cancel = base.fireButtonCombinationReleasedEvent(args);
     if (cancel) { System.Diagnostics.Debug.WriteLine("InteractionManager Event canceled"); }
     return cancel;
 }
コード例 #10
0
 void InteractionManager_ButtonReleased(object sender, ButtonReleasedEventArgs e)
 {
     if (e != null)
     {
         checkForKeyCombination(e.Device, e.PressedGeneralKeys, e.PressedGenericKeys, e.ReleasedGeneralKeys, e.ReleasedGenericKeys);
     }
 }
コード例 #11
0
        protected override void im_ButtonCombinationReleased(object sender, ButtonReleasedEventArgs e)
        {
            if ((e.ReleasedGenericKeys.Count == 1 && e.ReleasedGenericKeys[0] == "crc") ||
                (e.ReleasedGenericKeys.Count == 2 && e.ReleasedGenericKeys.Contains("crc") &&
                    (e.ReleasedGenericKeys.Contains("cru") || e.ReleasedGenericKeys.Contains("crl") || e.ReleasedGenericKeys.Contains("crr") || e.ReleasedGenericKeys.Contains("crd"))))
            {
                switch (saveMenu)
                {
                    case SaveDialog.NonActive:
                        //first call make save dialog visible
                        //saveDialog = SaveDialog.Active;
                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[SHAPE EDIT DIALOG] open save dialog");
                        saveMenu = SaveDialog.Save;
                        showMenuDetailView();
                        UnderLiningHook.selectedString = LL.GetTrans("tangram.lector.image_data.save");
                        SaveBrailleInput(activeProperty, removeInputStr(activeProperty, Property.None));
                        audioRenderer.PlaySoundImmediately(
                            LL.GetTrans("tangram.lector.image_data.save_dialog.opend")
                            + " " + LL.GetTrans("tangram.lector.image_data.save_dialog.entry_selected"
                            , LL.GetTrans("tangram.lector.image_data.save")));
                        break;
                    case SaveDialog.Abort:
                        //close save dialog
                        saveMenu = SaveDialog.NonActive;
                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[SHAPE EDIT DIALOG] save menu aborted");

                        detailViewDic[TITLE_DESC_SAVE_VIEW_NAME].SetVisibility(false);
                        ShowImageDetailView(TITLE_DESC_VIEW_NAME, 15, 0, activeProperty);
                        break;
                    case SaveDialog.NotSave:
                        // quit dialog without saving changes
                        CloseImageDialog(false);
                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[SHAPE EDIT DIALOG] changes were not saved, dialog closed");
                        break;
                    case SaveDialog.Save:
                        // quit dialog and save changes
                        CloseImageDialog(true);
                        Logger.Instance.Log(LogPriority.MIDDLE, this, "[SHAPE EDIT DIALOG] changes were saved, dialog closed");
                        break;
                }
                e.Cancel = true;
            }

            // bei Verlassen des Dialoges
            else if (e.ReleasedGenericKeys.Count == 1 && e.PressedGenericKeys.Count == 0)
            {
                switch (e.ReleasedGenericKeys[0])
                {
                    // scrolling through save, not saving and abort
                    case "crr":
                        //right scrolling through saveCommand
                        if (saveMenu != SaveDialog.NonActive)
                        {
                            rotateThroughSaveDialog(1);
                        }
                        else // editing mode --> move caret to right
                        {
                            bki.MoveCaret(1);
                            Logger.Instance.Log(LogPriority.MIDDLE, this, "[SHAPE EDIT DIALOG] move caret to right");
                        }
                        e.Cancel = true;
                        break;
                    case "crl":
                        if (saveMenu != SaveDialog.NonActive)
                        {
                            rotateThroughSaveDialog(-1);
                        }
                        else // editing mode --> move caret to left
                        {
                            bki.MoveCaret(-1);
                            Logger.Instance.Log(LogPriority.MIDDLE, this, "[SHAPE EDIT DIALOG] move caret to left");
                        }
                        e.Cancel = true;
                        break;
                    case "cru":
                        rotateThroughProperties();
                        e.Cancel = true;
                        break;
                    case "crd":
                        rotateThroughProperties();
                        e.Cancel = true;
                        break;
                    default:
                        break;
                }
            }
        }
コード例 #12
0
 internal void fire_ButtonCombinationReleased(object sender, ButtonReleasedEventArgs e)
 {
     this.im_ButtonCombinationReleased(sender, e);
 }