Skip to content

Commit 979c38f

Browse files
Added Examples.
1 parent 5cadc88 commit 979c38f

File tree

130 files changed

+23367
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+23367
-0
lines changed

CoreReferences.props

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<PackageReference Include="ShellBrowser.Core">
5+
<Version>6.2.*</Version>
6+
</PackageReference>
7+
</ItemGroup>
8+
</Project>

CoreSample/CoreSample.csproj

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{A226D9C3-2CD6-4F80-974A-38BE39551F09}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>CoreSample</RootNamespace>
10+
<AssemblyName>CoreSample</AssemblyName>
11+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<TargetFrameworkProfile />
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
<Prefer32Bit>false</Prefer32Bit>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<PlatformTarget>AnyCPU</PlatformTarget>
29+
<DebugType>pdbonly</DebugType>
30+
<Optimize>true</Optimize>
31+
<OutputPath>bin\Release\</OutputPath>
32+
<DefineConstants>TRACE</DefineConstants>
33+
<ErrorReport>prompt</ErrorReport>
34+
<WarningLevel>4</WarningLevel>
35+
<Prefer32Bit>false</Prefer32Bit>
36+
</PropertyGroup>
37+
<PropertyGroup>
38+
<ApplicationIcon>..\ShellBrowserComponents-Icon.ico</ApplicationIcon>
39+
</PropertyGroup>
40+
<ItemGroup>
41+
<Reference Include="System" />
42+
<Reference Include="System.Core" />
43+
<Reference Include="System.Xml.Linq" />
44+
<Reference Include="System.Data.DataSetExtensions" />
45+
<Reference Include="Microsoft.CSharp" />
46+
<Reference Include="System.Data" />
47+
<Reference Include="System.Xml" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<Compile Include="Program.cs" />
51+
<Compile Include="Properties\AssemblyInfo.cs" />
52+
</ItemGroup>
53+
<ItemGroup>
54+
<None Include="app.config" />
55+
</ItemGroup>
56+
<Import Project="..\CoreReferences.props" />
57+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
58+
</Project>

CoreSample/Program.cs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System;
2+
using Jam.Shell;
3+
4+
namespace CoreSample
5+
{
6+
class Program
7+
{
8+
static void Main(string[] args)
9+
{
10+
try
11+
{
12+
if (args.Length < 3)
13+
throw new ArgumentException(String.Format("Missing parameter!\nUsage \"{0}\" CanonicalShellColumnId [GET | SET PropertyValue] File(s) \n\nNote that files must be absolute paths and enquoted.\n\nExample: To set property \"Artist\" of an .mp3 file use \"{0}\" System.Music.Artist \"Great Artist\" \"C:\\Users\\Public\\album.mp3\".\n\nVisit https://msdn.microsoft.com/en-us/library/windows/desktop/mt805470(v=vs.85).aspx for more properties.", System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName));
14+
15+
SHCOLUMNID lShellColumnId = new SHCOLUMNID(args[0]);
16+
17+
if (lShellColumnId.IsInvalid())
18+
throw new ArgumentException("Invalid canonical property name. Use e.g. System.Music.Artist");
19+
20+
bool lSetProperty = args[1].Equals("SET", StringComparison.OrdinalIgnoreCase);
21+
22+
for (int i = (lSetProperty ? 3 : 2); i < args.Length; i++)
23+
{
24+
ItemIdList itemIdList = new ItemIdList(args[i]);
25+
26+
if (itemIdList.IsInvalid)
27+
{
28+
Console.WriteLine("\"{0}\" is invalid", args[i]);
29+
continue;
30+
}
31+
32+
// Get or set properties
33+
if (lSetProperty)
34+
{
35+
Console.WriteLine("Setting property \"{0}\" with value \"{1}\" of \"{2}\"", lShellColumnId.ToString(), args[2], args[i]);
36+
itemIdList.SetPropertyValue(lShellColumnId, args[2]);
37+
38+
if (!args[2].Equals(itemIdList.GetPropertyDisplayValue(lShellColumnId)))
39+
Console.WriteLine("Failed to set property \"{0}\" with value \"{1}\" of \"{2}\"", lShellColumnId.ToString(), args[2], args[i]);
40+
}
41+
else
42+
{
43+
Console.WriteLine("Property \"{0}\" of \"{1}\" is \"{2}\"", lShellColumnId.ToString(), args[i], itemIdList.GetPropertyDisplayValue(lShellColumnId));
44+
}
45+
}
46+
}
47+
catch(Exception e)
48+
{
49+
Console.WriteLine("[Error] " + e.Message);
50+
}
51+
finally
52+
{
53+
Console.WriteLine("Done. Press enter to quit.");
54+
Console.ReadLine();
55+
}
56+
}
57+
}
58+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("CoreSample")]
9+
[assembly: AssemblyDescription("ShellBrowser.Core sample")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("JAM Software")]
12+
[assembly: AssemblyProduct("CoreSample")]
13+
[assembly: AssemblyCopyright("Copyright © JAM Software 2018")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("a226d9c3-2cd6-4f80-974a-38be39551f09")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

CoreSample/app.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

Customization/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
</configuration>

Customization/CustomColumns.Designer.cs

Lines changed: 108 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Customization/CustomColumns.cs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Drawing;
5+
using System.Data;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using System.Windows.Forms;
10+
using Jam.Shell;
11+
12+
namespace Jam.Samples.Customization
13+
{
14+
public partial class CustomColumns : UserControl, IExampleForm
15+
{
16+
public CustomColumns()
17+
{
18+
InitializeComponent();
19+
}
20+
21+
private static string cInfo = "This example shows how to add and fill custom columns easily." + Environment.NewLine +
22+
Environment.NewLine
23+
+ "The CreatedColumns event is called every time the columns for a ShellListView are created, i.e. when opening a folder or doing a FullRefresh. " +
24+
Environment.NewLine
25+
+ "You can either use it to display additional shell columns or to add custom columns. " +
26+
Environment.NewLine
27+
+ "Shell columns are filled automatically." + Environment.NewLine
28+
+ "For custom columns values have to be provided in the AddItem EventHandler. In the example, 2 columns are added, the first custom column will be used for the path length and the second for the link target." +
29+
Environment.NewLine
30+
+ "To fill the columns, we use the AddItem event handler. We retrieve the path length, the possible link target and add subitems containing these information to the currently added item.";
31+
32+
33+
34+
string cPathLengthString = "Path Length";
35+
string cLinkTargetString = "Link Target";
36+
37+
38+
private void shellListView1_AddItem(object sender, Shell.AddItemEventArgs e)
39+
{
40+
// get the path length
41+
string lLength = e.Item.FullPath.Length.ToString();
42+
// add the path length as subitem
43+
e.Item.SubItems.Add(lLength);
44+
45+
// check whether the item is a link
46+
// note: the next few lines are just used for illustrative purposes.
47+
// the retrieval of the link target may take some time for large file lists
48+
string lLinkTarget = ShellBrowser.GetLinkTarget(e.Item.FullPath);
49+
// add the link target as subitem (if it`s not a link, an empty string was returned)
50+
e.Item.SubItems.Add(lLinkTarget);
51+
52+
}
53+
54+
private void shellListView1_CreatedColumns(object sender, EventArgs e)
55+
{
56+
// add a column for the path length
57+
JamShellColumnHeader lCol = new JamShellColumnHeader();
58+
lCol.Text = cPathLengthString;
59+
lCol.TextAlign = HorizontalAlignment.Right;
60+
lCol.Width = 85;
61+
shellListView1.Columns.Add(lCol);
62+
63+
// add a column for the link target
64+
lCol = new JamShellColumnHeader();
65+
lCol.Text = cLinkTargetString;
66+
// the link target is a full path so we need a large column
67+
lCol.Width = 350;
68+
shellListView1.Columns.Add(lCol);
69+
70+
}
71+
72+
public ScrollableControl GetMainPanel()
73+
{
74+
return this;
75+
}
76+
77+
public string GetDescription()
78+
{
79+
return cInfo;
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)