Пример #1
0
 /* Analog event handler */
 private void ButtonChanged(ButtonEvent e)
 {
     forward = button.GetButtonState((int)(object)forwardKey);
     backward = button.GetButtonState((int)(object)backwardKey);
     left = button.GetButtonState((int)(object)leftKey);
     right = button.GetButtonState((int)(object)rightKey);
 }
Пример #2
0
 /* Button event handler */
 private void ButtonChanged(ButtonEvent e)
 {
     for (int i = 0; i < buttonValues.Capacity; i++)
     {
         if (i < button.GetNumButtons())
             buttonValues[i] = button.GetButtonState(i);
     }
 }
Пример #3
0
        public Button(Rectangle rectangle, string text, ButtonEvent onClickFunction, Color color)
        {
            this.Visible = true;
            this.Enabled = true;
            this.rect = rectangle;
            this.Position = new Vector2(rect.X, rect.Y);
            this.text = text;
            this.bColor = color;

            this.ClickFunction += onClickFunction;
            Component.Components.Add(this);
            data.EventHandler.onMouseLeftClick += onComponentClick;
            //data.Player.addEventListener(this);
        }
Пример #4
0
 public static void ButtonHandler(Button bStart, Button bStop, Button bRestart, ButtonEvent Event)
 {
     switch ((ButtonEvent)Event)
     {
         case ButtonEvent.Online:
             bStart.Enabled = false;
             bStop.Enabled = true;
             bRestart.Enabled = true;
             break;
         case ButtonEvent.Offline:
             bStart.Enabled = true;
             bStop.Enabled = false;
             bRestart.Enabled = false;
             break;
     }
 }
Пример #5
0
        //Can't pass ExecuteEvents as parameter? Unity gives error
        //Turns and Angle and Event type into a button action
        private void InteractButton(float angle, ButtonEvent evt)
        {
            //Get button ID from angle
            float buttonAngle = 360f / buttons.Count; //Each button is an arc with this angle
            angle = mod((angle + offsetRotation), 360); //Offset the touch coordinate with our offset

            int buttonID = (int)mod(((angle + (buttonAngle / 2f)) / buttonAngle), buttons.Count); //Convert angle into ButtonID (This is the magic)
            var pointer = new PointerEventData(EventSystem.current); //Create a new EventSystem (UI) Event

            //If we changed buttons while moving, un-hover and un-click the last button we were on
            if (currentHover != buttonID && currentHover != -1)
            {
                ExecuteEvents.Execute(menuButtons[currentHover], pointer, ExecuteEvents.pointerUpHandler);
                ExecuteEvents.Execute(menuButtons[currentHover], pointer, ExecuteEvents.pointerExitHandler);
                buttons[currentHover].OnHoverExit.Invoke();
                if (executeOnUnclick && currentPress != -1)
                {
                    ExecuteEvents.Execute(menuButtons[buttonID], pointer, ExecuteEvents.pointerDownHandler);
                    AttempHapticPulse((ushort)(baseHapticStrength * 1.666f));
                }
            }
            if (evt == ButtonEvent.click) //Click button if click, and keep track of current press (executes button action)
            {
                ExecuteEvents.Execute(menuButtons[buttonID], pointer, ExecuteEvents.pointerDownHandler);
                currentPress = buttonID;
                if (!executeOnUnclick)
                {
                    buttons[buttonID].OnClick.Invoke();
                    AttempHapticPulse((ushort)(baseHapticStrength * 2.5f));
                }
            }
            else if (evt == ButtonEvent.unclick) //Clear press id to stop invoking OnHold method (hide menu)
            {
                ExecuteEvents.Execute(menuButtons[buttonID], pointer, ExecuteEvents.pointerUpHandler);
                currentPress = -1;

                if (executeOnUnclick)
                {
                    AttempHapticPulse((ushort)(baseHapticStrength * 2.5f));
                    buttons[buttonID].OnClick.Invoke();
                }
            }
            else if (evt == ButtonEvent.hoverOn && currentHover != buttonID) // Show hover UI event (darken button etc). Show menu
            {
                ExecuteEvents.Execute(menuButtons[buttonID], pointer, ExecuteEvents.pointerEnterHandler);
                buttons[buttonID].OnHoverEnter.Invoke();
                AttempHapticPulse(baseHapticStrength);
            }
            currentHover = buttonID; //Set current hover ID, need this to un-hover if selected button changes
        }
Пример #6
0
 /// <summary>
 /// Erstellt einen neuen Button
 /// </summary>
 /// <param name="X">Horizontaler Abstand zum linken Rand</param>
 /// <param name="Y">Vertikaler Abstand zum oberen Rand</param>
 /// <param name="Text">Text welcher auf dem Button stehen soll</param>
 /// <param name="Command">Kommando welches ausgeführt werden soll wenn der Button mit Enter bestätigt wird</param>
 public Button(int X, int Y, string Text, ButtonEvent Command) : base(X, Y, Text)
 {
     mCommand = Command;
 }
Пример #7
0
 /// <summary>
 /// Triggered when the user releases a keyboard button.
 /// </summary>
 /// <param name="ev">Information about the keyboard release event.</param>
 private void OnButtonUp(ButtonEvent ev)
 {
     editor.OnButtonUp(ev);
 }
Пример #8
0
        private void propertiesToolbar_ButtonClicked(object sender, ButtonEvent be)
        {
            switch (be.Button.Key)
            {
                #region case "CRT":
            case "CRT":
                if (CurrentResource != null && CurrentResource.Type.Name == "Template")
                {
                    Response.Redirect(CurrentResource.URI + "?CRT=1");
//            HyperCatalog.Business.DAM.Specific.HOTTemplate template = new HyperCatalog.Business.DAM.Specific.HOTTemplate(currentResource.MasterVariant.CurrentFile);
//            HyperComponents.IO.Streaming.SendStream(Response,template.CRTStream,currentResource.Name + ".pdf");
                    Response.End();
                }
                break;

                #endregion
                #region case "Del":
            case "Del":
                if (SessionState.User.HasCapability(Business.CapabilitiesEnum.MANAGE_RESOURCES) && CurrentResource != null)
                {
                    if (SessionState.User.IsReadOnly || CurrentResource.Delete())
                    {
                        SetMessage(propertiesMsgLbl, "Resource \"" + CurrentResource.Name + "\" deleted", MessageLevel.Information);
                        libraryList.SelectedItem.Text = String.Format(libraryListPattern, CurrentLibrary.Name, CurrentLibrary.ResourceCount);
                        _currentResourceId            = -1;
                        BindLibrary();
                    }
                    else
                    {
                        SetMessage(propertiesMsgLbl, "Resource \"" + CurrentResource.Name + "\" could not be deleted", MessageLevel.Error);
                    }
                }
                break;

                #endregion
                #region case "Save":
            case "Save":
                if (txtFileBinaryValue.PostedFile.ContentLength > 0)
                {
                    SetMessage(propertiesMsgLbl, "You must provide a file", MessageLevel.Warning);
                    return;
                }
                if (SessionState.User.HasCapability(Business.CapabilitiesEnum.MANAGE_RESOURCES))
                {
                    if (SessionState.User.IsReadOnly)
                    {
                        return;
                    }

                    if (resourceTypesAttributes.Items.Count > txtResourceTypeValue.SelectedIndex)
                    {
                        if (txtResourceNameValue.Text == null || txtResourceNameValue.Text.Length == 0)
                        {
                            SetMessage(propertiesMsgLbl, "Resource must have a name", MessageLevel.Error);
                            break;
                        }
                        string[][] attrs = getAttributeValues(resourceTypesAttributes.Items[txtResourceTypeValue.SelectedIndex]);

                        if (CurrentResource != null)
                        {
                            CurrentResource.Name        = txtResourceNameValue.Text;
                            CurrentResource.Description = txtResourceDescriptionValue.Value;
                            if (CurrentResource.Save())
                            {
                                SetMessage(propertiesMsgLbl, "Resource \"" + txtResourceNameValue.Text + "\" updated", MessageLevel.Information);

                                if (addVariant)
                                {
                                    bool   success  = false;
                                    string errorMsg = "Variant for \"" + txtResourceNameValue.Text + "\" could not be created";
                                    try
                                    {
                                        success = CurrentResource.AddVariant(txtVariantCultureValue.SelectedValue, txtFileBinaryValue.PostedFile.InputStream, Path.GetExtension(txtFileBinaryValue.PostedFile.FileName), attrs) != null;
                                    }
                                    catch (AlreadyExistingVariantException)
                                    {
                                        errorMsg += ": this variant already exists.";
                                    }

                                    if (success)
                                    {
                                        SetMessage(propertiesMsgLbl, "Variant for \"" + txtResourceNameValue.Text + "\" created", MessageLevel.Information);
                                    }
                                    else
                                    {
                                        SetMessage(propertiesMsgLbl, errorMsg, MessageLevel.Error);
                                    }
                                }

                                BindLibrary();
                            }
                            else
                            {
                                SetMessage(propertiesMsgLbl, "Resource \"" + txtResourceNameValue.Text + "\" could not be updated", MessageLevel.Error);
                            }
                        }
                        else
                        {
                            HyperCatalog.Business.DAM.Resource newResource = CurrentLibrary.AddResource(txtResourceNameValue.Text + Path.GetExtension(txtFileBinaryValue.PostedFile.FileName), txtResourceDescriptionValue.Value, Convert.ToInt32(txtResourceTypeValue.SelectedValue), txtVariantCultureValue.SelectedValue, txtFileBinaryValue.PostedFile.InputStream, attrs);
                            if (newResource != null)
                            {
                                SetMessage(propertiesMsgLbl, "Resource \"" + txtResourceNameValue.Text + "\" created", MessageLevel.Information);
                                libraryList.SelectedItem.Text = String.Format(libraryListPattern, CurrentLibrary.Name, CurrentLibrary.ResourceCount);
                                _currentResourceId            = newResource.Id;
                                BindLibrary();
                            }
                            else
                            {
                                SetMessage(propertiesMsgLbl, "Resource \"" + txtResourceNameValue.Text + "\" could not be created", MessageLevel.Error);
                            }
                        }
                    }
                }
                break;
                #endregion
            }
        }
Пример #9
0
 public KeyBinding(string alias, Keys k, ButtonEvent kevent)
     : this(alias, k, KeyModifier.None, kevent, null)
 {
 }
Пример #10
0
 protected ButtonBinding(string alias, ButtonEvent bEvent, ButtonBindingDelegate bDel)
     : this(alias, bEvent)
 {
     Callback = bDel;
 }
Пример #11
0
 private void ButtonScriptOn()
 {
     buttonEvent           = targetTr.GetComponent <ButtonEvent>();
     buttonEvent.isTrigger = true;
 }
Пример #12
0
 public GamePadButtonBinding(string alias, Buttons b, ButtonEvent kevent, ButtonBindingDelegate kdel)
     : base(alias, kevent, kdel)
 {
     Button   = b;
     Callback = kdel;
 }
Пример #13
0
 protected ButtonBinding(string alias, ButtonEvent bEvent)
     : base(alias)
 {
     ButtonEvent = bEvent;
 }
Пример #14
0
 public GamePadButtonBinding(string alias, Buttons b, ButtonEvent kevent)
     : this(alias, b, kevent, null)
 {
 }
Пример #15
0
 public ServicesAndCatalog(ButtonEvent buttonEvent = ButtonEvent.Save)
 {
     InitializeComponent();
     this.buttonEvent = buttonEvent;
 }
Пример #16
0
 public void Click(ButtonEvent ev)
 {
     Count++;
     IsChanged = true;
 }
 static SelectionModeChooser()
 {
     ChangeSelectionMode = new ButtonEvent(EventLayers.Gui);
     ChangeSelectionMode.addButton(KeyboardButtonCode.KC_TAB);
     DefaultEvents.registerDefaultEvent(ChangeSelectionMode);
 }
Пример #18
0
    // Use this for initialization
    void Start()
    {
        if (SceneManager.Scene == null)
            SceneManager.Scene = this;

        //initialise the main camera object
        if(MainCamObj == null) MainCamObj = Camera.main.gameObject;
        MainCamObj.SetActive(true);

        // initialise the volume controls if necessary
        if (!Application.loadedLevelName.Contains ("LevelSelect")
            && Application.loadedLevelName != "Start"
            && Application.loadedLevelName != "HowToPlay"
            && Application.loadedLevelName != "Credits"
            && !Application.loadedLevelName.Contains("Main") ){
                        if (VolMusicButton == null) {
                                VolMusicButton = MainCamObj.transform.FindChild ("PauseMenu").FindChild ("VolMusic").FindChild ("ButtonGUI").GetComponent<ButtonEvent> ();
                                VolMusicButton.receiver = gameObject;
                        }
                        if (VolSFXButton == null) {
                                VolSFXButton = MainCamObj.transform.FindChild ("PauseMenu").FindChild ("VolSFX").FindChild ("ButtonGUI").GetComponent<ButtonEvent> ();
                                VolSFXButton.receiver = gameObject;
                        }
                }
        if(GameManager.instance != null){
            VolMusic();
            VolMusic();
            VolSFX();
            VolSFX();
        }

        LevelSelectString = "LevelSelect";
        //optionally set the 'levelselectstring'
        /*	if (GameManager.instance != null && !GameManager.instance.IsDemo) {
                        LevelSelectString = "LevelSelect";
        }
        else if(Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.Android){
            LevelSelectString = "LevelSelectDemoMOBILE";
        }
        else
            LevelSelectString = "LevelSelectDemoPC";
        */

        //fade from white.
        pixel = (Texture2D) Resources.Load("pixel");
        iTween.CameraFadeAdd(pixel);
        iTween.CameraFadeFrom(1,0.7f);
    }
Пример #19
0
 internal void NotifyHome(ButtonEvent buttonEvent)
 {
     if (HomePressed != null)
     HomePressed(this, new HomeButtonEventArgs() { Event = buttonEvent });
 }
        public OffsetSequenceEditorContext(OffsetModifierSequence movementSequence, String file, OffsetSequenceTypeController typeController, GuiFrameworkUICallback uiCallback, SimObjectMover simObjectMover)
        {
            this.typeController            = typeController;
            this.currentFile               = file;
            this.movementSequence          = movementSequence;
            this.simObjectMover            = simObjectMover;
            simObjectMover.ShowMoveTools   = true;
            simObjectMover.ShowRotateTools = false;

            mvcContext = new AnomalousMvcContext();
            mvcContext.StartupAction = "Common/Start";
            mvcContext.FocusAction   = "Common/Focus";
            mvcContext.BlurAction    = "Common/Blur";
            mvcContext.SuspendAction = "Common/Suspended";
            mvcContext.ResumeAction  = "Common/Resumed";

            mvcContext.Models.add(new EditMenuManager());

            OffsetSequenceEditorView offsetSequenceView = new OffsetSequenceEditorView("SequenceEditor", uiCallback, simObjectMover, movementSequence);

            offsetSequenceView.ElementName = new MDILayoutElementName(GUILocationNames.MDI, DockLocation.Bottom);
            mvcContext.Views.add(offsetSequenceView);

            EditorTaskbarView taskbar = new EditorTaskbarView("InfoBar", currentFile, "Editor/Close");

            taskbar.addTask(new CallbackTask("SaveAll", "Save All", "Editor/SaveAllIcon", "", 0, true, item =>
            {
                saveAll();
            }));
            taskbar.addTask(new RunMvcContextActionTask("Save", "Save Movement Sequence File", "CommonToolstrip/Save", "File", "Editor/Save", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Cut", "Cut", "Editor/CutIcon", "", "Editor/Cut", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Copy", "Copy", "Editor/CopyIcon", "", "Editor/Copy", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Paste", "Paste", "Editor/PasteIcon", "", "Editor/Paste", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("SelectAll", "Select All", "Editor/SelectAllIcon", "", "Editor/SelectAll", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Translation", "Translation", "Editor/TranslateIcon", "", "Editor/Translation", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Rotation", "Rotation", "Editor/RotateIcon", "", "Editor/Rotation", mvcContext));
            mvcContext.Views.add(taskbar);

            mvcContext.Controllers.add(new MvcController("Editor",
                                                         new RunCommandsAction("Show",
                                                                               new ShowViewCommand("SequenceEditor"),
                                                                               new ShowViewCommand("InfoBar")),
                                                         new RunCommandsAction("Close", new CloseAllViewsCommand()),
                                                         new CallbackAction("Save", context =>
            {
                save();
            }),
                                                         new CutAction(),
                                                         new CopyAction(),
                                                         new PasteAction(),
                                                         new SelectAllAction(),
                                                         new CallbackAction("Translation", context =>
            {
                this.simObjectMover.ShowMoveTools   = true;
                this.simObjectMover.ShowRotateTools = false;
            }),
                                                         new CallbackAction("Rotation", context =>
            {
                this.simObjectMover.ShowMoveTools   = false;
                this.simObjectMover.ShowRotateTools = true;
            })));

            mvcContext.Controllers.add(new MvcController("Common",
                                                         new RunCommandsAction("Start", new RunActionCommand("Editor/Show")),
                                                         new CallbackAction("Focus", context =>
            {
                GlobalContextEventHandler.setEventContext(eventContext);
                if (Focus != null)
                {
                    Focus.Invoke(this);
                }
            }),
                                                         new CallbackAction("Blur", context =>
            {
                GlobalContextEventHandler.disableEventContext(eventContext);
                if (Blur != null)
                {
                    Blur.Invoke(this);
                }
            }),
                                                         new RunCommandsAction("Suspended", new SaveViewLayoutCommand()),
                                                         new RunCommandsAction("Resumed", new RestoreViewLayoutCommand())));

            eventContext = new EventContext();
            ButtonEvent saveEvent = new ButtonEvent(EventLayers.Gui);

            saveEvent.addButton(KeyboardButtonCode.KC_LCONTROL);
            saveEvent.addButton(KeyboardButtonCode.KC_S);
            saveEvent.FirstFrameUpEvent += eventManager =>
            {
                saveAll();
            };
            eventContext.addEvent(saveEvent);

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                mvcContext.runAction("Editor/Cut");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_X }));

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                mvcContext.runAction("Editor/Copy");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_C }));

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                mvcContext.runAction("Editor/Paste");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_V }));

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                mvcContext.runAction("Editor/SelectAll");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_A }));

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                mvcContext.runAction("Editor/Translation");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_T }));

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                mvcContext.runAction("Editor/Rotation");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_R }));
        }
Пример #21
0
 public void btnNewSet(ButtonEvent dd)
 {
     btnNew.Click += new EventHandler(dd);
 }
Пример #22
0
 /// <summary>
 /// Triggered when the user releases a keyboard button.
 /// </summary>
 /// <param name="ev">Information about the keyboard release event.</param>
 private void OnButtonUp(ButtonEvent ev)
 {
     curveEditor.OnButtonUp(ev);
 }
Пример #23
0
 public KeyBinding(string alias, Keys k, KeyModifier mods, ButtonEvent kevent, ButtonBindingDelegate kdel)
     : base(alias, kevent, kdel)
 {
     Key       = k;
     Modifiers = mods;
 }
Пример #24
0
 public Services(service editService, ButtonEvent buttonEvent = ButtonEvent.Edit)
 {
     InitializeComponent();
     _editServiceHelper = editService;
     LoadServiceToControl(_editServiceHelper);
 }
Пример #25
0
 public KeyBinding(string alias, Keys k, ButtonEvent kevent, ButtonBindingDelegate kdel)
     : this(alias, k, KeyModifier.None, kevent, kdel)
 {
 }
Пример #26
0
 protected override void DoStateTransition(SelectionState state, bool instant)
 {
     base.DoStateTransition(state, instant);
     ButtonEvent?.Invoke(this, new ButtonEventArgs((int)state, instant));
 }
Пример #27
0
        /// <summary>
        /// Called by EasyHook to begin any hooking etc in the target process
        /// </summary>
        /// <param name="InContext"></param>
        /// <param name="InArg1"></param>
        public void Run(RemoteHooking.IContext InContext, String InArg1)
        {
            Interface.Write("Running in target.");
            int pid = RemoteHooking.GetCurrentProcessId();

            try
            {
                // NOTE: We are now already running within the target process

                // We want to hook each method of we are interested in
                IntPtr pGetControllerState         = IntPtr.Zero;
                IntPtr pGetControllerStateWithPose = IntPtr.Zero;
                IntPtr pPollNextEvent         = IntPtr.Zero;
                IntPtr pPollNextEventWithPose = IntPtr.Zero;

                // TODO: Find out version of openvr dll, which will determine the correct index of the function
                // ver = vr::IVRSystem_Version; returns string
                // string matching determines which enum to use

                if (RemoteHooking.IsX64Process(pid))
                {
                    /*
                     * EVRInitError error = EVRInitError.None;
                     * OpenVR.Init(ref error);
                     * if(error == EVRInitError.None)
                     * {
                     *  Func<in uint, VRControllerState_t, in uint, out bool> ptr = null;
                     *  ptr = OpenVR.System.GetControllerState;
                     * }
                     */

                    Interface.Write("64 bit process");
                    pGetControllerState         = GetIVRSystemFunctionAddress64((short)OpenVRFunctionIndex.GetControllerState, (int)OpenVRFunctionIndex.Count);
                    pGetControllerStateWithPose = GetIVRSystemFunctionAddress64((short)OpenVRFunctionIndex.GetControllerStateWithPose, (int)OpenVRFunctionIndex.Count);
                    pPollNextEvent         = GetIVRSystemFunctionAddress64((short)OpenVRFunctionIndex.PollNextEvent, (int)OpenVRFunctionIndex.Count);
                    pPollNextEventWithPose = GetIVRSystemFunctionAddress64((short)OpenVRFunctionIndex.PollNextEventWithPose, (int)OpenVRFunctionIndex.Count);
                }
                else
                {
                    Interface.Write("32 bit process");
                    pGetControllerState         = GetIVRSystemFunctionAddress32((short)OpenVRFunctionIndex.GetControllerState, (int)OpenVRFunctionIndex.Count);
                    pGetControllerStateWithPose = GetIVRSystemFunctionAddress32((short)OpenVRFunctionIndex.GetControllerStateWithPose, (int)OpenVRFunctionIndex.Count);
                    pPollNextEvent         = GetIVRSystemFunctionAddress32((short)OpenVRFunctionIndex.PollNextEvent, (int)OpenVRFunctionIndex.Count);
                    pPollNextEventWithPose = GetIVRSystemFunctionAddress32((short)OpenVRFunctionIndex.PollNextEventWithPose, (int)OpenVRFunctionIndex.Count);
                }

                if ((pGetControllerState == IntPtr.Zero && pGetControllerStateWithPose == IntPtr.Zero) ||
                    (pPollNextEvent == IntPtr.Zero || pPollNextEventWithPose == IntPtr.Zero))
                {
                    throw new VRNotInitializedException("No runtime installed, no HMD present, version mismatch, or other error.");
                }

                Interface.Write("GetControllerState function pointer: " + (pGetControllerState).ToString());
                Interface.Write("GetControllerStateWithPose function pointer: " + (pGetControllerStateWithPose).ToString());
                Interface.Write("PollNextEventEvent function pointer: " + (pPollNextEvent).ToString());
                Interface.Write("PollNextEventWithPose function pointer: " + (pPollNextEventWithPose).ToString());

                GetControllerStatePtr  = pGetControllerState;
                GetControllerStateHook = LocalHook.Create(
                    pGetControllerState,
                    new vr_GetControllerStateDelegate(GetControllerState_Hooked),
                    this);

                GetControllerStateWithPosePtr  = pGetControllerStateWithPose;
                GetControllerStateWithPoseHook = LocalHook.Create(
                    pGetControllerStateWithPose,
                    new vr_GetControllerStateWithPoseDelegate(GetControllerStateWithPose_Hooked),
                    this);

                PollNextEventPtr  = pPollNextEvent;
                PollNextEventHook = LocalHook.Create(
                    pPollNextEvent,
                    new vr_PollNextEventDelegate(PollNextEvent_Hooked),
                    this);

                PollNextEventWithPosePtr  = pPollNextEventWithPose;
                PollNextEventWithPoseHook = LocalHook.Create(
                    pPollNextEventWithPose,
                    new vr_PollNextEventWithPoseDelegate(PollNextEventWithPose_Hooked),
                    this);

                /*
                 * Don't forget that all hooks will start deactivated...
                 * The following ensures that all threads are intercepted:
                 * Note: you must do this for each hook.
                 */
                GetControllerStateHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
                GetControllerStateWithPoseHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
                PollNextEventHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
                PollNextEventWithPoseHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
            }
            catch (Exception e)
            {
                /*
                 *  We should notify our host process about this error...
                 */
                Interface.Write("Error: ");
                Interface.ReportError(pid, e);
                return;
            }

            Interface.Write("DLL installed");
            Interface.IsInstalled(pid);

            // Wait for host process termination...
            try
            {
                ChosenDeviceIndex = 0; // base station
                while (ChosenDeviceIndex == 0)
                {
                    if (!Interface.Installed)
                    {
                        Interface.Write("Need to uninstall hooks!");
                        break;
                    }

                    // wait until controller comes on?
                    if (RemoteHooking.IsX64Process(pid))
                    {
                        LeftHandIndex  = GetLeftHandIndex64();
                        RightHandIndex = GetRightHandIndex64();
                    }
                    else
                    {
                        LeftHandIndex  = GetLeftHandIndex32();
                        RightHandIndex = GetRightHandIndex32();
                    }
                    Interface.Write("Left hand " + LeftHandIndex);
                    Interface.Write("Right hand " + RightHandIndex);
                    ChosenDeviceIndex = Interface.Hand == PStrafeHand.Left ? LeftHandIndex : RightHandIndex;
                    Thread.Sleep(300);
                }

                while (true)
                {
                    Thread.Sleep(10);
                    if (!Interface.Installed)
                    {
                        break;
                    }
                    bool running = Interface.UserIsRunning;
                    if (running != UserRunning)
                    {
                        // look for interface changes (keybinding, user is running, etc)
                        RunButton         = Interface.RunButton;
                        ButtonType        = Interface.ButtonType;
                        ChosenDeviceIndex = Interface.Hand == PStrafeHand.Left ? LeftHandIndex : RightHandIndex;
                        UserRunning       = running;

                        // create event for vive controller
                        MyEvent = new ButtonEvent()
                        {
                            Queued      = true,
                            ShouldPress = ButtonType == PStrafeButtonType.Press,
                            ShouldTouch = true
                        };
                    }
                }
            }
            catch
            {
                // NET Remoting will raise an exception if host is unreachable
                Interface.ReportError(pid, new Exception("Host unreachable?"));
            }
            finally
            {
                // Note: this will probably not get called if the target application closes before the
                //       host application.
                Interface.Write("Remove and cleanup hooks");
                Cleanup();
            }
        }
Пример #28
0
 public void EnableEvent(ButtonEvent ev)
 {
 }
Пример #29
0
        public override void ButtonPressed(Location location, ButtonEvent buttonEvent)
        {
            base.ButtonPressed(location, buttonEvent);

            _callbackClient.ButtonPressed(Id, location, buttonEvent);
        }
Пример #30
0
 private void ButtonChanged(ButtonEvent e)
 {
 }
Пример #31
0
 private void ButtonChangedMiddle(ButtonEvent e)
 {
     if (ButtonChanged != null)
         ButtonChanged(e);
 }
Пример #32
0
 public ButtonEventArgs(ButtonEvent buttonEvent, SensorState toState)
 {
     this.button = buttonEvent;
     this.toState = toState;
 }
Пример #33
0
 public void DisableEvent(ButtonEvent ev)
 {
 }
Пример #34
0
 public Services(service_catalog serviceCatalog, ButtonEvent buttonEvent = ButtonEvent.Save)
 {
     InitializeComponent();
     _service_catalog = serviceCatalog;
     this.buttonEvent = buttonEvent;
 }
Пример #35
0
        public override void ButtonPressed(Location location, ButtonEvent buttonEvent)
        {
            base.ButtonPressed(location, buttonEvent);

            LayoutContext.SetPreviousLayout();
        }
Пример #36
0
 public ButtonStateChangedArgs(PinMeta pin, ButtonEvent buttonEvent)
 {
     Pin         = pin;
     ButtonEvent = buttonEvent;
 }
    //Can't pass ExecuteEvents as parameter? Unity gives error
    //Turns and Angle and Event type into a button action
    void InteractButton(float angle, ButtonEvent evt)
    {
        //Get button ID from angle
        float buttonAngle = 360f / Buttons.Count; //Each button is an arc with this angle
        angle = mod((angle + offsetRotation), 360); //Offset the touch coordinate with our offset
        currentTouchAngle = angle; //Keep track of our angle for outside use if we want it later
        int buttonID = (int)mod(((angle + (buttonAngle / 2f)) / buttonAngle), Buttons.Count); //Convert angle into ButtonID (This is the magic)
        var pointer = new PointerEventData(EventSystem.current); //Create a new EventSystem (UI) Event

        //If we changed buttons while moving, un-hover and un-click the last button we were on
        if (currentHover != buttonID && currentHover != -1)
        {
            ExecuteEvents.Execute(menuButtons[currentHover], pointer, ExecuteEvents.pointerUpHandler);
            ExecuteEvents.Execute(menuButtons[currentHover], pointer, ExecuteEvents.pointerExitHandler);
        }
        if (evt == ButtonEvent.click) //Click button if click, and keep track of current press
        {
            ExecuteEvents.Execute(menuButtons[buttonID], pointer, ExecuteEvents.pointerDownHandler);
            currentPress = 1;
            Buttons[buttonID].Click();
        }
        else if (evt == ButtonEvent.unclick) //Clear press id to stop invoking OnHold method
        {
            ExecuteEvents.Execute(menuButtons[buttonID], pointer, ExecuteEvents.pointerUpHandler);
            currentPress = -1;
        }
        else if (evt == ButtonEvent.hoverOn && currentHover != buttonID) // Show hover UI event (darken button etc)
        {
            ExecuteEvents.Execute(menuButtons[buttonID], pointer, ExecuteEvents.pointerEnterHandler);
        }
        currentHover = buttonID; //Set current hover ID, need this to un-hover if selected button changes
    }
        public PluginEditorContext(DDAtlasPlugin plugin, String file, PluginTypeController pluginTypeController, EditorController editorController, GuiFrameworkUICallback uiCallback, StandaloneController standaloneController)
        {
            this.pluginTypeController = pluginTypeController;
            this.currentFile          = file;
            this.plugin               = plugin;
            this.editorController     = editorController;
            this.standaloneController = standaloneController;

            mvcContext = new AnomalousMvcContext();
            mvcContext.StartupAction = "Common/Start";
            mvcContext.FocusAction   = "Common/Focus";
            mvcContext.BlurAction    = "Common/Blur";
            mvcContext.SuspendAction = "Common/Suspended";
            mvcContext.ResumeAction  = "Common/Resumed";

            mvcContext.Models.add(new EditMenuManager());

            GenericPropertiesFormView genericPropertiesView = new GenericPropertiesFormView("MvcContext", plugin.EditInterface, editorController, uiCallback, true);

            genericPropertiesView.ElementName = new MDILayoutElementName(GUILocationNames.MDI, DockLocation.Left);
            mvcContext.Views.add(genericPropertiesView);

            EditorTaskbarView taskbar = new EditorTaskbarView("InfoBar", currentFile, "Editor/Close");

            taskbar.addTask(new CallbackTask("SaveAll", "Save All", "Editor/SaveAllIcon", "", 0, true, item =>
            {
                saveAll();
            }));
            taskbar.addTask(new RunMvcContextActionTask("Save", "Save Plugin Definition File", "CommonToolstrip/Save", "File", "Editor/Save", mvcContext));
            taskbar.addTask(new CallbackTask("FindDependencies", "Find Dependencies", "EditorFileIcon/.ddp", "", item =>
            {
                findDependencies();
            }));
            mvcContext.Views.add(taskbar);

            mvcContext.Controllers.add(new MvcController("Editor",
                                                         new RunCommandsAction("Show",
                                                                               new ShowViewCommand("MvcContext"),
                                                                               new ShowViewCommand("InfoBar")),
                                                         new RunCommandsAction("Close", new CloseAllViewsCommand()),
                                                         new CallbackAction("Save", context =>
            {
                save();
            })));

            mvcContext.Controllers.add(new MvcController("Common",
                                                         new RunCommandsAction("Start", new RunActionCommand("Editor/Show")),
                                                         new CallbackAction("Focus", context =>
            {
                GlobalContextEventHandler.setEventContext(eventContext);
                if (Focus != null)
                {
                    Focus.Invoke(this);
                }
            }),
                                                         new CallbackAction("Blur", context =>
            {
                GlobalContextEventHandler.disableEventContext(eventContext);
                if (Blur != null)
                {
                    Blur.Invoke(this);
                }
            }),
                                                         new RunCommandsAction("Suspended", new SaveViewLayoutCommand()),
                                                         new RunCommandsAction("Resumed", new RestoreViewLayoutCommand())));

            eventContext = new EventContext();
            ButtonEvent saveEvent = new ButtonEvent(EventLayers.Gui);

            saveEvent.addButton(KeyboardButtonCode.KC_LCONTROL);
            saveEvent.addButton(KeyboardButtonCode.KC_S);
            saveEvent.FirstFrameUpEvent += eventManager =>
            {
                saveAll();
            };
            eventContext.addEvent(saveEvent);
        }
Пример #39
0
 public EventedButton(string label, string color, ButtonEvent evt)
     : base(label, RandomString(7), color)
 {
     this.buttonEvent = evt;
 }
Пример #40
0
        public RmlEditorContext(String file, RmlTypeController rmlTypeController, AnomalousMvcContext editingMvcContext, EditorController editorController, EditorUICallback uiCallback)
        {
            this.rmlTypeController = rmlTypeController;
            this.currentFile       = file;
            this.uiCallback        = uiCallback;

            undoBuffer = new UndoRedoBuffer(50);

            rmlTypeController.loadText(currentFile);

            mvcContext = new AnomalousMvcContext();
            mvcContext.StartupAction = "Common/Start";
            mvcContext.FocusAction   = "Common/Focus";
            mvcContext.BlurAction    = "Common/Blur";
            mvcContext.SuspendAction = "Common/Suspended";
            mvcContext.ResumeAction  = "Common/Resumed";

            TextEditorView textEditorView = new TextEditorView("RmlEditor", () => rmlComponent.CurrentRml, wordWrap: false, textHighlighter: RmlTextHighlighter.Instance);

            textEditorView.ElementName = new MDILayoutElementName(GUILocationNames.MDI, DockLocation.Left);
            textEditorView.Buttons.add(new CloseButtonDefinition("Close", "RmlTextEditor/Close"));
            textEditorView.ComponentCreated += (view, component) =>
            {
                textEditorComponent = component;
            };
            mvcContext.Views.add(textEditorView);

            RmlWysiwygView rmlView = new RmlWysiwygView("RmlView", uiCallback, undoBuffer);

            rmlView.ElementName       = new MDILayoutElementName(GUILocationNames.MDI, DockLocation.Left);
            rmlView.RmlFile           = file;
            rmlView.ComponentCreated += (view, component) =>
            {
                rmlComponent            = component;
                rmlComponent.RmlEdited += rmlEditor =>
                {
                    if (textEditorComponent != null)
                    {
                        textEditorComponent.Text = rmlEditor.CurrentRml;
                    }
                };
            };
            mvcContext.Views.add(rmlView);

            DragAndDropView <WysiwygDragDropItem> htmlDragDrop = new DragAndDropView <WysiwygDragDropItem>("HtmlDragDrop",
                                                                                                           new WysiwygDragDropItem("Heading", "Editor/HeaderIcon", "<h1>Heading</h1>"),
                                                                                                           new WysiwygDragDropItem("Paragraph", "Editor/ParagraphsIcon", "<p>Add paragraph text here.</p>"),
                                                                                                           new WysiwygDragDropItem("Image", "Editor/ImageIcon", String.Format("<img src=\"{0}\" style=\"width:200px;\"></img>", RmlWysiwygComponent.DefaultImage)),
                                                                                                           new WysiwygDragDropItem("Link", "Editor/LinksIcon", "<a onclick=\"None\">Link</a>"),
                                                                                                           new WysiwygDragDropItem("Button", "Editor/AddButtonIcon", "<input type=\"submit\" onclick=\"None\">Button</input>"),
                                                                                                           new WysiwygDragDropItem("Separator", CommonResources.NoIcon, "<x-separator/>"),
                                                                                                           new WysiwygDragDropItem("Two Columns", CommonResources.NoIcon, "<div class=\"TwoColumn\"><div class=\"Column\"><p>Column 1 text goes here.</p></div><div class=\"Column\"><p>Column 2 text goes here.</p></div></div>"),
                                                                                                           new WysiwygDragDropItem("Heading and Paragraph", CommonResources.NoIcon, "<h1>Heading For Paragraph.</h1><p>Paragraph for heading.</p>", "div"),
                                                                                                           new WysiwygDragDropItem("Left Image and Paragraph", CommonResources.NoIcon, String.Format("<div class=\"ImageParagraphLeft\"><img src=\"{0}\" style=\"width:200px;\"/><p>Add paragraph text here.</p></div>", RmlWysiwygComponent.DefaultImage)),
                                                                                                           new WysiwygDragDropItem("Right Image and Paragraph", CommonResources.NoIcon, String.Format("<div class=\"ImageParagraphRight\"><img src=\"{0}\" style=\"width:200px;\"/><p>Add paragraph text here.</p></div>", RmlWysiwygComponent.DefaultImage))
                                                                                                           );

            htmlDragDrop.Dragging += (item, position) =>
            {
                rmlComponent.setPreviewElement(position, item.PreviewMarkup, item.PreviewTagType);
            };
            htmlDragDrop.DragEnded += (item, position) =>
            {
                if (rmlComponent.contains(position))
                {
                    rmlComponent.insertRml(item.createDocumentMarkup());
                }
                else
                {
                    rmlComponent.cancelAndHideEditor();
                    rmlComponent.clearPreviewElement(false);
                }
            };
            htmlDragDrop.ItemActivated += (item) =>
            {
                rmlComponent.insertRml(item.createDocumentMarkup());
            };
            htmlDragDrop.ElementName = new MDILayoutElementName(GUILocationNames.MDI, DockLocation.Left);
            mvcContext.Views.add(htmlDragDrop);

            EditorTaskbarView taskbar = new EditorTaskbarView("InfoBar", currentFile, "Editor/Close");

            taskbar.addTask(new CallbackTask("SaveAll", "Save All", "Editor/SaveAllIcon", "", 0, true, item =>
            {
                saveAll();
            }));
            taskbar.addTask(new RunMvcContextActionTask("Save", "Save Rml File", "CommonToolstrip/Save", "File", "Editor/Save", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Undo", "Undo", CommonResources.NoIcon, "Edit", "Editor/Undo", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Redo", "Redo", CommonResources.NoIcon, "Edit", "Editor/Redo", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Cut", "Cut", "Editor/CutIcon", "Edit", "Editor/Cut", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Copy", "Copy", "Editor/CopyIcon", "Edit", "Editor/Copy", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Paste", "Paste", "Editor/PasteIcon", "Edit", "Editor/Paste", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("SelectAll", "Select All", "Editor/SelectAllIcon", "Edit", "Editor/SelectAll", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("RmlEditor", "Edit Rml", RmlTypeController.Icon, "Edit", "RmlTextEditor/Show", mvcContext));
            mvcContext.Views.add(taskbar);

            mvcContext.Controllers.add(new MvcController("RmlTextEditor",
                                                         new RunCommandsAction("Show",
                                                                               new ShowViewIfNotOpenCommand("RmlEditor")),
                                                         new RunCommandsAction("Close",
                                                                               new CloseViewCommand(),
                                                                               new CallbackCommand(context =>
            {
                textEditorComponent = null;
            }))
                                                         ));

            mvcContext.Controllers.add(new MvcController("HtmlDragDrop",
                                                         new RunCommandsAction("Show",
                                                                               new ShowViewIfNotOpenCommand("HtmlDragDrop")),
                                                         new RunCommandsAction("Close",
                                                                               new CloseViewCommand())
                                                         ));

            mvcContext.Controllers.add(new MvcController("Editor",
                                                         new RunCommandsAction("Show",
                                                                               new ShowViewCommand("RmlView"),
                                                                               new ShowViewCommand("InfoBar")),
                                                         new RunCommandsAction("Close", new CloseAllViewsCommand()),
                                                         new CallbackAction("Save", context =>
            {
                save();
            }),
                                                         new CallbackAction("Cut", context =>
            {
                if (textEditorComponent != null)
                {
                    textEditorComponent.cut();
                }
            }),
                                                         new CallbackAction("Copy", context =>
            {
                if (textEditorComponent != null)
                {
                    textEditorComponent.copy();
                }
            }),
                                                         new CallbackAction("Paste", context =>
            {
                if (textEditorComponent != null)
                {
                    textEditorComponent.paste();
                }
            }),
                                                         new CallbackAction("SelectAll", context =>
            {
                if (textEditorComponent != null)
                {
                    textEditorComponent.selectAll();
                }
            }),
                                                         new CallbackAction("Undo", context =>
            {
                undoBuffer.undo();
            }),
                                                         new CallbackAction("Redo", context =>
            {
                undoBuffer.execute();
            })
                                                         ));

            mvcContext.Controllers.add(new MvcController("Common",
                                                         new RunCommandsAction("Start", new RunActionCommand("HtmlDragDrop/Show"), new RunActionCommand("Editor/Show")),
                                                         new CallbackAction("Focus", context =>
            {
                GlobalContextEventHandler.setEventContext(eventContext);
                if (Focus != null)
                {
                    Focus.Invoke(this);
                }
            }),
                                                         new CallbackAction("Blur", context =>
            {
                GlobalContextEventHandler.disableEventContext(eventContext);
                if (Blur != null)
                {
                    Blur.Invoke(this);
                }
            }),
                                                         new RunCommandsAction("Suspended", new SaveViewLayoutCommand()),
                                                         new RunCommandsAction("Resumed", new RestoreViewLayoutCommand())));

            eventContext = new EventContext();
            ButtonEvent saveEvent = new ButtonEvent(EventLayers.Gui);

            saveEvent.addButton(KeyboardButtonCode.KC_LCONTROL);
            saveEvent.addButton(KeyboardButtonCode.KC_S);
            saveEvent.FirstFrameUpEvent += eventManager =>
            {
                saveAll();
            };
            eventContext.addEvent(saveEvent);

            ButtonEvent undoEvent = new ButtonEvent(EventLayers.Gui);

            undoEvent.addButton(KeyboardButtonCode.KC_LCONTROL);
            undoEvent.addButton(KeyboardButtonCode.KC_Z);
            undoEvent.FirstFrameUpEvent += eventManager =>
            {
                undoBuffer.undo();
            };
            eventContext.addEvent(undoEvent);

            ButtonEvent redoEvent = new ButtonEvent(EventLayers.Gui);

            redoEvent.addButton(KeyboardButtonCode.KC_LCONTROL);
            redoEvent.addButton(KeyboardButtonCode.KC_Y);
            redoEvent.FirstFrameUpEvent += eventManager =>
            {
                undoBuffer.execute();
            };
            eventContext.addEvent(redoEvent);

            if (editingMvcContext != null)
            {
                String controllerName = PathExtensions.RemoveExtension(file);
                if (editingMvcContext.Controllers.hasItem(controllerName))
                {
                    MvcController viewController = editingMvcContext.Controllers[controllerName];

                    GenericPropertiesFormView genericPropertiesView = new GenericPropertiesFormView("MvcContext", viewController.getEditInterface(), editorController, uiCallback, true);
                    genericPropertiesView.ElementName = new MDILayoutElementName(GUILocationNames.MDI, DockLocation.Left);
                    genericPropertiesView.Buttons.add(new CloseButtonDefinition("Close", "MvcEditor/Close"));
                    mvcContext.Views.add(genericPropertiesView);

                    taskbar.addTask(new RunMvcContextActionTask("EditActions", "Edit Actions", "MvcContextEditor/ControllerIcon", "Edit", "MvcEditor/Show", mvcContext));

                    mvcContext.Controllers.add(new MvcController("MvcEditor",
                                                                 new RunCommandsAction("Show",
                                                                                       new ShowViewIfNotOpenCommand("MvcContext")),
                                                                 new RunCommandsAction("Close",
                                                                                       new CloseViewCommand())
                                                                 ));
                }

                if (editingMvcContext.Views.hasItem(controllerName))
                {
                    RmlView view = editingMvcContext.Views[controllerName] as RmlView;
                    if (view != null && view.RmlFile == file)
                    {
                        GenericPropertiesFormView genericPropertiesView = new GenericPropertiesFormView("MvcView", view.getEditInterface(), editorController, uiCallback, true);
                        genericPropertiesView.ElementName = new MDILayoutElementName(GUILocationNames.MDI, DockLocation.Left);
                        genericPropertiesView.Buttons.add(new CloseButtonDefinition("Close", "MvcViewEditor/Close"));
                        mvcContext.Views.add(genericPropertiesView);

                        taskbar.addTask(new RunMvcContextActionTask("EditView", "Edit View", "MvcContextEditor/IndividualViewIcon", "Edit", "MvcViewEditor/Show", mvcContext));

                        mvcContext.Controllers.add(new MvcController("MvcViewEditor",
                                                                     new RunCommandsAction("Show",
                                                                                           new ShowViewIfNotOpenCommand("MvcView")),
                                                                     new RunCommandsAction("Close",
                                                                                           new CloseViewCommand())
                                                                     ));
                    }
                }

                taskbar.addTask(new CallbackTask("PreviewMvc", "Preview", "MvcContextEditor/MVCcomIcon", "", 0, true, (item) =>
                {
                    uiCallback.previewMvcContext(editingMvcContext);
                }));
            }
        }