public DialogResult ShowDialog(FileItem item, IWin32Window owner = null) { this.FileItem = item ?? new FileItem() { TargetDir = GlobalPath.GetFilePaths().FirstOrDefault(), FileOverride = FileOverride.Try }; this.txtFile.Text = FileItem.Path; this.cmbTargetDir.SelectedItem = FileItem.TargetDir; this.cmbOverride.SelectedItem = FileItem.FileOverride; if (owner != null) { return(this.ShowDialog(owner)); } else { return(this.ShowDialog()); } }
public DlgFolder() { InitializeComponent(); this.dlg.Description = "选择文件夹"; this.dlg.ShowNewFolderButton = false; filePaths = GlobalPath.GetFilePaths(); this.cmbTargetDir.Items.AddRange(filePaths); if (this.cmbTargetDir.Items.Count > 0) { this.cmbTargetDir.SelectedIndex = 0; } this.cmbOverride.DataSource = EnumHelper.GetFileOverridePairs().ToList(); this.cmbOverride.DisplayMember = "Value"; this.cmbOverride.ValueMember = "Key"; this.cmbOverride.SelectedValue = FileOverride.Try; this.btnSelect.Click += BtnSelect_Click; this.btnOk.Click += BtnOk_Click; this.btnCancel.Click += BtnCancel_Click; }
public DlgFile() { InitializeComponent(); this.dlg.Multiselect = false; this.dlg.Title = "选择文件"; this.dlg.RestoreDirectory = false; filePaths = GlobalPath.GetFilePaths(); this.cmbTargetDir.Items.AddRange(filePaths); if (this.cmbTargetDir.Items.Count > 0) { this.cmbTargetDir.SelectedIndex = 0; } this.cmbOverride.DataSource = EnumHelper.GetFileOverridePairs().ToList(); this.cmbOverride.DisplayMember = "Value"; this.cmbOverride.ValueMember = "Key"; this.cmbOverride.SelectedValue = FileOverride.Try; this.btnSelect.Click += BtnSelect_Click; this.btnOk.Click += BtnOk_Click; this.btnCancel.Click += BtnCancel_Click; }
private void InitGlobal() { this.lvGlobal.ShowGroups = true; this.lvGlobal.Items.Clear(); var vars = this.context.PageItemKeys; if (vars.Any()) { var grp = new ListViewGroup("变量"); this.lvGlobal.Groups.Add(grp); foreach (var @var in vars) { var item = new ListViewItem($"$[{@var}]", grp); this.lvGlobal.Items.Add(item); } } var paths = GlobalPath.GetInstallPaths().Concat(GlobalPath.GetShortCutPaths()).Concat(GlobalPath.GetFilePaths()); if (paths.Any()) { var grp = new ListViewGroup("路径"); this.lvGlobal.Groups.Add(grp); foreach (var path in paths) { var item = new ListViewItem(path, grp); this.lvGlobal.Items.Add(item); } } if (this.context.Files != null && this.context.Files.Any()) { var grp = new ListViewGroup("文件"); this.lvGlobal.Groups.Add(grp); foreach (var file in this.context.Files) { var item = new ListViewItem(file.Key, grp); this.lvGlobal.Items.Add(item); } } this.lvGlobal.EnableGroupEvent(); this.lvGlobal.EnableSort(); }