Esempio n. 1
0
    private void Awake()
    {
        if (!Application.isEditor)
        {
            Destroy(gameObject);
            return;
        }

        manualController = GetComponent <CustomInputControl>();

        currentButtonStates = new ButtonStates();
        currentlyVisible    = false;
        visibilityChanged   = false;
        controllerId        = (uint)Random.value;
    }
Esempio n. 2
0
        public MobileRemoteUI()
        {
            this.IsLoaded = false;
            Properties.Settings.Load();
            L2CAPAPI.BthGetMode(out _initialRadioMode);
            _instance = this;
            this.Load += new EventHandler(MobileRemoteUI_Load);
            this.GotFocus += new EventHandler(MobileRemoteUI_GotFocus);
            _inputs = new List<InputInterfaceControl>(
                new InputInterfaceControl[]
                {
                    new InputInterfaceControl("Keyboard", _keyboardControl, Properties.Resources.keyboard, Properties.Resources.keyboard_down, Properties.Resources.keyboard_sel),
                    new InputInterfaceControl("Mouse", _mouseControl, Properties.Resources.mouse, Properties.Resources.mouse_down, Properties.Resources.mouse_sel),
                    new InputInterfaceControl("TouchPad", _touchPanel, Properties.Resources.touch, Properties.Resources.touch_down, Properties.Resources.touch_sel),
                    //new InputInterfaceControl("Media", _mediaControl, Properties.Resources.media, Properties.Resources.media_down, Properties.Resources.media_sel),
                    //new InputInterfaceControl("Present", _presentControl, Properties.Resources.present, Properties.Resources.present_down, Properties.Resources.present_sel)
                }
            );
            InitializeComponent();

            _hidWriter = new BluetoothHidWriter();
            _hidWriter.Connected += new EventHandler(_hidWriter_Connected);
            _hidWriter.Disconnected += new EventHandler(_hidWriter_Disconnected);

            //_presentControl.HidWriter = _hidWriter;
            //_mediaControl.HidWriter = _hidWriter;
            _mouseControl.HidWriter = _hidWriter;
            _touchPanel.HidWriter = _hidWriter;
            _keyboardControl.HidWriter = _hidWriter;
            _connectButton.HidWriter = _hidWriter;

            XmlSerializer xs = new XmlSerializer(typeof(Classes.CustomInput));
            foreach (string customInput in Directory.GetFiles(Path.Combine(Utils.GetWorkingDirectory(), "CustomInputs")))
            {
                using (StreamReader fs = File.OpenText(customInput))
                {
                    Classes.CustomInput ci = (Classes.CustomInput)xs.Deserialize(fs);
                    ci.ScaleToResolution();

                    CustomInputControl input = new CustomInputControl(ci, _hidWriter);
                    InputInterfaceControl interfaceControl = new InputInterfaceControl
                        (
                            ci.Name, input,
                            CustomInputControl.GetBitmap(ci.Image),
                            CustomInputControl.GetBitmap(ci.DownImage),
                            CustomInputControl.GetBitmap(ci.SelectedImage)
                        );

                    _inputs.Add(interfaceControl);
                }
            }

            Menu menu = null;

            if (!Platform.IsWindowsMobileClassic)
            {
                int totalButtonsVisible = (buttonPanel1.Width / buttonPanel1.Height) - 2;

                if (_inputs.Count < totalButtonsVisible)
                {
                    // great...
                    buttonPanel1.Controls.Remove(_inputsButton);
                }
                else
                {
                    totalButtonsVisible--;
                }

                int count = 0;
                foreach (InputInterfaceControl control in _inputs)
                {
                    PushButton button = new PushButton();
                    button.DownImage = control.Down;
                    button.Image = control.Up;
                    button.Name = control.Text;
                    button.Text = control.Text;
                    button.SelectedImage = control.Sel;
                    button.Size = new System.Drawing.Size(buttonPanel1.Height, buttonPanel1.Height);
                    button.TabIndex = 11;
                    button.Dock = DockStyle.Left;
                    button.Click += new EventHandler(button_Click);
                    button.RightClick += new EventHandler(_controlSettingsMenu_Click);

                    if (_inputList.Count < totalButtonsVisible)
                    {
                    }
                    else
                    {
                        button.Visible = false;
                    }
                    buttonPanel1.Controls.Add(button);
                    buttonPanel1.Controls.SetChildIndex(button, count++);

                    control.Click = button_Click;
                    control.Tag = button;

                    _inputList.Add(button, control);
                }
                ((PushButton)_inputs[0].Tag).IsSelected = true;

                menu = _mainContextMenu;
            }
            else
            {
                this.buttonPanel1.Visible = false;

                _leftMenu = new MenuItem();
                _leftMenu.Text = "";

                MenuItem rightMenu = new MenuItem();
                rightMenu.Text = "Menu";

                _mainMenu.MenuItems.Add(_leftMenu);
                _mainMenu.MenuItems.Add(rightMenu);

                int i = 0;
                foreach (InputInterfaceControl control in _inputs)
                {
                    if (!control.Control.RequiresTouchscreen)
                    {
                        MenuItem menuItem = new MenuItem();
                        menuItem.Text = String.Format("&{1}", i++, control.Text);
                        menuItem.Click += new EventHandler(menuItem_Click);
                        rightMenu.MenuItems.Add(menuItem);

                        control.Click = menuItem_Click;
                        control.Tag = menuItem;

                        _inputList.Add(menuItem, control);
                    }
                }
                ((MenuItem)_inputs[0].Tag).Checked = true;

                MenuItem seperatorMenu1 = new MenuItem();
                seperatorMenu1.Text = "-";
                rightMenu.MenuItems.Add(seperatorMenu1);

                this.Menu = _mainMenu;
                menu = rightMenu;
            }

            MenuItem connectionSettingsMenu = new MenuItem();
            connectionSettingsMenu.Text = "Connection &Settings";
            connectionSettingsMenu.Click += new EventHandler(connectionSettingsMenu_Click);

            _controlSettingsMenu.Text = "Control Settings";
            _controlSettingsMenu.Click += new EventHandler(_controlSettingsMenu_Click);

            MenuItem recorderMenu = new MenuItem();
            recorderMenu.Text = "&Recorder";

            _startRecorder.Text = "&Create Recording";
            _startRecorder.Click += new EventHandler(startRecorder_Click);

            _stopRecorder.Text = "&Stop Recording";
            _stopRecorder.Enabled = false;
            _stopRecorder.Click += new EventHandler(stopRecorder_Click);

            _loadRecorder.Text = "&Load Recording";
            _loadRecorder.Enabled = true;
            _loadRecorder.Popup += new EventHandler(_loadRecorder_Popup);

            MenuItem nullMenuItem = new MenuItem();
            nullMenuItem.Text = "--No Saved Recordings--";
            _loadRecorder.MenuItems.Add(nullMenuItem);

            recorderMenu.MenuItems.Add(_loadRecorder);
            recorderMenu.MenuItems.Add(_startRecorder);
            recorderMenu.MenuItems.Add(_stopRecorder);

            _connectionMenuItem.Text = "&Connect";
            _connectionMenuItem.Click += new EventHandler(connect_Click);

            _registerMenu.Text = "Re&gister";
            _registerMenu.Click += new EventHandler(_registerMenu_Click);

            MenuItem aboutMenuItem = new MenuItem();
            aboutMenuItem.Text = "&About";
            aboutMenuItem.Click += new EventHandler(aboutMenuItem_Click);

            MenuItem exitMenu = new MenuItem();
            exitMenu.Text = "E&xit";
            exitMenu.Click += new EventHandler(exitMenu_Click);

            menu.MenuItems.Add(recorderMenu);
            menu.MenuItems.Add(_connectionMenuItem);
            menu.MenuItems.Add(connectionSettingsMenu);
            menu.MenuItems.Add(_controlSettingsMenu);
            menu.MenuItems.Add(_registerMenu);
            menu.MenuItems.Add(aboutMenuItem);
            menu.MenuItems.Add(exitMenu);

            SetActivePanel(_inputs[0]);
            this.Closing += new CancelEventHandler(MobileRemoteUI_Closing);
            this.IsLoaded = true;
        }
Esempio n. 3
0
        public MobileRemoteUI()
        {
            this.IsLoaded = false;
            Properties.Settings.Load();
            L2CAPAPI.BthGetMode(out _initialRadioMode);
            _instance      = this;
            this.Load     += new EventHandler(MobileRemoteUI_Load);
            this.GotFocus += new EventHandler(MobileRemoteUI_GotFocus);
            _inputs        = new List <InputInterfaceControl>(
                new InputInterfaceControl[]
            {
                new InputInterfaceControl("Keyboard", _keyboardControl, Properties.Resources.keyboard, Properties.Resources.keyboard_down, Properties.Resources.keyboard_sel),
                new InputInterfaceControl("Mouse", _mouseControl, Properties.Resources.mouse, Properties.Resources.mouse_down, Properties.Resources.mouse_sel),
                new InputInterfaceControl("TouchPad", _touchPanel, Properties.Resources.touch, Properties.Resources.touch_down, Properties.Resources.touch_sel),
                //new InputInterfaceControl("Media", _mediaControl, Properties.Resources.media, Properties.Resources.media_down, Properties.Resources.media_sel),
                //new InputInterfaceControl("Present", _presentControl, Properties.Resources.present, Properties.Resources.present_down, Properties.Resources.present_sel)
            }
                );
            InitializeComponent();

            _hidWriter               = new BluetoothHidWriter();
            _hidWriter.Connected    += new EventHandler(_hidWriter_Connected);
            _hidWriter.Disconnected += new EventHandler(_hidWriter_Disconnected);

            //_presentControl.HidWriter = _hidWriter;
            //_mediaControl.HidWriter = _hidWriter;
            _mouseControl.HidWriter    = _hidWriter;
            _touchPanel.HidWriter      = _hidWriter;
            _keyboardControl.HidWriter = _hidWriter;
            _connectButton.HidWriter   = _hidWriter;

            XmlSerializer xs = new XmlSerializer(typeof(Classes.CustomInput));

            foreach (string customInput in Directory.GetFiles(Path.Combine(Utils.GetWorkingDirectory(), "CustomInputs")))
            {
                using (StreamReader fs = File.OpenText(customInput))
                {
                    Classes.CustomInput ci = (Classes.CustomInput)xs.Deserialize(fs);
                    ci.ScaleToResolution();

                    CustomInputControl    input            = new CustomInputControl(ci, _hidWriter);
                    InputInterfaceControl interfaceControl = new InputInterfaceControl
                                                             (
                        ci.Name, input,
                        CustomInputControl.GetBitmap(ci.Image),
                        CustomInputControl.GetBitmap(ci.DownImage),
                        CustomInputControl.GetBitmap(ci.SelectedImage)
                                                             );

                    _inputs.Add(interfaceControl);
                }
            }

            Menu menu = null;

            if (!Platform.IsWindowsMobileClassic)
            {
                int totalButtonsVisible = (buttonPanel1.Width / buttonPanel1.Height) - 2;

                if (_inputs.Count < totalButtonsVisible)
                {
                    // great...
                    buttonPanel1.Controls.Remove(_inputsButton);
                }
                else
                {
                    totalButtonsVisible--;
                }

                int count = 0;
                foreach (InputInterfaceControl control in _inputs)
                {
                    PushButton button = new PushButton();
                    button.DownImage     = control.Down;
                    button.Image         = control.Up;
                    button.Name          = control.Text;
                    button.Text          = control.Text;
                    button.SelectedImage = control.Sel;
                    button.Size          = new System.Drawing.Size(buttonPanel1.Height, buttonPanel1.Height);
                    button.TabIndex      = 11;
                    button.Dock          = DockStyle.Left;
                    button.Click        += new EventHandler(button_Click);
                    button.RightClick   += new EventHandler(_controlSettingsMenu_Click);

                    if (_inputList.Count < totalButtonsVisible)
                    {
                    }
                    else
                    {
                        button.Visible = false;
                    }
                    buttonPanel1.Controls.Add(button);
                    buttonPanel1.Controls.SetChildIndex(button, count++);

                    control.Click = button_Click;
                    control.Tag   = button;

                    _inputList.Add(button, control);
                }
                ((PushButton)_inputs[0].Tag).IsSelected = true;

                menu = _mainContextMenu;
            }
            else
            {
                this.buttonPanel1.Visible = false;

                _leftMenu      = new MenuItem();
                _leftMenu.Text = "";

                MenuItem rightMenu = new MenuItem();
                rightMenu.Text = "Menu";

                _mainMenu.MenuItems.Add(_leftMenu);
                _mainMenu.MenuItems.Add(rightMenu);

                int i = 0;
                foreach (InputInterfaceControl control in _inputs)
                {
                    if (!control.Control.RequiresTouchscreen)
                    {
                        MenuItem menuItem = new MenuItem();
                        menuItem.Text   = String.Format("&{1}", i++, control.Text);
                        menuItem.Click += new EventHandler(menuItem_Click);
                        rightMenu.MenuItems.Add(menuItem);

                        control.Click = menuItem_Click;
                        control.Tag   = menuItem;

                        _inputList.Add(menuItem, control);
                    }
                }
                ((MenuItem)_inputs[0].Tag).Checked = true;

                MenuItem seperatorMenu1 = new MenuItem();
                seperatorMenu1.Text = "-";
                rightMenu.MenuItems.Add(seperatorMenu1);

                this.Menu = _mainMenu;
                menu      = rightMenu;
            }


            MenuItem connectionSettingsMenu = new MenuItem();

            connectionSettingsMenu.Text   = "Connection &Settings";
            connectionSettingsMenu.Click += new EventHandler(connectionSettingsMenu_Click);

            _controlSettingsMenu.Text   = "Control Settings";
            _controlSettingsMenu.Click += new EventHandler(_controlSettingsMenu_Click);

            MenuItem recorderMenu = new MenuItem();

            recorderMenu.Text = "&Recorder";

            _startRecorder.Text   = "&Create Recording";
            _startRecorder.Click += new EventHandler(startRecorder_Click);

            _stopRecorder.Text    = "&Stop Recording";
            _stopRecorder.Enabled = false;
            _stopRecorder.Click  += new EventHandler(stopRecorder_Click);

            _loadRecorder.Text    = "&Load Recording";
            _loadRecorder.Enabled = true;
            _loadRecorder.Popup  += new EventHandler(_loadRecorder_Popup);

            MenuItem nullMenuItem = new MenuItem();

            nullMenuItem.Text = "--No Saved Recordings--";
            _loadRecorder.MenuItems.Add(nullMenuItem);

            recorderMenu.MenuItems.Add(_loadRecorder);
            recorderMenu.MenuItems.Add(_startRecorder);
            recorderMenu.MenuItems.Add(_stopRecorder);

            _connectionMenuItem.Text   = "&Connect";
            _connectionMenuItem.Click += new EventHandler(connect_Click);

            _registerMenu.Text   = "Re&gister";
            _registerMenu.Click += new EventHandler(_registerMenu_Click);

            MenuItem aboutMenuItem = new MenuItem();

            aboutMenuItem.Text   = "&About";
            aboutMenuItem.Click += new EventHandler(aboutMenuItem_Click);

            MenuItem exitMenu = new MenuItem();

            exitMenu.Text   = "E&xit";
            exitMenu.Click += new EventHandler(exitMenu_Click);

            menu.MenuItems.Add(recorderMenu);
            menu.MenuItems.Add(_connectionMenuItem);
            menu.MenuItems.Add(connectionSettingsMenu);
            menu.MenuItems.Add(_controlSettingsMenu);
            menu.MenuItems.Add(_registerMenu);
            menu.MenuItems.Add(aboutMenuItem);
            menu.MenuItems.Add(exitMenu);

            SetActivePanel(_inputs[0]);
            this.Closing += new CancelEventHandler(MobileRemoteUI_Closing);
            this.IsLoaded = true;
        }