/// <summary> /// Loads a new 3D model file into the ModelViewerControl. /// </summary> FyriFont LoadFontToProject(string fontName) { if (currentProject != null) { Cursor = Cursors.WaitCursor; FyriFont loadedFont = fontManager.LoadFont(fontName); if (loadedFont != null) { if (!currentProject.LoadedFonts.Exists(p => p.FontName == fontName)) { currentProject.LoadedFonts.Add(loadedFont); } //fontViewerControl.SpriteFont = loadedFont.Font; //AddFontToTreeView(loadedFont); } Cursor = Cursors.Arrow; return(loadedFont); } return(null); }
void AddFontToTreeView(FyriFont fontToAdd) { if (FontNode == null) { FontNode = new TreeNode(); FontNode.Text = "Fonts"; //ProjectNameNode.Nodes.Add(FontNode); } TreeNode nodeToAdd = new TreeNode(); nodeToAdd.Text = fontToAdd.FontName; nodeToAdd.Tag = fontToAdd; FontNode.Nodes.Add(nodeToAdd); //projectContentTV.CollapseAll(); nodeToAdd.EnsureVisible(); //projectContentTV.Refresh(); }
public void RefreshProject() { //ProjectNameNode.Text = "Project Name"; //ProjectNameNode.Nodes.Clear(); Canvas.XnaGraphics = null; Canvas.DrawingBatch = null; Canvas.DrawingContext = null; Canvas.LineBatch = null; Canvas.SpriteFont = null; Canvas.Effect = null; Canvas.Texture = null; if (xnaGraphics != null) { xnaGraphics = null; } if (drawingContext != null) { drawingContext = null; } if (drawingBatch != null) { drawingBatch = null; } if (lineBatch != null) { lineBatch = null; } if (effectManager != null) { effectManager = null; } if (fontManager != null) { fontManager = null; } if (texture2dManager != null) { texture2dManager = null; } if (modelManager != null) { modelManager = null; } if (contentManager != null) { contentManager.Unload(); contentManager.Dispose(); contentManager = null; } if (contentBuilder != null) { contentBuilder.Clear(); contentBuilder.Dispose(); contentBuilder = null; } if (currentProject != null) { //ProjectNameNode.Text = currentProject.ProjectName; contentBuilder = new ContentBuilder(currentProject.ProjectContentFolder, false); contentManager = new ContentManager(this.Services, contentBuilder.OutputDirectory); modelManager = new XnaModelManager(contentBuilder, contentManager, currentProject.OriginalContentFolder); texture2dManager = new XnaTexture2dManager(contentBuilder, contentManager, currentProject.OriginalContentFolder); fontManager = new XnaFontManager(contentBuilder, contentManager, currentProject.OriginalContentFolder); effectManager = new XnaEffectManager(contentBuilder, contentManager, currentProject.OriginalContentFolder); //roundLineTechniqueNames = roundLineManager.TechniqueNames; //ProjectNameNode.Nodes.Clear(); ModelNode = null; Texture2dNode = null; FontNode = null; EffectNode = null; //effectViewerControl.Effect = null; if (currentProject.LoadedModels.Count > 0) { currentProject.LoadedModels = modelManager.RefreshList(currentProject.LoadedModels); //foreach (FyriModel model in currentProject.LoadedModels) //{ // AddModelToTreeView(model); //} } else { //Load default Sphere string defSphereFileName = Directory.GetCurrentDirectory() + "\\Default\\Sphere.fbx"; if (File.Exists(defSphereFileName)) { LoadModelToProject(defSphereFileName); } } if (currentProject.LoadedTexture2ds.Count > 0) { currentProject.LoadedTexture2ds = texture2dManager.RefreshList(currentProject.LoadedTexture2ds); //foreach (FyriTexture2d texture in currentProject.LoadedTexture2ds) //{ // AddTexture2dToTreeView(texture); //} } else { //Load default Sphere string defTulipsPngFileName = Directory.GetCurrentDirectory() + "\\Default\\Tulips.png"; if (File.Exists(defTulipsPngFileName)) { LoadTexture2dToProject(defTulipsPngFileName); } } if (currentProject.LoadedFonts.Count > 0) { currentProject.LoadedFonts = fontManager.RefreshList(currentProject.LoadedFonts); //foreach (FyriFont font in currentProject.LoadedFonts) //{ // AddFontToTreeView(font); //} } else { //Load default Sphere string defSpriteFontFileName = Directory.GetCurrentDirectory() + "\\Default\\SpriteFont.spritefont"; if (File.Exists(defSpriteFontFileName)) { LoadFontToProject(defSpriteFontFileName); } string defSegoeFontFileName = Directory.GetCurrentDirectory() + "\\Default\\SegoeUI.spritefont"; if (File.Exists(defSegoeFontFileName)) { LoadFontToProject(defSegoeFontFileName); } } if (currentProject.LoadedEffects.Count > 0) { currentProject.LoadedEffects = effectManager.RefreshList(currentProject.LoadedEffects); //foreach (FyriEffect effect in currentProject.LoadedEffects) //{ // AddEffectToTreeView(effect); //} } else { //Load default Sphere string defRLEffectFileName = Directory.GetCurrentDirectory() + "\\Default\\RoundLine.fx"; if (File.Exists(defRLEffectFileName)) { LoadEffectToProject(defRLEffectFileName); } } FyriEffect roundlineEffect = effectManager.GetEffect("RoundLine"); FyriFont roundlineFont = fontManager.GetFont("SpriteFont"); FyriFont segoeUIFont = fontManager.GetFont("SegoeUI"); FyriTexture2d tulipsPng = texture2dManager.GetTexture2d("Tulips"); lineBatch = new XnaLine2dBatch(); lineBatch.Init(this.graphicsDeviceService.GraphicsDevice, roundlineEffect.Effect); drawingBatch = new XnaDrawingBatch(this.graphicsDeviceService.GraphicsDevice); drawingContext = new XnaDrawingContext(this.graphicsDeviceService.GraphicsDevice); xnaGraphics = new XnaGraphics(this.graphicsDeviceService.GraphicsDevice, drawingContext); PDefaults.DefaultGraphics = xnaGraphics; PDefaults.DefaultSpriteFont = fontManager.GetFont("SpriteFont").Font; Canvas.SpriteFont = segoeUIFont.Font; Canvas.Effect = roundlineEffect.Effect; Canvas.Texture = tulipsPng.Texture; Canvas.DrawingBatch = drawingBatch; Canvas.DrawingContext = drawingContext; Canvas.LineBatch = lineBatch; Canvas.XnaGraphics = xnaGraphics; } }