public void SaveFile() { ResetDirty(); //_dirtyCounter = 2; _storedDocHash = _shaderTextEditor.Document.TextContent.GetHashCode(); _shaderTextEditor.SaveFile(_shaderTextEditor.FileName); }
public void RenderShader() { CompileShader(); if (_compiler.IsCompiled == false) { return; } try { this.InputControlsTab.IsEnabled = false; string path = Properties.Settings.Default.FolderPath_Output; if (!File.Exists(path + Constants.FileNames.TempShaderPs)) { return; } var ps = new PixelShader { UriSource = new Uri(path + Constants.FileNames.TempShaderPs) }; this._shaderModel = Shazzam.CodeGen.CodeParser.ParseShader(this._shaderTextEditor.FileName, this.CodeText); string codeString = CreatePixelShaderClass.GetSourceText(new CSharpCodeProvider(), this._shaderModel, true); Assembly autoAssembly = CreatePixelShaderClass.CompileInMemory(codeString); if (autoAssembly == null) { MessageBox.Show(ShazzamSwitchboard.MainWindow, "Cannot compile the generated C# code.", "Compile error", MessageBoxButton.OK, MessageBoxImage.Error); return; } Type t = autoAssembly.GetType(String.Format("{0}.{1}", _shaderModel.GeneratedNamespace, _shaderModel.GeneratedClassName)); this.FillEditControls(); var outputFolder = String.Format("{0}{1}", Properties.Settings.Default.FolderPath_Output, _shaderModel.GeneratedClassName); if (!Directory.Exists(outputFolder)) { Directory.CreateDirectory(outputFolder); } _csTextEditor.SaveFile(String.Format("{0}\\{1}.cs", outputFolder, _shaderModel.GeneratedClassName)); _vbTextEditor.SaveFile(String.Format("{0}\\{1}.vb", outputFolder, _shaderModel.GeneratedClassName)); CreateFileCopies(outputFolder + @"\", _shaderModel.GeneratedClassName); this.CurrentShaderEffect = (ShaderEffect)Activator.CreateInstance(t, new object[] { ps }); this.InputControlsTab.IsEnabled = true; } catch (Exception) { MessageBox.Show(ShazzamSwitchboard.MainWindow, "Cannot create a WPF shader from the code snippet.", "Compile error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btSaveXsltFile_Click(object sender, System.EventArgs e) { try { textEditorControl.SaveFile(this.strFileToLoad); lbFileSaved.Visible = true; } catch (Exception ex) { MessageBox.Show("Error in btSaveXsltFile_Click:" + ex.Message); } }