コード例 #1
0
ファイル: AssetsView.cs プロジェクト: corefan/FX-Studio
        public void AddEffect(string sourceFileName, string effectName, bool fromExist)
        {
            string destOjbect  = m_ProjectLocation + @"\Effects\" + Path.GetFileNameWithoutExtension(sourceFileName) + ".fxo";
            var    processInfo = new ProcessStartInfo
            {
                FileName = "fxc.exe",
#if (Debug)
                Arguments = "/Od /Zi /T fx_5_0 /nologo /Fo \"" + destOjbect + "\" \"" + sourceFileName + "\"",
#else
                Arguments = "/T fx_5_0 /nologo /Fo \"" + destOjbect + "\" \"" + sourceFileName + "\"",
#endif
                CreateNoWindow         = true,
                UseShellExecute        = false,
                RedirectStandardOutput = true,
                RedirectStandardError  = true,
                WindowStyle            = ProcessWindowStyle.Hidden
            };
            var    fxcProcess  = Process.Start(processInfo);
            string compileInfo = fxcProcess.StandardOutput.ReadToEnd();
            string errorInfo   = fxcProcess.StandardError.ReadToEnd();

            fxcProcess.WaitForExit();

            m_OuputDeleagate?.Invoke(compileInfo, errorInfo);

            if (!string.IsNullOrEmpty(compileInfo))
            {
                uint size = RenderMethods.AddEffect(@"Effects\" + Path.GetFileName(destOjbect), sourceFileName, effectName);
                if (size > 0)
                {
                    StringBuilder effectXml = new StringBuilder((int)size);
                    RenderMethods.GetEffectXml(@"Effects\" + Path.GetFileName(destOjbect), effectXml, size);

                    XmlDocument effectDoc = new XmlDocument();
                    effectDoc.LoadXml(effectXml.ToString());
                    XmlElement effectXmlNode = effectDoc.DocumentElement;

                    XmlNode effectRoot = m_XmlDoc.DocumentElement.SelectSingleNode("Effects");
                    if (effectRoot != null)
                    {
                        effectRoot.AppendChild(m_XmlDoc.ImportNode(effectXmlNode, true));
                        TreeNode effectsTreeNode = treeViewAssets.Nodes["Effects"];
                        if (effectsTreeNode != null)
                        {
                            AddEffect(effectsTreeNode, effectRoot.LastChild);
                        }
                    }
                }
            }
        }