private void WriteProjectReference(ReferencedFile reference, XmlWriter writer, IDesignerProject project)
 {
     writer.WriteStartElement("Reference");
     writer.WriteAttributeString("filename", project.GetPathRelativeToProjectFile(reference.FileName));
     writer.WriteAttributeString("mergewithassembly", reference.MergeWithAssembly.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString("useinworkbench", reference.UseInWorkbench.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString("isprovider", reference.IsProvider.ToString(CultureInfo.InvariantCulture));
     writer.WriteEndElement();
 }
示例#2
0
 public bool Equals(ReferencedFile other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.FileName, FileName) && other.MergeWithAssembly.Equals(MergeWithAssembly) && other.UseInWorkbench.Equals(UseInWorkbench));
 }
示例#3
0
        public void AddReferencedFile(ReferencedFile reference)
        {
            bool found = false;

            for (int i = 0; i < m_references.Count(); i++)
            {
                if (m_references[i].FileName == reference.FileName)
                {
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                m_references.Add(reference);

                ReferencedFilesModified();
                Events.RaiseDataChangedEvent(GetType(), (MethodInfo)MethodBase.GetCurrentMethod(), null, reference);
            }
        }
示例#4
0
 public bool Equals(ReferencedFile other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.FileName, FileName) && other.MergeWithAssembly.Equals(MergeWithAssembly) && other.UseInWorkbench.Equals(UseInWorkbench);
 }
示例#5
0
 public void RemoveReference(ReferencedFile file)
 {
     m_references.Remove(file);
     ReferencedFilesModified();
     Events.RaiseDataChangedEvent(GetType(), (MethodInfo)MethodBase.GetCurrentMethod(), file, null);
 }
示例#6
0
        private void ShowFileDialogForReference(bool editSelected)
        {
            //int selectedIndex = -1;
            openFileDialog1.Filter = "DLL files (*.DLL)|*.DLL";
            openFileDialog1.Filter += "|ArchAngel Templates (*.AAT.DLL)|*.AAT.DLL";
            openFileDialog1.Filter += "|All files (*.*)|*.*";
            openFileDialog1.DefaultExt = ".DLL";
            openFileDialog1.FileName = "";
            openFileDialog1.InitialDirectory = Environment.CurrentDirectory;

            if (gridReferencedFiles.SelectedRows.Count > 0)
            {
                string file = (string)gridReferencedFiles.SelectedRows[0].Cells["colRefPath"].Value;// lstReferences2.SelectedItems[0].SubItems[2].Text;
                openFileDialog1.FileName = file;
                openFileDialog1.DefaultExt = Path.GetExtension(file);

                if (file.Length > 0 &&
                    Directory.Exists(Path.GetDirectoryName(file)))
                {
                    openFileDialog1.InitialDirectory = Path.GetDirectoryName(file);
                }
                if (file.EndsWith(".aat.dll", StringComparison.OrdinalIgnoreCase))
                {
                    openFileDialog1.Filter = "ArchAngel Template files (*.AAT.DLL)|*.AAT.DLL|DLL files (*.DLL)|*.DLL|All files (*.*)|*.*";
                }
                else
                {
                    openFileDialog1.Filter = "DLL files (*.DLL)|*.DLL|ArchAngel Template files (*.AAT.DLL)|*.AAT.DLL|All files (*.*)|*.*";
                }
            }
            if (!editSelected ||
                (gridReferencedFiles.SelectedRows.Count > 0))
            {
                Controller.ShadeMainForm();

                if (openFileDialog1.ShowDialog(this.ParentForm) == DialogResult.OK)
                {
                    Controller.UnshadeMainForm();
                    Controller.Instance.MainForm.Refresh();

                    string fileName = openFileDialog1.FileName;

                    if (fileName.Length > 0)
                    {
                        if (editSelected && Path.GetFileName(fileName.ToLower()) != GetSelectedAssemblyFilename().ToLower())
                        {
                            MessageBox.Show(this, "Filename doesn't match the referenced file you are trying to edit.", "Invalid file", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                        try
                        {
                            Cursor = Cursors.WaitCursor;
                            bool merge = false;
                            bool useInWorkbench = false;

                            if (editSelected)
                            {
                                NotifyUserThatARestartIsRequired(RestartReason.ReferencedAssemblyEdited);

                                bool isProvider = IsSelectedRowReadOnly();

                                if (isProvider)
                                {
                                    useInWorkbench = (bool)gridReferencedFiles.SelectedRows[0].Cells["colRefDisplay"].Value;
                                }
                                AddReferenceToList(Path.GetFileName(fileName), fileName, merge, useInWorkbench, isProvider, gridReferencedFiles.SelectedRows[0].Index);
                            }
                            else
                            {
                                if (Project.Instance.AssemblyNameAlreadyLoadedFromAnotherLocation(fileName))
                                {
                                    NotifyUserThatARestartIsRequired(RestartReason.NewAssemblyCannotBeLoadedDueToNameConflict);
                                }

                                var referencedFile = new ReferencedFile(fileName, false, false);
                                Project.Instance.AddReferencedFile(referencedFile);
                                AddReferenceToList(Path.GetFileName(fileName), fileName, merge, useInWorkbench, referencedFile.IsProvider);
                            }
                            // Check whether any of the other missing files can be found at the same new location
                            string dir = Path.GetDirectoryName(fileName);

                            for (int i = 0; i < gridReferencedFiles.Rows.Count; i++)
                            {
                                if (gridReferencedFiles.Rows[i].Tag != null && (Color)gridReferencedFiles.Rows[i].Tag == MissingFileBackColour)
                                {
                                    string tempPath = Path.Combine(dir, (string)gridReferencedFiles.Rows[i].Cells["colRefFile"].Value);

                                    if (File.Exists(tempPath))
                                    {
                                        gridReferencedFiles.Rows[i].Cells["colRefPath"].Value = tempPath;
                                        gridReferencedFiles.Rows[i].Tag = Color.White;

                                        // Update the path in References
                                        for (int refFileCounter = 0; refFileCounter < Project.Instance.References.Count(); refFileCounter++)
                                        {
                                            var refFile = Project.Instance.References.ElementAt(refFileCounter);
                                            if (Slyce.Common.Utility.StringsAreEqual(Path.GetFileName(refFile.FileName), Path.GetFileName((string)gridReferencedFiles.Rows[i].Cells["colRefFile"].Value), false))
                                            {
                                                string filePath = Path.Combine(dir, Path.GetFileName(refFile.FileName));
                                                refFile.FileName = filePath;
                                            }
                                        }
                                    }
                                }
                            }
                            Save(true);
                        }
                        finally
                        {
                            Cursor = Cursors.Default;
                        }
                    }
                }
                Controller.UnshadeMainForm();
            }
            ProcessMissingFiles();
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="parentNode"></param>
 /// <param name="myReferencedFile"></param>
 /// <param name="theirReferencedFile"></param>
 /// <returns>True if the referenced files were different and a node was added, false if they were the same and no node was added.</returns>
 private bool AddReferencedFileNode(TreeListNode parentNode, ReferencedFile myReferencedFile, ReferencedFile theirReferencedFile)
 {
     if (myReferencedFile != null && theirReferencedFile != null)
     {
         if (Slyce.Common.Utility.StringsAreEqual(theirReferencedFile.FileName, myReferencedFile.FileName, false) &&
             theirReferencedFile.UseInWorkbench == myReferencedFile.UseInWorkbench)
         {
             return false;
         }
         if (theirReferencedFile.FileName != myReferencedFile.FileName)
         {
             AddNodeBoth("Location", theirReferencedFile.FileName, myReferencedFile.FileName, parentNode, null);
         }
         if (theirReferencedFile.UseInWorkbench != myReferencedFile.UseInWorkbench)
         {
             AddNodeBoth("Display In Workbench", theirReferencedFile.UseInWorkbench, myReferencedFile.UseInWorkbench, parentNode, null);
         }
     }
     else if (theirReferencedFile != null)
     {
         AddNodeTheirs("Location", theirReferencedFile.FileName, "", parentNode, null);
         AddNodeTheirs("Display In Workbench", theirReferencedFile.UseInWorkbench, "", parentNode, null);
     }
     else if (myReferencedFile != null)
     {
         AddNodeMine("Location", "", myReferencedFile.FileName, parentNode, null);
         AddNodeMine("Display In Workbench", "", myReferencedFile.UseInWorkbench, parentNode, null);
     }
     return true;
 }
示例#8
0
 public void RemoveReference(ReferencedFile file)
 {
     m_references.Remove(file);
     ReferencedFilesModified();
     Events.RaiseDataChangedEvent(GetType(), (MethodInfo)MethodBase.GetCurrentMethod(), file, null);
 }
示例#9
0
        public void AddReferencedFile(ReferencedFile reference)
        {
            bool found = false;

            for (int i = 0; i < m_references.Count(); i++)
            {
                if (m_references[i].FileName == reference.FileName)
                {
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                m_references.Add(reference);

                ReferencedFilesModified();
                Events.RaiseDataChangedEvent(GetType(), (MethodInfo)MethodBase.GetCurrentMethod(), null, reference);
            }
        }
        protected virtual void ProcessProjectReferences(XmlNodeList nodes, IDesignerProject project, string projectFilename)
        {
            if (nodes == null) return;

            List<ReferencedFile> referencedFiles = new List<ReferencedFile>();
            foreach (XmlNode referenceNode in nodes)
            {
                NodeProcessor proc = new NodeProcessor(referenceNode);

                string relativeFileName = proc.Attributes.GetString("filename");
                bool mergeWithAssembly = proc.Attributes.GetBool("mergewithassembly");
                bool useInWorkbench = proc.Attributes.GetBool("useinworkbench");
                bool isProvider = proc.Attributes.GetBool("isprovider");

                string fileName = controller.ToAbsolutePath(relativeFileName, projectFilename);

                ReferencedFile file = new ReferencedFile(fileName, mergeWithAssembly, useInWorkbench);
                file.IsProvider = isProvider;

                referencedFiles.Add(file);
            }
            project.SetReferencedFiles(referencedFiles);
        }
示例#11
0
        private void VerifyReferencedFiles()
        {
            int numBlanks = 0;
            foreach (ReferencedFile refFile in m_references)
            {
                if (refFile == null || refFile.FileName.Trim().ToLower().Length == 0) { numBlanks++; }
            }
            for (int i = 0; i < m_references.Count; i++)
            {
                // Make sure we only have one copy of ArchAngel.Interfaces.dll, and it is the copy in the installation folder
                if (Path.GetFileName(m_references[i].FileName).ToLower() == "archangel.interfaces.dll" && Path.GetDirectoryName(m_references[i].FileName).ToLower() != Path.GetDirectoryName(Application.ExecutablePath).ToLower())
                {
                    m_references.RemoveAt(i);
                    break;
                }
            }
            // Ensure that System.Xml is always included

            if (numBlanks > 0)
            {
                List<ReferencedFile> tempRefFiles = new List<ReferencedFile>(m_references.Count - numBlanks);
                int insertPos = 0;

                for (int i = 0; i < m_references.Count; i++)
                {
                    if (m_references[i] != null && m_references[i].FileName.Trim().Length > 0)
                    {
                        tempRefFiles[insertPos] = new ReferencedFile(m_references[i].FileName, m_references[i].MergeWithAssembly, m_references[i].UseInWorkbench);
                        insertPos++;
                    }
                }
                // Reset the insertPos
                m_references = tempRefFiles;
            }
            // Make sure required files are referenced
            bool interfaceAssemblyFound = false;

            for (int i = 0; i < m_references.Count; i++)
            {
                if (m_references[i].FileName.ToLower().IndexOf("archangel.interfaces.dll") >= 0)
                {
                    interfaceAssemblyFound = true;
                }
            }
            if (!interfaceAssemblyFound)
            {
                string installDir = Path.GetDirectoryName(Application.ExecutablePath);
                string interfaceAssemblyPath = Path.Combine(installDir, "ArchAngel.Interfaces.dll");

                if (!File.Exists(interfaceAssemblyPath))
                {
                    string message = "ArchAngel.Interfaces.dll is missing from the ArchAngel folder (" + installDir + ").\n\nPlease repair ArchAngel via the Control Panel -> Add/Remove Programs.";
                    MessageBox.Show(Controller.Instance.MainForm, message, "Missing File", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                m_references.Add(new ReferencedFile(interfaceAssemblyPath, false, false));
                m_referencedAssemblies.Clear();
                RefreshReferencedAssemblies = true;
            }
        }