コード例 #1
0
		public SysTrayIcon()
		{
			this.extradatakey = new StringBuilder(resources.GetString("VBoxService.ExtraDataKey"));
			
			vbox = new VirtualBox.VirtualBox();
			vboxcallback = new virtualboxcallback(this);
			vbox.RegisterCallback(vboxcallback);
			
			this.menuitem = new System.Windows.Forms.ContextMenu();
			for(int i=0; i<((Array)vbox.Machines).Length;i++) {
				MenuItem menu = new MenuItem( vbox.Machines[i].Name);
				menu.Name = vbox.Machines[i].Name;
				menu.Click += contextClick;
				menu.Tag = vbox.Machines[i].Id;
				
				if (vbox.Machines[i].GetExtraData(this.extradatakey.ToString()).ToLower() == "yes")
					menu.Checked = true;
				else
					menu.Checked = false;
				
				this.menuitem.MenuItems.Add(menu);
			}
			this.menuitem.MenuItems.Add("-");
			this.menuitem.MenuItems.Add("&About",AboutBox);
			this.menuitem.MenuItems.Add("E&xit",ExitSystray);
					
			this.notifyIcon = new NotifyIcon();
			this.notifyIcon.Icon = (System.Drawing.Icon)resources.GetObject("icon");
			this.notifyIcon.Visible = true;
			this.notifyIcon.Text = resources.GetString("Application.Name");
			this.notifyIcon.ContextMenu = this.menuitem;
		}
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: zys0807/VirtualKD
        public MainWindow()
        {
            InitializeComponent();

            this.DataContext = this;

            _VirtualBox        = new VirtualBox.VirtualBox();
            lblVersion.Content = _VirtualBox.Version;
            if (int.Parse(_VirtualBox.Version.Split('.')[0]) < 5)
            {
                throw new Exception("VirtualBox older than 5.0 detected. Please install VirtualBox 5.0 or later to use this version of VirtualKD.");
            }

            var         is64Bit = App.Is64Bit();
            RegistryKey key     = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Oracle\VirtualBox");
            string      dir;

            if (key != null)
            {
                dir = key.GetValue("InstallDir") as string;
            }
            else
            {
                dir = Environment.GetEnvironmentVariable(is64Bit ? "ProgramW6432" : "ProgramFiles") + "\\Oracle\\VirtualBox";
            }
            if (dir == null || !Directory.Exists(dir))
            {
                throw new Exception("VirtualBox directory not found");
            }
            VirtualBoxPath = dir.TrimEnd('\\');

            Refresh();
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: sysprogs/VirtualKD
        public MainWindow()
        {
            InitializeComponent();

            this.DataContext = this;

            _VirtualBox = new VirtualBox.VirtualBox();
            lblVersion.Content = _VirtualBox.Version;
            if (int.Parse(_VirtualBox.Version.Split('.')[0]) < 5)
            {
                throw new Exception("VirtualBox older than 5.0 detected. Please install VirtualBox 5.0 or later to use this version of VirtualKD.");
            }

            var is64Bit = App.Is64Bit();
            RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Oracle\VirtualBox");
            string dir;
            if (key != null)
                dir = key.GetValue("InstallDir") as string;
            else
                dir = Environment.GetEnvironmentVariable(is64Bit ? "ProgramW6432" : "ProgramFiles") + "\\Oracle\\VirtualBox";
            if (dir == null || !Directory.Exists(dir))
                throw new Exception("VirtualBox directory not found");
            VirtualBoxPath = dir.TrimEnd('\\');

            Refresh();
        }
コード例 #4
0
        public SysTrayIcon()
        {
            this.extradatakey = new StringBuilder(resources.GetString("VBoxService.ExtraDataKey"));

            vbox         = new VirtualBox.VirtualBox();
            vboxcallback = new virtualboxcallback(this);
            vbox.RegisterCallback(vboxcallback);

            this.menuitem = new System.Windows.Forms.ContextMenu();
            for (int i = 0; i < ((Array)vbox.Machines).Length; i++)
            {
                MenuItem menu = new MenuItem(vbox.Machines[i].Name);
                menu.Name   = vbox.Machines[i].Name;
                menu.Click += contextClick;
                menu.Tag    = vbox.Machines[i].Id;

                if (vbox.Machines[i].GetExtraData(this.extradatakey.ToString()).ToLower() == "yes")
                {
                    menu.Checked = true;
                }
                else
                {
                    menu.Checked = false;
                }

                this.menuitem.MenuItems.Add(menu);
            }
            this.menuitem.MenuItems.Add("-");
            this.menuitem.MenuItems.Add("&About", AboutBox);
            this.menuitem.MenuItems.Add("E&xit", ExitSystray);

            this.notifyIcon             = new NotifyIcon();
            this.notifyIcon.Icon        = (System.Drawing.Icon)resources.GetObject("icon");
            this.notifyIcon.Visible     = true;
            this.notifyIcon.Text        = resources.GetString("Application.Name");
            this.notifyIcon.ContextMenu = this.menuitem;
        }
コード例 #5
0
        public MainWindow()
        {
            RegistryKey key;
            string      locationerr = "Unable to locate VirtualBox. Please install the latest version of VirtualBox.";
            string      versionerr  = "VirtualBox older than 6.1 detected. Please install VirtualBox 6.1 or later to use this version of VirtualKD-Redux.";

            InitializeComponent();

            this.DataContext = this;

            key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Oracle\VirtualBox");
            if (key == null)
            {
                MessageBox.Show(locationerr, "VirtualBoxIntegration", MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(1);
            }

            try
            {
                _VirtualBox = new VirtualBox.VirtualBox();
            }
            catch (System.InvalidCastException e)
            {
                string version = key.GetValue("Version") as string;

                if (version == null)
                {
                    MessageBox.Show(locationerr, "VirtualBoxIntegration", MessageBoxButton.OK, MessageBoxImage.Error);
                    Environment.Exit(1);
                }

                if (!IsMinimumVirtualBoxVersion(version))
                {
                    MessageBox.Show(versionerr, "VirtualBoxIntegration", MessageBoxButton.OK, MessageBoxImage.Error);
                    Environment.Exit(1);
                }

                throw e;
            }

            lblVersion.Content = _VirtualBox.Version;
            if (!IsMinimumVirtualBoxVersion(_VirtualBox.Version))
            {
                MessageBox.Show(versionerr, "VirtualBoxIntegration", MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(1);
            }

            var is64Bit = App.Is64Bit();

            string dir;

            if (key != null)
            {
                dir = key.GetValue("InstallDir") as string;
            }
            else
            {
                dir = Environment.GetEnvironmentVariable(is64Bit ? "ProgramW6432" : "ProgramFiles") + "\\Oracle\\VirtualBox";
            }
            if (dir == null || !Directory.Exists(dir))
            {
                throw new Exception("VirtualBox directory not found");
            }
            VirtualBoxPath = dir.TrimEnd('\\');

            Refresh();
        }