Exemple #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;
                importingObjectsTree.Model = null;
                return;
            }

            FillCheckedListBox();
        }
Exemple #2
0
        /// <summary>
        /// Заполнение списка именами объектов
        /// </summary>
        private void FillCheckedListBox()
        {
            importingObjectsTree.Model = null;
            if (TechObjectsImporter.GetInstance().RootItems.Length != 0)
            {
                importingObjectsTree.BeginUpdate();
                importingObjectsTree.Model = null;
                importingObjectsTree.Refresh();
                var treeModel = new TreeModel();

                ITreeViewItem[] objects = TechObjectsImporter.GetInstance()
                                          .RootItems;
                foreach (var s88Obj in objects)
                {
                    var root = new Node(s88Obj.DisplayText[0]);
                    root.Tag = s88Obj;

                    LoadObjectsForImport(s88Obj.Items, root);
                    treeModel.Nodes.Add(root);
                }

                importingObjectsTree.Model = treeModel;
                importingObjectsTree.EndUpdate();
                importButton.Enabled = true;
            }
            else
            {
                MessageBox.Show("Объекты для импорта не найдены",
                                "Предупреждение", MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                importButton.Enabled = false;
            }
        }
 /// <summary>
 /// Singleton
 /// </summary>
 /// <returns></returns>
 public static TechObjectsImporter GetInstance()
 {
     if (techObjectsImporter == null)
     {
         techObjectsImporter = new TechObjectsImporter();
     }
     return(techObjectsImporter);
 }
Exemple #4
0
        /// <summary>
        /// Кнопка "Импортировать"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void importButton_Click(object sender, EventArgs e)
        {
            List <ITreeViewItem> checkedItems = GetCheckedForImportItems();

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

            Editor.GetInstance().EditorForm.RefreshTree();
            Close();
        }