Ejemplo n.º 1
0
        void AddFontToTreeView(FyriFont fontToAdd)
        {
            if (FontNode == null)
            {
                if (AssetsNode == null)
                {
                    AssetsNode      = new TreeNode();
                    AssetsNode.Text = "Assets";
                    ProjectNameNode.Nodes.Add(AssetsNode);
                }
                FontNode      = new TreeNode();
                FontNode.Text = "Fonts";
                AssetsNode.Nodes.Add(FontNode);
            }

            TreeNode nodeToAdd = new TreeNode();

            nodeToAdd.Text = fontToAdd.FontName;
            nodeToAdd.Tag  = fontToAdd;

            FontNode.Nodes.Add(nodeToAdd);

            contentTreeView.CollapseAll();
            nodeToAdd.EnsureVisible();
            contentTreeView.Refresh();
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        public void Initialize(IntPtr handle, int width, int height)
        {
            graphicsDeviceService = GraphicsDeviceService.AddRef(handle,
                                                                 width,
                                                                 height);

            // Register the service, so components like ContentManager can find it.
            services.AddService <IGraphicsDeviceService>(graphicsDeviceService);

            contentBuilder = new ContentBuilder(ProjectContentFolder, false);

            contentManager = new ContentManager(this.Services,
                                                contentBuilder.OutputDirectory);

            modelManager = new XnaModelManager(contentBuilder, contentManager, OriginalContentFolder);

            texture2dManager = new XnaTexture2dManager(contentBuilder, contentManager, OriginalContentFolder);

            fontManager = new XnaFontManager(contentBuilder, contentManager, OriginalContentFolder);

            effectManager = new XnaEffectManager(contentBuilder, contentManager, OriginalContentFolder);

            spriterManager = new XnaSpriterManager(contentBuilder, contentManager, OriginalContentFolder);

            RefreshLists();

            FyriEffect roundlineEffect = effectManager.GetEffect("RoundLine");
            FyriFont   roundlineFont   = fontManager.GetFont("SpriteFont");

            roundLineManager = new RoundLineManager();
            roundLineManager.Init(this.graphicsDeviceService.GraphicsDevice, roundlineEffect.Effect);

            lineBatch = new XnaLine2dBatch();
            lineBatch.Init(this.graphicsDeviceService.GraphicsDevice, roundlineEffect.Effect);

            drawingContext = new XnaDrawingContext(this.graphicsDeviceService.GraphicsDevice);

            IsInitialized = true;
        }
Ejemplo n.º 5
0
        public override FyriFont LoadFont(string fileName)
        {
            if (fontList.FirstOrDefault(p => p.OriginalFileName == fileName) != null)
            {
                return(fontList.FirstOrDefault(p => p.OriginalFileName == fileName));
            }

            FyriFont newlyAddedFont = new FyriFont();

            newlyAddedFont.OriginalFileName = fileName;

            //string pathToMoveTo = ProjectOriginalContentFolder + Path.GetFileName(fileName);
            //if (!File.Exists(pathToMoveTo))
            //    File.Copy(fileName, pathToMoveTo);
            newlyAddedFont.FileName = fileName;

            newlyAddedFont.XnbFileLocation = contentBuilder.OutputDirectory;

            string fontName = Path.GetFileNameWithoutExtension(fileName);

            newlyAddedFont.FontName = fontName;

            SpriteFont loadedFont = null;

            string xnbFileLoc    = newlyAddedFont.XnbFileLocation + "\\" + fontName + ".xnb";
            bool   xnbFileExists = File.Exists(xnbFileLoc);

            if (!xnbFileExists)
            {
                // Unload any existing model.
                //xna2dEditorControl.Model = null;
                //contentManager.Unload();

                // Tell the ContentBuilder what to build.
                contentBuilder.Clear();

                string ext = Path.GetExtension(fileName).ToLower();

                if (ext == ".spritefont")
                {
                    contentBuilder.Add(fileName, fontName, null, "FontDescriptionProcessor");
                }
                else
                {
                    contentBuilder.Add(fileName, fontName, null, "FontTextureProcessor");
                }

                // Build this new model data.
                string buildError = contentBuilder.Build();

                if (string.IsNullOrEmpty(buildError))
                {
                    // If the build succeeded, use the ContentManager to
                    // load the temporary .xnb file that we just created.
                    loadedFont = contentManager.Load <SpriteFont>(fontName);
                }
                else
                {
                    // If the build failed, display an error message.
                    MessageBox.Show(buildError, "Error");
                    return(null);
                }
            }
            else
            {
                loadedFont = contentManager.Load <SpriteFont>(fontName);
            }

            if (loadedFont != null)
            {
                newlyAddedFont.Font = loadedFont;
            }
            else
            {
                return(null);
            }

            fontList.Add(newlyAddedFont);
            return(newlyAddedFont);
        }
Ejemplo n.º 6
0
        public override FyriFont GetFont(string fontName)
        {
            FyriFont fontToReturn = fontList.FirstOrDefault(p => p.FontName == fontName);

            return(fontToReturn);
        }
Ejemplo n.º 7
0
        public void RefreshProject()
        {
            //ProjectNameNode.Text = "Project Name";

            //ProjectNameNode.Nodes.Clear();

            roundLineDemoViewerControl.RoundLineManager = null;
            roundLineDemoViewerControl.SpriteFont       = null;
            roundLineDemoViewerControl.Effect           = null;

            if (roundLineManager != null)
            {
                roundLineManager = 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);
                    //}
                }

                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);
                    }
                }

                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");

                roundLineManager = new RoundLineManager();
                roundLineManager.Init(this.graphicsDeviceService.GraphicsDevice, roundlineEffect.Effect);

                roundLineDemoViewerControl.RoundLineManager = roundLineManager;
                roundLineDemoViewerControl.SpriteFont       = roundlineFont.Font;
                roundLineDemoViewerControl.Effect           = roundlineEffect.Effect;
            }
        }
Ejemplo n.º 8
0
        public void RefreshProject()
        {
            //ProjectNameNode.Text = "Project Name";

            //ProjectNameNode.Nodes.Clear();

            xnaToolBox1.ToolSelectionChanged   += SetTool;
            xna2dShapeControl1.ItemsSelected   += ItemsSelected;
            propertyGrid1.PropertyValueChanged += new PropertyValueChangedEventHandler(propertyGrid1_PropertyValueChanged);

            xna2dShapeControl1.Project          = null;
            xna2dShapeControl1.TextureManager   = null;
            xna2dShapeControl1.RoundLineManager = null;
            xna2dShapeControl1.LineBatch        = null;
            xna2dShapeControl1.SpriteFont       = null;
            xna2dShapeControl1.Effect           = null;
            xna2dShapeControl1.DrawingContext   = null;

            if (drawingContext != null)
            {
                drawingContext = null;
            }

            if (roundLineManager != null)
            {
                roundLineManager = 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);
                    //}
                }

                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);
                    }
                }

                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");

                roundLineManager = new RoundLineManager();
                roundLineManager.Init(this.graphicsDeviceService.GraphicsDevice, roundlineEffect.Effect);

                lineBatch = new XnaLine2dBatch();
                lineBatch.Init(this.graphicsDeviceService.GraphicsDevice, roundlineEffect.Effect);

                drawingContext = new XnaDrawingContext(this.graphicsDeviceService.GraphicsDevice);


                xna2dShapeControl1.ShapeProperties  = this.propertyGrid1;
                xna2dShapeControl1.ToolBox          = this.xnaToolBox1;
                xna2dShapeControl1.RoundLineManager = roundLineManager;
                xna2dShapeControl1.LineBatch        = lineBatch;
                xna2dShapeControl1.SpriteFont       = roundlineFont.Font;
                xna2dShapeControl1.Effect           = roundlineEffect.Effect;
                xna2dShapeControl1.DrawingContext   = drawingContext;
                xna2dShapeControl1.TextureManager   = texture2dManager;
                xna2dShapeControl1.Project          = currentProject;
            }
        }
Ejemplo n.º 9
0
        public void RefreshProject()
        {
            //ProjectNameNode.Text = "Project Name";

            //ProjectNameNode.Nodes.Clear();

            //xna2dSvgPaintVC.DrawingBatch = null;
            //xna2dSvgPaintVC.DrawingContext = null;
            //xna2dSvgPaintVC.LineBatch = null;
            //xna2dSvgPaintVC.SpriteFont = null;
            //xna2dSvgPaintVC.Effect = null;
            //xna2dSvgPaintVC.Texture = null;

            _svgMainFiles.XnaItems = 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);

                _svgMainFiles.XnaItems = new XnaItems();
                _svgMainFiles.XnaItems.ModelManager     = modelManager;
                _svgMainFiles.XnaItems.Texture2dManager = texture2dManager;
                _svgMainFiles.XnaItems.EffectManager    = effectManager;
                _svgMainFiles.XnaItems.FontManager      = fontManager;

                _svgMainFiles.XnaItems.DrawingBatch   = drawingBatch;
                _svgMainFiles.XnaItems.DrawingContext = drawingContext;
                _svgMainFiles.XnaItems.LineBatch      = lineBatch;

                //xna2dSvgPaintVC.SpriteFont = segoeUIFont.Font;
                //xna2dSvgPaintVC.Effect = roundlineEffect.Effect;
                //xna2dSvgPaintVC.Texture = tulipsPng.Texture;
                //xna2dSvgPaintVC.DrawingBatch = drawingBatch;
                //xna2dSvgPaintVC.DrawingContext = drawingContext;
                //xna2dSvgPaintVC.LineBatch = lineBatch;
            }
        }