Exemple #1
0
        /// <summary>
        /// Initialize the form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            cls_main main_func = new cls_main();
            if (main_func.check_for_components(false))
            {
                if (!File.Exists(appdir + "umk_manager_08.exe")) { pict_mngr.Visible = false; };
                if (Directory.Exists(appdir + "system\\service") == false) { chk_service_enabled.Enabled = false; } else { chk_service_enabled.Enabled = true; }
                main_func.create_registry();
                prj_exist = true;
                umk_folder = main_func.get_value_from_infofile(appdir + "configs\\settings.ini", "umk_folder");
                if (umk_folder == "")
                {
                    MessageBox.Show("УМК не найдены. Запустите УМК Менеджер, чтобы указать правильный путь к директории с УМК.", "УМК не найдены!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }
                else
                {
                    if (Microsoft.VisualBasic.Strings.Right(umk_folder, 1)== "\\")
                    {
                        umk_folder = Microsoft.VisualBasic.Strings.Left(umk_folder, umk_folder.Length-1);
                    };
                    if (Microsoft.VisualBasic.Strings.Left(umk_folder, 6) == "APPDIR")
                    {
                        umk_folder = main_func.ReplaceAll(umk_folder, "APPDIR\\", appdir);
                    }
                 }
                clear_form();
                show_dg_open();
                if (Environment.OSVersion.Version.Major > 5)
                {
                    MsftDiscMaster2 discMaster = null;
                    try
                    {
                        discMaster = new MsftDiscMaster2();

                        if (!discMaster.IsSupportedEnvironment)
                            return;
                        foreach (string uniqueRecorderID in discMaster)
                        {
                            MsftDiscRecorder2 discRecorder2 = new MsftDiscRecorder2();
                            discRecorder2.InitializeDiscRecorder(uniqueRecorderID);

                            devicesComboBox.Items.Add(discRecorder2);
                        }
                        if (devicesComboBox.Items.Count > 0)
                        {
                            devicesComboBox.SelectedIndex = 0;
                        }
                    }
                    catch (COMException ex)
                    {
                        MessageBox.Show(ex.Message,
                            string.Format("Error:{0} - Пожалуйста, установите IMAPI2", ex.ErrorCode),
                            MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return;
                    }
                    finally
                    {
                        if (discMaster != null)
                        {
                            Marshal.ReleaseComObject(discMaster);
                        }
                    }
                    //
                    // Create the volume label based on the current date
                    //
                    DateTime now = DateTime.Now;
                    textBoxLabel.Text = now.Year + "_" + now.Month + "_" + now.Day;

                    labelStatusText.Text = string.Empty;
                    labelFormatStatusText.Text = string.Empty;

                    //
                    // Select no verification, by default
                    //
                    comboBoxVerification.SelectedIndex = 0;

                    UpdateCapacity();
                }
                else
                {
                    devicesComboBox.Visible = false;
                    label43.Visible = false;
                    MessageBox.Show("В данной версии ОС некоторые функции программы будут недоступны!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                Application.Exit();
            }
        }