Exemple #1
0
 public AddTextMode(Controller controller, UndoMgr undoMgr, SelectionMgr selectionMgr, EventDB eventDB, string text, string fontName, bool fontBold, bool fontItalic, SpecialColor fontColor)
 {
     this.controller = controller;
     this.undoMgr = undoMgr;
     this.selectionMgr = selectionMgr;
     this.eventDB = eventDB;
     this.text = text;
     this.fontName = fontName;
     this.fontBold = fontBold;
     this.fontItalic = fontItalic;
     this.fontColor = fontColor;
     this.displayText = CourseFormatter.ExpandText(eventDB, selectionMgr.ActiveCourseView, text);
 }
Exemple #2
0
 public SpecialColor GetAttributeColor(string name, SpecialColor defValue)
 {
     string value = Reader.GetAttribute(name);
     if (value == null || value == string.Empty)
         return defValue;
     else {
         try {
             return SpecialColor.Parse(value);
         }
         catch (FormatException) {
             BadXml("Bad format for color attribute '{0}'", name);
             return defValue;
         }
     }
 }
Exemple #3
0
 public BasicTextCourseObj(Id<Special> specialId, string text, RectangleF rectBounding, string fontName, FontStyle fontStyle, SpecialColor color)
     : base(Id<ControlPoint>.None, Id<CourseControl>.None, specialId, text, new PointF(rectBounding.Left, rectBounding.Bottom), fontName, fontStyle, color, CalculateEmHeight(text, fontName, fontStyle, rectBounding.Size), 0.0F)
 {
     this.rectBounding = rectBounding;
 }
Exemple #4
0
        private float outlineWidth; // width of white outline (0 for none)

        #endregion Fields

        #region Constructors

        // NOTE: scale ratio is not used for this type of object!
        public TextCourseObj(Id<ControlPoint> controlId, Id<CourseControl> courseControlId, Id<Special> specialId, string text, PointF topLeft, string fontName, FontStyle fontStyle, SpecialColor fontColor, float emHeight, float outlineWidth)
            : base(controlId, courseControlId, specialId, 1.0F, new CourseAppearance())
        {
            this.text = text;
            this.topLeft = topLeft;
            this.fontName = fontName;
            this.fontStyle = fontStyle;
            this.fontColor = fontColor;
            this.emHeight = emHeight;
            this.outlineWidth = outlineWidth;
            this.size = MeasureText();
        }
Exemple #5
0
 public RectSpecialCourseObj(Id<Special> specialId, CourseAppearance appearance, SpecialColor color, LineKind lineKind, float lineWidth, float cornerRadius, float gapSize, float dashSize, RectangleF rect)
     : base(Id<ControlPoint>.None, Id<CourseControl>.None, specialId, 1.0F, appearance, rect)
 {
     this.color = color;
     this.lineKind = lineKind;
     this.lineWidth = lineWidth;
     this.cornerRadius = cornerRadius;
     this.gapSize = gapSize;
     this.dashSize = dashSize;
 }
Exemple #6
0
 public LineSpecialCourseObj(Id<Special> specialId, CourseAppearance appearance, SpecialColor color, LineKind lineKind, float lineWidth, float gapSize, float dashSize, SymPath path)
     : base(Id<ControlPoint>.None, Id<CourseControl>.None, Id<CourseControl>.None, specialId, 1.0F, appearance, 
            (lineKind == LineKind.Double) ? (lineWidth * 2 + gapSize) : lineWidth, path, null)
 {
     this.color = color;
     this.lineKind = lineKind;
     this.lineWidth = lineWidth;
     this.gapSize = gapSize;
     this.dashSize = dashSize;
 }
Exemple #7
0
        // Add a text special to the event
        public static Id<Special> AddTextSpecial(EventDB eventDB, RectangleF boundingRectangle, string text, string fontName, bool bold, bool italic, SpecialColor color)
        {
            Special special = new Special(SpecialKind.Text, new PointF[2] { new PointF(boundingRectangle.Left, boundingRectangle.Bottom), new PointF(boundingRectangle.Right, boundingRectangle.Top) });
            special.text = text;
            special.fontName = fontName;
            special.fontBold = bold;
            special.fontItalic = italic;
            special.color = color;

            return eventDB.AddSpecial(special);
        }
Exemple #8
0
 public static Id<Special> AddRectangleSpecial(EventDB eventDB, RectangleF rect, SpecialColor color, LineKind lineKind, float lineWidth, float gapSize, float dashSize, float cornerRadius)
 {
     Special special = new Special(SpecialKind.Rectangle, new PointF[] { rect.Location, new PointF(rect.Right, rect.Bottom)});
     special.color = color;
     special.lineKind = lineKind;
     special.lineWidth = lineWidth;
     special.gapSize = gapSize;
     special.dashSize = dashSize;
     special.cornerRadius = cornerRadius;
     return eventDB.AddSpecial(special);
 }
Exemple #9
0
 public static Id<Special> AddLineSpecial(EventDB eventDB, PointF[] locations, SpecialColor color, LineKind lineKind, float lineWidth, float gapSize, float dashSize)
 {
     Special special = new Special(SpecialKind.Line, locations);
     special.color = color;
     special.lineKind = lineKind;
     special.lineWidth = lineWidth;
     special.gapSize = gapSize;
     special.dashSize = dashSize;
     return eventDB.AddSpecial(special);
 }
Exemple #10
0
        // 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);
        }
Exemple #11
0
        // 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);
        }
 public ColorAndText(string text, CmykColor color)
 {
     this.Text = text;
     this.SpecialColor = new SpecialColor(color);
     this.Color = color;
 }
 public ColorAndText(string text, SpecialColor specialColor, CmykColor color)
 {
     this.Text = text;
     this.SpecialColor = specialColor;
     this.Color = color;
 }
        private void CustomizeColor(CmykColor color)
        {
            ColorChooserDialog colorChooserDialog = new ColorChooserDialog();
            colorChooserDialog.Color = color;

            if (colorChooserDialog.ShowDialog() == DialogResult.OK) {
                Color = new SpecialColor(colorChooserDialog.Color);
            }

            colorChooserDialog.Dispose();
            comboBox.Invalidate();

            SendChangeNotification();
        }
Exemple #15
0
        public override void ReadAttributesAndContent(XmlInput xmlinput)
        {
            string kindText = xmlinput.GetAttributeString("kind");
            switch (kindText) {
            case "first-aid": kind = SpecialKind.FirstAid; break;
            case "water": kind = SpecialKind.Water; break;
            case "optional-crossing-point": kind = SpecialKind.OptCrossing; break;
            case "forbidden-route": kind = SpecialKind.Forbidden; break;
            case "registration-mark": kind = SpecialKind.RegMark; break;
            case "boundary": kind = SpecialKind.Boundary; break;
            case "out-of-bounds": kind = SpecialKind.OOB; break;
            case "dangerous-area": kind = SpecialKind.Dangerous; break;
            case "white-out": kind = SpecialKind.WhiteOut; break;
            case "text": kind = SpecialKind.Text; break;
            case "descriptions": kind = SpecialKind.Descriptions; break;
            case "image": kind = SpecialKind.Image; break;
            case "line": kind = SpecialKind.Line; break;
            case "rectangle": kind = SpecialKind.Rectangle; break;
              
            default: xmlinput.BadXml("Invalid special-object kind '{0}'", kindText); break;
            }

            if (kind == SpecialKind.OptCrossing)
                orientation = xmlinput.GetAttributeFloat("orientation");

            text = null;
            locations = null;
            allCourses = true;
            courses = null;
            imageBitmap = null;
            List<PointF> locationList = new List<PointF>();

            if (kind == SpecialKind.Text || kind == SpecialKind.Line || kind == SpecialKind.Rectangle)
                color = SpecialColor.Purple;  // default color is purple.

            bool first = true;
            while (xmlinput.FindSubElement(first, "text", "font", "location", "appearance", "courses", "image-data")) {
                switch (xmlinput.Name) {
                case "text":
                    text = xmlinput.GetContentString();
                    break;

                case "image-data":
                    // We ignore the format, since Image.FromStream auto-detects.
                    MemoryStream stm = xmlinput.GetContentBase64();
                    try {
                        imageBitmap = (Bitmap) Image.FromStream(stm);
                    }
                    catch (ArgumentException) {
                        xmlinput.BadXml("Image data could not be loaded");
                    }
                    break;

                case "font":
                    fontName = xmlinput.GetAttributeString("name");
                    fontBold = xmlinput.GetAttributeBool("bold");
                    fontItalic = xmlinput.GetAttributeBool("italic");
                    xmlinput.Skip();
                    break;

                case "location":
                    float x = xmlinput.GetAttributeFloat("x");
                    float y = xmlinput.GetAttributeFloat("y");
                    locationList.Add(new PointF(x, y));
                    xmlinput.Skip();
                    break;

                case "appearance":
                    numColumns = xmlinput.GetAttributeInt("columns", 1);

                    if (kind == SpecialKind.Text || kind == SpecialKind.Line || kind == SpecialKind.Rectangle) {
                        color = xmlinput.GetAttributeColor("color", SpecialColor.Purple);
                    }

                    string lineKindValue = xmlinput.GetAttributeString("line-kind", "");
                    switch (lineKindValue) {
                        case "single": lineKind = LineKind.Single; break;
                        case "double": lineKind = LineKind.Double; break;
                        case "dashed": lineKind = LineKind.Dashed; break;
                    }

                    lineWidth = xmlinput.GetAttributeFloat("line-width", 0);
                    gapSize = xmlinput.GetAttributeFloat("gap-size", 0);
                    dashSize = xmlinput.GetAttributeFloat("dash-size", 0);
                    if (kind == SpecialKind.Rectangle)
                        cornerRadius = xmlinput.GetAttributeFloat("corner-radius", 0);

                    xmlinput.Skip();
                    break;

                case "courses":
                    allCourses = xmlinput.GetAttributeBool("all", false);
                    if (!allCourses) {
                        List<CourseDesignator> courseIdList = new List<CourseDesignator>();
                        xmlinput.MoveToContent();

                        bool firstCourse = true;
                        while (xmlinput.FindSubElement(firstCourse, "course")) {
                            int id = xmlinput.GetAttributeInt("course");
                            int part = xmlinput.GetAttributeInt("part", -1);
                            if (part >= 0)
                                courseIdList.Add(new CourseDesignator(new Id<Course>(id), part));
                            else
                                courseIdList.Add(new CourseDesignator(new Id<Course>(id)));
                            xmlinput.Skip();
                            firstCourse = false;
                        }

                        courses = courseIdList.ToArray();
                    }
                    else {
                        xmlinput.Skip();
                    }
                    break;
                }

                first = false;
            }

            if (locationList.Count == 0)
                xmlinput.BadXml("missing 'location' element");
            if ((kind == SpecialKind.Text) && fontName == null)
                xmlinput.BadXml("missing 'font' element");
            if ((kind == SpecialKind.Image) && imageBitmap == null)
                xmlinput.BadXml("Missing 'image-data' element");
            locations = locationList.ToArray();
        }