forked from SwensenSoftware/fseye
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue 43: mostly done, but still working on getting to work with an I…
…Enumerable (not directly supported by the data grid)
- Loading branch information
stephen.swensen
committed
Nov 2, 2013
1 parent
055955d
commit aac3e58
Showing
6 changed files
with
185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
namespace FsEye.DataGridView.Plugin | ||
|
||
open System.Reflection | ||
open System.Runtime.CompilerServices | ||
open System.Runtime.InteropServices | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[<assembly: AssemblyTitle("FsEye.DataGridView.Plugin")>] | ||
[<assembly: AssemblyDescription("")>] | ||
[<assembly: AssemblyConfiguration("")>] | ||
[<assembly: AssemblyCompany("")>] | ||
[<assembly: AssemblyProduct("FsEye.DataGridView.Plugin")>] | ||
[<assembly: AssemblyCopyright("Copyright © Stephen Swensen 2013")>] | ||
[<assembly: AssemblyTrademark("")>] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[<assembly: ComVisible(false)>] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[<assembly: Guid("02476582-997c-4780-859a-e81188e8339b")>] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[<assembly: AssemblyVersion("1.0.0.*")>] | ||
[<assembly: AssemblyFileVersion("1.0.0.*")>] | ||
|
||
() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
namespace Swensen.FsEye.Plugins | ||
|
||
open System | ||
open Swensen.FsEye | ||
open System.Windows.Forms | ||
open System.Drawing | ||
|
||
//todo:share common code between this plugin and the PropertyGrid plugin | ||
|
||
module private Helpers = | ||
//see http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.datasource.aspx | ||
let ValidDataSourceTypes = [ | ||
typeof<System.Collections.IList> | ||
typeof<System.ComponentModel.IListSource> | ||
typeof<System.ComponentModel.IBindingList> | ||
typeof<System.ComponentModel.IBindingListView>] | ||
|
||
///A DataGridView-based watch viewer | ||
type DataGridViewWatchViewer() = | ||
let panel = new Panel() | ||
|
||
let dgv = new DataGridView(Dock=DockStyle.Fill) | ||
do | ||
panel.Controls.Add(dgv) | ||
|
||
let labelPanel = new FlowLayoutPanel(Dock=DockStyle.Top, AutoSize=true, Padding=Padding(0,3,3,5)) | ||
let labelLabel = new Label(Text="Source Expression:", AutoSize=true) | ||
let expressionLabel = new Label(AutoSize=true) | ||
do | ||
labelLabel.Font <- new Font(labelLabel.Font, FontStyle.Bold) | ||
labelPanel.Controls.Add(labelLabel) | ||
|
||
labelPanel.Controls.Add(expressionLabel) | ||
|
||
panel.Controls.Add(labelPanel) | ||
|
||
interface IWatchViewer with | ||
///Set or refresh the DataGridView DataSource with the given value. | ||
member this.Watch(label, value, ty) = | ||
expressionLabel.Text <- label | ||
// let value = | ||
// if not (Helpers.ValidDataSourceTypes |> List.exists (fun validTy -> validTy.IsAssignableFrom(ty))) then //must be non-generic IEnumerable | ||
// value :?> System.Collections.IEnumerable |> Seq.cast<obj> |> Seq.toArray :> obj //arrays implement IList | ||
// else | ||
// value | ||
dgv.DataSource <- value | ||
///Get the underlying Control of this watch view | ||
member this.Control = panel :> Control | ||
|
||
///A Plugin that creates DataGridViewWatchViewers | ||
type DataGridViewPlugin() = | ||
interface IPlugin with | ||
///"Property Grid" | ||
member __.Name = "Data Grid" | ||
///Create a new instance of a DataGridViewWatchViewer | ||
member __.CreateWatchViewer() = new DataGridViewWatchViewer() :> IWatchViewer | ||
///Returns true if and only if the given value is not null and the given type implements one of the interfaces supported by DataGridView.DataSource. | ||
member this.IsWatchable(value:obj, ty:Type) = | ||
//we convert non-generic IEnumerables to ILists for convenience | ||
//let validTys = typeof<System.Collections.IEnumerable> :: Helpers.ValidDataSourceTypes | ||
let validTys = Helpers.ValidDataSourceTypes | ||
value <> null && (validTys |> List.exists (fun validTy -> validTy.IsAssignableFrom(ty))) |
63 changes: 63 additions & 0 deletions
63
FsEye.DataGridView.Plugin/FsEye.DataGridView.Plugin.fsproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?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)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{cc563dcc-2eaf-4822-b4ce-9d80acca6b5e}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<RootNamespace>FsEye.DataGridView.Plugin</RootNamespace> | ||
<AssemblyName>FsEye.DataGridView.Plugin</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<Name>FsEye.DataGridView.Plugin</Name> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<Tailcalls>false</Tailcalls> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<WarningLevel>3</WarningLevel> | ||
<DocumentationFile>bin\Debug\FsEye.DataGridView.Plugin.XML</DocumentationFile> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<Tailcalls>true</Tailcalls> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<WarningLevel>3</WarningLevel> | ||
<DocumentationFile>bin\Release\FsEye.DataGridView.Plugin.XML</DocumentationFile> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="mscorlib" /> | ||
<Reference Include="FSharp.Core" /> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Numerics" /> | ||
<Reference Include="System.Windows.Forms" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="AssemblyInfo.fs" /> | ||
<Compile Include="DataGridViewPlugin.fs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\FsEye\FsEye.fsproj"> | ||
<Name>FsEye</Name> | ||
<Project>{20de2466-d7b1-4f72-b8f8-51f10f5f186e}</Project> | ||
<Private>True</Private> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildExtensionsPath32)\FSharp\1.0\Microsoft.FSharp.Targets" Condition="!Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets" Condition=" Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" /> | ||
<!-- 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters