private void onLibraryLoadFileSelected(OpenFileDialogParams openParams) { if (openParams.FileNames != null) { this.libraryDataView.CurrentLibraryProvider.AddFilesToLibrary(openParams.FileNames, null); } }
public override bool OpenFileDialog(OpenFileDialogParams openParams, OpenFileDialogDelegate callback) { WidgetForWindowsFormsAbstract.MainWindowsFormsWindow.ShowingSystemDialog = true; openParams.FileName = ""; openParams.FileNames = null; OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = openParams.InitialDirectory; openFileDialog1.Filter = openParams.Filter; openFileDialog1.Multiselect = openParams.MultiSelect; openFileDialog1.Title = openParams.Title; openFileDialog1.FilterIndex = openParams.FilterIndex; openFileDialog1.RestoreDirectory = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { openParams.FileNames = openFileDialog1.FileNames; openParams.FileName = openFileDialog1.FileName; } WidgetForWindowsFormsAbstract.MainWindowsFormsWindow.ShowingSystemDialog = false; UiThread.RunOnIdle((object state) => { callback(openParams); }); return(true); }
void loadMatterScript_Click(object sender, EventArgs mouseEvent) { OpenFileDialogParams openParams = new OpenFileDialogParams("MatterScript Files, c-sharp code|*.part;*.cs"); FileDialog.OpenFileDialog(openParams, (streamToLoadFrom) => { if (streamToLoadFrom != null) { SuspendLayout(); var loadedFileName = openParams.FileName; string extension = Path.GetExtension(openParams.FileName).ToUpper(CultureInfo.InvariantCulture); string text = File.ReadAllText(loadedFileName); StreamReader streamReader = new StreamReader(streamToLoadFrom.FileName); textEdit.Text = streamReader.ReadToEnd(); streamReader.Close(); varticalSplitter.SplitterDistance = varticalSplitter.SplitterDistance - 1; varticalSplitter.SplitterDistance = varticalSplitter.SplitterDistance + 1; ResumeLayout(); AnchorAll(); varticalSplitter.AnchorAll(); textSide.AnchorAll(); objectEditorView.Invalidate(); textSide.PerformLayout(); trackBallWidget.AnchorAll(); Invalidate(); } }); }
void onLibraryLoadFileSelected(OpenFileDialogParams openParams) { if (openParams.FileNames != null) { LibraryData.Instance.LoadFilesIntoLibrary(openParams.FileNames); } }
private static void onLibraryLoadFileSelected(OpenFileDialogParams openParams) { if (openParams.FileNames != null) { currentPrintLibraryWidget.libraryDataView.CurrentLibraryProvider.AddFilesToLibrary(openParams.FileNames, null); } }
private void onSettingsFileSelected(OpenFileDialogParams openParams) { if (openParams.FileNames != null) { LoadConfigurationSettingsFromFileAsUnsaved(openParams.FileName); ApplicationController.Instance.ReloadAdvancedControlsPanel(); } }
void onManifestFileLoad(OpenFileDialogParams openParams) { if (openParams.FileName != null) { string loadedFileName = openParams.FileName; List <PrintItem> printItems = ImportFromJson(loadedFileName); } }
private void openFileButton_ButtonClick(object sender, EventArgs mouseEvent) { UiThread.RunOnIdle(() => { OpenFileDialogParams openParams = new OpenFileDialogParams("gcode files|*.gcode"); FileDialog.OpenFileDialog(openParams, onFileSelected); }); }
public void LoadSettingsFromIni() { OpenFileDialogParams openParams = new OpenFileDialogParams("Load Slice Configuration|*.slice;*.ini"); openParams.ActionButtonLabel = "Load Configuration"; openParams.Title = "MatterControl: Select A File"; FileDialog.OpenFileDialog(openParams, onSettingsFileSelected); }
void importPresets_Click(object sender, EventArgs mouseEvent) { OpenFileDialogParams openParams = new OpenFileDialogParams("Load Slice Preset|*.slice;*.ini"); openParams.ActionButtonLabel = "Load Slice Preset"; openParams.Title = "MatterControl: Select A File"; FileDialog.OpenFileDialog(openParams, onLoadPreset); }
private void importPresetDo() { OpenFileDialogParams openParams = new OpenFileDialogParams("Load Slice Preset|*.slice;*.ini"); openParams.ActionButtonLabel = "Load Slice Preset"; openParams.Title = "MatterControl: Select A File"; FileDialog.OpenFileDialog(openParams, onPresetLoad); }
private void onFileSelected(OpenFileDialogParams openParams) { if (openParams.FileName != null && openParams.FileName != "") { gCodeViewWidget.Load(openParams.FileName); currentLayerIndex.Value = 0; currentLayerIndex.MaxValue = gCodeViewWidget.LoadedGCode.NumChangesInZ; } Invalidate(); }
private void onFileSelected(OpenFileDialogParams openParams) { if (!string.IsNullOrEmpty(openParams.FileName)) { gCodeViewWidget.LoadFile(openParams.FileName); currentLayerIndex.Value = 0; currentLayerIndex.MaxValue = gCodeViewWidget.LoadedGCode.NumChangesInZ; } Invalidate(); }
public override bool OpenFileDialog(OpenFileDialogParams openParams, Action <OpenFileDialogParams> callback) { WidgetForWindowsFormsAbstract.MainWindowsFormsWindow.ShowingSystemDialog = true; Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(openParams.Title, null, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); fc.SetCurrentFolder(openParams.InitialDirectory); fc.SelectMultiple = openParams.MultiSelect; Gtk.FileFilter filter = new Gtk.FileFilter(); filter.Name = openParams.Filter.Split('|')[0]; string[] extensions = openParams.Filter.Split('|') [1].Split(';'); foreach (string e in extensions) { filter.AddPattern(e.ToLower()); filter.AddPattern(e.ToUpper()); } fc.AddFilter(filter); Gtk.Application.Init(); if (fc.Run() == (int)ResponseType.Accept) { openParams.FileNames = fc.Filenames; openParams.FileName = fc.Filename; UiThread.RunOnIdle((state) => { OpenFileDialogParams openParamsIn = state as OpenFileDialogParams; if (openParamsIn != null) { callback(openParamsIn); } }, openParams); } fc.Destroy(); while (Gtk.Application.EventsPending()) { Gtk.Main.Iteration(); } WidgetForWindowsFormsAbstract.MainWindowsFormsWindow.ShowingSystemDialog = false; return(true); }
void AddButtonOnIdle(object state) { string selectInstruction = "Select an STL file".Localize(); OpenFileDialogParams openParams = new OpenFileDialogParams("{0}|*.stl".FormatWith(selectInstruction), multiSelect: true); FileDialog.OpenFileDialog(ref openParams); if (openParams.FileNames != null) { foreach (string loadedFileName in openParams.FileNames) { QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(Path.GetFileNameWithoutExtension(loadedFileName), Path.GetFullPath(loadedFileName)))); } } }
private void LoadStl_Click(object sender, EventArgs e) { OpenFileDialogParams opeParams = new OpenFileDialogParams("STL Files|*.stl"); FileDialog.OpenFileDialog(opeParams, (openParams) => { var streamToLoadFrom = File.Open(openParams.FileName, FileMode.Open); if (streamToLoadFrom != null) { var loadedFileName = openParams.FileName; meshToRender = StlProcessing.Load(streamToLoadFrom); ImageBuffer plateInventory = new ImageBuffer((int)(300 * 8.5), 300 * 11, 32, new BlenderBGRA()); Graphics2D plateGraphics = plateInventory.NewGraphics2D(); plateGraphics.Clear(RGBA_Bytes.White); double inchesPerMm = 0.0393701; double pixelsPerInch = 300; double pixelsPerMm = inchesPerMm * pixelsPerInch; AxisAlignedBoundingBox aabb = meshToRender.GetAxisAlignedBoundingBox(); Vector2 lowerLeftInMM = new Vector2(-aabb.minXYZ.x, -aabb.minXYZ.y); Vector3 centerInMM = (aabb.maxXYZ - aabb.minXYZ) / 2; Vector2 offsetInMM = new Vector2(20, 30); { RectangleDouble bounds = new RectangleDouble(offsetInMM.x * pixelsPerMm, offsetInMM.y * pixelsPerMm, (offsetInMM.x + aabb.maxXYZ.x - aabb.minXYZ.x) * pixelsPerMm, (offsetInMM.y + aabb.maxXYZ.y - aabb.minXYZ.y) * pixelsPerMm); bounds.Inflate(3 * pixelsPerMm); RoundedRect rect = new RoundedRect(bounds, 3 * pixelsPerMm); plateGraphics.Render(rect, RGBA_Bytes.LightGray); Stroke rectOutline = new Stroke(rect, .5 * pixelsPerMm); plateGraphics.Render(rectOutline, RGBA_Bytes.DarkGray); } OrthographicZProjection.DrawTo(plateGraphics, meshToRender, lowerLeftInMM + offsetInMM, pixelsPerMm); plateGraphics.DrawString(Path.GetFileName(openParams.FileName), (offsetInMM.x + centerInMM.x) * pixelsPerMm, (offsetInMM.y - 10) * pixelsPerMm, 50, Agg.Font.Justification.Center); //ImageBuffer logoImage = new ImageBuffer(); //ImageIO.LoadImageData("Logo.png", logoImage); //plateGraphics.Render(logoImage, (plateInventory.Width - logoImage.Width) / 2, plateInventory.Height - logoImage.Height - 10 * pixelsPerMm); //ImageIO.SaveImageData("plate Inventory.jpeg", plateInventory); } }); }
public List <PrintItem> OpenFromDialog() { OpenFileDialogParams openParams = new OpenFileDialogParams("Zip file|*.zip"); FileDialog.OpenFileDialog(ref openParams); if (openParams.FileNames != null) { string loadedFileName = openParams.FileName; return(ImportFromProjectArchive(loadedFileName)); } else { return(null); } }
string [] IFileDialogs.OpenFileDialog(OpenFileDialogParams prms) { var dlg = NSOpenPanel.OpenPanel; dlg.CanChooseFiles = prms.CanChooseFiles; dlg.AllowsMultipleSelection = prms.AllowsMultipleSelection; dlg.CanChooseDirectories = prms.CanChooseDirectories; if (dlg.RunModal() == 1) { return(dlg.Urls.Select(u => u.Path).Where(p => p != null).ToArray()); } return(null); }
public List <PrintItem> OpenFromDialog() { OpenFileDialogParams openParams = new OpenFileDialogParams("Select a Project file|*.mcp"); System.IO.Stream streamToLoadFrom = FileDialog.OpenFileDialog(ref openParams); if (streamToLoadFrom != null) { string loadedFileName = openParams.FileName; return(ImportFromJson(loadedFileName)); } else { return(null); } }
void AddItemsToQueue(object state) { OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file, Select a GCODE file|*.stl;*.gcode", multiSelect: true); openParams.ActionButtonLabel = "Add to Queue"; openParams.Title = "MatterControl: Select A File"; FileDialog.OpenFileDialog(ref openParams); if (openParams.FileNames != null) { foreach (string loadedFileName in openParams.FileNames) { QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(Path.GetFileNameWithoutExtension(loadedFileName), Path.GetFullPath(loadedFileName)))); } } }
public bool LoadSettingsFromIni() { OpenFileDialogParams openParams = new OpenFileDialogParams("Load Slice Configuration|*." + configFileExtension); openParams.ActionButtonLabel = "Load Configuration"; openParams.Title = "MatterControl: Select A File"; FileDialog.OpenFileDialog(ref openParams); if (openParams.FileNames != null) { LoadConfigurationSettingsFromFileAsUnsaved(openParams.FileName); return(true); } return(false); }
private void onProjectArchiveLoad(OpenFileDialogParams openParams) { List <PrintItem> partFiles; if (openParams.FileNames != null) { string loadedFileName = openParams.FileName; partFiles = ImportFromProjectArchive(loadedFileName); if (partFiles != null) { foreach (PrintItem part in partFiles) { QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(part.Name, part.FileLocation))); } } } }
void AddButtonOnIdle(object state) { OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file|*.stl", multiSelect: true); FileDialog.OpenFileDialog(ref openParams); if (openParams.FileNames != null) { foreach (string loadedFileName in openParams.FileNames) { PrintQueueItem queueItem = new PrintQueueItem(System.IO.Path.GetFileNameWithoutExtension(loadedFileName), System.IO.Path.GetFullPath(loadedFileName)); PrintQueueControl.Instance.AddChild(queueItem); } PrintQueueControl.Instance.EnsureSelection(); PrintQueueControl.Instance.Invalidate(); } PrintQueueControl.Instance.SaveDefaultQueue(); }
void importPresets_Click(object sender, MouseEventArgs mouseEvent) { OpenFileDialogParams openParams = new OpenFileDialogParams("Load Slice Preset|*.slice;*.ini"); openParams.ActionButtonLabel = "Load Slice Preset"; openParams.Title = "MatterControl: Select A File"; FileDialog.OpenFileDialog(ref openParams); if (openParams.FileNames != null) { Dictionary <string, DataStorage.SliceSetting> settingsDictionary = new Dictionary <string, DataStorage.SliceSetting>(); try { if (File.Exists(openParams.FileName)) { string[] lines = System.IO.File.ReadAllLines(openParams.FileName); foreach (string line in lines) { //Ignore commented lines if (!line.StartsWith("#")) { string[] settingLine = line.Split('='); string keyName = settingLine[0].Trim(); string settingDefaultValue = settingLine[1].Trim(); DataStorage.SliceSetting sliceSetting = new DataStorage.SliceSetting(); sliceSetting.Name = keyName; sliceSetting.Value = settingDefaultValue; sliceSetting.SettingsCollectionId = windowController.ActivePresetLayer.settingsCollectionData.Id; settingsDictionary.Add(keyName, sliceSetting); } } windowController.ActivePresetLayer.settingsDictionary = settingsDictionary; LoadSettingsRows(); } } catch (Exception e) { // Error loading configuration } } }
void loadFile_ClickOnIdle(object state) { OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file, Select a GCODE file|*.stl;*.gcode", multiSelect: true); FileDialog.OpenFileDialog(ref openParams); if (openParams.FileNames != null) { foreach (string loadedFileName in openParams.FileNames) { PrintItem printItem = new PrintItem(); printItem.Name = Path.GetFileNameWithoutExtension(loadedFileName); printItem.FileLocation = Path.GetFullPath(loadedFileName); printItem.PrintItemCollectionID = LibraryData.Instance.LibraryCollection.Id; printItem.Commit(); LibraryData.Instance.AddItem(new PrintItemWrapper(printItem)); } } }
private void onPresetLoad(OpenFileDialogParams openParams) { if (openParams.FileNames != null) { SliceSettingsCollection settingsCollection; try { if (File.Exists(openParams.FileName)) { //Create collection to hold preset settings settingsCollection = new SliceSettingsCollection(); settingsCollection.Tag = windowController.filterTag; settingsCollection.PrinterId = ActivePrinterProfile.Instance.ActivePrinter.Id; settingsCollection.Name = System.IO.Path.GetFileNameWithoutExtension(openParams.FileName); settingsCollection.Commit(); string[] lines = System.IO.File.ReadAllLines(openParams.FileName); foreach (string line in lines) { //Ignore commented lines if (!line.StartsWith("#")) { string[] settingLine = line.Split('='); string keyName = settingLine[0].Trim(); string settingDefaultValue = settingLine[1].Trim(); //To do - validate imported settings as valid (KP) SliceSetting sliceSetting = new SliceSetting(); sliceSetting.Name = keyName; sliceSetting.Value = settingDefaultValue; sliceSetting.SettingsCollectionId = settingsCollection.Id; sliceSetting.Commit(); } } windowController.ChangeToSlicePresetList(); } } catch (Exception) { // Error loading configuration } } }
void loadFile_Click(object sender, MouseEventArgs mouseEvent) { OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file, Select a GCODE file|*.stl;*.gcode", multiSelect: true); FileDialog.OpenFileDialog(ref openParams); if (openParams.FileNames != null) { foreach (string loadedFileName in openParams.FileNames) { PrintItem printItem = new PrintItem(); printItem.Name = System.IO.Path.GetFileNameWithoutExtension(loadedFileName); printItem.FileLocation = System.IO.Path.GetFullPath(loadedFileName); printItem.PrintItemCollectionID = ToolsListControl.Instance.LibraryCollection.Id; printItem.Commit(); ToolsListItem queueItem = new ToolsListItem(new PrintItemWrapper(printItem)); ToolsListControl.Instance.AddChild(queueItem); } ToolsListControl.Instance.Invalidate(); } ToolsListControl.Instance.SaveLibraryItems(); }
void onLoadPreset(OpenFileDialogParams openParams) { if (openParams.FileNames != null) { Dictionary <string, DataStorage.SliceSetting> settingsDictionary = new Dictionary <string, DataStorage.SliceSetting>(); try { if (File.Exists(openParams.FileName)) { string[] lines = System.IO.File.ReadAllLines(openParams.FileName); foreach (string line in lines) { //Ignore commented lines if (!line.StartsWith("#")) { string[] settingLine = line.Split('='); string keyName = settingLine[0].Trim(); string settingDefaultValue = settingLine[1].Trim(); DataStorage.SliceSetting sliceSetting = new DataStorage.SliceSetting(); sliceSetting.Name = keyName; sliceSetting.Value = settingDefaultValue; sliceSetting.SettingsCollectionId = windowController.ActivePresetLayer.settingsCollectionData.Id; settingsDictionary.Add(keyName, sliceSetting); } } windowController.ActivePresetLayer.settingsDictionary = settingsDictionary; LoadSettingsRows(); } } catch (Exception e) { // Error loading configuration } } }
void LoadFileOnIdle(object state) { OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file, Select a GCODE file|*.stl;*.gcode", multiSelect: true); openParams.ActionButtonLabel = "Add to Queue"; openParams.Title = "MatterControl: Select A File"; FileDialog.OpenFileDialog(ref openParams); if (openParams.FileNames != null) { foreach (string loadedFileName in openParams.FileNames) { PrintQueueItem queueItem = new PrintQueueItem(System.IO.Path.GetFileNameWithoutExtension(loadedFileName), System.IO.Path.GetFullPath(loadedFileName)); PrintQueueControl.Instance.AddChild(queueItem); } if (PrintQueueControl.Instance.Count > 0) { PrintQueueControl.Instance.SelectedIndex = PrintQueueControl.Instance.Count - 1; } //PrintQueueControl.Instance.EnsureSelection(); PrintQueueControl.Instance.Invalidate(); } PrintQueueControl.Instance.SaveDefaultQueue(); }
public void OpenFromDialog() { OpenFileDialogParams openParams = new OpenFileDialogParams("Zip file|*.zip"); FileDialog.OpenFileDialog(openParams, onProjectArchiveLoad); }