Exemple #1
0
        private void loadFile(string filename)
        {
            close();

            ModelClass entry;

            model.Changed        += new EventHandler(model_Changed);
            model.ProgressStart  += new DataModelEventHandler(dataModel_ProgressStart);
            model.ProgressUpdate += new DataModelEventHandler(dataModel_ProgressUpdate);
            model.ProgressStop   += new DataModelEventHandler(dataModel_ProgressStop);
            model.SaveError      += new EventHandler(model_SaveError);

            //try
            //{
            model.Load(filename);
            //}
            //catch
            //{
            //    MessageBox.Show(Localization.Strings.Load_Error,
            //        Localization.Strings.NitroCast, MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    close();
            //    return;
            //}

            // Trigger model change event
            model_Changed(null, EventArgs.Empty);

            menuSave.Visible = model.FileName != string.Empty;

            mExplorer.BindModel(model);

            foreach (ModelFolder folder in model.Folders)
            {
                foreach (object folderItem in folder.Items)
                {
                    if (folderItem is ModelClass)
                    {
                        entry = (ModelClass)folderItem;

                        if (entry.Attributes["WindowState"] == "True")
                        {
                            ClassEditor editor = new ClassEditor(entry);
                            editor.MdiParent = this;
                            editor.Show();
                        }
                    }
                }
            }
        }
Exemple #2
0
        private void modelTree_DoubleClick(object sender, System.EventArgs e)
        {
            TreeNode selectedNode = this.modelTree.SelectedNode;

            if (selectedNode.Parent == null &&
                selectedNode.Tag is DataModel)
            {
                modelProperties(this, e);
            }
            else
            {
                if (selectedNode.Parent.Tag is ModelFolder)
                {
                    if (selectedNode.Tag is ModelClass)
                    {
                        ModelClass editClass = (ModelClass)selectedNode.Tag;

                        // Bring the edit window to focus if there is already one attached to the field
                        if (editClass.Editor != null)
                        {
                            ((ClassEditor)editClass.Editor).Focus();
                            return;
                        }

                        ClassEditor classEditor = new ClassEditor(editClass);
                        classEditor.MdiParent = this.MdiParent;
                        classEditor.Show();
                    }
                    else if (selectedNode.Tag is ModelEnum)
                    {
                        ModelEnum editEnum = (ModelEnum)selectedNode.Tag;

                        if (editEnum.Editor != null)
                        {
                            ((EnumEditor)editEnum.Editor).Focus();
                            return;
                        }

                        EnumEditor enumEditor = new EnumEditor(editEnum);
                        enumEditor.MdiParent = this.MdiParent;
                        enumEditor.Show();
                    }
                }
            }
        }
Exemple #3
0
        private void addClass(object sender, System.EventArgs e)
        {
            TreeNode    selectedNode;
            ModelFolder folder;

            selectedNode = modelTree.SelectedNode;

            // Find Current Folder
            while (selectedNode.Parent != null &
                   !(selectedNode.Tag is ModelFolder))
            {
                selectedNode = selectedNode.Parent;
            }

            if (selectedNode.Tag is ModelFolder)
            {
                folder = (ModelFolder)selectedNode.Tag;
            }
            else
            {
                return;
            }

            // Instantiate new class object
            ModelClass newClass = new ModelClass();

            newClass.ParentModel = this.model;
            newClass.Namespace   = this.model.DefaultNamespace;
            folder.Items.Add(newClass);

            // Add class object to DataTypeManager
            DataTypeManager.ReferenceTypes.Add(new ReferenceType(newClass, null));

            // Instantiate new class object editor
            ClassEditor newClassEditor = new ClassEditor(newClass);

            newClassEditor.MdiParent = this.MdiParent;
            newClassEditor.Show();

            refreshTree();
        }