Example #1
0
        public override bool Connect(IApplicationData data, IEventAggregator eventaggre)
        {
            _data  = data;
            _event = eventaggre;

            (data.ActiveDocument as IRBuilderDocument).GetShaderPaths().ForEach((item) =>
            {
                Shaderfiles.Add(new ShaderFileInfo(item));
            });


            _rdoc = _data.ActiveDocument as IRBuilderDocument;

            return(true);
        }
Example #2
0
        private void SaveShaderDocumentCommandHandler()
        {
            if (isNewFile || string.IsNullOrEmpty(currentFilePath))
            {
                SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                saveFileDialog1.InitialDirectory = ConstantNames.ShadersDirectory;
                saveFileDialog1.Title            = "Save R3D Shader Files";
                //saveFileDialog1.CheckFileExists = true;
                //saveFileDialog1.CheckPathExists = true;
                saveFileDialog1.DefaultExt = ConstantNames.ShaderExtension;
                //saveFileDialog1.Filter = "r3d Shader Files (*.txt)|*.txt|All files (*.*)|*.*";
                saveFileDialog1.FilterIndex      = 2;
                saveFileDialog1.RestoreDirectory = true;

                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    string content = Document.Text;

                    File.WriteAllText(saveFileDialog1.FileName, content);

                    Shaderfiles.Add(new ShaderFileInfo(saveFileDialog1.FileName));

                    (_data.ActiveDocument as IRBuilderDocument).AddShaderPathToCurrentShaderLibrary(saveFileDialog1.FileName);
                }
            }
            else
            {
                string content = Document.Text;

                File.WriteAllText(currentFilePath, content);

                Shaderfiles.Add(new ShaderFileInfo(currentFilePath));

                (_data.ActiveDocument as IRBuilderDocument).AddShaderPathToCurrentShaderLibrary(currentFilePath);
            }
        }