1 | ///
|
---|
2 | /// This file is part of ILNumerics Community Edition.
|
---|
3 | ///
|
---|
4 | /// ILNumerics Community Edition - high performance computing for applications.
|
---|
5 | /// Copyright (C) 2006 - 2012 Haymo Kutschbach, http://ilnumerics.net
|
---|
6 | ///
|
---|
7 | /// ILNumerics Community Edition is free software: you can redistribute it and/or modify
|
---|
8 | /// it under the terms of the GNU General Public License version 3 as published by
|
---|
9 | /// the Free Software Foundation.
|
---|
10 | ///
|
---|
11 | /// ILNumerics Community Edition is distributed in the hope that it will be useful,
|
---|
12 | /// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | /// GNU General Public License for more details.
|
---|
15 | ///
|
---|
16 | /// You should have received a copy of the GNU General Public License
|
---|
17 | /// along with ILNumerics Community Edition. See the file License.txt in the root
|
---|
18 | /// of your distribution package. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | ///
|
---|
20 | /// In addition this software uses the following components and/or licenses:
|
---|
21 | ///
|
---|
22 | /// =================================================================================
|
---|
23 | /// The Open Toolkit Library License
|
---|
24 | ///
|
---|
25 | /// Copyright (c) 2006 - 2009 the Open Toolkit library.
|
---|
26 | ///
|
---|
27 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
|
---|
28 | /// of this software and associated documentation files (the "Software"), to deal
|
---|
29 | /// in the Software without restriction, including without limitation the rights to
|
---|
30 | /// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
---|
31 | /// the Software, and to permit persons to whom the Software is furnished to do
|
---|
32 | /// so, subject to the following conditions:
|
---|
33 | ///
|
---|
34 | /// The above copyright notice and this permission notice shall be included in all
|
---|
35 | /// copies or substantial portions of the Software.
|
---|
36 | ///
|
---|
37 | /// =================================================================================
|
---|
38 | ///
|
---|
39 |
|
---|
40 | using System;
|
---|
41 | using System.Collections.Generic;
|
---|
42 | using System.Text;
|
---|
43 | using System.Drawing;
|
---|
44 | using ILNumerics.Drawing;
|
---|
45 | using ILNumerics.Drawing.Labeling;
|
---|
46 |
|
---|
47 | namespace ILNumerics.Drawing.Marker {
|
---|
48 | public abstract class ILStyledMarkerShape : ILMarkerShape {
|
---|
49 |
|
---|
50 | #region attributes
|
---|
51 | protected MarkerStyle m_style;
|
---|
52 | #endregion
|
---|
53 |
|
---|
54 | #region properties
|
---|
55 | /// <summary>
|
---|
56 | /// The style of markers
|
---|
57 | /// </summary>
|
---|
58 | public MarkerStyle Style {
|
---|
59 | get {
|
---|
60 | return m_style;
|
---|
61 | }
|
---|
62 | set {
|
---|
63 | m_style = value;
|
---|
64 | CacheMarkerBitmap();
|
---|
65 | }
|
---|
66 | }
|
---|
67 | #endregion
|
---|
68 |
|
---|
69 | #region constructor
|
---|
70 | /// <summary>
|
---|
71 | /// create new styled marker
|
---|
72 | /// </summary>
|
---|
73 | internal ILStyledMarkerShape (ILPanel panel, MarkerStyle style) : base(panel) {
|
---|
74 | m_style = style;
|
---|
75 | }
|
---|
76 | #endregion
|
---|
77 |
|
---|
78 | #region public interface
|
---|
79 | public override string ToString() {
|
---|
80 | return String.Format("");
|
---|
81 | }
|
---|
82 | public string Hash() {
|
---|
83 | string key = Enum.GetName(typeof(MarkerStyle),m_style);
|
---|
84 | key = key.Substring(0, 3) + key.Substring(key.Length - 3);
|
---|
85 | return String.Format("M:{0}",key);
|
---|
86 | }
|
---|
87 | /// <summary>
|
---|
88 | /// convert marker style into bitmap
|
---|
89 | /// </summary>
|
---|
90 | /// <param name="marker">marker with style property</param>
|
---|
91 | /// <returns>bitmap according to style</returns>
|
---|
92 | /// <remarks>the bitmap will be loaded from ILNumerics.Drawing ressources. For marker style 'bitmap'
|
---|
93 | /// the bitmap referenced in the marker will be returned.</remarks>
|
---|
94 | public static Bitmap BitmapFromStyle(MarkerStyle style) {
|
---|
95 | switch (style) {
|
---|
96 | case MarkerStyle.Circle:
|
---|
97 | return Resources.Markers.Circle25x25;
|
---|
98 | case MarkerStyle.Diamond:
|
---|
99 | return Resources.Markers.Diamond25x25;
|
---|
100 | case MarkerStyle.TriangleUp:
|
---|
101 | return Resources.Markers.TriangleUp25x25;
|
---|
102 | case MarkerStyle.TriangleDown:
|
---|
103 | return Resources.Markers.TriangleDown25x25;
|
---|
104 | case MarkerStyle.TriangleLeft:
|
---|
105 | return Resources.Markers.TriangleLeft25x25;
|
---|
106 | case MarkerStyle.TriangleRight:
|
---|
107 | return Resources.Markers.TriangleRight25x25;
|
---|
108 | case MarkerStyle.Plus:
|
---|
109 | return Resources.Markers.Plus25x25;
|
---|
110 | case MarkerStyle.Cross:
|
---|
111 | return Resources.Markers.Cross25x25;
|
---|
112 | default:
|
---|
113 | throw new NotImplementedException("ILStyledMarker: marker style not supported!");
|
---|
114 | }
|
---|
115 | }
|
---|
116 |
|
---|
117 |
|
---|
118 | #endregion
|
---|
119 |
|
---|
120 | #region private helper
|
---|
121 |
|
---|
122 | protected void CacheMarkerBitmap() {
|
---|
123 | ILTextureManager mana = m_panel.TextureManager;
|
---|
124 | string key = Hash();
|
---|
125 | Bitmap markerbmp = BitmapFromStyle(m_style);
|
---|
126 | // we need it in format Argb!
|
---|
127 | mana.StoreTextureItem(key, markerbmp);
|
---|
128 | }
|
---|
129 |
|
---|
130 | #endregion
|
---|
131 | }
|
---|
132 | }
|
---|