Skip to content

Commit

Permalink
Added options for matrix devices.
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalshow committed Nov 22, 2016
1 parent f293453 commit 483b478
Show file tree
Hide file tree
Showing 11 changed files with 284 additions and 2 deletions.
32 changes: 31 additions & 1 deletion pcd-ddf-in-wpf/DeviceEditor.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--
<!--
pcd-ddf-in-wpf: A DDF editor for PC_DIMMER, an open source light
control software.
Copyright (C) 2016 Ingo Koinzer
Expand All @@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<UserControl x:Class="Koinzer.pcdddfinwpf.DeviceEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ctrls="clr-namespace:Koinzer.pcdddfinwpf.Controls"
xmlns:model="clr-namespace:Koinzer.pcdddfinwpf.Model"
xmlns:self="clr-namespace:Koinzer.pcdddfinwpf">
<Grid>
<GroupBox Header="{self:Loc Device}" Margin="4">
Expand All @@ -29,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
Expand All @@ -44,6 +47,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Description, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Row="4" Grid.Column="0" Text="{self:Loc Image}" />
<self:RelativeFileTextBox Grid.Row="4" Grid.Column="1" RelativeFolder="\Devicepictures" FileName="{Binding DeviceImageFileName}" />
<GroupBox Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2">
<GroupBox.Header>
<CheckBox Content="{self:Loc MatrixDevice}" IsChecked="{Binding IsMatrixDevice}" />
</GroupBox.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition Width="0.5*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="{self:Loc MatrixRows}" IsEnabled="{Binding IsMatrixDevice}" />
<ctrls:IntegerUpDown Grid.Row="0" Grid.Column="1" Value="{Binding MatrixRows}" Minimum="1" IsEnabled="{Binding IsMatrixDevice}" />
<TextBlock Grid.Row="1" Grid.Column="0" Text="{self:Loc MatrixColumns}" IsEnabled="{Binding IsMatrixDevice}" />
<ctrls:IntegerUpDown Grid.Row="1" Grid.Column="1" Value="{Binding MatrixColumns}" Minimum="1" IsEnabled="{Binding IsMatrixDevice}" />
<TextBlock Grid.Row="2" Grid.Column="0" Text="{self:Loc MatrixOrderType}" IsEnabled="{Binding IsMatrixDevice}" />
<ComboBox Grid.Row="2" Grid.Column="1"
SelectedValue="{Binding MatrixOrderType}"
ItemsSource="{x:Static model:PCDMatrixOrderTypeItemsSource.Items}"
DisplayMemberPath="Value"
SelectedValuePath="Key"
IsEnabled="{Binding IsMatrixDevice}" />
</Grid>
</GroupBox>
</Grid>
</GroupBox>
</Grid>
Expand Down
33 changes: 33 additions & 0 deletions pcd-ddf-in-wpf/Model/PCDDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public PCDDevice(): base()
FormWidth = 300;
FormHeight = 400;

IsMatrixDevice = false;
MatrixColumns = 1;
MatrixRows = 1;
MatrixOrderType = PCDMatrixOrderType.LeftRightTopBottom;

GUIElements.Add(new GUI.PCDDeviceImage(this) { Left = 10, Top = 10 });
GUIElements.Add(new GUI.PCDDeviceName(this) { Left = 80, Top = 8 });
GUIElements.Add(new GUI.PCDDeviceAddress(this) { Left = 80, Top = 24 });
Expand Down Expand Up @@ -127,5 +132,33 @@ public int FormHeight {
public ObservableCollection<GUI.PCDDeviceElement> GUIElements { get; private set; }

public ObservableCollection<PCDDevicePreset> Presets { get; private set; }

bool isMatrixDevice;

public bool IsMatrixDevice {
get { return isMatrixDevice; }
set { SetProperty(ref isMatrixDevice, value); }
}

int matrixRows;

public int MatrixRows {
get { return matrixRows; }
set { SetProperty(ref matrixRows, value); }
}

int matrixColumns;

public int MatrixColumns {
get { return matrixColumns; }
set { SetProperty(ref matrixColumns, value); }
}

PCDMatrixOrderType matrixOrderType;

public PCDMatrixOrderType MatrixOrderType {
get { return matrixOrderType; }
set { SetProperty(ref matrixOrderType, value); }
}
}
}
53 changes: 53 additions & 0 deletions pcd-ddf-in-wpf/Model/PCDMatrixOrderType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
pcd-ddf-in-wpf: A DDF editor for PC_DIMMER, an open source light
control software.
Copyright (C) 2016 Ingo Koinzer
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;

namespace Koinzer.pcdddfinwpf.Model
{
/// <summary>
/// Description of PCDMatrixOrderType.
/// </summary>
public enum PCDMatrixOrderType
{
LeftRightTopBottom,
LeftRightLeftTopBottom,
TopBottomLeftRight,
TopBottomTopLeftRight
}

public class PCDMatrixOrderTypeItemsSource {
public static KeyValuePair<PCDMatrixOrderType, string>[] Items = new KeyValuePair<PCDMatrixOrderType, string>[]{
new KeyValuePair<PCDMatrixOrderType, string>(
PCDMatrixOrderType.LeftRightTopBottom,
"PCDMatrixOrderType.LeftRightTopBottom".Localize()),
new KeyValuePair<PCDMatrixOrderType, string>(
PCDMatrixOrderType.LeftRightLeftTopBottom,
"PCDMatrixOrderType.LeftRightLeftTopBottom".Localize()),
new KeyValuePair<PCDMatrixOrderType, string>(
PCDMatrixOrderType.TopBottomLeftRight,
"PCDMatrixOrderType.TopBottomLeftRight".Localize()),
new KeyValuePair<PCDMatrixOrderType, string>(
PCDMatrixOrderType.TopBottomTopLeftRight,
"PCDMatrixOrderType.TopBottomTopLeftRight".Localize())
};
}
}
22 changes: 22 additions & 0 deletions pcd-ddf-in-wpf/Parser/PCDDeviceParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
using System.IO;
using System.Windows.Media;
using System.Xml;
using Koinzer.pcdddfinwpf.Model;

namespace Koinzer.pcdddfinwpf.Parser
{
Expand Down Expand Up @@ -107,6 +108,27 @@ public override void Parse(XmlDocument doc, Model.PCDDevice device, ParseResults
}
device.Channels.Add(chan);
}

XmlNode matrix = GetNode(doc, "matrix");
device.IsMatrixDevice = (matrix != null);
if (device.IsMatrixDevice) {
device.MatrixRows = int.Parse(matrix.Attributes["ycount"].Value);
device.MatrixColumns = int.Parse(matrix.Attributes["xcount"].Value);
switch (matrix.Attributes["ordertype"].Value) {
case "1":
device.MatrixOrderType = PCDMatrixOrderType.LeftRightTopBottom;
break;
case "2":
device.MatrixOrderType = PCDMatrixOrderType.LeftRightLeftTopBottom;
break;
case "3":
device.MatrixOrderType = PCDMatrixOrderType.TopBottomLeftRight;
break;
case "4":
device.MatrixOrderType = PCDMatrixOrderType.TopBottomTopLeftRight;
break;
}
}
}
}
}
2 changes: 1 addition & 1 deletion pcd-ddf-in-wpf/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ You should have received a copy of the GNU General Public License
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("1.3.*")]
[assembly: AssemblyVersion("1.4.*")]
72 changes: 72 additions & 0 deletions pcd-ddf-in-wpf/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions pcd-ddf-in-wpf/Strings.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,18 @@
<data name="LoadWarnings" xml:space="preserve">
<value>Beim Laden der Datei wurden folgende Warnungen generiert.</value>
</data>
<data name="MatrixDevice" xml:space="preserve">
<value>Matrixgerät</value>
</data>
<data name="MatrixRows" xml:space="preserve">
<value>Matrix-Zeilenanzahl</value>
</data>
<data name="MatrixColumns" xml:space="preserve">
<value>Matrix-Spaltenanzahl</value>
</data>
<data name="MatrixOrderType" xml:space="preserve">
<value>Matrix-Richtung</value>
</data>
<data name="Max" xml:space="preserve">
<value>Max</value>
</data>
Expand Down Expand Up @@ -411,6 +423,18 @@
<data name="PCDGUIWriter.InvalidPresetName" xml:space="preserve">
<value>Das Preset '{0}' konnte einem Button nicht zugewiesen werden da der Presetname ungültig ist.</value>
</data>
<data name="PCDMatrixOrderType.LeftRightLeftTopBottom" xml:space="preserve">
<value>Links nach rechts nach links, oben nach unten</value>
</data>
<data name="PCDMatrixOrderType.LeftRightTopBottom" xml:space="preserve">
<value>Links nach rechts, oben nach unten</value>
</data>
<data name="PCDMatrixOrderType.TopBottomLeftRight" xml:space="preserve">
<value>Oben nach unten, links nach rechts</value>
</data>
<data name="PCDMatrixOrderType.TopBottomTopLeftRight" xml:space="preserve">
<value>Oben nach unten nach oben, links nach rechts</value>
</data>
<data name="PCDPresetWriter.PresetItemNotAssociated" xml:space="preserve">
<value>Beim Preset '{0}' wurde ein Eintrag keinem Kanal zugeordnet.</value>
</data>
Expand Down
24 changes: 24 additions & 0 deletions pcd-ddf-in-wpf/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,18 @@
<data name="LoadWarnings" xml:space="preserve">
<value>While loading the file some warnings were generated.</value>
</data>
<data name="MatrixDevice" xml:space="preserve">
<value>Matrix device</value>
</data>
<data name="MatrixRows" xml:space="preserve">
<value>Matrix row count</value>
</data>
<data name="MatrixColumns" xml:space="preserve">
<value>Matrix column count</value>
</data>
<data name="MatrixOrderType" xml:space="preserve">
<value>Matrix order type</value>
</data>
<data name="Max" xml:space="preserve">
<value>Max</value>
</data>
Expand All @@ -414,6 +426,18 @@
<data name="PCDFadetimeCheckbox.UseFadetime" xml:space="preserve">
<value>Use fadetime</value>
</data>
<data name="PCDMatrixOrderType.LeftRightLeftTopBottom" xml:space="preserve">
<value>Left to right to left, top to bottom</value>
</data>
<data name="PCDMatrixOrderType.LeftRightTopBottom" xml:space="preserve">
<value>Left to right, top to bottom</value>
</data>
<data name="PCDMatrixOrderType.TopBottomLeftRight" xml:space="preserve">
<value>Top to bottom, left to right</value>
</data>
<data name="PCDMatrixOrderType.TopBottomTopLeftRight" xml:space="preserve">
<value>Top to bottom to top, left to right</value>
</data>
<data name="PngImage" xml:space="preserve">
<value>Portable Network Graphic</value>
</data>
Expand Down
1 change: 1 addition & 0 deletions pcd-ddf-in-wpf/Writer/PCDCodeWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void Write(XElement codeEl, Model.PCDDevice device, WriteResults results)
StringBuilder functionFormRefresh = new StringBuilder();
functionFormRefresh.AppendLine("var");
functionFormRefresh.AppendLine(" value: Integer;");
functionFormRefresh.AppendLine(" temp, phi, r: Double;");
functionFormRefresh.AppendLine("begin");
functionFormRefresh.AppendLine(" if dontRefresh then begin");
functionFormRefresh.AppendLine(" dontRefresh := false;");
Expand Down
22 changes: 22 additions & 0 deletions pcd-ddf-in-wpf/Writer/PCDDeviceWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,28 @@ public WriteResults Save(Model.PCDDevice device, String fileName)
nodeDevice.Add(channels);
nodeDevice.Add(initvalues);

if (device.IsMatrixDevice) {
int ordertype = 1;
switch (device.MatrixOrderType) {
case Model.PCDMatrixOrderType.LeftRightTopBottom:
ordertype = 1;
break;
case Model.PCDMatrixOrderType.LeftRightLeftTopBottom:
ordertype = 2;
break;
case Model.PCDMatrixOrderType.TopBottomLeftRight:
ordertype = 3;
break;
case Model.PCDMatrixOrderType.TopBottomTopLeftRight:
ordertype = 4;
break;
}
nodeDevice.Add(new XElement("matrix",
new XAttribute("xcount", device.MatrixColumns),
new XAttribute("ycount", device.MatrixRows),
new XAttribute("ordertype", ordertype)));
}

new PCDColorsWriter().Write(nodeDevice, device, results);
new PCDGobosWriter().Write(nodeDevice, device, results);
new PCDFeatureWriter().Write(nodeDevice, device, results);
Expand Down
Loading

0 comments on commit 483b478

Please sign in to comment.