/// <summary> /// Add windows and tools to the control ribbon. /// </summary> private void AddRibbonItems() { foreach (var aTool in this.toolItems) { var tool = aTool; RibbonPanel group = GetRibbonPanel(tool); RibbonButton toolItem = new RibbonButton(tool.Caption); SetupToolbarItem(tool, toolItem); group.Items.Add(toolItem); tool.ToolbarItemInitialized(); } foreach (var aGroupedTool in this.groupedToolItems) { var groupedTool = aGroupedTool; RibbonPanel group = GetRibbonPanel(groupedTool); RibbonButtonList hostList = null; if (groupedTool.IsButtonList) { hostList = new RibbonButtonList(); hostList.ButtonsSizeMode = RibbonElementSizeMode.DropDown; //hostList.MaxSizeMode = RibbonElementSizeMode.Compact; //hostList.MinSizeMode = RibbonElementSizeMode.Compact; //hostList.Text = "Hello"; group.Items.Add(hostList); } foreach (var tool in groupedTool.ToolbarItems) { RibbonButton toolItem = new RibbonButton(tool.Caption); if (groupedTool.IsButtonList) { hostList.Buttons.Add(toolItem); } else { group.Items.Add(toolItem); } SetupToolbarItem(tool, toolItem); } groupedTool.ToolbarItemInitialized(); } foreach (var aMenuTool in this.menuButtonToolItems) { var menuTool = aMenuTool.Value; RibbonPanel group = GetRibbonPanel(menuTool); RibbonButton theButton = new RibbonButton(menuTool.Caption); theButton.Style = RibbonButtonStyle.SplitDropDown; theButton.DropDownItemClicked += delegate(object sender, RibbonItemEventArgs e) { menuTool.MenuItemClicked(e.Item.Text); }; SetupToolbarItem(menuTool, theButton); group.Items.Add(theButton); foreach (var menuItem in menuTool.MenuItems) { RibbonItem item = new RibbonButton(menuItem); theButton.DropDownItems.Add(item); } if (theButton.DropDownItems.Count == 0) { theButton.Style = RibbonButtonStyle.Normal; } menuTool.ToolbarItemInitialized(); } foreach (var aComboTool in this.comboToolItems) { var comboTool = aComboTool; RibbonPanel group = GetRibbonPanel(comboTool); RibbonComboBox theButton = new RibbonComboBox(); theButton.Text = ""; // comboTool.Caption; theButton.AllowTextEdit = false; //if (theButton.Text.Length == 0) //{ // theButton.LabelWidth = 1; //} //else if (comboTool.Image == null) { RibbonLabel label = new RibbonLabel(); label.Text = comboTool.Caption; group.Items.Add(label); } theButton.Image = comboTool.Image; //theButton.SmallImage = comboTool.SmallImage; //theButton.CheckOnClick = comboTool.CheckOnClick; //theButton.Style = RibbonButtonStyle.SplitDropDown; theButton.DropDownItemClicked += delegate(object sender, RibbonItemEventArgs e) { comboTool.ComboItemClicked(e.Item.Text); }; comboTool.ComboSelectedTextChanged += delegate(object o, Core.Window.Events.ComboSelectedTextChangedEventArgs e) { //theButton.SelectedValue = e.Text; theButton.TextBoxText = e.Text; }; this.toolToUiMap[comboTool] = theButton; group.Items.Add(theButton); //comboTool.ComboItemsChanged; foreach (var comboItem in comboTool.ComboItems) { RibbonItem item = new RibbonButton(comboItem); theButton.DropDownItems.Add(item); } comboTool.ComboItemsAdded += delegate(object sender, Core.Window.Events.ComboItemsAddedEvent e) { theButton.DropDownItems.Clear(); foreach (var item in comboTool.ComboItems) { theButton.DropDownItems.Add(new RibbonButton(item)); } }; comboTool.ToolbarItemInitialized(); } foreach (var aUpDownTool in this.upDownToolItems) { var upDownTool = aUpDownTool; RibbonPanel group = GetRibbonPanel(upDownTool); RibbonUpDown theButton = new RibbonUpDown(); theButton.Text = upDownTool.Caption; theButton.Image = upDownTool.Image; this.toolToUiMap[upDownTool] = theButton; theButton.Value = upDownTool.InitialValue.ToString(); theButton.UpButtonClicked += delegate(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { int val = 0; if (int.TryParse(theButton.Value, out val)) { val += upDownTool.Interval; if (val <= upDownTool.MaximumValue) { upDownTool.Value = val; theButton.Value = val.ToString(); theButton.TextBoxText = theButton.Value; upDownTool.Click(); } } } }; theButton.DownButtonClicked += delegate(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { int val = 0; if (int.TryParse(theButton.Value, out val)) { val -= upDownTool.Interval; if (val >= upDownTool.MinimumValue) { upDownTool.Value = val; theButton.Value = val.ToString(); theButton.TextBoxText = theButton.Value; upDownTool.Click(); } } } }; ////theButton. ////theButton.SmallImage = comboTool.SmallImage; ////theButton.CheckOnClick = comboTool.CheckOnClick; ////theButton.Style = RibbonButtonStyle.SplitDropDown; //theButton.DropDownItemClicked += // delegate(object sender, RibbonItemEventArgs e) // { // upDownTool.ComboItemClicked(e.Item.Text); // }; //group.Items.Add(theButton); //upDownTool.ButtonStatusChanged += // delegate(object o, Window.ToolbarItemEvent e) // { // theButton.Enabled = e.IsEnabled; // }; ////comboTool.ComboItemsChanged; //foreach (var comboItem in upDownTool.ComboItems) //{ // RibbonItem item = new RibbonButton(comboItem); // theButton.DropDownItems.Add(item); //} //upDownTool.ComboItemsAdded += // delegate(object sender, ComboItemsAddedEvent e) // { // theButton.DropDownItems.Clear(); // foreach (var item in upDownTool.ComboItems) // { // theButton.DropDownItems.Add(new RibbonButton(item)); // } // }; upDownTool.ToolbarItemInitialized(); } foreach (var hostItem in this.hostedItems) { RibbonPanel group = GetRibbonPanel(hostItem); RibbonButton theButton = new RibbonButton(); theButton.Text = hostItem.Caption; theButton.Image = hostItem.Image; theButton.SmallImage = hostItem.SmallImage; theButton.Style = RibbonButtonStyle.DropDown; this.toolToUiMap[hostItem] = theButton; var uiHost = new RibbonHost(); uiHost.HostedControl = hostItem.UserControl; theButton.DropDownItems.Add(uiHost); hostItem.UserControlFinished += delegate { uiHost.HostCompleted(); }; group.Items.Add(theButton); hostItem.ToolbarItemInitialized(); } this.ribbon.Tabs.Sort(TabSorter); }
private void PopulateUI() { ribbonEquipmentSetting = new RibbonTab(); ribbonEquipmentSetting.Text = "Equipment Setting"; #region Test Connection - Populate UI RibbonPanel connectionTest = new RibbonPanel(); connectionTest.Text = "Connection Test"; ribbonEquipmentSetting.Panels.Add(connectionTest); // Get equipment lists Panel pnlEquipment = new Panel(); pnlEquipment.Size = new Size(100, 55); pnlEquipment.AutoScroll = true; //pnlEquipment.BackColor = Color.Transparent; cbEquipment = new CheckBox[EquipmentList.Count]; for (int index = 0; index < EquipmentList.Count; index++) { cbEquipment[index] = new CheckBox(); cbEquipment[index].Text = EquipmentList[index]; cbEquipment[index].AutoCheck = false; cbEquipment[index].Appearance = Appearance.Button; cbEquipment[index].TextAlign = ContentAlignment.MiddleLeft; cbEquipment[index].AutoSize = false; cbEquipment[index].Size = new Size(80, 20); if (TestConnection(EquipmentList[index])) { cbEquipment[index].BackColor = Color.Green; } else { cbEquipment[index].BackColor = Color.Red; } if (pnlEquipment.Controls.Count == 0) { pnlEquipment.Controls.Add(cbEquipment[index]); } else { cbEquipment[index].Location = new Point(pnlEquipment.Controls[pnlEquipment.Controls.Count - 1].Location.X, pnlEquipment.Controls[pnlEquipment.Controls.Count - 1].Location.Y + cbEquipment[index].Height); pnlEquipment.Controls.Add(cbEquipment[index]); } } RibbonHost pnlEquipmentHost = new RibbonHost(); pnlEquipmentHost.HostedControl = pnlEquipment; connectionTest.Items.Add(pnlEquipmentHost); Button btTestCon = new Button(); btTestCon.Text = "Test"; btTestCon.Size = new Size(50, 55); btTestCon.FlatStyle = FlatStyle.Popup; btTestCon.BackColor = Color.LightBlue; btTestCon.Click += new EventHandler(btTestCon_Click); RibbonHost btTestConHost = new RibbonHost(); btTestConHost.HostedControl = btTestCon; connectionTest.Items.Add(btTestConHost); #endregion }
private void PopulateUI_CameraMic() { #region Camera - Populate UI // Panel for Camera RibbonPanel cameraSetting = new RibbonPanel(); cameraSetting.Text = "Camera Setting"; ribbonEquipmentSetting.Panels.Add(cameraSetting); // Picture Box Settings pictureBox = new PictureBox(); pictureBox.Size = new System.Drawing.Size(100, 50); pictureBox.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox.DoubleClick += new EventHandler(pictureBox_DoubleClick); RibbonHost pictureBoxHost = new RibbonHost(); pictureBoxHost.HostedControl = pictureBox; pictureBoxHost.ToolTip = "Click to enlarge"; // Popup Picture Box Settings pictureBoxPopup = new PictureBox(); pictureBoxPopup.Size = new System.Drawing.Size(ResWidth, ResHeight); pictureBoxPopup.SizeMode = PictureBoxSizeMode.StretchImage; popupBox = new Form(); popupBox.MaximizeBox = false; popupBox.ControlBox = true; popupBox.FormBorderStyle = FormBorderStyle.FixedSingle; popupBox.Size = new System.Drawing.Size(pictureBoxPopup.Size.Width, pictureBoxPopup.Size.Height); popupBox.FormClosing += new FormClosingEventHandler(popupBox_FormClosing); popupBox.StartPosition = FormStartPosition.CenterScreen; popupBox.Controls.Add(pictureBoxPopup); pictureBoxPopup.Location = new Point(popupBox.Location.X, popupBox.Location.Y); Panel panelCam = new Panel(); panelCam.Size = new Size(100, 50); //panelCam.BackColor = Color.Transparent; // On/Off Button Settings btOnOffCam = new Button(); btOnOffCam.Text = "On"; btOnOffCam.Size = new Size(100, 20); btOnOffCam.Enabled = true; btOnOffCam.FlatStyle = FlatStyle.Popup; btOnOffCam.BackColor = Color.LightBlue; btOnOffCam.Click += new EventHandler(btOnOffCam_Click); panelCam.Controls.Add(btOnOffCam); // Camera List cbCamList = new ComboBox(); cbCamList.Size = new Size(100, 20); cbCamList.SelectedIndexChanged += new EventHandler(cbCamList_SelectedIndexChanged); cbCamList.Location = new Point(panelCam.Controls[panelCam.Controls.Count - 1].Location.X, panelCam.Controls[panelCam.Controls.Count - 1].Location.Y + btOnOffCam.Height + 5); panelCam.Controls.Add(cbCamList); RibbonHost panelCamHost = new RibbonHost(); panelCamHost.HostedControl = panelCam; // Add items to Camera Setting Panel cameraSetting.Items.Add(pictureBoxHost); cameraSetting.Items.Add(panelCamHost); #endregion #region Mic - Populate UI // Panel for mic RibbonPanel micSetting = new RibbonPanel(); micSetting.Text = "MIC Setting"; ribbonEquipmentSetting.Panels.Add(micSetting); Panel panelMic1 = new Panel(); panelMic1.Size = new Size(100, 50); //panelMic1.BackColor = Color.Transparent; Panel panelMic2 = new Panel(); panelMic2.Size = new Size(100, 50); //panelMic2.BackColor = Color.Transparent; // Volume Indicator Progress Bar Settings pbVolIndicator = new ProgressBar(); pbVolIndicator.Size = new Size(100, 20); pbVolIndicator.Maximum = 100; panelMic1.Controls.Add(pbVolIndicator); // Volume Indicator Background Worker Settings bwVolIndicator = new BackgroundWorker(); bwVolIndicator.DoWork += new DoWorkEventHandler(bwVolIndicator_DoWork); bwVolIndicator.ProgressChanged += new ProgressChangedEventHandler(bwVolIndicator_ProgressChanged); bwVolIndicator.WorkerSupportsCancellation = true; bwVolIndicator.WorkerReportsProgress = true; bwVolIndicator.RunWorkerAsync(); // Volume Threshold Track Bar Settings tbVolThres = new TrackBar(); tbVolThres.AutoSize = false; tbVolThres.Size = new Size(100, 30); tbVolThres.Maximum = 100; tbVolThres.TickStyle = TickStyle.None; tbVolThres.Scroll += new EventHandler(tbVolThres_Scroll); tbVolThres.Location = new Point(panelMic1.Controls[panelMic1.Controls.Count - 1].Location.X, panelMic1.Controls[panelMic1.Controls.Count - 1].Location.Y + pbVolIndicator.Height + 5); panelMic1.Controls.Add(tbVolThres); // Volume Threshold Label Settings lblVolThres = new Label(); lblVolThres.TextAlign = ContentAlignment.MiddleLeft; lblVolThres.BackColor = Color.LightYellow; lblVolThres.Size = new Size(100, 20); lblVolThres_val(0); panelMic2.Controls.Add(lblVolThres); // MIC List cbMicList = new ComboBox(); cbMicList.Size = new Size(100, 20); cbMicList.SelectedIndexChanged += new EventHandler(cbMicList_SelectedIndexChanged); cbMicList.Location = new Point(panelMic2.Controls[panelMic2.Controls.Count - 1].Location.X, panelMic2.Controls[panelMic2.Controls.Count - 1].Location.Y + lblVolThres.Height + 5); panelMic2.Controls.Add(cbMicList); RibbonHost panelMic1Host = new RibbonHost(); panelMic1Host.HostedControl = panelMic1; RibbonHost panelMic2Host = new RibbonHost(); panelMic2Host.HostedControl = panelMic2; micSetting.Items.Add(panelMic1Host); micSetting.Items.Add(panelMic2Host); #endregion }
private void PopulateUI() { ribbonEquipmentSetting = new RibbonTab(); ribbonEquipmentSetting.Text = "Equipment Setting"; #region Test Connection - Populate UI RibbonPanel connectionTest = new RibbonPanel(); connectionTest.Text = "Connection Test"; ribbonEquipmentSetting.Panels.Add(connectionTest); // Get equipment lists Panel pnlEquipment = new Panel(); pnlEquipment.Size = new Size(100, 55); pnlEquipment.AutoScroll = true; //pnlEquipment.BackColor = Color.Transparent; cbEquipment = new CheckBox[EquipmentList.Count]; for (int index = 0; index < EquipmentList.Count; index++) { cbEquipment[index] = new CheckBox(); cbEquipment[index].Text = EquipmentList[index]; cbEquipment[index].AutoCheck = false; cbEquipment[index].Appearance = Appearance.Button; cbEquipment[index].TextAlign = ContentAlignment.MiddleLeft; cbEquipment[index].AutoSize = false; cbEquipment[index].Size = new Size(80, 20); if (TestConnection(EquipmentList[index])) { cbEquipment[index].BackColor = Color.Green; } else { cbEquipment[index].BackColor = Color.Red; } if (pnlEquipment.Controls.Count == 0) { pnlEquipment.Controls.Add(cbEquipment[index]); } else { cbEquipment[index].Location = new Point(pnlEquipment.Controls[pnlEquipment.Controls.Count - 1].Location.X, pnlEquipment.Controls[pnlEquipment.Controls.Count - 1].Location.Y + cbEquipment[index].Height); pnlEquipment.Controls.Add(cbEquipment[index]); } } RibbonHost pnlEquipmentHost = new RibbonHost(); pnlEquipmentHost.HostedControl = pnlEquipment; connectionTest.Items.Add(pnlEquipmentHost); Button btTestCon = new Button(); btTestCon.Text = "Test"; btTestCon.Size = new Size(50, 55); btTestCon.FlatStyle = FlatStyle.Popup; btTestCon.BackColor = Color.LightBlue; btTestCon.Click += new EventHandler(btTestCon_Click); RibbonHost btTestConHost = new RibbonHost(); btTestConHost.HostedControl = btTestCon; connectionTest.Items.Add(btTestConHost); #endregion #region Load EDID Spec - Populate UI RibbonPanel LoadEDIDSpec = new RibbonPanel(); LoadEDIDSpec.Text = "Load EDID Spec"; ribbonEquipmentSetting.Panels.Add(LoadEDIDSpec); Panel pnlLoadEDID = new Panel(); pnlLoadEDID.Size = new Size(100, 55); pnlLoadEDID.AutoScroll = true; cbPanel = new ComboBox(); cbPanel.Items.Add("WXGA panel"); cbPanel.Items.Add("Full HD panel"); cbPanel.Items.Add("UHD panel"); cbPanel.Items.Add("UHD panel - Laser"); cbPanel.Size = new Size(80, 20); pnlLoadEDID.Controls.Add(cbPanel); cbBrand = new ComboBox(); cbBrand.Items.Add("PHILIPS"); cbBrand.Items.Add("SANYO"); cbBrand.Items.Add("MAGNAVOX"); cbBrand.Size = new Size(80, 20); cbBrand.Location = new Point(pnlLoadEDID.Controls[pnlLoadEDID.Controls.Count - 1].Location.X, pnlLoadEDID.Controls[pnlLoadEDID.Controls.Count - 1].Location.Y + cbBrand.Height); pnlLoadEDID.Controls.Add(cbBrand); cbHDMI = new ComboBox(); cbHDMI.Items.Add("HDMI1"); cbHDMI.Items.Add("HDMI2"); cbHDMI.Items.Add("HDMI3"); cbHDMI.Items.Add("HDMI4"); cbHDMI.Items.Add("HDMI5"); cbHDMI.Size = new Size(80, 20); cbHDMI.Location = new Point(pnlLoadEDID.Controls[pnlLoadEDID.Controls.Count - 1].Location.X, pnlLoadEDID.Controls[pnlLoadEDID.Controls.Count - 1].Location.Y + cbHDMI.Height); pnlLoadEDID.Controls.Add(cbHDMI); RibbonHost pnlLoadEDIDHost = new RibbonHost(); pnlLoadEDIDHost.HostedControl = pnlLoadEDID; LoadEDIDSpec.Items.Add(pnlLoadEDIDHost); Button btLoadEDID = new Button(); btLoadEDID.Text = "Load"; btLoadEDID.Size = new Size(55, 22); btLoadEDID.FlatStyle = FlatStyle.Popup; btLoadEDID.BackColor = Color.LightBlue; btLoadEDID.Click += new EventHandler(btLoadEDID_Click); RibbonHost btLoadEDIDHost = new RibbonHost(); btLoadEDIDHost.HostedControl = btLoadEDID; LoadEDIDSpec.Items.Add(btLoadEDIDHost); Button btRefEDID = new Button(); btRefEDID.Text = "Refresh"; btRefEDID.Size = new Size(55, 22); btRefEDID.FlatStyle = FlatStyle.Popup; btRefEDID.BackColor = Color.LightBlue; btRefEDID.Click += new EventHandler(btRefEDID_Click); RibbonHost btRefEDIDHost = new RibbonHost(); btRefEDIDHost.HostedControl = btRefEDID; LoadEDIDSpec.Items.Add(btRefEDIDHost); Button btViewEDID = new Button(); btViewEDID.Text = "View Data"; btViewEDID.Size = new Size(55, 47); btViewEDID.FlatStyle = FlatStyle.Popup; btViewEDID.BackColor = Color.LightBlue; btViewEDID.Click += new EventHandler(btViewEDID_Click); RibbonHost btViewEDIDHost = new RibbonHost(); btViewEDIDHost.HostedControl = btViewEDID; LoadEDIDSpec.Items.Add(btViewEDIDHost); dgvSpec = new DataGridView(); dgvSpec.Size = new Size(500, 300); dgvSpec.Location = new Point(20, 20); dgvSpec.ColumnCount = 16; dgvSpec.ColumnHeadersVisible = true; dgvSpec.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dgvSpec.RowHeadersVisible = false; DataGridViewCellStyle columnHeaderStyle = new DataGridViewCellStyle(); columnHeaderStyle.BackColor = Color.Beige; columnHeaderStyle.Font = new Font("Verdana", 10, FontStyle.Bold); columnHeaderStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgvSpec.ColumnHeadersDefaultCellStyle = columnHeaderStyle; for (int i = 0; i < 16; i++) { dgvSpec.Columns[i].Name = string.Format("{0:X}", i); dgvSpec.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; } Label lblSpec = new Label(); lblSpec.Text = "Spec EDID Data"; //lblSpec.Font = new Font("Verdana", 10, FontStyle.Bold); lblSpec.Location = new Point(dgvSpec.Location.X + 200, dgvSpec.Location.Y - 15); dgvActual = new DataGridView(); dgvActual.Size = new Size(500, 300); dgvActual.Location = new Point(dgvSpec.Location.X + dgvSpec.Size.Width + 50, dgvSpec.Location.Y); Label lblActual = new Label(); lblActual.Text = "Actual EDID Data"; //lblActual.Font = new Font("Verdana", 10, FontStyle.Bold); lblActual.Location = new Point(dgvActual.Location.X + 200, dgvActual.Location.Y - 15); popupBox = new Form(); popupBox.MaximizeBox = false; popupBox.ControlBox = true; popupBox.FormBorderStyle = FormBorderStyle.FixedSingle; popupBox.Size = new System.Drawing.Size(1100, 400); popupBox.FormClosing += new FormClosingEventHandler(popupBox_FormClosing); popupBox.StartPosition = FormStartPosition.CenterScreen; popupBox.Controls.Add(dgvActual); popupBox.Controls.Add(lblActual); popupBox.Controls.Add(dgvSpec); popupBox.Controls.Add(lblSpec); /*TextBox tbEDID = new TextBox(); * tbEDID.Size = new Size(50, 20); * RibbonHost tbEDIDHost = new RibbonHost(); * tbEDIDHost.HostedControl = tbEDID; * LoadEDIDSpec.Items.Add(tbEDIDHost);*/ #endregion }