public override void PropertyChanged(string propertyName, object oldValue) { FontEditor editor = ((FontEditor)_guiController.ActivePane.Control); AGS.Types.Font itemBeingEdited = editor.ItemToEdit; if (propertyName == "Name") { RePopulateTreeView(); foreach (ContentDocument doc in _documents.Values) { doc.Name = ((FontEditor)doc.Control).ItemToEdit.WindowTitle; } FontTypeConverter.SetFontList(_agsEditor.CurrentGame.Fonts); } else { Factory.NativeProxy.OnFontUpdated(Factory.AGSEditor.CurrentGame, itemBeingEdited.ID, false); if (propertyName == "SizeMultiplier") { editor.OnFontUpdated(); } } }
public void TestFontConverter() { var converter = new FontTypeConverter(); var microSize = Device.GetNamedSize(NamedSize.Micro, null, false); var mediumSize = Device.GetNamedSize(NamedSize.Medium, null, false); var largeSize = Device.GetNamedSize(NamedSize.Large, null, false); Assert.True(converter.CanConvertFrom(typeof(string))); Assert.AreEqual(Font.SystemFontOfSize(mediumSize), converter.ConvertFromInvariantString("Medium")); Assert.AreEqual(Font.SystemFontOfSize(42), converter.ConvertFromInvariantString("42")); Assert.AreEqual(Font.OfSize("Foo", microSize), converter.ConvertFromInvariantString("Foo, Micro")); Assert.AreEqual(Font.OfSize("Foo", 42), converter.ConvertFromInvariantString("Foo, 42")); Assert.AreEqual(Font.OfSize("Foo", 12.7), converter.ConvertFromInvariantString("Foo, 12.7")); Assert.AreEqual(Font.SystemFontOfSize(largeSize, FontWeight.Bold), converter.ConvertFromInvariantString("Bold, Large")); Assert.AreEqual(Font.SystemFontOfSize(42, FontWeight.Bold), converter.ConvertFromInvariantString("Bold, 42")); Assert.AreEqual(Font.OfSize("Foo", mediumSize), converter.ConvertFromInvariantString("Foo")); Assert.AreEqual(Font.OfSize("Foo", largeSize).WithAttributes(FontAttributes.Bold), converter.ConvertFromInvariantString("Foo, Bold, Large")); Assert.AreEqual(Font.OfSize("Foo", largeSize).WithAttributes(FontAttributes.Italic), converter.ConvertFromInvariantString("Foo, Italic, Large")); Assert.AreEqual(Font.OfSize("Foo", largeSize).WithAttributes(FontAttributes.Bold | FontAttributes.Italic), converter.ConvertFromInvariantString("Foo, Bold, Italic, Large")); Assert.AreEqual(Font.OfSize("Foo", 12).WithAttributes(FontAttributes.Bold), converter.ConvertFromInvariantString("Foo, Bold, 12")); Assert.AreEqual(Font.OfSize("Foo", 12.7).WithAttributes(FontAttributes.Bold), converter.ConvertFromInvariantString("Foo, Bold, 12.7")); Assert.AreEqual(Font.OfSize("Foo", 12).WithAttributes(FontAttributes.Italic), converter.ConvertFromInvariantString("Foo, Italic, 12")); Assert.AreEqual(Font.OfSize("Foo", 12.7).WithAttributes(FontAttributes.Italic), converter.ConvertFromInvariantString("Foo, Italic, 12.7")); Assert.AreEqual(Font.OfSize("Foo", 12).WithAttributes(FontAttributes.Bold | FontAttributes.Italic), converter.ConvertFromInvariantString("Foo, Bold, Italic, 12")); Assert.AreEqual(Font.OfSize("Foo", 12.7).WithAttributes(FontAttributes.Bold | FontAttributes.Italic), converter.ConvertFromInvariantString("Foo, Bold, Italic, 12.7")); }
public override void RefreshDataFromGame() { foreach (ContentDocument doc in _documents.Values) { _guiController.RemovePaneIfExists(doc); doc.Dispose(); } _documents.Clear(); RePopulateTreeView(); FontTypeConverter.SetFontList(_agsEditor.CurrentGame.Fonts); }
public override void PropertyChanged(string propertyName, object oldValue) { if (propertyName == "Name") { RePopulateTreeView(); foreach (ContentDocument doc in _documents.Values) { doc.Name = ((FontEditor)doc.Control).ItemToEdit.WindowTitle; } FontTypeConverter.SetFontList(_agsEditor.CurrentGame.Fonts); } }
public void TestFontConverter() { var converter = new FontTypeConverter(); Assert.True(converter.CanConvertFrom(typeof(string))); Assert.AreEqual(Font.SystemFontOfSize(NamedSize.Medium), converter.ConvertFromInvariantString("Medium")); Assert.AreEqual(Font.SystemFontOfSize(42), converter.ConvertFromInvariantString("42")); Assert.AreEqual(Font.OfSize("Foo", NamedSize.Micro), converter.ConvertFromInvariantString("Foo, Micro")); Assert.AreEqual(Font.OfSize("Foo", 42), converter.ConvertFromInvariantString("Foo, 42")); Assert.AreEqual(Font.OfSize("Foo", 12.7), converter.ConvertFromInvariantString("Foo, 12.7")); Assert.AreEqual(Font.SystemFontOfSize(NamedSize.Large, FontAttributes.Bold), converter.ConvertFromInvariantString("Bold, Large")); Assert.AreEqual(Font.SystemFontOfSize(42, FontAttributes.Bold), converter.ConvertFromInvariantString("Bold, 42")); Assert.AreEqual(Font.OfSize("Foo", NamedSize.Medium), converter.ConvertFromInvariantString("Foo")); Assert.AreEqual(Font.OfSize("Foo", NamedSize.Large).WithAttributes(FontAttributes.Bold), converter.ConvertFromInvariantString("Foo, Bold, Large")); Assert.AreEqual(Font.OfSize("Foo", NamedSize.Large).WithAttributes(FontAttributes.Italic), converter.ConvertFromInvariantString("Foo, Italic, Large")); Assert.AreEqual(Font.OfSize("Foo", NamedSize.Large).WithAttributes(FontAttributes.Bold | FontAttributes.Italic), converter.ConvertFromInvariantString("Foo, Bold, Italic, Large")); Assert.AreEqual(Font.OfSize("Foo", 12).WithAttributes(FontAttributes.Bold), converter.ConvertFromInvariantString("Foo, Bold, 12")); Assert.AreEqual(Font.OfSize("Foo", 12.7).WithAttributes(FontAttributes.Bold), converter.ConvertFromInvariantString("Foo, Bold, 12.7")); Assert.AreEqual(Font.OfSize("Foo", 12).WithAttributes(FontAttributes.Italic), converter.ConvertFromInvariantString("Foo, Italic, 12")); Assert.AreEqual(Font.OfSize("Foo", 12.7).WithAttributes(FontAttributes.Italic), converter.ConvertFromInvariantString("Foo, Italic, 12.7")); Assert.AreEqual(Font.OfSize("Foo", 12).WithAttributes(FontAttributes.Bold | FontAttributes.Italic), converter.ConvertFromInvariantString("Foo, Bold, Italic, 12")); Assert.AreEqual(Font.OfSize("Foo", 12.7).WithAttributes(FontAttributes.Bold | FontAttributes.Italic), converter.ConvertFromInvariantString("Foo, Bold, Italic, 12.7")); }
//Get application data from config file public DepartureTimeData GetData() { DepartureTimeData data = new DepartureTimeData(); FontTypeConverter fontType = new FontTypeConverter(); VerifyDocuments(); data.WorkingHours = TimeSpan.Parse((string)GetDataFromXML(_BaliseWH)); data.BgColor = ColorsHelper.StringToColor((string)GetDataFromXML(_BaliseBGC)); data.TxtColor = ColorsHelper.StringToColor((string)GetDataFromXML(_BaliseTC)); string selectedFont = (string)GetDataFromXML(_BaliseFT); if (selectedFont == "Default") { data.SelectedFont = ""; } else { data.SelectedFont = selectedFont; } return(data); }
public void TestFontConverter () { var converter = new FontTypeConverter (); Assert.True (converter.CanConvertFrom (typeof(string))); Assert.AreEqual (Font.SystemFontOfSize (NamedSize.Medium), converter.ConvertFromInvariantString ("Medium")); Assert.AreEqual (Font.SystemFontOfSize (42), converter.ConvertFromInvariantString ("42")); Assert.AreEqual (Font.OfSize ("Foo", NamedSize.Micro), converter.ConvertFromInvariantString ("Foo, Micro")); Assert.AreEqual (Font.OfSize ("Foo", 42), converter.ConvertFromInvariantString ("Foo, 42")); Assert.AreEqual (Font.OfSize ("Foo", 12.7), converter.ConvertFromInvariantString ("Foo, 12.7")); Assert.AreEqual (Font.SystemFontOfSize (NamedSize.Large, FontAttributes.Bold), converter.ConvertFromInvariantString ("Bold, Large")); Assert.AreEqual (Font.SystemFontOfSize (42, FontAttributes.Bold), converter.ConvertFromInvariantString ("Bold, 42")); Assert.AreEqual (Font.OfSize ("Foo", NamedSize.Medium), converter.ConvertFromInvariantString ("Foo")); Assert.AreEqual (Font.OfSize ("Foo", NamedSize.Large).WithAttributes (FontAttributes.Bold), converter.ConvertFromInvariantString ("Foo, Bold, Large")); Assert.AreEqual (Font.OfSize ("Foo", NamedSize.Large).WithAttributes (FontAttributes.Italic), converter.ConvertFromInvariantString ("Foo, Italic, Large")); Assert.AreEqual (Font.OfSize ("Foo", NamedSize.Large).WithAttributes (FontAttributes.Bold | FontAttributes.Italic), converter.ConvertFromInvariantString ("Foo, Bold, Italic, Large")); Assert.AreEqual (Font.OfSize ("Foo", 12).WithAttributes (FontAttributes.Bold), converter.ConvertFromInvariantString ("Foo, Bold, 12")); Assert.AreEqual (Font.OfSize ("Foo", 12.7).WithAttributes (FontAttributes.Bold), converter.ConvertFromInvariantString ("Foo, Bold, 12.7")); Assert.AreEqual (Font.OfSize ("Foo", 12).WithAttributes (FontAttributes.Italic), converter.ConvertFromInvariantString ("Foo, Italic, 12")); Assert.AreEqual (Font.OfSize ("Foo", 12.7).WithAttributes (FontAttributes.Italic), converter.ConvertFromInvariantString ("Foo, Italic, 12.7")); Assert.AreEqual (Font.OfSize ("Foo", 12).WithAttributes (FontAttributes.Bold | FontAttributes.Italic), converter.ConvertFromInvariantString ("Foo, Bold, Italic, 12")); Assert.AreEqual (Font.OfSize ("Foo", 12.7).WithAttributes (FontAttributes.Bold | FontAttributes.Italic), converter.ConvertFromInvariantString ("Foo, Bold, Italic, 12.7")); }
public override void CommandClick(string controlID) { if (controlID == COMMAND_NEW_ITEM) { IList <AGS.Types.Font> items = _agsEditor.CurrentGame.Fonts; AGS.Types.Font newItem = new AGS.Types.Font(); newItem.ID = items.Count; newItem.Name = "Font " + newItem.ID; newItem.OutlineStyle = FontOutlineStyle.None; newItem.PointSize = items[0].PointSize; newItem.SourceFilename = Utilities.GetRelativeToProjectPath(items[0].SourceFilename); items.Add(newItem); Utilities.CopyFont(0, newItem.ID); Factory.NativeProxy.GameSettingsChanged(_agsEditor.CurrentGame); _guiController.ProjectTree.StartFromNode(this, TOP_LEVEL_COMMAND_ID); _guiController.ProjectTree.AddTreeLeaf(this, GetNodeID(newItem), newItem.ID.ToString() + ": " + newItem.Name, "FontIcon"); _guiController.ProjectTree.SelectNode(this, GetNodeID(newItem)); ShowOrAddPane(newItem); FontTypeConverter.SetFontList(_agsEditor.CurrentGame.Fonts); } else if (controlID == COMMAND_DELETE_ITEM) { if (MessageBox.Show("Are you sure you want to delete this font? Doing so could break any scripts that refer to fonts by number.", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int removingID = _itemRightClicked.ID; _agsEditor.DeleteFileOnDiskAndSourceControl(_itemRightClicked.WFNFileName); _agsEditor.DeleteFileOnDiskAndSourceControl(_itemRightClicked.TTFFileName); foreach (AGS.Types.Font item in _agsEditor.CurrentGame.Fonts) { if (item.ID > removingID) { if (File.Exists(item.WFNFileName)) { _agsEditor.SourceControlProvider.RenameFileOnDiskAndInSourceControl(item.WFNFileName, "agsfnt" + (item.ID - 1) + ".wfn"); } if (File.Exists(item.TTFFileName)) { _agsEditor.SourceControlProvider.RenameFileOnDiskAndInSourceControl(item.TTFFileName, "agsfnt" + (item.ID - 1) + ".ttf"); } item.ID--; } } if (_documents.ContainsKey(_itemRightClicked)) { _guiController.RemovePaneIfExists(_documents[_itemRightClicked]); _documents.Remove(_itemRightClicked); } _agsEditor.CurrentGame.Fonts.Remove(_itemRightClicked); _agsEditor.CurrentGame.FilesAddedOrRemoved = true; Factory.NativeProxy.GameSettingsChanged(_agsEditor.CurrentGame); RePopulateTreeView(); FontTypeConverter.SetFontList(_agsEditor.CurrentGame.Fonts); } } else { if (controlID != TOP_LEVEL_COMMAND_ID) { AGS.Types.Font chosenFont = _agsEditor.CurrentGame.Fonts[Convert.ToInt32(controlID.Substring(3))]; ShowOrAddPane(chosenFont); } } }
public XamlFontTypeConverter() { _converter = new FontTypeConverter(); }