本文整理汇总了C#中PurplePen.EventDB.ReplaceSpecial方法的典型用法代码示例。如果您正苦于以下问题:C# EventDB.ReplaceSpecial方法的具体用法?C# EventDB.ReplaceSpecial怎么用?C# EventDB.ReplaceSpecial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PurplePen.EventDB
的用法示例。
在下文中一共展示了EventDB.ReplaceSpecial方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChangeDisplayedCourses
// Change the set of courses that a special is on. If all the courses are in the new array, changes the special to display in
// all courses.
public static void ChangeDisplayedCourses(EventDB eventDB, Id<Special> specialId, CourseDesignator[] displayedCourses)
{
// Check if the array contains all of the courses.
bool allCourses = true;
Special special = (Special) eventDB.GetSpecial(specialId).Clone();
foreach (Id<Course> courseId in eventDB.AllCourseIds) {
if (Array.IndexOf(displayedCourses, new CourseDesignator(courseId)) < 0) {
allCourses = false;
break;
}
}
if (special.kind == SpecialKind.Descriptions) {
if (Array.IndexOf(displayedCourses, CourseDesignator.AllControls) < 0)
allCourses = false; // all courses includes all controls only for descriptions.
}
special.allCourses = allCourses;
if (allCourses)
special.courses = null;
else
special.courses = displayedCourses;
eventDB.ReplaceSpecial(specialId, special);
// Descriptions special are unique per course -- enforce this.
if (special.kind == SpecialKind.Descriptions)
UpdateDescriptionCourses(eventDB, specialId);
}
示例2: ChangeSpecialLineAppearance
// Change the line properties associated with a special
internal static void ChangeSpecialLineAppearance(EventDB eventDB, Id<Special> specialId, SpecialColor color, LineKind lineKind, float lineWidth, float gapSize, float dashSize, float cornerRadius)
{
Special special = eventDB.GetSpecial(specialId);
Debug.Assert(special.kind == SpecialKind.Rectangle || special.kind == SpecialKind.Line);
special = (Special)special.Clone();
special.color = color;
special.lineKind = lineKind;
special.lineWidth = lineWidth;
special.gapSize = gapSize;
special.dashSize = dashSize;
if (special.kind == SpecialKind.Rectangle)
special.cornerRadius = cornerRadius;
eventDB.ReplaceSpecial(specialId, special);
}
示例3: ChangeDescriptionColumns
// Change the number of columns of a descriptions
public static void ChangeDescriptionColumns(EventDB eventDB, Id<Special> specialId, int numColumns)
{
Special special = eventDB.GetSpecial(specialId);
Debug.Assert(special.kind == SpecialKind.Descriptions);
special = (Special)special.Clone();
special.numColumns = numColumns;
eventDB.ReplaceSpecial(specialId, special);
}
示例4: UpdateDescriptionCourses
// Check all descriptions other than the passed one, and remove any duplicate courses.
public static void UpdateDescriptionCourses(EventDB eventDB, Id<Special> descriptionId)
{
// Which courses to remove?
CourseDesignator[] coursesToRemove = QueryEvent.GetSpecialDisplayedCourses(eventDB, descriptionId);
// Find all descriptions to change.
List<Id<Special>> allDescriptionIds = new List<Id<Special>>();
foreach (Id<Special> specialId in eventDB.AllSpecialIds) {
if (eventDB.GetSpecial(specialId).kind == SpecialKind.Descriptions && specialId != descriptionId)
allDescriptionIds.Add(specialId);
}
foreach (Id<Special> descriptionToChange in allDescriptionIds) {
// Remove any courses that overlap with the courses the given description has..
bool changes = false; // track if any changes made.
List<CourseDesignator> courses = new List<CourseDesignator>(QueryEvent.GetSpecialDisplayedCourses(eventDB, descriptionToChange));
for (int courseIndex = 0; courseIndex < courses.Count; ++courseIndex) {
foreach (CourseDesignator courseToRemove in coursesToRemove) {
if (courseIndex >= 0 && courseIndex < courses.Count) {
if (courseToRemove == courses[courseIndex]) {
changes = true;
courses.RemoveAt(courseIndex--);
}
else if (courseToRemove.CourseId == courses[courseIndex].CourseId) {
changes = true;
if (!courseToRemove.AllParts && courses[courseIndex].AllParts) {
int removedPart = courseToRemove.Part;
courses.RemoveAt(courseIndex--);
for (int part = 0; part < QueryEvent.CountCourseParts(eventDB, courseToRemove.CourseId); ++part) {
if (part != removedPart)
courses.Add(new CourseDesignator(courseToRemove.CourseId, part));
}
}
else if (courseToRemove.AllParts) {
courses.RemoveAt(courseIndex--);
}
}
}
}
}
// Commit the removal to the event database.
if (changes) {
if (courses.Count == 0) {
// Remove the given description entire, since it has no displayed courses.
eventDB.RemoveSpecial(descriptionToChange);
}
else {
Special newDescription = (Special) eventDB.GetSpecial(descriptionToChange).Clone();
newDescription.allCourses = false;
newDescription.courses = courses.ToArray();
eventDB.ReplaceSpecial(descriptionToChange, newDescription);
}
}
}
}
示例5: DeleteCourse
// Delete a course and all of its course controls.
public static void DeleteCourse(EventDB eventDB, Id<Course> courseId)
{
// Remember the set of course controls.
List<Id<CourseControl>> courseControls = new List<Id<CourseControl>>(QueryEvent.EnumCourseControlIds(eventDB, new CourseDesignator(courseId)));
// Remove the course.
eventDB.RemoveCourse(courseId);
// Remove each of the course controls in that course
foreach (Id<CourseControl> courseControlId in courseControls) {
eventDB.RemoveCourseControl(courseControlId);
}
// Now check specials, and see which need to be modified
List<Id<Special>> specialsToChange = new List<Id<Special>>();
foreach (Id<Special> specialId in eventDB.AllSpecialIds) {
Special special = eventDB.GetSpecial(specialId);
if (!special.allCourses && special.courses.Any(cd => cd.CourseId == courseId)) {
// This special is not an all controls special, and is present on the course being deleted. Update it.
specialsToChange.Add(specialId);
}
}
// Update each of the specials.
foreach (Id<Special> specialId in specialsToChange) {
Special special = eventDB.GetSpecial(specialId);
CourseDesignator[] newCourses = special.courses.Where(cd => cd.CourseId != courseId).ToArray();
if (newCourses.Length == 0)
ChangeEvent.DeleteSpecial(eventDB, specialId);
else {
special = (Special) special.Clone();
special.courses = newCourses;
eventDB.ReplaceSpecial(specialId, special);
}
}
}
示例6: ChangeSpecialText
// Change the text associated with a special. Must be an text special
public static void ChangeSpecialText(EventDB eventDB, Id<Special> specialId, string newText, string fontName, bool fontBold, bool fontItalic, SpecialColor specialColor)
{
Special special = eventDB.GetSpecial(specialId);
Debug.Assert(special.kind == SpecialKind.Text);
special = (Special) special.Clone();
special.text = newText;
special.fontName = fontName;
special.fontBold = fontBold;
special.fontItalic = fontItalic;
special.color = specialColor;
eventDB.ReplaceSpecial(specialId, special);
}
示例7: ChangeSpecialOrientation
// Change the orientation associated with a special. Must be an optional crossing point.
public static void ChangeSpecialOrientation(EventDB eventDB, Id<Special> specialId, float newOrientation)
{
Special special = eventDB.GetSpecial(specialId);
Debug.Assert(special.kind == SpecialKind.OptCrossing);
special = (Special) special.Clone();
special.orientation = newOrientation;
eventDB.ReplaceSpecial(specialId, special);
}
示例8: ChangeSpecialLocations
// Change the locations associated with a special.
public static void ChangeSpecialLocations(EventDB eventDB, Id<Special> specialId, PointF[] newLocations)
{
Special special = eventDB.GetSpecial(specialId);
special = (Special) special.Clone();
special.locations = (PointF[]) newLocations.Clone();
eventDB.ReplaceSpecial(specialId, special);
}