Skip to content

Commit

Permalink
replaced FileDialog.ShowDialog() logic to Shown event
Browse files Browse the repository at this point in the history
  • Loading branch information
Meragon committed Nov 24, 2016
1 parent 6e00237 commit 764b9bf
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions System/Windows/Forms/FileDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,28 @@ public FileDialog()
};

fileRender.filesTree.NodeMouseClick += filesTree_NodeMouseClick;

this.Shown += FileDialog_Shown;
}

private void FileDialog_Shown(object sender, EventArgs e)
{
var fs = Filter.Split('|');
for (int i = 0; i < fs.Length; i += 2)
comboFilter.Items.Add(fs[i]);

if (comboFilter.Items.Count > 0)
{
comboFilter.SelectedIndex = 0;
comboFilter.SelectedIndexChanged += (s, a) =>
{
fileRender.SetDirectory(fileRender.currentPath);
};
}

fileRender.SetDirectory(fileRender.currentPath);

}
protected virtual void filesTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (e.Button == MouseButtons.Right)
Expand Down Expand Up @@ -240,27 +260,6 @@ protected override void OnPaint(PaintEventArgs e)
base.OnPaint(e);
e.Graphics.DrawLine(new Pen(BorderColor), 1, HeaderHeight, Width - 1, HeaderHeight);
}
public new DialogResult ShowDialog()
{
var fs = Filter.Split('|');
for (int i = 0; i < fs.Length; i += 2)
comboFilter.Items.Add(fs[i]);

if (comboFilter.Items.Count > 0)
{
comboFilter.SelectedIndex = 0;
comboFilter.SelectedIndexChanged += (sender, args) =>
{
fileRender.SetDirectory(fileRender.currentPath);
};
}

fileRender.SetDirectory(fileRender.currentPath);

base.ShowDialog();

return Forms.DialogResult.None;
}

protected void OpenFile()
{
Expand Down

0 comments on commit 764b9bf

Please sign in to comment.