示例#1
0
        private void fLauchVMX(string _sPath)
        {
            if (_sPath != "" && !File.Exists(_sPath))
            {
                fOut(null, "Error >> File not exist: " + _sPath);
            }

            fStartLaodingLauch();
            sLauched_Path = _sPath;

            if (_sPath == "" || !cbFullScreen.Checked)  //Normal Mode
            {
                bFullScreenMode = false;
                oLauch          = new LauchTool();

                //oLauch.dOut = new LauchTool.dIOut(fOut);
                oLauch.dExit           = new LauchTool.dIExit(fLauchClose);
                oLauch.oFromWindow     = this;
                oLauch.bOutput         = false;
                oLauch.bStartMinimised = true;

                if (ckbAdmin.Checked)
                {
                    // oLauch.bRunAsAdmin = true;
                }
                fOut(null, "Lauch[vmplayer]: " + _sPath);
                if (_sPath == "")
                {
                    oLauch.fLauchExe(sVM_Path + "vmplayer.exe", "");
                }
                else
                {
                    oLauch.fLauchExe(sVM_Path + "vmplayer.exe", " " + "\"" + _sPath + "\"");
                }
            }
            else    //FULLSceen Mode
            {
                bFullScreenMode = true;
                oLauch          = new LauchTool();

                //oLauch.dOut = new LauchTool.dIOut(fOut);
                oLauch.dExit = new LauchTool.dIExit(fLauchClose);
                // oLauch.oFromWindow = this;
                oLauch.bOutput = false;
                // oLauch.bStartMinimised  =true;

                if (ckbAdmin.Checked)
                {
                    // oLauch.bRunAsAdmin = true;
                }

                fOut(null, "Lauch[vmplayer-kvm]: " + _sPath);
                oLauch.fLauchExe(sVM_Path + "vmware-kvm.exe", " " + "\"" + _sPath + "\"");
            }


            //oLauch.fLauchExe(sVM_Path + "vmplayer-kvm.exe", " " + "\""  +_sPath + "\"");
            //ovftool.exe --lax source.ova destination.vmx
        }
示例#2
0
 private void btnReset_Click(object sender, EventArgs e)
 {
     oKvmAction         = new LauchTool();
     oKvmAction.bOutput = false;
     oKvmAction.fLauchExe(sVM_Path + "vmware-kvm.exe", "--reset " + "\"" + sLauched_Path + "\"");
     //--exit can cause problem
 }
示例#3
0
 private void btStop_Click(object sender, EventArgs e)
 {
     oKvmAction         = new LauchTool();
     oKvmAction.bOutput = false;
     oKvmAction.fLauchExe(sVM_Path + "vmware-kvm.exe", "--power-off " + "\"" + sLauched_Path + "\"");
     fStopLaodingLauch();
 }
示例#4
0
 private void btPause_Click(object sender, EventArgs e)
 {
     //fFound_VM_Ware(false);
     oKvmAction         = new LauchTool();
     oKvmAction.bOutput = false;
     oKvmAction.fLauchExe(sVM_Path + "vmware-kvm.exe", "--suspend " + "\"" + sLauched_Path + "\"");
     fStopLaodingLauch();
 }
示例#5
0
 private void btConfig_Click(object sender, EventArgs e)
 {
     fFound_VM_Ware();
     // fStopLaodingLauch();
     oKvmAction         = new LauchTool();
     oKvmAction.bOutput = false;
     oKvmAction.fLauchExe(sVM_Path + "vmware-kvm.exe", "--preferences " + "\"" + sLauched_Path + "\"");
     //--detach ??
     //--reset
     //--exit
 }
示例#6
0
        public void fConvertOva(string _sPath, string _sDest)
        {
            fFound_VM_Ware();
            oConvert         = new LauchTool();
            oConvert.dOut    = new LauchTool.dIOut(fOut);
            oConvert.dError  = new LauchTool.dIError(fOut);
            oConvert.dExit   = new LauchTool.dIExit(fConvertFinish);
            oConvert.bHidden = true;

            oConvert.bOutput = true;

            fOut(null, "Export: " + "\"" + _sPath + "\" \"" + _sDest + "\"");
            oConvert.fLauchExe(sVM_Path + @"OVFTool\ovftool.exe", "\"" + _sPath + "\" \"" + _sDest + "\"");
        }
示例#7
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (WinApi.GetFullPathFromWindows("imdisk.exe") != null)
            {
                string _sPath = cbDrive.Text;

                if (File.Exists(_sPath))
                {
                    if (btnEdit.Text != "UnMount")
                    {
                        fOut(null, "Mount[DiscUtilsDevio] ");

                        //  btPause_Click(null,null);
                        string _sDirectory = Path.GetDirectoryName(_sPath) + "\\" + Path.GetFileNameWithoutExtension(_sPath) + "_Mount";
                        if (!Directory.Exists(_sDirectory))
                        {
                            Directory.CreateDirectory(_sDirectory);
                        }
                        else
                        {
                            if (Directory.GetFileSystemEntries(_sDirectory, "*.*").Length != 0)       //Use a new directory if already in use
                            {
                                string _sNewPath = _sDirectory;
                                int    _nCount   = 1;
                                try {
                                    do
                                    {
                                        /*
                                         * if( Directory.GetFileSystemEntries(_sNewPath, "*.*").Length != 0 ){
                                         *
                                         *     fUnMount(_sNewPath, true); //TODO check if attribute is mounted
                                         *     if(!Directory.Exists(_sNewPath)){ // Able to unmount
                                         *         break;
                                         *     }
                                         *
                                         * }else{
                                         *    // break;
                                         * }*/
                                        _nCount++;
                                        _sNewPath = _sDirectory + "_" + _nCount.ToString();
                                    } while (Directory.Exists(_sNewPath));
                                }catch (Exception ex)  {    //If is already mounted and crash
                                    if (File.Exists(_sNewPath))
                                    {
                                        fUnMount(_sNewPath);
                                    }
                                }

                                _sDirectory = _sNewPath;
                                Directory.CreateDirectory(_sDirectory);
                            }
                        }
                        bIsUnMount           = false;
                        oLDrive              = new LauchTool();
                        oLDrive.dOut         = new LauchTool.dIOut(fOut);
                        oLDrive.bRunAsAdmin  = true;
                        oLDrive.bOutput      = false;
                        oLDrive.bStartHidden = true;


                        sMountDirectory = _sDirectory;
                        oLoadedDrive    = oLDrive;
                        fOut(null, "Mount[DiscUtilsDevio]: " + sMountDirectory);
                        // oLauch.bRunInThread = false;
                        // oLDrive.fLauchExe(PathHelper.GetExeDirectory() + @"ImDiskTk/DiscUtilsDevio.exe", "/filename=" + "\"" + _sPath + "\"" + " /mount=Z:");
                        oLDrive.fLauchExe(PathHelper.GetExeDirectory() + @"ImDiskTk/DiscUtilsDevio.exe", "/filename=" + "\"" + _sPath + "\"" + " /mount=\"" + sMountDirectory + "\"");


                        //System.Diagnostics.Process.Start(sMountDirectory);



                        //   oLFolder = new LauchTool();
                        // oLFolder.bOutput = false;
                        //  oLFolder.fLauchExe("explorer.exe", "\"" + sMountDirectory + "\"");

                        if (cbOpen.Checked)
                        {
                            fOpenFolder();
                        }

                        btnEdit.Text = "UnMount";
                    }
                    else
                    {
                        fUnMount(sMountDirectory);
                    }
                }
                else
                {
                    fOut(null, "Error: Drive not exist: \"" + _sPath + "\"");
                }
            }
            else
            {
                fOut(null, "Driver is required to 'Edit Drive'");
                btnEdit.Enabled = false;
                DialogResult dr = MessageBox.Show("Driver 'imdisk' is required to 'Edit Drive', install?", "Install Driver", MessageBoxButtons.YesNo);
                switch (dr)
                {
                case DialogResult.Yes:

                    oInstallDriver        = new LauchTool();
                    oInstallDriver.dOut   = new LauchTool.dIOut(fOut);
                    oInstallDriver.dError = new LauchTool.dIError(fOut);
                    oInstallDriver.dExit  = new LauchTool.dIExit(fDriverFinish);
                    //  oInstallDriver.bHidden = true;

                    oInstallDriver.bOutput = false;
                    //oConvert.bStartMinimised  =true;
                    // oLauch.UseShellExecute = true;
                    //oLauch.fLauchExe(@"C:\Program Files (x86)\VMware\VMware Player\vmplayer.exe", "-X " + "\"E:/MyVM/CpcDos/My_Cpcdos OSx.vmx\"");

                    if (ckbAdmin.Checked)
                    {
                        oInstallDriver.bRunAsAdmin = true;
                        //    oInstallDriver.bOutput = false;
                    }
                    string _sPath = PathHelper.GetCurrentDirectory() + "ImDiskTk/driver/install.cmd";
                    //  string _sPath = PathHelper.GetCurrentDirectory() + "ImDiskTk/config.exe";

                    fOut(null, "Install Driver: " + _sPath);
                    oInstallDriver.fLauchExe(_sPath, "");

                    break;

                case DialogResult.No:
                    fOut(null, "Error: Driver not installed!");
                    btnEdit.Enabled = true;
                    break;
                }
            }
        }
示例#8
0
        public void fLauch(string _sPath)
        {
            this.BeginInvoke((MethodInvoker) delegate  {
                if (_sPath == "")
                {
                    fOut(null, "Lauch Library " + _sPath);
                    fLauchVMX("");
                }


                fOut(null, "Lauch: " + _sPath);
                if (File.Exists(_sPath))
                {
                    ConfigMng.oConfig.fAddRecent(_sPath);
                }
                string _sType = Path.GetFileName(_sPath);
                _sType        = _sType.Substring(_sType.LastIndexOf('.') + 1);
                Console.WriteLine("_sType :" + _sType);
                switch (_sType)
                {
                case "vmx":
                    fLauchVMX(_sPath);
                    break;

                case "ova":
                case "ovf":

                    string _sDest  = fGetVMX(_sPath);
                    sConvertToFile = _sDest;

                    if (!File.Exists(_sDest))
                    {
                        fStartLaodingLauch();
                        //!!!!Generate .vmx!!!!!

                        oConvert         = new LauchTool();
                        oConvert.dOut    = new LauchTool.dIOut(fOut);
                        oConvert.dError  = new LauchTool.dIError(fOut);
                        oConvert.dExit   = new LauchTool.dIExit(fConvertFinish);
                        oConvert.bHidden = true;

                        oConvert.bOutput = true;
                        //oConvert.bStartMinimised  =true;
                        // oLauch.UseShellExecute = true;
                        //oLauch.fLauchExe(@"C:\Program Files (x86)\VMware\VMware Player\vmplayer.exe", "-X " + "\"E:/MyVM/CpcDos/My_Cpcdos OSx.vmx\"");

                        if (ckbAdmin.Checked)
                        {
                            // oLauch.bRunAsAdmin = true;
                        }

                        ConfigMng.oConfig.fAddRecent(_sPath);
                        fOut(null, "Convert: " + _sPath);
                        oConvert.fLauchExe(sVM_Path + @"OVFTool\ovftool.exe", "--lax " + "\"" + _sPath + "\" \"" + _sDest + "\"");
                    }
                    else
                    {
                        fLauchVMX(_sDest);
                    }
                    break;
                }
            });
        }
示例#9
0
        private void fUnMount(string _sPath, bool _bForce = false)
        {
            Console.WriteLine("Try to unmount: " + _sPath);
            if (btnEdit.Text == "UnMount" || _bForce)
            {
                bIsUnMount           = false;
                oLDrive              = new LauchTool();
                oLDrive.dOut         = new LauchTool.dIOut(fOut);
                oLDrive.bRunAsAdmin  = true;
                oLDrive.bOutput      = false;
                oLDrive.bStartHidden = true;

                try {
                    oLDrive.fLauchExe(PathHelper.GetExeDirectory() + @"ImDiskTk/ImDisk-Dlg.exe", "RM \"" + _sPath + "\"");
                }catch (Exception ex) {
                    Console.WriteLine("Error: " + ex.Message);
                }

                try {
                    /////// Delete directory  ///////////
                    BackgroundWorker bw = new BackgroundWorker();
                    bw.DoWork += new DoWorkEventHandler(
                        delegate(object o, DoWorkEventArgs args) {
                        int _nTimeOut = 3000;
                        while (oLDrive.bExeLauch || (oLoadedDrive != null && oLoadedDrive.bExeLauch))
                        {
                            Thread.Sleep(1);
                        }
                        if (_bForce)
                        {
                            Thread.Sleep(500);
                        }
                        // if(File.Exists(_sPath)) { //Not work&! But useless
                        try {
                            Directory.Delete(_sPath);
                        }catch (Exception ex) {
                            Console.WriteLine("Error: " + ex.Message);
                        }
                        // }
                        fFinishUnmount();
                    });
                    bw.RunWorkerAsync();
                    //////////////////////////////////////
                }catch (Exception ex) {
                    Console.WriteLine("Error: " + ex.Message);
                }
                if (nFolderHandle != null)
                {
                    sCloseLocation = oFolderWindow.LocationURL.Replace("%20", " ").Replace("file:///", "").Replace('/', '\\');

                    // if(sCloseLocation.Length > sMountDirectory.Length){
                    int _nIndex = sCloseLocation.IndexOf(sMountDirectory);
                    if (_nIndex != -1)
                    {
                        sCloseLocation = sCloseLocation.Substring(_nIndex + sMountDirectory.Length);
                    }

                    fOut(null, "Close Location: " + sCloseLocation);
                    //   fOut(null, "sMountDirectory: " +sMountDirectory.Replace('\\', '/'));
                    oFolderWindow.Quit();
                    tbControl.SelectTab("tbConsole");
                }

                //  btnEdit.Text = "Edit Drive";
            }
        }