Permalink
Browse files

Commit for Publication (Revised)

  • Loading branch information...
0 parents commit d897540e86ad4e2cd795334396b2ad281e424904 @xivSolutions xivSolutions committed May 24, 2012
@@ -0,0 +1,152 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using System.Windows.Forms.Layout;
+using System.Runtime.InteropServices;
+
+namespace GroupedListControl
+{
+
+ public class GroupListControl : FlowLayoutPanel
+ {
+
+ public GroupListControl()
+ {
+ // Default configuration. Adapt to suit your needs:
+ this.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
+ this.AutoScroll = true;
+ this.WrapContents = false;
+
+ // Add a local handler for the ControlAdded Event.
+ this.ControlAdded += new ControlEventHandler(GroupListControl_ControlAdded);
+ }
+
+
+ /// <summary>
+ /// COnsumed by the Win API calls below:
+ /// </summary>
+ private enum ScrollBarDirection
+ {
+ SB_HORZ = 0,
+ SB_VERT = 1,
+ SB_CTL = 2,
+ SB_BOTH = 3
+ }
+
+
+ /// <summary>
+ /// Disables the horizontal scrollbar in the primary container control.
+ /// Individual ListGroups within the GroupList have their own scrollbars
+ /// if needed.
+ /// </summary>
+ /// <param name="hWnd"></param>
+ /// <param name="wBar"></param>
+ /// <param name="bShow"></param>
+ /// <returns></returns>
+ protected override void WndProc(ref System.Windows.Forms.Message m)
+ {
+ // Call to unmanaged WinAPI:
+ ShowScrollBar(this.Handle, (int)ScrollBarDirection.SB_HORZ, false);
+ base.WndProc(ref m);
+ }
+
+
+ /// <summary>
+ /// Imported from WinAPI: Method to control Scrollbar visibility.
+ /// </summary>
+ /// <param name="hWnd"></param>
+ /// <param name="wBar"></param>
+ /// <param name="bShow"></param>
+ /// <returns></returns>
+ [DllImport("user32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool ShowScrollBar(IntPtr hWnd, int wBar, bool bShow);
+
+
+ /// <summary>
+ /// Handles the ControlAdded Event for the current instance.
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ void GroupListControl_ControlAdded(object sender, ControlEventArgs e)
+ {
+ ListGroup lg = (ListGroup)e.Control;
+ lg.Width = this.Width;
+ lg.GroupCollapsed += new ListGroup.GroupExpansionHandler(lg_GroupCollapsed);
+ lg.GroupExpanded += new ListGroup.GroupExpansionHandler(lg_GroupExpanded);
+ }
+
+
+ /// <summary>
+ /// Gets or Sets a boolean value indicating whether multiple ListGroups
+ /// may be in the expanded state at the same time. When set to true, the current expanded
+ /// ListGroup is collapsed when a new ListGroup is expanded.
+ /// </summary>
+ public bool SingleItemOnlyExpansion { get; set; }
+
+
+ /// <summary>
+ /// Handles the Expanded event for the current instance.
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ void lg_GroupExpanded(object sender, EventArgs e)
+ {
+ // Grab a reference to the ListGroup which sent the message:
+ ListGroup expanded = (ListGroup)sender;
+
+ // If Single item only expansion, collapse all ListGroups in except
+ // the one currently exanding:
+ if(this.SingleItemOnlyExpansion)
+ {
+ this.SuspendLayout();
+ foreach(ListGroup lg in this.Controls)
+ {
+ if (!lg.Equals(expanded))
+ lg.Collapse();
+ }
+ this.ResumeLayout(true);
+ }
+
+ }
+
+
+ /// <summary>
+ /// Handles the Collapsed event for the current instance.
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ void lg_GroupCollapsed(object sender, EventArgs e)
+ {
+ // No need.
+ }
+
+
+ /// <summary>
+ /// Expands all listgroups contained in the current instance.
+ /// </summary>
+ public void ExpandAll()
+ {
+ foreach(ListGroup lg in this.Controls)
+ {
+ lg.Expand();
+ }
+ }
+
+
+ /// <summary>
+ /// Collapses all ListGroups contained in the current instance.
+ /// </summary>
+ public void CollapseAll()
+ {
+ foreach (ListGroup lg in this.Controls)
+ {
+ lg.Collapse();
+ }
+ }
+
+ }
+
+}
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{2C43437C-5E27-48BE-BAC3-A3D0CDB30BFB}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>GroupedListControl</RootNamespace>
+ <AssemblyName>GroupedListControl</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup>
+ <StartupObject />
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Deployment" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="GroupListControl.cs">
+ <SubType>Component</SubType>
+ </Compile>
+ <Compile Include="ListGroup.cs">
+ <SubType>Component</SubType>
+ </Compile>
+ <Compile Include="ListGroupColumnEventArgs.cs" />
+ <Compile Include="ListGroupItemEventArgs.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Resources.resx</DependentUpon>
+ <DesignTime>True</DesignTime>
+ </Compile>
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Settings.settings</DependentUpon>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Resources\CollapsedGroup_png_1616.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Resources\ExpandedGroup_png_1616.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Resources\CollapsedGroupSmall_png_1616.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Resources\ExpandedGroupSmall_png_1616.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Resources\EmptyGroupSmall_png_1616.png" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,29 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GroupedListControl", "GroupedListControl.csproj", "{2C43437C-5E27-48BE-BAC3-A3D0CDB30BFB}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GroupedListDemo", "..\GroupedListDemo\GroupedListDemo.csproj", "{B90BCCEB-6690-44D2-94CC-8C16D1FC8EA6}"
+ ProjectSection(ProjectDependencies) = postProject
+ {2C43437C-5E27-48BE-BAC3-A3D0CDB30BFB} = {2C43437C-5E27-48BE-BAC3-A3D0CDB30BFB}
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x86 = Debug|x86
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {2C43437C-5E27-48BE-BAC3-A3D0CDB30BFB}.Debug|x86.ActiveCfg = Debug|x86
+ {2C43437C-5E27-48BE-BAC3-A3D0CDB30BFB}.Debug|x86.Build.0 = Debug|x86
+ {2C43437C-5E27-48BE-BAC3-A3D0CDB30BFB}.Release|x86.ActiveCfg = Release|x86
+ {2C43437C-5E27-48BE-BAC3-A3D0CDB30BFB}.Release|x86.Build.0 = Release|x86
+ {B90BCCEB-6690-44D2-94CC-8C16D1FC8EA6}.Debug|x86.ActiveCfg = Debug|x86
+ {B90BCCEB-6690-44D2-94CC-8C16D1FC8EA6}.Debug|x86.Build.0 = Debug|x86
+ {B90BCCEB-6690-44D2-94CC-8C16D1FC8EA6}.Release|x86.ActiveCfg = Release|x86
+ {B90BCCEB-6690-44D2-94CC-8C16D1FC8EA6}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
Binary file not shown.
Oops, something went wrong.

0 comments on commit d897540

Please sign in to comment.