public DialogResult ShowDialog(MobileRemoteUI parentForm, WaitHandle waitResult, AddressSelector.BluetoothDevice device, BluetoothHidWriter hidWriter) { _statusLabel.Text = "Connecting..."; _hidWriter = hidWriter; _waitResult = waitResult; if (device.Address > 0) { _existingMachine.Dock = DockStyle.Fill; _existingMachine.Visible = true; _newMachineLabel.Visible = false; } else { _newMachineLabel.Dock = DockStyle.Fill; _newMachineLabel.Visible = true; _existingMachine.Visible = false; } timer1.Enabled = true; if (waitResult.WaitOne(1000, false)) { //return DialogResult.OK; } try { return base.ShowDialog(parentForm); } finally { timer1.Enabled = false; } }
private void AddMenuItems(MobileRemoteUI parentForm, Bitmap expand, Bitmap menuDown, Bitmap menuUp, Font font, List <ImageLabel> labels, int y, Menu.MenuItemCollection menuItems, IList container) { _clickedButton = null; foreach (MenuItem menuItem in menuItems) { // TODO: handle disabled menu items ImageLabel label = new ImageLabel(this); label.Height = (int)(60 * MobileRemoteUI.ScaleFactor.Height); label.Width = this.Width + 4; label.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; label.Location = new Point(-2, y); label.Click += new EventHandler(label_Click); label.Text = menuItem.Text.Replace("&", ""); label.Font = font; label.MenuItem = menuItem; label.SelectedImage = menuDown; label.RegularImage = menuUp; label.ExpandImage = expand; label.ItemActivated += new EventHandler(label_ItemActivated); label.Tag = menuItem; labels.Add(label); if (labels != container) { container.Add(label); } y += label.Height + 1; } }
public DialogResult ShowDialog(MobileRemoteUI parentForm, WaitHandle waitResult, AddressSelector.BluetoothDevice device, BluetoothHidWriter hidWriter) { _statusLabel.Text = "Connecting..."; _hidWriter = hidWriter; _waitResult = waitResult; if (device.Address > 0) { _existingMachine.Dock = DockStyle.Fill; _existingMachine.Visible = true; _newMachineLabel.Visible = false; } else { _newMachineLabel.Dock = DockStyle.Fill; _newMachineLabel.Visible = true; _existingMachine.Visible = false; } timer1.Enabled = true; if (waitResult.WaitOne(1000, false)) { //return DialogResult.OK; } try { return(base.ShowDialog(parentForm)); } finally { timer1.Enabled = false; } }
protected void ScaleWindow(MobileRemoteUI parentForm, bool fitToContents) { if (fitToContents) { ScaleToContents(); } else { this._contentPanel.Dock = DockStyle.None; this._contentPanel.Width = this.Width - 4; this._contentPanel.Height = this.Height - 4 - ((_showMenuBar) ? this.titleBar1.Height : 0); this._contentPanel.Location = new Point(2, ((_showMenuBar) ? this.titleBar1.Bottom : 0) + 2); this._contentPanel.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; } PerformLayout(parentForm); }
protected void PerformLayout(MobileRemoteUI parentForm) { Point location; int xStart = (parentForm.Width - this.Width) / 2; switch (this.Alignment) { case VerticalAlignment.Top: { location = new Point(xStart, 0); } break; case VerticalAlignment.Bottom: { location = new Point(xStart, parentForm.Bottom - this.Height); } break; default: { location = new Point(xStart, parentForm.Height / 2 - this.Height / 2); } break; } if (this.IsAnimated) { _endLocation = location; _yDiff = (parentForm.Bottom - _endLocation.Y) / 8; _timer.Interval = 20; this.Location = new Point(xStart, parentForm.Bottom); if (_isLoaded) { _timer.Enabled = true; } } else { this.Location = location; } }
public DialogResult ShowDialog(MobileRemoteUI parentForm, Menu menu) { this._contentPanel.Controls.Clear(); _labels = new List<ImageLabel>(); _ui = parentForm; //_roundedBar.Dock = DockStyle.Top; //this.Controls.Add(_roundedBar); AddMenuItems(parentForm, _expand, _menuDown, _menuUp, _font, _labels, 5, menu.MenuItems, this._contentPanel.Controls); this._contentPanel.BackColor = Color.Black; _currentLabels = _labels; HandleSelections(_labels[0]); return base.ShowDialog(parentForm, true); }
public DialogResult ShowDialog(MobileRemoteUI parentForm, Menu menu) { this._contentPanel.Controls.Clear(); _labels = new List <ImageLabel>(); _ui = parentForm; //_roundedBar.Dock = DockStyle.Top; //this.Controls.Add(_roundedBar); AddMenuItems(parentForm, _expand, _menuDown, _menuUp, _font, _labels, 5, menu.MenuItems, this._contentPanel.Controls); this._contentPanel.BackColor = Color.Black; _currentLabels = _labels; HandleSelections(_labels[0]); return(base.ShowDialog(parentForm, true)); }
public virtual DialogResult ShowDialog(MobileRemoteUI parentForm, bool fitToContents) { // TODO: figure out scaling for this form // perhaps have a global xScale and yScale factor _inUse = true; this.titleBar1.Height = (int)(MobileRemoteUI.ScaleFactor.Height * this.titleBar1.Height); if (Platform.IsWindowsMobileStandard) { this.Dock = DockStyle.Fill; } else { this.Height = Math.Min(parentForm.Height, (int)(MobileRemoteUI.ScaleFactor.Height * this.Height)); this.Width = Math.Min(parentForm.Width - _widthPadding, (int)(MobileRemoteUI.ScaleFactor.Width * (this.titleBar1.Width - _widthPadding))); this.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; } this.titleBar1.Visible = _showMenuBar; if (!_alreadySized) { _alreadySized = true; ScaleWindow(parentForm, fitToContents); } titleBar1.Text = this.Text; using (Graphics gxSrc = parentForm.CreateGraphics()) { Cursor.Current = Cursors.WaitCursor; parentForm.SuspendLayout(); AlphaLayerControl alphaControl = null; if (!Platform.IsWindowsMobileStandard) { alphaControl = new AlphaLayerControl(gxSrc, parentForm.ClientSize, 50); alphaControl.Location = new Point(0, 0); alphaControl.Size = parentForm.ClientSize; alphaControl.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; alphaControl.Click += new EventHandler(alphaControl_Click); parentForm.Controls.Add(alphaControl); parentForm.Controls.SetChildIndex(alphaControl, 0); AlphaLayerSet(alphaControl); } parentForm.Controls.Add(this); parentForm.Controls.SetChildIndex(this, 0); //parentForm.ResumeLayout(true); Cursor.Current = Cursors.Default; this.SetFocus(); try { MainMenu previousMenu = null; if (Platform.IsWindowsMobileStandard) { previousMenu = parentForm.Menu; parentForm.Menu = new MainMenu(); parentForm.Menu.MenuItems.Add(new MenuItem()); parentForm.Menu.MenuItems.Add(new MenuItem()); parentForm.Menu.MenuItems[0].Text = "OK"; parentForm.Menu.MenuItems[0].Click += new EventHandler(okButton_Click); parentForm.Menu.MenuItems[1].Text = "Cancel"; parentForm.Menu.MenuItems[1].Click += new EventHandler(cancelButton_Click); } try { OnLoad(); _isLoaded = true; HookFocus(_contentPanel.Controls); parentForm.ResumeLayout(); if (this.IsAnimated) { _timer.Enabled = true; } while (!_waitHandle.WaitOne(20, false)) { Application.DoEvents(); } _waitHandle.Reset(); return(this.DialogResult); } finally { if (null != previousMenu) { parentForm.SuspendLayout(); parentForm.Menu = previousMenu; parentForm.ResumeLayout(); } } } finally { _isLoaded = false; _timer.Enabled = false; parentForm.SuspendLayout(); parentForm.Controls.Remove(this); if (null != alphaControl) { parentForm.Controls.Remove(alphaControl); } parentForm.ResumeLayout(true); parentForm.FocusActive(); OnClosed(); _inUse = false; } } }
public virtual DialogResult ShowDialog(MobileRemoteUI parentForm) { return(ShowDialog(parentForm, false)); }
private void AddMenuItems(MobileRemoteUI parentForm, Bitmap expand, Bitmap menuDown, Bitmap menuUp, Font font, List<ImageLabel> labels, int y, Menu.MenuItemCollection menuItems, IList container) { _clickedButton = null; foreach (MenuItem menuItem in menuItems) { // TODO: handle disabled menu items ImageLabel label = new ImageLabel(this); label.Height = (int)(60 * MobileRemoteUI.ScaleFactor.Height); label.Width = this.Width + 4; label.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; label.Location = new Point(-2, y); label.Click += new EventHandler(label_Click); label.Text = menuItem.Text.Replace("&", ""); label.Font = font; label.MenuItem = menuItem; label.SelectedImage = menuDown; label.RegularImage = menuUp; label.ExpandImage = expand; label.ItemActivated += new EventHandler(label_ItemActivated); label.Tag = menuItem; labels.Add(label); if (labels != container) { container.Add(label); } y += label.Height + 1; } }
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; }
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; }