Ejemplo n.º 1
0
        private void ImportTTFFont(string fileName, string newTTFName, string newWFNName)
        {
            FontHeightDefinition sizeType;
            int sizeValue;

            if (!ImportTTFDialog.Show(out sizeType, out sizeValue,
                                      _item.PointSize > 0 ? _item.PointSize : DEFAULT_IMPORTED_FONT_SIZE, Int32.MaxValue))
            {
                return;
            }
            File.Copy(fileName, newTTFName, true);
            try
            {
                if (File.Exists(newWFNName))
                {
                    Factory.AGSEditor.DeleteFileOnDiskAndSourceControl(newWFNName);
                }
                Factory.NativeProxy.ReloadFont(_item.ID);
                // If user asked to get a certain pixel height, then try to change the font's
                // point size, until found the closest result
                if (sizeType == FontHeightDefinition.PixelHeight)
                {
                    sizeValue = Factory.NativeProxy.FindTTFSizeForHeight(newTTFName, sizeValue);
                }
            }
            catch (AGSEditorException ex)
            {
                Factory.GUIController.ShowMessage("Unable to import the font.\n\n" + ex.Message, MessageBoxIcon.Warning);
                File.Delete(newTTFName);
            }

            _item.PointSize      = sizeValue;
            _item.SizeMultiplier = 1;
            _item.SourceFilename = Utilities.GetRelativeToProjectPath(fileName);
        }
Ejemplo n.º 2
0
        public static bool Show(out FontHeightDefinition sizeType, out int sizeValue, int currentSize, int maxSize)
        {
            ImportTTFDialog dialog = new ImportTTFDialog(FontHeightDefinition.NominalHeight, currentSize, maxSize);
            bool            result = dialog.ShowDialog() == DialogResult.OK;

            sizeType  = dialog.SizeType;
            sizeValue = dialog.SizeValue;
            return(result);
        }