Store in GIT

This commit is contained in:
2026-06-17 15:58:48 +02:00
parent 163db046ef
commit adcacd2cc1
64 changed files with 2249 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
+63
View File
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9D404DA7-E094-4031-B3B9-3041C2E69CE4}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>HueLights</RootNamespace>
<AssemblyName>HueLights</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</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|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</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.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Light.cs" />
<Compile Include="LightHandler.cs" />
<Compile Include="LightHue.cs" />
<Compile Include="LigthLux.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</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>
+74
View File
@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HueLights
{
public abstract class Light
{
protected int id { get; }
protected bool on { get; set; }
protected int bri { get; set; }
protected int hue { get; set; }
protected int sat { get; set; }
public Light(int id)
{
this.id = id;
this.on = false;
this.bri = 255;
this.hue = 0;
this.sat = 0;
}
public virtual int getID()
{
return id;
}
public virtual bool getState()
{
return on;
}
public virtual void setState(bool on)
{
this.on = on;
}
public virtual int getBrightness()
{
return bri;
}
public virtual void setBrightness(int bri)
{
this.bri = bri;
}
public virtual int getHue()
{
return hue;
}
public virtual void setHue(int hue)
{
this.hue = hue;
}
public virtual int getSaturation()
{
return sat;
}
public virtual void setSaturation(int sat)
{
this.sat = sat;
}
public abstract void Update();
public override string ToString()
{
return "Light " + id + " is " + (getState() ? "on" : "off");
}
}
}
+54
View File
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HueLights
{
class LightHandler
{
static void Main(string[] args)
{
new LightHandler();
}
private List<Light> lights;
public LightHandler()
{
lights = new List<Light>();
Populate();
RunTest();
}
private void RunTest()
{
Random r = new Random();
TurnOn(lights[r.Next(0, lights.Count)].getID());
Update();
Console.ReadLine();
}
private void Populate()
{
lights.Add(new LightHue(1, 100));
lights.Add(new LightHue(2, 200));
lights.Add(new LigthLux(3, 300));
}
public void TurnOn(int id)
{
lights.ForEach(a => { if (a.getID() == id) { a.setState(true); } });
}
public void Update()
{
lights.ForEach(a => a.Update() );
}
}
}
+27
View File
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HueLights
{
public class LightHue : Light
{
public LightHue(int id, int hue) : base(id)
{
this.hue = hue;
this.sat = 255;
}
public override void Update()
{
Console.WriteLine(this.ToString());
}
public override string ToString()
{
return base.ToString() + ". bri=" + bri + ", hue=" + hue + ", sat=" + sat;
}
}
}
+26
View File
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HueLights
{
public class LigthLux : Light
{
public LigthLux(int id, int bri) : base(id)
{
this.bri = bri;
}
public override void Update()
{
Console.WriteLine(this.ToString());
}
public override string ToString()
{
return base.ToString() + ". bri=" + bri;
}
}
}
+36
View File
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using 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("HueLights")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HueLights")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 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("9d404da7-e094-4031-b3b9-3041c2e69ce4")]
// 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.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]