private void BuildPngOnClick(object sender, RoutedEventArgs e) { var loadsGrid = LoadsGrid; loadsGrid.Measure(LoadsChart.RenderSize); loadsGrid.Arrange(new Rect(new Point(0, 0), LoadsChart.RenderSize)); LoadsChart.Update(true, true); //force chart redraw loadsGrid.UpdateLayout(); // Displays a SaveFileDialog so the user can save the Image // assigned to Button2. SaveFileDialog saveFileDialog1 = new SaveFileDialog { Filter = "PNG Image|*.png", Title = "Save an Image File" }; saveFileDialog1.ShowSaveDialog(); // If the file name is not an empty string open it for saving. if (saveFileDialog1.FileName != "") { SaveToPng(LoadsChart, saveFileDialog1.FileName); } //png file was created at the root directory. }
protected override Result RunCommand(Rhino.RhinoDoc doc, RunMode mode) { SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "glTF 1.0/2.0 binary (ShapeDiver) (*.glb)"; dlg.DefaultExt = ".glb"; dlg.Title = "Save glTF file"; dlg.FileName = "Export.glb"; var result = dlg.ShowSaveDialog(); var filename = dlg.FileName; if (result) { string strCommand = @"_-Export " + filename + " Enter"; RhinoApp.RunScript(strCommand, false); } if (serverManager.IsRunning) { serverManager.Broadcast(filename); } return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var go = new GetObject(); go.SetCommandPrompt("Selet surface or polysurface to serialize to a file."); go.GeometryFilter = ObjectType.Surface | ObjectType.PolysrfFilter; go.SubObjectSelect = false; go.Get(); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } var brep = go.Object(0).Brep(); if (null == brep) { return(Result.Failure); } string path = null; if (mode == RunMode.Interactive) { var dialog = new SaveFileDialog { Title = EnglishName, Filter = @"Bin Files (*.bin)|*.bin||", DefaultExt = "bin" }; if (!dialog.ShowSaveDialog()) { return(Result.Cancel); } path = dialog.FileName; } else { var result = RhinoGet.GetString("Save file name", false, ref path); if (result != Result.Success) { return(result); } } path = path.Trim(); if (string.IsNullOrEmpty(path)) { return(Result.Nothing); } if (!Path.HasExtension(path)) { path = Path.ChangeExtension(path, ".bin"); } var rc = SampleCsGeometryHelper.WriteToFile(path, brep); return(rc ? Result.Success : Result.Failure); }