Esempio n. 1
0
        private string GetUriRelPath(IResource resource)
        {
            if (resource == null)
            {
                return(string.Empty);
            }

            try
            {
                return
                    (SledUtil.GetRelativePath(
                         resource.Uri.LocalPath,
                         m_projectService.AssetDirectory));
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLine(
                    SledMessageType.Error,
                    "Exception getting relative " +
                    "path for Uri \"{0}\": {1}",
                    resource.Uri, ex.Message);

                return(resource.Uri.LocalPath);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Create SledProjectFilesFileType
        /// </summary>
        /// <param name="szAbsPath">Absolute path of file</param>
        /// <param name="project">Project details used to aid in creating the project file representation</param>
        /// <returns>SledProjectFilesFileType</returns>
        public static SledProjectFilesFileType Create(string szAbsPath, SledProjectFilesType project)
        {
            var node = new DomNode(SledSchema.SledProjectFilesFileType.Type);

            var file = node.As <SledProjectFilesFileType>();

            file.Uri  = new Uri(szAbsPath);
            file.Name = System.IO.Path.GetFileName(szAbsPath);
            file.Path = SledUtil.GetRelativePath(szAbsPath, project.AssetDirectory);

            return(file);
        }
Esempio n. 3
0
        public void GetRelativePath()
        {
            var basePaths = new[] { @"C:\usr\local\cell", @"C:\usr\local\cell\" };

            var absPath1 = @"C:\usr\local\file.txt";

            var relPath1 = SledUtil.GetRelativePath(absPath1, basePaths[0]);
            var relPath2 = SledUtil.GetRelativePath(absPath1, basePaths[1]);
            var relPath3 = @"..\file.txt";

            Assert.That(
                (string.Compare(relPath1, relPath2) == 0) &&
                (string.Compare(relPath2, relPath3) == 0) &&
                (string.Compare(relPath3, relPath1) == 0));

            absPath1 = @"C:\usr\local\cell\some\sub\directory\file.txt";

            relPath1 = SledUtil.GetRelativePath(absPath1, basePaths[0]);
            relPath2 = SledUtil.GetRelativePath(absPath1, basePaths[1]);
            relPath3 = @"some\sub\directory\file.txt";

            Assert.That(
                (string.Compare(relPath1, relPath2) == 0) &&
                (string.Compare(relPath2, relPath3) == 0) &&
                (string.Compare(relPath3, relPath1) == 0));

            absPath1 = @"D:\usr\local\cell\some\sub\directory\file.txt";

            relPath1 = SledUtil.GetRelativePath(absPath1, basePaths[0]);
            relPath2 = SledUtil.GetRelativePath(absPath1, basePaths[1]);
            relPath3 = absPath1;

            Assert.That(
                (string.Compare(relPath1, relPath2) == 0) &&
                (string.Compare(relPath2, relPath3) == 0) &&
                (string.Compare(relPath3, relPath1) == 0));

            absPath1 = @"C:\some\other\completely\different\directory\file.txt";

            relPath1 = SledUtil.GetRelativePath(absPath1, basePaths[0]);
            relPath2 = SledUtil.GetRelativePath(absPath1, basePaths[1]);
            relPath3 = @"..\..\..\some\other\completely\different\directory\file.txt";

            Assert.That(
                (string.Compare(relPath1, relPath2) == 0) &&
                (string.Compare(relPath2, relPath3) == 0) &&
                (string.Compare(relPath3, relPath1) == 0));
        }
Esempio n. 4
0
        private void UpdatePaths(bool option1)
        {
            m_lstFiles.Items.Clear();
            m_lstFiles.BeginUpdate();

            foreach (var file in m_files)
            {
                string pathNew;

                if (option1)
                {
                    var absPath =
                        SledUtil.GetAbsolutePath(file.Path, m_assetDirOld);

                    pathNew =
                        SledUtil.GetRelativePath(absPath, m_assetDirNew);
                }
                else
                {
                    var absPath =
                        m_assetDirNew + file.Path;

                    pathNew =
                        SledUtil.GetRelativePath(absPath, m_assetDirNew);
                }

                var lstItem =
                    new ListViewItem(
                        new[] { file.Name, file.Path, pathNew });

                m_lstFiles.Items.Add(lstItem);
            }

            m_lstFiles.EndUpdate();

            foreach (ColumnHeader hdr in m_lstFiles.Columns)
            {
                hdr.Width = -1;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Add location to the list
        /// </summary>
        /// <param name="loc"></param>
        /// <param name="lineText"></param>
        public void AddLocation(SledVarLocationType loc, string lineText)
        {
            var lstItem =
                new ListViewItem(
                    new[]
            {
                SledUtil.GetRelativePath(loc.File, m_projectService.Get.AssetDirectory),
                loc.Line.ToString(),
                loc.Occurence.ToString(),
                lineText
            })
            {
                Tag = loc
            };

            m_lstView.Items.Add(lstItem);

            m_lstView.Columns[0].Width = -1;
            m_lstView.Columns[1].Width = -1;
            m_lstView.Columns[2].Width = -1;
            m_lstView.Columns[3].Width = -2;
        }