Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle double click on the contentTree #1443

Merged
merged 1 commit into from
Sep 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GUI/Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions GUI/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,15 +1063,20 @@ private void FocusMod(string key, bool exactMatch)

private void RecommendedModsToggleCheckbox_CheckedChanged(object sender, EventArgs e)
{
var state = ((CheckBox)sender).Checked;
foreach (ListViewItem item in RecommendedModsListView.Items)
{
if (item.Checked != state)
var state = ((CheckBox)sender).Checked;
foreach (ListViewItem item in RecommendedModsListView.Items)
{
item.Checked = state;
if (item.Checked != state)
{
item.Checked = state;
}
}
}
RecommendedModsListView.Refresh();
RecommendedModsListView.Refresh();
}

private void ContentsPreviewTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
OpenFileBrowser(e.Node);
}
}

Expand Down
29 changes: 29 additions & 0 deletions GUI/MainModInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;

namespace CKAN
{
Expand Down Expand Up @@ -266,5 +268,32 @@ private void _PostModCaching(CkanModule module)
UpdateModContentsTree(module, true);
RecreateDialogs();
}

/// <summary>
/// Opens the file browser of the users system
/// with the folder of the clicked node opened
/// TODO: Open a file broweser with the file selected
/// </summary>
/// <param name="node">A node of the ContentsPreviewTree</param>
internal void OpenFileBrowser(TreeNode node)
{
string location = node.Text;

if (File.Exists(location))
{
//We need the Folder of the file
//Otherwise the OS would try to open the file in it's default application
location = Path.GetDirectoryName(location);
}

if (!Directory.Exists(location))
{
//User either selected the parent node
//or he clicked on the tree node of a cached, but not installed mod
return;
}

Process.Start(location);
}
}
}