WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
MatrixDictionaryBase.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 
6 namespace DirectOutput.Cab.Toys.Layer
7 {
11  public class MatrixDictionaryBase<MatrixElementType> : SortedDictionary<int, MatrixElementType[,]>
12  where MatrixElementType:new()
13  {
14 
24  public new MatrixElementType[,] this[int LayerNr]
25  {
26  get
27  {
28  try
29  {
30  return base[LayerNr];
31  }
32  catch
33  {
34  MatrixElementType[,] L = new MatrixElementType[Width, Height];
35  for (int y = 0; y < Height; y++)
36  {
37  for (int x = 0; x < Width; x++)
38  {
39  L[x, y] = new MatrixElementType();
40  }
41  }
42 
43 
44  Add(LayerNr, L);
45  return L;
46  }
47  }
48  //TODO: Check if set should be private
49  set
50  {
51  if (value.GetUpperBound(0) == Width - 1 && value.GetUpperBound(1) == Height - 1)
52  {
53  base[LayerNr] = value;
54  }
55  else
56  {
57  throw new Exception("Supplied array has a illegal width ({0}) or height ({1}). Expecting {2} for width and {3} for height.".Build(new object[] {value.GetUpperBound(0)+1,value.GetUpperBound(1)+1,Width,Height}));
58  }
59  }
60  }
61 
62  private int _Width=1;
63 
70  public int Width
71  {
72  get { return _Width; }
73  set { _Width = value.Limit(1,int.MaxValue); }
74  }
75 
76 
77  private int _Height=1;
78 
85  public int Height
86  {
87  get { return _Height; }
88  set { _Height = value.Limit(1,int.MaxValue); }
89  }
90 
91 
92 
93  }
94 }
Sorted dictionary of layers for the matrix toys.