AGS.Editor.Utilities.GetRelativeToProjectPath C# (CSharp) Метод

GetRelativeToProjectPath() публичный статический Метод

public static GetRelativeToProjectPath ( string absolutePath ) : string
absolutePath string
Результат string
        public static string GetRelativeToProjectPath(string absolutePath)
        {
            if (String.IsNullOrEmpty(absolutePath) ||
                !absolutePath.Contains(Factory.AGSEditor.CurrentGame.DirectoryPath))
            {
                return absolutePath;
            }

            Uri currentProjectUri = new Uri(Factory.AGSEditor.CurrentGame.DirectoryPath + Path.DirectorySeparatorChar);
            Uri currentPathUri = new Uri(absolutePath);

            return Uri.UnescapeDataString(currentProjectUri.MakeRelativeUri(currentPathUri).OriginalString);
        }

Usage Example

Пример #1
0
        private void ImportTTFFont(string fileName, string newTTFName, string newWFNName)
        {
            int fontSize = NumberEntryDialog.Show("Font size", "Select the font size to import this TTF font at:", DEFAULT_IMPORTED_FONT_SIZE, 1);

            if (fontSize > 0)
            {
                File.Copy(fileName, newTTFName, true);
                try
                {
                    if (File.Exists(newWFNName))
                    {
                        Factory.AGSEditor.DeleteFileOnDiskAndSourceControl(newWFNName);
                    }
                    Factory.NativeProxy.ReloadFont(_item.ID);
                    _item.PointSize      = fontSize;
                    _item.SizeMultiplier = 1;
                    _item.SourceFilename = Utilities.GetRelativeToProjectPath(fileName);
                }
                catch (AGSEditorException ex)
                {
                    Factory.GUIController.ShowMessage("Unable to import the font.\n\n" + ex.Message, MessageBoxIcon.Warning);
                    File.Delete(newTTFName);
                }
            }
        }
All Usage Examples Of AGS.Editor.Utilities::GetRelativeToProjectPath