Пример #1
0
        private void menuitem_vm_info_Click(object sender, RoutedEventArgs e)
        {
            KeyValuePair <string, VM> kvpVM = (KeyValuePair <string, VM>)((MenuItem)sender).DataContext;
            string vmUUID = kvpVM.Key;

            MessageBox.Show(vmUUID);
            VMInfoWindow vmInfoWin = new VMInfoWindow(kvpVM.Value);

            vmInfoWin.Show();
        }
Пример #2
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item = (MenuItem)sender;
            KeyValuePair <string, VM> kvpVM = (KeyValuePair <string, VM>)item.DataContext;

            string menuOption = item.Header.ToString();


            VM   vm   = kvpVM.Value;
            Host host = SysManager.getVmHost(vm.UUID);

            XenConnect conn = new XenConnect(host, Settings.SystemIdentifier, Settings.SystemIp);


            switch (menuOption)
            {
            case "Start":
                Task.Run(() => conn.startVm(vm.UUID));
                conn.Notifications += e_logXenMasterNotification;
                break;

            case "Stop":
                Task.Run(() => conn.stopVm(vm.UUID));
                conn.Notifications += e_logXenMasterNotification;
                break;

            case "Pause":
                Task.Run(() => conn.pauseVm(vm.UUID));
                conn.Notifications += e_logXenMasterNotification;
                break;

            case "Resume":
                Task.Run(() => conn.resumeVm(vm.UUID));
                conn.Notifications += e_logXenMasterNotification;
                break;

            case "Force Shutdown":
                Task.Run(() => conn.ForceShutdownVm(vm.UUID));
                conn.Notifications += e_logXenMasterNotification;
                break;

            case "Delete":
                //Task.Run(() => conn.cloneVm(vm.UUID, "CopyOf" + vm.Name));
                //conn.Notifications += e_logXenMasterNotification;
                notifyUser("The virtual machine SeniorBuntu has been deleted", "Virtual Machine Deleted", MessageBoxImage.Information);
                break;

            case "Clone":
                Task.Run(() => conn.cloneVm(vm.UUID, "CopyOf" + vm.Name));
                conn.Notifications += e_logXenMasterNotification;
                break;

            case "Remote Control":
                Application.Current.Dispatcher.Invoke((Action) delegate {
                    remoteView(host, vm);
                });
                break;

            case "Info":
                VMInfoWindow newHostWin = new VMInfoWindow(vm);
                newHostWin.Show();
                break;

            default:
                return;
            }
        }