void view_BurnMedia(object sender, EventArgs e)
        {
            if (null != __MediaObject)
            {
                BurnMedia burnMediaForm        = new BurnMedia( );
                MediaObjectsStateService state = new MediaObjectsStateService(new MediaCreationQueue( ));

                __MediaObject.ExecutionStatus.ExecutionStatus = ExecutionStatus.Creating;

                state.MediaQueue.Add(__MediaObject);
                state.ActiveMediaItem = __MediaObject;

                BurnMediaPresenter burnPresenter = new BurnMediaPresenter(burnMediaForm.BurnMediaControl,
                                                                          state,
                                                                          System.Windows.Forms.WindowsFormsSynchronizationContext.Current);

                burnMediaForm.Tag = burnPresenter;

                burnMediaForm.FormClosing += new FormClosingEventHandler(burnMediaForm_FormClosing);

                burnMediaForm.StartPosition = FormStartPosition.CenterParent;

                if (DialogResult.OK == burnMediaForm.ShowDialog(ViewerContainer.State.ActiveWorkstation))
                {
                }
            }
        }
Esempio n. 2
0
        void statusController_BurnActiveMedia(object sender, EventArgs e)
        {
            if (null != __State.ActiveMediaItem)
            {
                BurnMedia burnMediaForm = new BurnMedia( );

                BurnMediaPresenter burnPresenter = new BurnMediaPresenter(burnMediaForm.BurnMediaControl,
                                                                          __State,
                                                                          System.Windows.Forms.WindowsFormsSynchronizationContext.Current);

                burnMediaForm.Tag = burnPresenter;

                burnMediaForm.FormClosing += new FormClosingEventHandler(burnMediaForm_FormClosing);

                burnMediaForm.StartPosition = FormStartPosition.CenterParent;

                if (DialogResult.OK == burnMediaForm.ShowDialog(_mainForm))
                {
                }
            }
        }
        void view_BurnMedia(object sender, EventArgs e)
        {
            if (null != __MediaObject)
            {
                BurnMedia burnMediaForm        = new BurnMedia( );
                MediaObjectsStateService state = new MediaObjectsStateService(new MediaCreationQueue( ));

                __MediaObject.ExecutionStatus.ExecutionStatus = ExecutionStatus.Creating;

                state.MediaQueue.Add(__MediaObject);
                state.ActiveMediaItem = __MediaObject;

                BurnMediaPresenter burnPresenter = new BurnMediaPresenter(burnMediaForm.BurnMediaControl,
                                                                          state,
                                                                          System.Windows.Forms.WindowsFormsSynchronizationContext.Current);

                burnMediaForm.Tag = burnPresenter;

                burnMediaForm.FormClosing += new FormClosingEventHandler(burnMediaForm_FormClosing);

                burnMediaForm.StartPosition = FormStartPosition.CenterParent;

                if (DialogResult.OK == burnMediaForm.ShowDialog(ViewerContainer.State.ActiveWorkstation))
                {
                    //currently always cleared after a successful burn
                    if (__View.ClearInstancesAfterRequest)
                    {
                        try
                        {
                            if (burnPresenter.Status == BurnStatus.BurnCompleted)
                            {
                                OnClearInstances();
                            }
                        }
                        catch { }
                    }
                }
            }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            while (true)
            {
                try
                {
                    #region 查找光驱设备
                    Console.Clear();
                    Console.WriteLine("正在查找光驱设备..");
                    List <Recorder> recorderList = RecorderHelper.GetRecorderList();
                    if (recorderList.Count <= 0)
                    {
                        Console.WriteLine("没有可以使用的光驱,请检查.");
                        Console.WriteLine("请连接光驱后,按任意键重试...");
                        Console.ReadKey();
                        continue;
                    }
                    for (int i = 0; i < recorderList.Count; i++)
                    {
                        Recorder tempRecorder = recorderList[i];
                        Console.WriteLine($"发现光驱设备:[{i+1}]  {tempRecorder.RecorderName}");
                        Console.WriteLine($"媒体类型:{tempRecorder.CurMediaTypeName}");
                        Console.WriteLine($"媒体状态:{tempRecorder.CurMediaStateName}");
                        Console.WriteLine("支持刻录:" + (tempRecorder.CanBurn ? "√" : "×"));
                        Console.WriteLine($"可用大小:{FormatFileSize(tempRecorder.FreeDiskSize)}");
                        Console.WriteLine($"总大小:{FormatFileSize(tempRecorder.TotalDiskSize)}");
                    }
                    if (!recorderList.Any(r => r.CanBurn))
                    {
                        Console.WriteLine("没有可以用于刻录的光驱设备,请检查后,按任意键重试.");
                        Console.ReadKey();
                        continue;
                    }
                    #endregion

                    #region  择刻录使用的光驱
                    Recorder recorder;
                    if (recorderList.Count > 1)
                    {
                        Console.WriteLine("发现多个光驱设备,请输入序号选择刻录使用的光驱.");
                        int recorderIndex = -1;
                        while (recorderIndex == -1)
                        {   //tempIndex 1开始
                            int    tempIndex        = -1;
                            string recorderIndexStr = Console.ReadLine();
                            int.TryParse(recorderIndexStr, out tempIndex);
                            if (tempIndex - 1 < 0 || tempIndex > recorderList.Count)
                            {
                                Console.WriteLine("输入序号无效,请重新输入.");
                                continue;
                            }
                            if (!recorderList[tempIndex - 1].CanBurn)
                            {
                                Console.WriteLine("当前设备状态异常,不能进行刻录,请选择其它设备.");
                                continue;
                            }
                            recorderIndex = tempIndex - 1;
                        }
                        recorder = recorderList[recorderIndex];
                    }
                    else
                    {
                        recorder = recorderList[0];
                    }
                    Console.WriteLine($"使用设备[{recorder.RecorderName}  {recorder.CurMediaTypeName}]进行刻录");
                    #endregion

                    #region 添加刻录文件
                    while (true)
                    {
                        Console.WriteLine("添加文件:请输入待刻录文件或文件夹路径. 0完成 1查看已添加文件");
                        string filePath = Console.ReadLine();
                        if (string.IsNullOrEmpty(filePath))
                        {
                            continue;
                        }
                        else if (filePath == "0")
                        {
                            break;
                        }
                        else if (filePath == "1")
                        {
                            ShowBurnMediaListInfo(recorder);
                        }
                        else
                        {
                            try
                            {
                                BurnMedia media = recorder.AddBurnMedia(filePath);
                                Console.WriteLine($"添加成功:{filePath}");
                                Console.WriteLine("文件大小:" + FormatFileSize(media.Size));
                                Console.WriteLine("已添加文件总大小:" + FormatFileSize(recorder.BurnMediaFileSize));
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine($"添加失败:{ex.Message}");
                            }
                        }
                    }
                    #endregion

                    #region 刻录文件

                    if (recorder.BurnMediaList.Count <= 0)
                    {
                        Console.WriteLine($"未添加任何刻录文件.已退出刻录过程.");
                    }
                    else
                    {
                        #region 刻录前确认
                        bool confirmBurn = false;
                        Console.Clear();
                        ShowBurnMediaListInfo(recorder);
                        while (true)
                        {
                            Console.WriteLine();
                            Console.ForegroundColor = ConsoleColor.DarkGreen; //设置颜色.
                            Console.WriteLine($"刻录过程一旦开始,终止可能会造成磁盘损坏.确认要开始刻录(y/n)?");
                            Console.ForegroundColor = colorFore;              //还原颜色.
                            string confirmStr = Console.ReadLine();
                            if (confirmStr.ToLower() == "n")
                            {
                                break;
                            }
                            else if (confirmStr.ToLower() == "y")
                            {
                                confirmBurn = true;
                                break;
                            }
                        }
                        if (!confirmBurn)
                        {
                            Console.WriteLine($"本次刻录过程已退出");
                            continue;
                        }
                        #endregion
                        Console.CursorVisible = false; //隐藏光标
                        ShowBurnProgressChanged(recorder);
                        recorder.Burn();               //刻录
                        Console.WriteLine();
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"异常:{ex.Message}\r\n{ex.StackTrace}");
                }
                Console.WriteLine($"按任意键退出...");
                Console.ReadKey();
            }
        }