本文整理汇总了C#中PurplePen.EventDB.GetEvent方法的典型用法代码示例。如果您正苦于以下问题:C# EventDB.GetEvent方法的具体用法?C# EventDB.GetEvent怎么用?C# EventDB.GetEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PurplePen.EventDB
的用法示例。
在下文中一共展示了EventDB.GetEvent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComputeSpecialLength
// Get Length of a special, in meters.
public static float ComputeSpecialLength(EventDB eventDB, Id<Special> specialId)
{
Special special = eventDB.GetSpecial(specialId);
SymPath path = new SymPath(special.locations);
return (float)((eventDB.GetEvent().mapScale * path.Length) / 1000.0);
}
示例2: ComputeFlaggedLegLength
// Similar to ComputeLegLength. However, if the leg is flagged partially, only the length of the flagged portion is returned.
// Note: if the flagging is NONE, this still returns the length of the whole leg!
public static float ComputeFlaggedLegLength(EventDB eventDB, Id<ControlPoint> controlId1, Id<ControlPoint> controlId2, Id<Leg> legId)
{
PointF location1 = eventDB.GetControl(controlId1).location;
PointF location2 = eventDB.GetControl(controlId2).location;
PointF[] bends = null;
Leg leg = null;
if (legId.IsNotNone) {
leg = eventDB.GetLeg(legId);
Debug.Assert(leg.controlId1 == controlId1 && leg.controlId2 == controlId2);
bends = leg.bends;
}
if (bends == null) {
return (float)((eventDB.GetEvent().mapScale * Geometry.Distance(location1, location2)) / 1000.0);
}
else {
List<PointF> points = new List<PointF>();
int bendIndexStart, bendIndexStop;
points.Add(location1);
points.AddRange(bends);
points.Add(location2);
// Which part is flagged?
if (leg.flagging == FlaggingKind.Begin) {
bendIndexStart = 0; bendIndexStop = points.IndexOf(leg.flagStartStop);
}
else if (leg.flagging == FlaggingKind.End) {
bendIndexStart = points.IndexOf(leg.flagStartStop); bendIndexStop = points.Count - 1;
}
else {
bendIndexStart = 0; bendIndexStop = points.Count - 1;
}
double dist = 0;
for (int i = bendIndexStart + 1; i <= bendIndexStop; ++i)
dist += Geometry.Distance(points[i - 1], points[i]);
return (float)((eventDB.GetEvent().mapScale * dist) / 1000.0);
}
}
示例3: ComputeLegLength
// Compute the length of a leg between two controls, in meters. The indicated leg id, if non-zero, is used
// to get bend information. The event map scale converts between the map scale, in mm, which is used
// for the coordinate information, to meters in the world scale.
public static float ComputeLegLength(EventDB eventDB, Id<ControlPoint> controlId1, Id<ControlPoint> controlId2, Id<Leg> legId)
{
PointF location1 = eventDB.GetControl(controlId1).location;
PointF location2 = eventDB.GetControl(controlId2).location;
SymPath path = GetLegPath(eventDB, controlId1, controlId2, legId);
return (float)((eventDB.GetEvent().mapScale * path.Length) / 1000.0);
}
示例4: GetPrintArea
// Get the print area for a course, or for all controls if CourseId is none.
public static PrintArea GetPrintArea(EventDB eventDB, CourseDesignator courseDesignator)
{
PrintArea printArea;
if (courseDesignator.IsAllControls)
printArea = eventDB.GetEvent().printArea;
else {
Course course = eventDB.GetCourse(courseDesignator.CourseId);
printArea = course.printArea;
if (!courseDesignator.AllParts && course.partPrintAreas.ContainsKey(courseDesignator.Part))
printArea = course.partPrintAreas[courseDesignator.Part];
}
return printArea;
}
示例5: AutoRenumberControls
// Renumber all controls according the current start code/invertible code.
// Rather than change every control, any code that will continue to be used remains assigned to the same control id. Controls getting
// new codes are assigned in code order, to new codes in code order.
public static void AutoRenumberControls(EventDB eventDB)
{
Event e = eventDB.GetEvent();
Dictionary<string, bool> newCodes = new Dictionary<string,bool>(); // dictionary of new codes and if we still need to assign them
Dictionary<string, Id<ControlPoint>> codeToControl = new Dictionary<string, Id<ControlPoint>>(); // dictionary mapping current codes to control ids.
// Initialize the newCodes and codeToControl data structures
int newCode = e.firstControlCode;
string newCodeString = newCode.ToString();
foreach (Id<ControlPoint> controlId in eventDB.AllControlPointIds) {
ControlPoint control = eventDB.GetControl(controlId);
string reason;
bool legal;
if (control.kind == ControlPointKind.Normal) {
// Add to codeToControl mapping dictionary.
codeToControl.Add(control.code, controlId);
// Add a new code to the new code dictionary
newCodes.Add(newCodeString, true);
do {
++newCode;
if (newCode >= 1000)
newCode = 31;
newCodeString = newCode.ToString();
// Is the new code legal and preferred?
legal = QueryEvent.IsPreferredControlCode(eventDB, newCodeString, out reason);
} while (!legal || reason != null); // filters out invertible (if selected in the event).
}
}
// Remove controls from the codeToControl dictionary that have codes we will continue to use, and mark those
// codes are assigned.
List<string> newCodeStrings = new List<string>(newCodes.Keys);
foreach (string code in newCodeStrings) {
if (codeToControl.ContainsKey(code)) {
codeToControl.Remove(code);
newCodes[code] = false;
}
}
// Put the codeToControl dictionary into a list and sort it.
List<KeyValuePair<string, Id<ControlPoint>>> codeToControlList = new List<KeyValuePair<string, Id<ControlPoint>>>(codeToControl);
codeToControlList.Sort(delegate(KeyValuePair<string, Id<ControlPoint>> pair1, KeyValuePair<string, Id<ControlPoint>> pair2) {
return Util.CompareCodes(pair1.Key, pair2.Key);
});
// Put the codes still to be assigned into a list and sort it.
List<string> newCodeList = new List<string>();
foreach (string code in newCodes.Keys)
if (newCodes[code])
newCodeList.Add(code);
newCodeList.Sort(Util.CompareCodes);
// Assign new codes.
Debug.Assert(codeToControlList.Count == newCodeList.Count);
for (int i = 0; i < codeToControlList.Count; ++i) {
ChangeEvent.ChangeCode(eventDB, codeToControlList[i].Value, newCodeList[i]);
}
}
示例6: GetCustomSymbolText
// Gets the custom symbol text/key dictionary. Makes a copy of them, so that changes don't cause weird effects.
public static void GetCustomSymbolText(EventDB eventDB, out Dictionary<string, List<SymbolText>> customSymbolText, out Dictionary<string, bool> customSymbolKey)
{
Event ev = eventDB.GetEvent();
customSymbolText = Util.CopyDictionary(ev.customSymbolText);
customSymbolKey = Util.CopyDictionary(ev.customSymbolKey);
}
示例7: GetDescriptionLanguage
// Get the description language.
public static string GetDescriptionLanguage(EventDB eventDB)
{
Event ev = eventDB.GetEvent();
return ev.descriptionLangId;
}
示例8: ChangeEventTitle
// Change the event title. Seperate lines with "|".
public static void ChangeEventTitle(EventDB eventDB, string newTitle)
{
Event e = eventDB.GetEvent();
e = (Event) e.Clone();
e.title = newTitle;
eventDB.ChangeEvent(e);
}
示例9: ChangeMapScale
// Change the map scale.
public static void ChangeMapScale(EventDB eventDB, float newScale)
{
Event e = eventDB.GetEvent();
e = (Event) e.Clone();
e.mapScale = newScale;
eventDB.ChangeEvent(e);
}
示例10: ChangeCustomSymbolText
// Change the custom system text for the event.
public static void ChangeCustomSymbolText(EventDB eventDB, Dictionary<string, List<SymbolText>> customSymbolText, Dictionary<string, bool> customSymbolKey)
{
Event e = eventDB.GetEvent();
e = (Event) e.Clone();
e.customSymbolText = Util.CopyDictionary(customSymbolText);
e.customSymbolKey = Util.CopyDictionary(customSymbolKey);
eventDB.ChangeEvent(e);
}
示例11: ChangeDescriptionLanguage
// Change the description language
public static void ChangeDescriptionLanguage(EventDB eventDB, string newLangId)
{
Event e = eventDB.GetEvent();
e = (Event) e.Clone();
e.descriptionLangId = newLangId;
eventDB.ChangeEvent(e);
}
示例12: ChangeCourseAppearance
// Set the course appearance for this event.
public static void ChangeCourseAppearance(EventDB eventDB, CourseAppearance courseAppearance)
{
Event e = eventDB.GetEvent();
e = (Event) e.Clone();
e.courseAppearance = (CourseAppearance) courseAppearance.Clone();
eventDB.ChangeEvent(e);
}
示例13: ChangeAutoNumbering
// Change the auto numbering options.
public static void ChangeAutoNumbering(EventDB eventDB, int startCode, bool disallowInvertibleCodes)
{
Event e = eventDB.GetEvent();
e = (Event) e.Clone();
e.firstControlCode = startCode;
e.disallowInvertibleCodes = disallowInvertibleCodes;
eventDB.ChangeEvent(e);
}
示例14: ChangeAllControlsProperties
// Change the attributes of a all controls display.
public static void ChangeAllControlsProperties(EventDB eventDB, float printScale, DescriptionKind descriptionKind)
{
Event e = eventDB.GetEvent();
e = (Event) e.Clone();
e.allControlsPrintScale = printScale;
e.allControlsDescKind = descriptionKind;
eventDB.ChangeEvent(e);
}
示例15: DistanceBetweenPointsInMeters
// Get the real world distance, in meters, between two points.
public static float DistanceBetweenPointsInMeters(EventDB eventDB, PointF pt1, PointF pt2)
{
return (float)((eventDB.GetEvent().mapScale * Geometry.Distance(pt1, pt2)) / 1000.0);
}