My Project
C:/Users/Lab_411_02/Desktop/Violet1 - dox/violet/violet/ControlProperties.cs
查看本檔案說明文件.
1 // -----------------------------------------------------------------------
2 // Copyright (c) 2011, The Outercurve Foundation.
3 // This software is released under the Apache License, Version 2.0.
4 // The license and further copyright text can be found in the file LICENSE.TXT at
5 // the root directory of the distribution.
6 // -----------------------------------------------------------------------
7 using System;
8 using System.Collections.Generic;
9 using Microsoft.VisualStudio.Tools.Applications.Runtime;
10 
11 namespace Chem4Word.Core
12 {
16  [Serializable]
17  public class ControlProperties
18  {
19  #region ChemistryControlType enum
20 
23  [Serializable]
25  {
28  DocumentHostControl
29  } ;
30 
31  #endregion
32 
33  private string customXmLid;
34  private float height;
35 
36  private bool inline;
37  private List<KeyValuePair<string, object>> list;
38  private string name;
40  private float width;
41  private float x;
42  private float y;
43 
48  {}
49 
61  public ControlProperties(string name, ChemistryControlType type, float x, float y, float width, float height,
62  string customXmlid, params KeyValuePair<string, object>[] properties)
63  {
64  this.name = name;
65  this.type = type;
66  this.x = x;
67  this.y = y;
68  this.width = width;
69  this.height = height;
70  this.CustomXmlId = customXmlid;
71  this.list = new List<KeyValuePair<string, object>>();
72  this.list.AddRange(properties);
73  }
74 
86  public ControlProperties(string name, ChemistryControlType type, int start, int end, float width, float height,
87  string customXmlid, params KeyValuePair<string, object>[] properties)
88  {
89  this.name = name;
90  this.type = type;
91  this.x = start;
92  this.y = end;
93  this.width = width;
94  this.height = height;
95  this.inline = true;
96  this.CustomXmlId = customXmlid;
97  this.list = new List<KeyValuePair<string, object>>();
98 
99  this.list.AddRange(properties);
100  }
101 
110  public ControlProperties(string name, ChemistryControlType type, int start, int end,
111  params KeyValuePair<string, object>[] properties)
112  : this(name, type, start, end, 0, 0, null, properties)
113  {}
114 
118  public string ControlName
119  {
120  get { return name; }
121  set { name = value; }
122  }
123 
128  {
129  get { return type; }
130  set { type = value; }
131  }
132 
135  public string CustomXmlId
136  {
137  get { return this.customXmLid; }
138  set { this.customXmLid = value; }
139  }
140 
144  public List<KeyValuePair<string, object>> PropertyList
145  {
146  get { return list; }
147  set { list = value; }
148  }
149 
153  public float ControlWidth
154  {
155  get { return width; }
156  set { width = value; }
157  }
158 
162  public float ControlHeight
163  {
164  get { return height; }
165  set { height = value; }
166  }
167 
171  public float ControlX
172  {
173  get { return x; }
174  set { x = value; }
175  }
176 
180  public float ControlY
181  {
182  get { return y; }
183  set { y = value; }
184  }
185 
190  public bool IsInline
191  {
192  get { return inline; }
193  set { inline = value; }
194  }
195  }
196 
201  [Serializable]
202  public class ControlCollection : List<ControlProperties>, ICachedType
203  {
204  private bool dirty = true;
205 
210  public bool BeforeLoad()
211  {
212  return true;
213  }
214 
219  public bool BeforeSave()
220  {
221  return true;
222  }
223 
227  public void AfterLoad()
228  {
229  // Immediately after loading we ae not dirty.
230  dirty = false;
231  }
232 
236  public void AfterSave()
237  {
238  // Immediately after saving we ae not dirty.
239  dirty = false;
240  }
241 
246  public bool IsDirty
247  {
248  get { return dirty; }
249  // Give clients the possibility to force saving by setting dirty = value;
250  set { dirty = value; }
251  }
252  }
253 
258  public class ControlCollectionComparer : IComparer<ControlProperties>
259  {
272  {
273  if (x.ControlX < y.ControlX)
274  {
275  return -1;
276  }
277  return x.ControlX > y.ControlX ? 1 : 0;
278  }
279  }
280 }
Class that stores a list of property values for a saved control.
ControlProperties(string name, ChemistryControlType type, float x, float y, float width, float height, string customXmlid, params KeyValuePair< string, object >[] properties)
Constructor for floating controls.
string ControlName
The control's name.
bool BeforeSave()
Called before the object is saved to the cache.
float ControlX
The control's X coordinate in points.
float ControlWidth
The control's width in points.
ChemistryControlType ControlType
The control's type.
float ControlHeight
The control's height in points.
void AfterSave()
Called after the object is saved to the cache.
int Compare(ControlProperties x, ControlProperties y)
Compares two ControlProperties objects based on their position in the document.
bool BeforeLoad()
Called before the object is loaded from the cache.
float ControlY
The control's Y coordinate in points.
List< KeyValuePair< string, object > > PropertyList
The control's property list.
ControlProperties(string name, ChemistryControlType type, int start, int end, float width, float height, string customXmlid, params KeyValuePair< string, object >[] properties)
Constructor for inline controls.
Comparer that will compare ControlProperties objects based on their position in the document.
bool IsDirty
Return true to indicate that the object is dirty, i.e. it needs to be saved to the cache.
ControlProperties(string name, ChemistryControlType type, int start, int end, params KeyValuePair< string, object >[] properties)
Constructor for host controls.
List< KeyValuePair< string, object > > list
ControlProperties()
Default constructor - used for de-serialization.
bool IsInline
Flag indicating if a control is in-line. If true, the control is in-line; if foalse,...
List of control's properties. This class provides an implementation of ICachedType for complete contr...
void AfterLoad()
Called after the object is loaded from the cache.