/[gr2lib]/trunk/gr2lib/core/coretypes/implementation/Layout.cs
ViewVC logotype

Contents of /trunk/gr2lib/core/coretypes/implementation/Layout.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 186 - (show annotations) (download)
Sat Jul 24 02:23:18 2010 UTC (9 years, 3 months ago) by william
File size: 4198 byte(s)
continue to add xml documentation

1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using gr2lib.core.helpers;
5 using gr2lib.core.interfaces;
6 using System.ComponentModel;
7 using gr2lib.core.ui.typeeditors;
8 using System.Drawing.Design;
9 using gr2lib.core.ui.helpers;
10 using gr2lib.core.ui.rigeditor.interfaces;
11 namespace gr2lib.core.coretypes.implementation
12 {
13 /// <summary>
14 /// Layout class
15 /// </summary>
16 [Editor(typeof(UILayoutEditor), typeof(UITypeEditor))]
17 public class Layout : ILayout//, IValueType<Layout>
18 {
19
20 //private Layout _Value;
21 //public Layout Value { get { return _Value; } set { _Value = value; } }
22
23 /// <summary>
24 /// set string representation
25 /// </summary>
26 /// <returns></returns>
27 public override string ToString()
28 {
29 string bytesperpixel = "{" + this.BytesPerPixel.ToString() + "}";
30 string shift = "{" + new arraytostring<int, int[]>(this.ShiftForComponent, false) + "}";
31 string bits = "{" + new arraytostring<int, int[]>(this.BitsForComponent, false) + "}";
32
33 return String.Format("{0} {1} {2}", bytesperpixel, shift, bits);
34 }
35
36 /// <summary>
37 /// default constructor
38 /// </summary>
39 public Layout() : this(4) { }
40 /// <summary>
41 /// default constructor: specify Bytes Per Pixel
42 /// </summary>
43 public Layout(int bytes_per_pixel)
44 {
45 this.BytesPerPixel = bytes_per_pixel;
46 this.ShiftForComponent = new int[bytes_per_pixel];
47 this.BitsForComponent = new int[bytes_per_pixel];
48 for (int i = 0; i < bytes_per_pixel; i++) { this.ShiftForComponent[i] = 0; this.BitsForComponent[i] = 0; }
49 //this.NativePointer = IntPtr.Zero;
50 }
51 internal static native.Layout AssignToStructure(Layout layout)
52 {
53 native.Layout _layout_struct = new gr2lib.core.coretypes.native.Layout();
54 _layout_struct.BitsForComponent = layout.BitsForComponent;
55 _layout_struct.BytesPerPixel = layout.BytesPerPixel;
56 _layout_struct.ShiftForComponent = layout.ShiftForComponent;
57 return _layout_struct;
58 }
59 internal static Layout ReadFromMemory(IntPtr pointer)
60 {
61 if (pointer == IntPtr.Zero) return null;
62 native.Layout native = Helpers.ReadFromMemory<native.Layout>(pointer);
63 Layout managed = ReadFromNative(native);
64 managed.NativePointer = pointer;
65 return managed;
66 }
67
68 internal static Layout ReadFromNative(native.Layout native)
69 {
70 Layout managed = new Layout();
71 managed.BytesPerPixel = native.BytesPerPixel;
72 managed.ShiftForComponent = native.ShiftForComponent;
73 managed.BitsForComponent = native.BitsForComponent;
74 return managed;
75 }
76
77 #region INativePointer Members
78 private IntPtr _NativePointer;
79 /// <summary>
80 /// When used in a derived class, gets the native pointer for this instance
81 /// </summary>
82 public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
83 #endregion
84
85
86 #region ILayout Members
87
88 private int _BytesPerPixel;
89 private int[] _ShiftForComponent;
90 private int[] _BitsForComponent;
91
92 /// <summary>
93 /// Get or set the Bytes Per Pixel of this instance
94 /// </summary>
95 public int BytesPerPixel { get { return _BytesPerPixel; } set { _BytesPerPixel = value; } }
96 /// <summary>
97 /// Get/set the bit shift per color for this instance (in format: RGBA)
98 /// </summary>
99 public int[] ShiftForComponent { get { return _ShiftForComponent; } set { _ShiftForComponent = value; } }
100 /// <summary>
101 /// Get/set the bits per color for this instance (in format: RGBA)
102 /// </summary>
103 public int[] BitsForComponent { get { return _BitsForComponent; } set { _BitsForComponent = value; } }
104 #endregion
105 }
106 }

  ViewVC Help
Powered by ViewVC 1.1.22