Beispiel #1
0
        public BaseDocument ShowDocument(ProjectElement Element)
        {
            if (Element.Document == null)
            {
                BaseDocument document = CreateDocument(Element.Type);

                Element.Document          = document;
                Element.Document.ShowHint = DockState.Document;
                document.SetProjectElement(Element);
                document.MainForm = MainForm;
                document.SetDocumentFilename(Element.Filename);
                if (document.DocumentFilename == null)
                {
                    // a new file
                    Element.Name = Element.Name;
                    Element.Document.Show(MainForm.panelMain);
                }
                else if (document.Load())
                {
                    Element.Name = Element.Name;
                    Element.Document.Show(MainForm.panelMain);
                }
                else
                {
                    Element.Document = null;
                    return(null);
                }
            }
            Element.Document.Select();
            return(Element.Document);
        }
Beispiel #2
0
        public BaseDocument ShowDocument(ProjectElement Element)
        {
            if (Element.DocumentInfo.Type == ProjectElement.ElementType.FOLDER)
            {
                return(null);
            }
            if (Element.Document == null)
            {
                BaseDocument document = Core.MainForm.CreateNewDocument(Element.DocumentInfo.Type, Element.DocumentInfo.Project);
                if (document == null)
                {
                    System.Windows.Forms.MessageBox.Show("Could not create document for " + Element.DocumentInfo.Type.ToString(), "Error creating document");
                    return(null);
                }

                Element.Document          = document;
                Element.Document.ShowHint = DockState.Document;
                Element.Document.Icon     = Core.MainForm.IconFromType(Element.DocumentInfo);
                document.SetProjectElement(Element);
                document.Core = Core;
                document.SetDocumentFilename(Element.Filename);
                if (Element.DocumentInfo.Project == null)
                {
                    // icon for non project documents
                    document.Icon = System.Drawing.SystemIcons.Asterisk;
                }
                if (document.DocumentFilename == null)
                {
                    // a new file
                    Element.Name = Element.Name;
                    Element.Document.Show(Core.MainForm.panelMain);
                }
                else if (document.Load())
                {
                    Element.Name = document.Text;
                    //Element.Name;
                    Element.Document.Show(Core.MainForm.panelMain);
                }
                else if (!string.IsNullOrEmpty(Element.Filename))
                {
                    Element.Document = null;
                    return(null);
                }

                if (Element.Document != null)
                {
                    Element.Document.DocumentInfo = Element.DocumentInfo;
                    Element.DocumentInfo.BaseDoc  = Element.Document;
                }

                if ((Element.Document != null) &&
                    (Element.Document is SourceASMEx))
                {
                    Element.Document.DocumentEvent += new BaseDocument.DocumentEventHandler(Core.MainForm.Document_DocumentEvent);
                }

                // set known tokens if we have any
                bool setFromMainDoc = false;
                if (!string.IsNullOrEmpty(Settings.MainDocument))
                {
                    var element = GetElementByFilename(Settings.MainDocument);
                    if ((element != null) &&
                        (element.DocumentInfo.Type == ProjectElement.ElementType.ASM_SOURCE) &&
                        (element.DocumentInfo.ASMFileInfo != null))
                    {
                        if (element.DocumentInfo.ASMFileInfo.ContainsFile(Element.DocumentInfo.FullPath))
                        {
                            if (!Core.Compiling.IsCurrentlyBuilding())
                            {
                                Element.DocumentInfo.SetASMFileInfo(element.DocumentInfo.ASMFileInfo, element.DocumentInfo.KnownKeywords, element.DocumentInfo.KnownTokens);
                            }
                            setFromMainDoc = true;
                        }
                    }
                }
                if ((!setFromMainDoc) &&
                    (Core.Compiling.ParserASM.ASMFileInfo.ContainsFile(Element.DocumentInfo.FullPath)))
                {
                    if (!Core.Compiling.IsCurrentlyBuilding())
                    {
                        Element.DocumentInfo.SetASMFileInfo(Core.Compiling.ParserASM.ASMFileInfo, Core.Compiling.ParserASM.KnownTokens(), Core.Compiling.ParserASM.KnownTokenInfo());
                    }
                }
                //Debug.Log( "m_Outline.RefreshFromDocument after showdoc" );
                Core.MainForm.m_Outline.RefreshFromDocument(Element.DocumentInfo.BaseDoc);
            }
            Element.Document.Select();
            Element.IsShown = true;
            Core.MainForm.RaiseApplicationEvent(new C64Studio.Types.ApplicationEvent(C64Studio.Types.ApplicationEvent.Type.DOCUMENT_OPENED, Element.DocumentInfo));
            Core.MainForm.RaiseApplicationEvent(new C64Studio.Types.ApplicationEvent(C64Studio.Types.ApplicationEvent.Type.ELEMENT_OPENED, Element));
            return(Element.Document);
        }