Ejemplo n.º 1
0
        /// <summary>
        /// Кнопка "Обзор".
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void overviewButton_Click(object sender, EventArgs e)
        {
            const string fileExtension = "lua";
            const string fileFilter    = "Скрипт LUA (.lua)|*.lua";

            var ofd = new OpenFileDialog();

            ofd.DefaultExt = fileExtension;
            ofd.Filter     = fileFilter;

            DialogResult dialog = ofd.ShowDialog();

            if (dialog == DialogResult.Cancel)
            {
                return;
            }

            try
            {
                TechObjectsImporter.GetInstance()
                .LoadImportingObjects(ofd.FileName);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Предупреждение",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                importButton.Enabled = false;
                checkedListBox.Items.Clear();
                return;
            }

            FillCheckedListBox();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Singleton
 /// </summary>
 /// <returns></returns>
 public static TechObjectsImporter GetInstance()
 {
     if (techObjectsImporter == null)
     {
         techObjectsImporter = new TechObjectsImporter();
     }
     return(techObjectsImporter);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Кнопка "Импортировать"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void importButton_Click(object sender, EventArgs e)
        {
            var checkedItems = GetCheckedForImportItems();

            try
            {
                TechObjectsImporter.GetInstance().Import(checkedItems);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Предупреждение",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Editor.Editor.GetInstance().EForm.RefreshTree();
                return;
            }

            Editor.Editor.GetInstance().EForm.RefreshTree();
            this.Close();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Заполнение списка именами объектов
        /// </summary>
        private void FillCheckedListBox()
        {
            checkedListBox.Items.Clear();
            var importedObjectsNames = TechObjectsImporter.GetInstance().
                                       ImportedObjectsNamesArray;
            bool objectsIsEmpty = importedObjectsNames.Length == 0;

            if (!objectsIsEmpty)
            {
                checkedListBox.Items.AddRange(TechObjectsImporter.GetInstance()
                                              .ImportedObjectsNamesArray);
                importButton.Enabled = true;
            }
            else
            {
                MessageBox.Show("Объекты для импорта не найдены",
                                "Предупреждение", MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                importButton.Enabled = false;
            }
        }