public RequestFileForm(string title = "", string defdir = "") { LockedSize = true; DirBox = new TextBoxForm( ).Set(55, 35, 300, 20) as TextBoxForm; FileBox = new TextBoxForm( ).Set(10, 415, 300, 20) as TextBoxForm; Add(DirBox); Add(FileBox); UIForm cancel = new ButtonForm().Set(10, 450, 120, 20, "Cancel"); UIForm ok = new ButtonForm().Set(180, 450, 120, 20, "Select"); void SelectFunc(int b) { Selected?.Invoke(DirBox.Text + "/" + FileBox.Text); } ok.Click = SelectFunc; Add(cancel); Add(ok); if (defdir == "") { defdir = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); } if (title == "") { title = "Select file"; } Set(FusionApp.W / 2 - 200, FusionApp.H / 2 - 250, 400, 500, title); Files = new ListForm( ).Set(10, 60, 370, 350, "") as ListForm; Add(Files); Scan(defdir); BackFolder = new ButtonForm( ).Set(0, 25, 64, 32, "").SetImage(new Texture2D("data/UI/backfolder1.png", LoadMethod.Single, true)) as ButtonForm; void BackFunc(int b) { if (new DirectoryInfo(CurPath).Parent == null) { return; } string curPath = new DirectoryInfo(CurPath).Parent.FullName; Forms.Remove(Files); Files = new ListForm( ).Set(10, 60, 370, 350, "") as ListForm; Add(Files); Scan(curPath); } BackFolder.Click = BackFunc; Add(BackFolder); }
private void ifilt(bool asEMBED) { _selected_file = string.Empty; if (openFileDialog.ShowDialog() == DialogResult.OK) { try { if (asEMBED) { _selected_file = this.openFileDialog.FileName; webBrowser.Navigate(_selected_file); } else { try { TextReader reader = new FilterReader(openFileDialog.FileName); using (reader) { string tmp_file = Path.Combine(Environment.GetEnvironmentVariable("TEMP"), DateTime.Now.Ticks.ToString() + ".html"); using (StreamWriter sw = new StreamWriter(tmp_file, false, DefaultEncoding)) { sw.Write(Regex.Replace(reader.ReadToEnd().Replace(Environment.NewLine, "<br>"), "\n", "<BR>" + Environment.NewLine, RegexOptions.Singleline)); sw.Close(); } ////object missing = System.Reflection.Missing.Value; ////object tmp = (object)tmp_file; _selected_file = tmp_file; webBrowser.Navigate(tmp_file); ////this.axWebBrowser1.Navigate2(ref tmp, ref missing, ref missing, ref missing, ref missing); } } catch (ArgumentException) { MessageBox.Show("Данный тип файлов не поддерживается"); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); return; } } SelectFile.Invoke(_selected_file); ////EditModeOn(); }
public RequestFileForm(string title = "", string defdir = "", bool folder = false) { Folder = folder; if (FolderPic == null) { FolderPic = new Texture2D("data/UI/folder1.png", LoadMethod.Single, true); FilePic = new Texture2D("data/UI/file1.png", LoadMethod.Single, true); BackPic = new Texture2D("data/ui/backbut1.png", LoadMethod.Single, true); } LockedSize = true; DirBox = new TextBoxForm().Set(55, 35, 300, 20) as TextBoxForm; FileBox = new TextBoxForm().Set(10, 415, 300, 20) as TextBoxForm; Add(DirBox); Add(FileBox); UIForm cancel = new ButtonForm().Set(10, 450, 120, 20, "Cancel"); UIForm ok = new ButtonForm().Set(180, 450, 120, 20, "Select"); cancel.Click = (b) => { if (UI.CurUI.Top == this) { UI.CurUI.Top = null; } }; void SelectFunc(int b) { if (!Folder) { Selected?.Invoke(DirBox.Text + "\\" + FileBox.Text); } else { Selected?.Invoke(DirBox.Text + "\\"); } } ok.Click = SelectFunc; Add(cancel); Add(ok); if (defdir == "") { defdir = DefDir; // System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); } if (title == "") { title = "Select file"; } Set(AppInfo.W / 2 - 200, AppInfo.H / 2 - 250, 400, 500, title); Files = new ListForm().Set(10, 60, 370, 350, "") as ListForm; Add(Files); Scan(defdir); BackFolder = new ButtonForm().Set(2, 30, 54, 22, "").SetImage(BackPic) as ButtonForm; void BackFunc(int b) { if (new DirectoryInfo(CurPath).Parent == null) { return; } string curPath = new DirectoryInfo(CurPath).Parent.FullName; Forms.Remove(Files); Files = new ListForm().Set(10, 60, 370, 350, "") as ListForm; Add(Files); Scan(curPath); } BackFolder.Click = BackFunc; Add(BackFolder); }