diff --git a/QEMUWF/Core.cs b/QEMUWF/Core.cs index 19ea0a7..ef4af92 100644 --- a/QEMUWF/Core.cs +++ b/QEMUWF/Core.cs @@ -1,32 +1,48 @@ using Microsoft.VisualBasic.Devices; using System; -using System.Collections.Generic; using System.Drawing; using System.IO; -using System.Linq; -using System.Text; +using System.Management; using System.Windows.Forms; + namespace QEMUWF { - class Core + internal class Core { - public static void SetStaticControls(TrackBar trackBar, ComboBox comboBox, ComboBox comboBox2, TabControl tabControl, NumericUpDown numericUpDown) + public static void SetStaticControls(TrackBar trackBar, TrackBar trackBar1, ComboBox comboBox, ComboBox comboBox2, TabControl tabControl, NumericUpDown numericUpDown) { ComputerInfo info = new ComputerInfo(); ulong h = info.TotalPhysicalMemory; h = h / (1024 * 1024); + trackBar.Minimum = 2; trackBar.Maximum = (int)h; trackBar.TickFrequency = 128; trackBar.SmallChange = trackBar.Maximum / trackBar.TickFrequency; + ulong v = h; + foreach (ManagementObject mo in new ManagementObjectSearcher("select AdapterRAM from Win32_VideoController").Get()) + { + var vram = mo.Properties["AdapterRAM"].Value as ulong?; + if (vram.HasValue) + { + v = (ulong)(vram / 1024 * 1024); + } + } + trackBar1.Maximum = (int)v; + trackBar1.TickFrequency = 128; + trackBar1.SmallChange = trackBar1.Maximum / trackBar1.TickFrequency; + trackBar1.Minimum = 2; + trackBar1.Maximum = (int)h; + comboBox2.SelectedIndex = 0; comboBox.SelectedIndex = 0; tabControl.Location = new Point(0, -25); tabControl.Size = new Size(438, 480); numericUpDown.Maximum = Environment.ProcessorCount; } - public static void SetDynamicControls(bool isCombox, bool isTrackbar, ComboBox comboBox, ComboBox comboBox2, - RadioButton radioButton1, RadioButton radioButton2, RadioButton radioButton3, TrackBar trackBar1, Label label10) + + public static void SetDynamicControls(bool isCombox, bool isTrackbar, bool isTrackbar2, ComboBox comboBox, ComboBox comboBox2, + RadioButton radioButton1, RadioButton radioButton2, RadioButton radioButton3, TrackBar trackBar, TrackBar trackBar1, Label label, Label label1) { if (isCombox) { @@ -57,10 +73,15 @@ public static void SetDynamicControls(bool isCombox, bool isTrackbar, ComboBox c } if (isTrackbar) { - label10.Text = "Selected RAM: " + trackBar1.Value.ToString() + " MB"; + label.Text = "Selected RAM: " + trackBar.Value.ToString() + " MB"; + } + if (isTrackbar2) + { + label1.Text = "Selected Video RAM: " + trackBar1.Value.ToString() + " MB"; } } - public static void SetDynamicControls2(bool diskSelec, RadioButton newdisk, RadioButton existig, Label sizeLbl, Label Formatlbl, NumericUpDown nmrSize, + + public static void SetDynamicControls2(bool diskSelec, RadioButton newdisk, RadioButton existig, Label sizeLbl, Label Formatlbl, NumericUpDown nmrSize, TextBox formatTxt, TextBox pathTxt, Button brsButton, CheckBox allocChexbox) { if (diskSelec) @@ -86,10 +107,10 @@ public static void SetDynamicControls2(bool diskSelec, RadioButton newdisk, Radi } } } + public static void Navigate(int direction, TabControl tabControl) { - - if (direction==1) + if (direction == 1) { if (tabControl.SelectedIndex != tabControl.TabCount - 1) tabControl.SelectedIndex++; } @@ -99,4 +120,4 @@ public static void Navigate(int direction, TabControl tabControl) } } } -} +} \ No newline at end of file diff --git a/QEMUWF/Form3.Designer.cs b/QEMUWF/Form3.Designer.cs index 7042bcc..e262a3f 100644 --- a/QEMUWF/Form3.Designer.cs +++ b/QEMUWF/Form3.Designer.cs @@ -45,6 +45,8 @@ private void InitializeComponent() this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.tabPage2 = new System.Windows.Forms.TabPage(); + this.comboBox4 = new System.Windows.Forms.ComboBox(); + this.label15 = new System.Windows.Forms.Label(); this.trackBar2 = new System.Windows.Forms.TrackBar(); this.label10 = new System.Windows.Forms.Label(); this.trackBar1 = new System.Windows.Forms.TrackBar(); @@ -73,8 +75,7 @@ private void InitializeComponent() this.label11 = new System.Windows.Forms.Label(); this.tabPage4 = new System.Windows.Forms.TabPage(); this.tabPage5 = new System.Windows.Forms.TabPage(); - this.label15 = new System.Windows.Forms.Label(); - this.comboBox4 = new System.Windows.Forms.ComboBox(); + this.label16 = new System.Windows.Forms.Label(); this.flowLayoutPanel1.SuspendLayout(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); @@ -169,10 +170,10 @@ private void InitializeComponent() this.tabPage1.Controls.Add(this.label3); this.tabPage1.Controls.Add(this.label2); this.tabPage1.Controls.Add(this.label1); - this.tabPage1.Location = new System.Drawing.Point(4, 25); + this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(430, 420); + this.tabPage1.Size = new System.Drawing.Size(430, 423); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "tabPage1"; // @@ -235,13 +236,14 @@ private void InitializeComponent() this.label1.Font = new System.Drawing.Font("Segoe UI Semibold", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label1.Location = new System.Drawing.Point(9, 13); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(397, 32); + this.label1.Size = new System.Drawing.Size(398, 32); this.label1.TabIndex = 0; this.label1.Text = "Welcome to Create new VM wizard"; // // tabPage2 // this.tabPage2.BackColor = System.Drawing.SystemColors.Window; + this.tabPage2.Controls.Add(this.label16); this.tabPage2.Controls.Add(this.comboBox4); this.tabPage2.Controls.Add(this.label15); this.tabPage2.Controls.Add(this.trackBar2); @@ -258,12 +260,39 @@ private void InitializeComponent() this.tabPage2.Controls.Add(this.comboBox2); this.tabPage2.Controls.Add(this.label6); this.tabPage2.Controls.Add(this.label5); - this.tabPage2.Location = new System.Drawing.Point(4, 25); + this.tabPage2.Location = new System.Drawing.Point(4, 22); this.tabPage2.Name = "tabPage2"; this.tabPage2.Padding = new System.Windows.Forms.Padding(3); - this.tabPage2.Size = new System.Drawing.Size(430, 420); + this.tabPage2.Size = new System.Drawing.Size(430, 423); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "tabPage2"; + this.tabPage2.Click += new System.EventHandler(this.tabPage2_Click); + // + // comboBox4 + // + this.comboBox4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBox4.FormattingEnabled = true; + this.comboBox4.Items.AddRange(new object[] { + "none", + "std ", + "cirrus", + "vmware ", + "qxl", + "virtio"}); + this.comboBox4.Location = new System.Drawing.Point(118, 174); + this.comboBox4.Name = "comboBox4"; + this.comboBox4.Size = new System.Drawing.Size(169, 21); + this.comboBox4.TabIndex = 15; + this.comboBox4.SelectedIndexChanged += new System.EventHandler(this.comboBox4_SelectedIndexChanged); + // + // label15 + // + this.label15.AutoSize = true; + this.label15.Location = new System.Drawing.Point(16, 174); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(32, 13); + this.label15.TabIndex = 14; + this.label15.Text = "GPU:"; // // trackBar2 // @@ -275,13 +304,14 @@ private void InitializeComponent() this.trackBar2.SmallChange = 2; this.trackBar2.TabIndex = 13; this.trackBar2.Value = 2; + this.trackBar2.Scroll += new System.EventHandler(this.trackBar2_Scroll); // // label10 // this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(23, 361); + this.label10.Location = new System.Drawing.Point(26, 355); this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(108, 13); + this.label10.Size = new System.Drawing.Size(109, 13); this.label10.TabIndex = 12; this.label10.Text = "Selected RAM: 2 MB"; // @@ -327,7 +357,7 @@ private void InitializeComponent() this.radioButton1.Enabled = false; this.radioButton1.Location = new System.Drawing.Point(191, 140); this.radioButton1.Name = "radioButton1"; - this.radioButton1.Size = new System.Drawing.Size(45, 17); + this.radioButton1.Size = new System.Drawing.Size(44, 17); this.radioButton1.TabIndex = 8; this.radioButton1.TabStop = true; this.radioButton1.Text = "TCG"; @@ -339,7 +369,7 @@ private void InitializeComponent() this.label9.Font = new System.Drawing.Font("Segoe UI Semibold", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label9.Location = new System.Drawing.Point(9, 214); this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(365, 32); + this.label9.Size = new System.Drawing.Size(366, 32); this.label9.TabIndex = 7; this.label9.Text = "Select your RAM and VRAM size"; // @@ -424,7 +454,7 @@ private void InitializeComponent() this.label5.Font = new System.Drawing.Font("Segoe UI Semibold", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label5.Location = new System.Drawing.Point(9, 13); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(274, 32); + this.label5.Size = new System.Drawing.Size(275, 32); this.label5.TabIndex = 0; this.label5.Text = "Hardware configuration"; // @@ -442,10 +472,10 @@ private void InitializeComponent() this.tabPage3.Controls.Add(this.choosExistig); this.tabPage3.Controls.Add(this.cretNew); this.tabPage3.Controls.Add(this.label11); - this.tabPage3.Location = new System.Drawing.Point(4, 25); + this.tabPage3.Location = new System.Drawing.Point(4, 22); this.tabPage3.Name = "tabPage3"; this.tabPage3.Padding = new System.Windows.Forms.Padding(3); - this.tabPage3.Size = new System.Drawing.Size(430, 420); + this.tabPage3.Size = new System.Drawing.Size(430, 423); this.tabPage3.TabIndex = 2; this.tabPage3.Text = "tabPage3"; // @@ -471,7 +501,7 @@ private void InitializeComponent() this.label13.AutoSize = true; this.label13.Location = new System.Drawing.Point(51, 219); this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(152, 13); + this.label13.Size = new System.Drawing.Size(153, 13); this.label13.TabIndex = 9; this.label13.Text = "Browse for a virtual disk file:"; // @@ -509,7 +539,7 @@ private void InitializeComponent() this.label12.AutoSize = true; this.label12.Location = new System.Drawing.Point(51, 100); this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(131, 13); + this.label12.Size = new System.Drawing.Size(132, 13); this.label12.TabIndex = 5; this.label12.Text = "Size of the disk (in MBs):"; // @@ -559,55 +589,38 @@ private void InitializeComponent() this.label11.Font = new System.Drawing.Font("Segoe UI Semibold", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label11.Location = new System.Drawing.Point(9, 13); this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(311, 32); + this.label11.Size = new System.Drawing.Size(312, 32); this.label11.TabIndex = 1; this.label11.Text = "Select or create virtual disk"; // // tabPage4 // this.tabPage4.BackColor = System.Drawing.SystemColors.Window; - this.tabPage4.Location = new System.Drawing.Point(4, 25); + this.tabPage4.Location = new System.Drawing.Point(4, 22); this.tabPage4.Name = "tabPage4"; this.tabPage4.Padding = new System.Windows.Forms.Padding(3); - this.tabPage4.Size = new System.Drawing.Size(430, 420); + this.tabPage4.Size = new System.Drawing.Size(430, 423); this.tabPage4.TabIndex = 3; this.tabPage4.Text = "tabPage4"; // // tabPage5 // this.tabPage5.BackColor = System.Drawing.SystemColors.Window; - this.tabPage5.Location = new System.Drawing.Point(4, 25); + this.tabPage5.Location = new System.Drawing.Point(4, 22); this.tabPage5.Name = "tabPage5"; this.tabPage5.Padding = new System.Windows.Forms.Padding(3); - this.tabPage5.Size = new System.Drawing.Size(430, 420); + this.tabPage5.Size = new System.Drawing.Size(430, 423); this.tabPage5.TabIndex = 4; this.tabPage5.Text = "tabPage5"; // - // label15 - // - this.label15.AutoSize = true; - this.label15.Location = new System.Drawing.Point(16, 174); - this.label15.Name = "label15"; - this.label15.Size = new System.Drawing.Size(32, 13); - this.label15.TabIndex = 14; - this.label15.Text = "GPU:"; - // - // comboBox4 + // label16 // - this.comboBox4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBox4.FormattingEnabled = true; - this.comboBox4.Items.AddRange(new object[] { - "none", - "std ", - "cirrus", - "vmware ", - "qxl", - "virtio"}); - this.comboBox4.Location = new System.Drawing.Point(118, 174); - this.comboBox4.Name = "comboBox4"; - this.comboBox4.Size = new System.Drawing.Size(169, 21); - this.comboBox4.TabIndex = 15; - this.comboBox4.SelectedIndexChanged += new System.EventHandler(this.comboBox4_SelectedIndexChanged); + this.label16.AutoSize = true; + this.label16.Location = new System.Drawing.Point(26, 378); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(142, 13); + this.label16.TabIndex = 16; + this.label16.Text = "Selected Video RAM: 2 MB"; // // Form3 // @@ -687,5 +700,6 @@ private void InitializeComponent() private System.Windows.Forms.TrackBar trackBar2; private System.Windows.Forms.ComboBox comboBox4; private System.Windows.Forms.Label label15; + private System.Windows.Forms.Label label16; } } \ No newline at end of file diff --git a/QEMUWF/Form3.cs b/QEMUWF/Form3.cs index 0dd05a1..cdc0229 100644 --- a/QEMUWF/Form3.cs +++ b/QEMUWF/Form3.cs @@ -1,13 +1,6 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; using System.Windows.Forms; -using System.IO; -using Microsoft.VisualBasic.Devices; + namespace QEMUWF { public partial class Form3 : Form @@ -15,11 +8,11 @@ public partial class Form3 : Form public Form3() { InitializeComponent(); - Core.SetStaticControls(trackBar1, comboBox1, comboBox2, tabControl1, numericUpDown1); + Core.SetStaticControls(trackBar1, trackBar2, comboBox1, comboBox2, tabControl1, numericUpDown1); } + private void Form3_Load(object sender, EventArgs e) { - } private void button1_Click(object sender, EventArgs e) @@ -32,21 +25,19 @@ private void bacc_Click(object sender, EventArgs e) Core.Navigate(0, tabControl1); } - private void cancel_Click(object sender, EventArgs e) { this.Close(); } - private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { - Core.SetDynamicControls(true, false, comboBox2, comboBox3, radioButton1, radioButton2, radioButton3, trackBar1, label10); + Core.SetDynamicControls(true, false, false, comboBox2, comboBox3, radioButton1, radioButton2, radioButton3, trackBar1, trackBar2, label10, label16); } private void trackBar1_Scroll(object sender, EventArgs e) { - Core.SetDynamicControls(false, true, comboBox2, comboBox3, radioButton1, radioButton2, radioButton3, trackBar1, label10); + Core.SetDynamicControls(false, true, false, comboBox2, comboBox3, radioButton1, radioButton2, radioButton3, trackBar1, trackBar2, label10, label16); } private void cretNew_CheckedChanged(object sender, EventArgs e) @@ -62,13 +53,19 @@ private void button1_Click_1(object sender, EventArgs e) "QEMU Copy On Write 2 (*.qcow2)|*.qcow2|QEMU Copy On Write (*.qcow)|*.qcow|Microsoft Virtual Hard Disk (*.vhd)|*.vhd|Microsoft Virtual Hard Disk Extended (*.vhdx)|*.vhdx|Raw disk (*.raw)|*.raw|Raw disk (*.img)|*.img|All files (*.*)|*.*"; fileDialog.ShowDialog(); textBox2.Text = fileDialog.FileName; - - } private void comboBox4_SelectedIndexChanged(object sender, EventArgs e) { + } + + private void tabPage2_Click(object sender, EventArgs e) + { + } + private void trackBar2_Scroll(object sender, EventArgs e) + { + Core.SetDynamicControls(false, false, true, comboBox2, comboBox3, radioButton1, radioButton2, radioButton3, trackBar1, trackBar2, label10, label16); } } -} +} \ No newline at end of file diff --git a/QEMUWF/QEMUWF.csproj b/QEMUWF/QEMUWF.csproj index 8eb16e8..2ab9464 100644 --- a/QEMUWF/QEMUWF.csproj +++ b/QEMUWF/QEMUWF.csproj @@ -39,6 +39,7 @@ +