/// <summary> /// フォルダを編集するダイアログを生成します。 /// </summary> /// <param name="btn">編集するフォルダボタン</param> public AddFolderDialog(FolderButton btn) { InitializeComponent(); SetEventHandler(); this.FolderButton = btn; SetValueToControls(); }
//新しくインスタンスを生成します。 private void CreateNew() { FolderButton = new FolderButton(tbPath.Text, tbName.Text) { BackColor = btnColor.BackColor }; }
/// <summary> /// 指定されている設定ファイルを読み込みます。 /// </summary> public void Load() { if (!File.Exists(FilePath)) { return; } FolderButtons = File.ReadLines(FilePath, Encoding.Unicode). Where(i => !string.IsNullOrWhiteSpace(i)). Select(i => FolderButton.LineToFolderPath(i)).ToList(); }
//ボタンパネル部にドラッグドロップ private void ButtonPanel_DragDrop(object sender, DragEventArgs e) { var aPath = (e.Data.GetData(DataFormats.FileDrop) as string[])?.FirstOrDefault(); if (e.Effect == DragDropEffects.Copy) { if (File.Exists(aPath) && aPath.EndsWith(FolderListFile.Extension)) { ListFile.FilePath = aPath; LoadFolderList(); } else if (Directory.Exists(aPath)) { ListFile.FolderButtons.Add(new FolderButton(aPath, "") { BackColor = FolderButton.RandomSampleColor() }); ListFile.Save(); LoadFolderList(); } } }