Skip to content

Commit 7926580

Browse files
author
fremag
committed
MemoDummy: basic script to periodically generate dummy objects
Closes #12
1 parent b1add74 commit 7926580

18 files changed

+843
-11
lines changed

MemoDummy/AbstractMemoScript.cs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.ComponentModel;
2+
3+
namespace MemoDummy
4+
{
5+
public abstract class AbstractMemoScript
6+
{
7+
protected bool stopRequested;
8+
9+
[Category("_ Info _")]
10+
[ReadOnly(true)]
11+
public abstract string Name { get; }
12+
[Category("_ Info _")]
13+
[ReadOnly(true)]
14+
public abstract string Description { get; }
15+
16+
public abstract void Run();
17+
18+
public override string ToString()
19+
{
20+
return Name;
21+
}
22+
23+
public void Stop()
24+
{
25+
stopRequested = true;
26+
}
27+
}
28+
}

MemoDummy/App.config

+6
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.6" />
5+
</startup>
6+
</configuration>

MemoDummy/MemoDummy.csproj

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" 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>{79528DEC-4446-4C3C-9431-02348CF43C67}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>MemoDummy</RootNamespace>
11+
<AssemblyName>MemoDummy</AssemblyName>
12+
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
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+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Deployment" />
43+
<Reference Include="System.Drawing" />
44+
<Reference Include="System.Net.Http" />
45+
<Reference Include="System.Windows.Forms" />
46+
<Reference Include="System.Xml" />
47+
</ItemGroup>
48+
<ItemGroup>
49+
<Compile Include="AbstractMemoScript.cs" />
50+
<Compile Include="MemoDummyForm.cs">
51+
<SubType>Form</SubType>
52+
</Compile>
53+
<Compile Include="MemoDummyForm.Designer.cs">
54+
<DependentUpon>MemoDummyForm.cs</DependentUpon>
55+
</Compile>
56+
<Compile Include="ObjectGeneratorScript.cs" />
57+
<Compile Include="Program.cs" />
58+
<Compile Include="Properties\AssemblyInfo.cs" />
59+
<EmbeddedResource Include="MemoDummyForm.resx">
60+
<DependentUpon>MemoDummyForm.cs</DependentUpon>
61+
</EmbeddedResource>
62+
<EmbeddedResource Include="Properties\Resources.resx">
63+
<Generator>ResXFileCodeGenerator</Generator>
64+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
65+
<SubType>Designer</SubType>
66+
</EmbeddedResource>
67+
<Compile Include="Properties\Resources.Designer.cs">
68+
<AutoGen>True</AutoGen>
69+
<DependentUpon>Resources.resx</DependentUpon>
70+
</Compile>
71+
<None Include="Properties\Settings.settings">
72+
<Generator>SettingsSingleFileGenerator</Generator>
73+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
74+
</None>
75+
<Compile Include="Properties\Settings.Designer.cs">
76+
<AutoGen>True</AutoGen>
77+
<DependentUpon>Settings.settings</DependentUpon>
78+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
79+
</Compile>
80+
</ItemGroup>
81+
<ItemGroup>
82+
<None Include="App.config" />
83+
</ItemGroup>
84+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
85+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
86+
Other similar extension points exist, see Microsoft.Common.targets.
87+
<Target Name="BeforeBuild">
88+
</Target>
89+
<Target Name="AfterBuild">
90+
</Target>
91+
-->
92+
</Project>

MemoDummy/MemoDummyForm.Designer.cs

+166
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MemoDummy/MemoDummyForm.cs

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.Reflection;
3+
using System.Threading.Tasks;
4+
using System.Windows.Forms;
5+
6+
namespace MemoDummy
7+
{
8+
public partial class MemoDummyForm : Form
9+
{
10+
public MemoDummyForm()
11+
{
12+
InitializeComponent();
13+
}
14+
15+
private void MemoDummyForm_Load(object sender, System.EventArgs e)
16+
{
17+
var types = Assembly.GetExecutingAssembly().GetTypes();
18+
foreach (var type in types)
19+
{
20+
if (type.IsSubclassOf(typeof (AbstractMemoScript)))
21+
{
22+
var script = Activator.CreateInstance(type);
23+
lbScripts.Items.Add(script);
24+
}
25+
}
26+
}
27+
28+
private AbstractMemoScript script;
29+
private void lbScripts_SelectedIndexChanged(object sender, EventArgs e)
30+
{
31+
script = lbScripts.SelectedItem as AbstractMemoScript;
32+
propertyGrid1.SelectedObject = script ;
33+
btnRun.Enabled = script != null;
34+
}
35+
36+
private void btnRun_Click(object sender, EventArgs e)
37+
{
38+
if (script != null)
39+
{
40+
Task.Factory.StartNew(() => script.Run());
41+
}
42+
}
43+
44+
private void btnStop_Click(object sender, EventArgs e)
45+
{
46+
if (script != null)
47+
script.Stop();
48+
}
49+
50+
private void timer1_Tick(object sender, EventArgs e)
51+
{
52+
propertyGrid1.Refresh();
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)