public void FileSelectorTest1() { string baseDir = "basetestdir/"; string dir1 = baseDir + "dir1/"; string dir2 = dir1 + "dir2/"; string file1 = baseDir + dir1 + "file1"; string file2 = baseDir + dir2 + "file2"; string file3 = baseDir + dir2 + "file3"; string file4 = baseDir + "dir3/file4"; try { Core.Miscellaneous.Utilities.EnsureFileExists(file1, true); Core.Miscellaneous.Utilities.EnsureFileExists(file2, true); Core.Miscellaneous.Utilities.EnsureFileExists(file3, true); Core.Miscellaneous.Utilities.EnsureFileExists(file4, true); FileSelector fileSelector = FileSelector.SingleFile(file2); Assert.AreEqual(1, fileSelector.Files.Count()); Assert.AreEqual(file2, fileSelector.Files.First()); fileSelector = FileSelector.FilesInFolder(baseDir, true); Assert.AreEqual(4, fileSelector.Files.Count()); fileSelector = FileSelector.FilesInFolder(baseDir, false); Assert.AreEqual(0, fileSelector.Files.Count()); } finally { Core.Miscellaneous.Utilities.EnsureDirectoryDoesNotExist(baseDir); } }
public void Open_File() { try { string file = FileSelector.BrowseFile(FileType.Excel97); DirectoryTabcontrol RanString = tabControl as DirectoryTabcontrol; int name = file.LastIndexOf("\\"); string _nametab = file.Substring(name + 1); try { RanString.duongdan.Add(_nametab, file); RanString.nameoftab = _nametab; RanString.Dir = file; RanString.Run(); } catch { RanString.nameoftab = _nametab; RanString.Dir = file; RanString.Run(); } counttabpage(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void TestJpgFilesOnly() { AddStep("create", () => Child = new FileSelector(validFileExtensions: new[] { ".jpg" }) { RelativeSizeAxes = Axes.Both }); }
public MainWindowViewModel() { PageContent = new HomeView(); fileSelector = new FileSelector(); InitializeCommands(); }
private void ChangeLogPlayerFile_Click(object sender, RoutedEventArgs e) { var dlg = new FileSelector("\\rawlogs", LogPlayerFileName.Text, "vms") { Owner = this, WindowStartupLocation = WindowStartupLocation.CenterOwner, ExcludeLockedFiles = true, }; if ((bool)dlg.ShowDialog()) { LogPlayerFileName.Text = dlg.ResultFilePath; } /*OpenFileDialog dlg = new OpenFileDialog * { * DefaultExt = ".vms", * Filter = "VMS Log Files (*.vms)|*.vms", * InitialDirectory = RawLogOpener.RawLogBaseDirectory, * }; * * bool? result = dlg.ShowDialog(); * if (result == true) * { * LogPlayerFileName.Text = dlg.FileName; * }*/ }
public string GetSrcFolder(string path) { var fetchResult = FileSelector.SelectSingle(ViewActivity, SelectorType.Directory, path); Task.WaitAll(fetchResult); return(fetchResult.Result); }
private void on_avatarButton_clicked(object o, EventArgs args) { FileSelector selector = new FileSelector("Select Image"); selector.Show(); int result = selector.Run(); if (result == (int)Gtk.ResponseType.Ok) { try { Gdk.Pixbuf pixbuf = new Gdk.Pixbuf(selector.Filename); if (pixbuf.Width > 80 | pixbuf.Height > 80) { pixbuf = pixbuf.ScaleSimple(80, 80, Gdk.InterpType.Hyper); } avatarImage.Pixbuf = pixbuf; avatarImage.Sensitive = true; } catch (Exception ex) { selector.Hide(); Gui.ShowMessageDialog(ex.Message); return; } } selector.Hide(); }
private void ChangeLogFile_Click(object sender, RoutedEventArgs e) { //"Text files (*.txt)|*.txt|All files (*.*)|*.*"; var dlg = new FileSelector("\\rawlogs", CurrentLogFile.Text, "vms") { Owner = this, WindowStartupLocation = WindowStartupLocation.CenterOwner, ExcludeLockedFiles = true, AllowNewFiles = true, NewFilesExtension = ".vms", AllowImports = true, ImportFilter = "VMS Log Files (*.vms)|*.vms", }; if ((bool)dlg.ShowDialog()) { bool okayToUseFile = true; var newFilePath = dlg.ResultFilePath; if (!FileOpener.IsFileEmpty(newFilePath)) { string messageBoxText = FileOpener.GetFileName(newFilePath) + " already exists. Logging to this file will overwrite it. Do you want to continue?"; string caption = "VMS Logging"; MessageBoxButton yesNoBtn = MessageBoxButton.YesNoCancel; MessageBoxImage icon = MessageBoxImage.Warning; MessageBoxResult messageResult = MessageBox.Show(messageBoxText, caption, yesNoBtn, icon); okayToUseFile = (messageResult == MessageBoxResult.Yes); } if (okayToUseFile) { Settings.rawLogFilePath = newFilePath; SetCurrentLogFileText(); } } }
private void RenderToolbar() { GUILayout.FlexibleSpace(); bool flag = GUI.enabled; GUI.enabled = !this.m_PackageController.IsUploading; if (GUILayout.Button("Refresh Packages", EditorStyles.toolbarButton, new GUILayoutOption[0])) { this.RefreshPackages(); } if (AssetStoreManager.sDbgButtons) { GUILayout.Label("Debug: ", AssetStoreManager.Styles.ToolbarLabel, new GUILayoutOption[0]); if (GUILayout.Button("FileSelector", EditorStyles.toolbarButton, new GUILayoutOption[0])) { FileSelector.Show("/", new List <string>(), (List <string> newList) => { foreach (string str in newList) { DebugUtils.Log(str); } }); } if (GUILayout.Button("Logout", EditorStyles.toolbarButton, new GUILayoutOption[0])) { AssetStoreClient.Logout(); } } GUI.enabled = flag; }
public static bool SerializeToFile <T>(T data, string typeName, string extension) where T : class { if (data == null) { return(dealWhenDataIsNull(typeName)); } string filter = string.Format("{0}文件(*.{1}) | *.{1}", typeName, extension); string fileName = FileSelector.SelectSaveFile(filter); try { if (!string.IsNullOrWhiteSpace(fileName)) { JsonParser.SerializeToFile <T>(data, fileName, true); string message = string.Format("成功导出{0}文件!", typeName); DialogWin.Show(message, "导出成功", DialogWinImage.Information); } } catch { string message = string.Format("{0}\"{1}\"导出失败!", typeName, fileName); DialogWin.Show(message, "导出错误", DialogWinImage.Error); } return(false); }
public void CompressFiles() { var fileSelector = new FileSelector(""); var readOptions = new ReadOptions(); var crc32 = new CRC32(); var inputStream = new Ionic.BZip2.BZip2InputStream(new FileStream("", FileMode.Open)); }
/// <summary> /// Utility method to populate a GTK FileSelector from the data properties. /// </summary> internal void SetDefaultProperties(FileSelector fdiag) { fdiag.Title = Title; fdiag.Action = Action.ToGtkAction(); fdiag.LocalOnly = true; fdiag.SelectMultiple = SelectMultiple; fdiag.TransientFor = TransientFor; if (!CurrentFolder.IsNullOrEmpty) { fdiag.SetCurrentFolder(CurrentFolder); } if (!string.IsNullOrEmpty(InitialFileName)) { fdiag.CurrentName = InitialFileName; } if (!CurrentFolder.IsNullOrEmpty && !string.IsNullOrEmpty(InitialFileName)) { var checkName = data.CurrentFolder.Combine(InitialFileName); if (System.IO.File.Exists(checkName)) { fdiag.SetFilename(checkName); } } SetGtkFileFilters(fdiag); }
protected override Control AddEditor(Control container) { FileSelector selector = new FileSelector(); selector.ID = Name; container.Controls.Add(selector); return(selector); }
private void Open_File_Click(object sender, EventArgs e) { string file = FileSelector.BrowseFile(FileType.Excel97); DirectoryTabcontrol RanString = tabControl as DirectoryTabcontrol; RanString.Dir = file; RanString.Run(); }
public void Open_Load_Dialog_File() { #if UNITY_WEBGL return; #else FileSelector.GetFile(Search_file_load, ".sav"); #endif }
protected void Page_Init(object sender, EventArgs e) { if (!IsPostBack && Request["LoadFile"] != null) { FileSelector.SetValue(Request["LoadFile"].ToString()); LoadFile(); } }
protected override Control AddEditor(Control container) { FileSelector selector = new FileSelector(); selector.SelectableExtensions = FileSelector.ImageExtensions; selector.ID = Name; container.Controls.Add(selector); return(selector); }
public SelectorUploadComposite() { SelectorControl = new FileSelector(); SelectorControl.ID = "Selector"; UploadControl = new FileUpload(); UploadControl.ID = "Uploader"; UploadLabel = new Label(); UploadLabel.AssociatedControlID = UploadControl.ID; }
protected override Control AddEditor(Control container) { FileSelector selector = new FileSelector(); selector.SelectableTypes = typeof(IFileSystemDirectory).Name; selector.ID = Name; container.Controls.Add(selector); return(selector); }
private void toolStripButtonOpen_Click(object sender, EventArgs e) { string file = FileSelector.BrowseFile(); if (file != null) { richTextBoxSource.Text = File.ReadAllText(file); } }
// Update is called once per frame void Update() { //if we don't have an open window yet, and the spacebar is down... if (!windowOpen && Input.GetKeyDown(KeyCode.Space)) { FileSelector.GetFile(GotFile, ".txt"); //generate a new FileSelector window windowOpen = true; //record that we have a window open } }
public void OpenFile() { if (!windowOpen) { this.menu.SetActive(false); FileSelector.GetFile(GotFile, ".dll"); windowOpen = true; } }
private void CmdBrowseFile_Click(object sender, EventArgs e) { if (FileSelector.ShowDialog() != DialogResult.OK) { return; } mParameterValue.Text = FileSelector.FileName; }
protected override Control AddEditor(Control container) { FileSelector selector = new FileSelector(); selector.SelectableExtensions = FileSelector.ImageExtensions; selector.ID = Name; selector.Placeholder(GetLocalizedText("Placeholder") ?? Placeholder); container.Controls.Add(selector); return(selector); }
private void Button_Validate_Click(object sender, EventArgs e) { FileSelector fsObj = new FileSelector(); List <string> error_List = new List <string>(); string ProjectPath; ProjectPath = Project_Path_text.Text; error_List = fsObj.ValidateAllFiles(ProjectPath); }
private void doSelectFile() { string ext = DirectoryHelper.LayoutFileExt; string file = FileSelector.SelectOpenFile($"布局文件(*.{ext})|*.{ext}"); if (!string.IsNullOrWhiteSpace(file)) { CurrentEdit.FileName = file; } }
protected override Control AddEditor(Control container) { FileSelector selector = new FileSelector(); selector.SelectableTypes = typeof(IFileSystemDirectory).Name; selector.ID = Name; selector.Placeholder(GetLocalizedText("Placeholder") ?? Placeholder); container.Controls.Add(selector); return(selector); }
public override bool UpdateItem(ContentItem item, Control editor) { FileSelector selector = (FileSelector)editor; if (selector.Url != item[Name] as string) { item[Name] = selector.Url; return(true); } return(false); }
public void Get(int _, IEnumerable <string> src, IEnumerable <string> expected) { var cmp = expected.Select(e => GetSource(e)).ToArray(); var dest = new FileSelector(IO).Get(src.Select(e => GetSource(e))).ToArray(); Assert.That(dest.Length, Is.EqualTo(cmp.Length)); for (var i = 0; i < dest.Length; ++i) { Assert.That(dest[i], Is.EqualTo(cmp[i])); } }
/// <summary> /// Save, this is the command action to the selected file. /// the interaction state will become 'is busy' /// </summary> public async void Save() { using (State.BusyScope()) { Emitter.Publish(CommonLocalised.LineDivider); Emitter.Publish(CommonLocalised.CommencingSaveFormat, DateTime.Now.AsUKDatetime()); Emitter.Publish(CommonLocalised.LineDivider); await Console.Save(() => FileSelector.GetFileName <IManageConsoleOutput>(TypeOfFileOperation.Save)); } }
private void addPluginButton_Clicked(object sender, EventArgs args) { FileSelector selector = new FileSelector ("Select plugin to load"); selector.Show (); int result = selector.Run (); if (result == (int)Gtk.ResponseType.Ok) { try { PluginInfo info = new PluginInfo (selector.Filename); pluginsListStore.AppendValues (info); } catch (Exception ex) { LoggingService.LogError(ex); } } selector.Destroy(); }
//This is called when the FileSelector window closes for any reason. //'Status' is an enumeration that tells us why the window closed and if 'path' is valid. void GotFile(FileSelector.Status status, string path){ Debug.Log("File Status : "+status+", Path : "+path); this.path = path; this.windowOpen = false; }
private void on_browseInputFile_clicked(object o, EventArgs e) { FileSelector fileSelector = new FileSelector("Select Glade XML File"); if (fileSelector.Run() == (int)Gtk.ResponseType.Ok) inputFileEntry.Text = fileSelector.Filename; fileSelector.Destroy(); }
private void on_avatarButton_clicked(object o, EventArgs args) { FileSelector selector = new FileSelector ("Select Image"); selector.Show (); int result = selector.Run (); if (result == (int)Gtk.ResponseType.Ok) { try { Gdk.Pixbuf pixbuf = new Gdk.Pixbuf (selector.Filename); if (pixbuf.Width > 80 | pixbuf.Height > 80) pixbuf = pixbuf.ScaleSimple (80, 80, Gdk.InterpType.Hyper); avatarImage.Pixbuf = pixbuf; avatarImage.Sensitive = true; } catch (Exception ex) { selector.Hide (); Gui.ShowMessageDialog (ex.Message); return; } } selector.Hide (); }
private void on_saveKeyButton_clicked(object o, EventArgs args) { FileSelector selector = new FileSelector("Save Public Key...", FileChooserAction.Save); selector.TransientFor = dialog; selector.CurrentName = nicknameEntry.Text + ".mpk"; if (selector.Run() == (int)ResponseType.Ok) { string publicKey = new PublicKey(nicknameEntry.Text, provider.ToXmlString(false)).ToArmoredString(); File.WriteAllText(selector.Filename, publicKey); } selector.Destroy(); }
public void Selector_Normalize() { string[][] sPairs = { new string[] { "name = '.\\Selector (this is a Test)\\this.txt'", null}, new string[] { "(size > 100)AND(name='Name (with Parens).txt')", "(size > 100 AND name = 'Name (with Parens).txt')"}, new string[] { "(size > 100) AND ((name='Name (with Parens).txt')OR(name=*.jpg))", "(size > 100 AND (name = 'Name (with Parens).txt' OR name = '*.jpg'))"}, new string[] { "name='*.txt' and name!='* *.txt'", "(name = '*.txt' AND name != '* *.txt')"}, new string[] { "name = *.txt AND name != '* *.txt'", "(name = '*.txt' AND name != '* *.txt')"}, }; for (int i=0; i < sPairs.Length; i++) { var pair = sPairs[i]; var selector = pair[0]; var expectedResult = pair[1]; var fsel = new FileSelector(selector); var stringVer = fsel.ToString().Replace("\u00006"," "); Assert.AreEqual<string>("FileSelector("+ (expectedResult ?? selector) +")", stringVer, "entry {0}", i); } }