protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      var file_name = "";

      var bitmap = doc.Views.ActiveView.CaptureToBitmap(true, true, true);
      bitmap.MakeTransparent();

      // copy bitmap to clipboard
      Clipboard.SetImage(bitmap);

      // save bitmap to file
      var save_file_dialog = new Rhino.UI.SaveFileDialog
      {
        Filter = "*.bmp",
        InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
      };
      if (save_file_dialog.ShowDialog() == DialogResult.OK)
      {
        file_name = save_file_dialog.FileName;
      }

      if (file_name != "")
        bitmap.Save(file_name);

      return Rhino.Commands.Result.Success;
    }
Exemple #2
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var file_name = "";

            var bitmap = doc.Views.ActiveView.CaptureToBitmap(true, true, true);

            bitmap.MakeTransparent();

            // copy bitmap to clipboard
            Clipboard.SetImage(bitmap);

            // save bitmap to file
            var save_file_dialog = new Rhino.UI.SaveFileDialog
            {
                Filter           = "*.bmp",
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
            };

            if (save_file_dialog.ShowDialog() == DialogResult.OK)
            {
                file_name = save_file_dialog.FileName;
            }

            if (file_name != "")
            {
                bitmap.Save(file_name);
            }

            return(Rhino.Commands.Result.Success);
        }
        public void SaveAsFile()
        {
            var fdi = new Rhino.UI.SaveFileDialog {
                Filter = "GSA Files(*.gwb)|*.gwb|All files (*.*)|*.*"
            };
            var res = fdi.ShowSaveDialog();

            if (res) // == DialogResult.OK)
            {
                fileName        = fdi.FileName;
                usersetFileName = true;
                string mes = gsaSaveModel.SaveAs(fileName).ToString();
                if (mes == GsaAPI.ReturnValue.GS_OK.ToString())
                {
                    canOpen = true;
                    //CreateAttributes();
                    mes = "Saved file";

                    //add panel input with string
                    //delete existing inputs if any
                    while (Params.Input[2].Sources.Count > 0)
                    {
                        Grasshopper.Instances.ActiveCanvas.Document.RemoveObject(Params.Input[2].Sources[0], false);
                    }

                    //instantiate  new panel
                    var panel = new Grasshopper.Kernel.Special.GH_Panel();
                    panel.CreateAttributes();

                    panel.Attributes.Pivot = new PointF((float)Attributes.DocObject.Attributes.Bounds.Left -
                                                        panel.Attributes.Bounds.Width - 40, (float)Attributes.DocObject.Attributes.Bounds.Bottom - panel.Attributes.Bounds.Height);

                    //populate value list with our own data
                    panel.UserText = fileName;

                    //Until now, the panel is a hypothetical object.
                    // This command makes it 'real' and adds it to the canvas.
                    Grasshopper.Instances.ActiveCanvas.Document.AddObject(panel, false);

                    //Connect the new slider to this component
                    Params.Input[2].AddSource(panel);
                    Params.OnParametersChanged();
                    ExpireSolution(true);
                }
                else
                {
                    mes = Char.ToUpper(mes[3]) + mes.Substring(4).ToLower().Replace("_", " ");
                }
                this.Message = mes;
            }
        }
Exemple #4
0
        private void toolStripButtonZip_Click(object sender, EventArgs e)
        {
            string folder = GetActiveFolderFullPath();
            string zip    = folder + ".zip";

            if (!ModifierKeys.HasFlag(Keys.Control))
            {
                Rhino.UI.SaveFileDialog fd = new Rhino.UI.SaveFileDialog();
                fd.Title      = "Zip File to export to";
                fd.Filter     = "zip files (*.zip)|*.zip|All files (*.*)|*.*";
                fd.DefaultExt = "zip";
                if (!fd.ShowSaveDialog())
                {
                    return;
                }

                zip = fd.FileName;
            }

            ZipFile.CreateFromDirectory(folder, zip);
        }