private NSMutableArray ReadRectanglesXml(PinboardData.RectangleInfo screenRectangle)
        {
            var list = new NSMutableArray();

            // Read <Rectangles>
            reader.ReadStartElement(rectanglesAtom);
            reader.MoveToContent();

            while (true)
            {
                if (String.ReferenceEquals(reader.Name, rectanglesAtom))
                {
                    reader.ReadEndElement();
                    reader.MoveToContent();
                    break;
                }

                var rectInfo = ReadRectangleXml();

                // Flip the rectangle top to bottom relative to the screen rectangle
                rectInfo.Y = screenRectangle.Height - rectInfo.Y - rectInfo.Height;

                list.Add(rectInfo);
            }

            return list;
        }
Esempio n. 2
0
        public static PinboardData ReadXml(XmlReader reader)
        {
            rectanglesAtom = reader.NameTable.Add("Rectangles");

            reader.MoveToContent();
            PinboardData data = ReadPinboardXml(reader);

            return(data);
        }
Esempio n. 3
0
        private void WritePinboardXml(XmlWriter writer, PinboardData data)
        {
            writer.WriteStartElement("Pinboard");
            writer.WriteAttributeString("Format", "2");

            WriteRectangleXml(writer, data.ScreenRectangle);

            WriteRectanglesXml(writer, data);
            writer.WriteEndElement();
        }
Esempio n. 4
0
        private static void WritePinboardXml(XmlWriter writer, PinboardData data)
        {
            writer.WriteStartElement("Pinboard");
            writer.WriteAttributeString("Format", "1");

            WriteRectangleXml(writer, data.ScreenRectInfo);

            WriteRectanglesXml(writer, data);
            writer.WriteEndElement();
        }
Esempio n. 5
0
 private void WriteRectangleXml(XmlWriter writer, PinboardData.RectangleInfo rectInfo)
 {
     writer.WriteStartElement("Rectangle");
     writer.WriteElementString("Name", rectInfo.Name.ToString());
     writer.WriteElementString("X", rectInfo.X.ToString());
     writer.WriteElementString("Y", rectInfo.Y.ToString());
     writer.WriteElementString("Width", rectInfo.Width.ToString());
     writer.WriteElementString("Height", rectInfo.Height.ToString());
     WriteColorXml(writer, rectInfo.Color);
     writer.WriteEndElement();
 }
Esempio n. 6
0
        private static void WriteRectanglesXml(XmlWriter writer, PinboardData data)
        {
            writer.WriteStartElement("Rectangles");

            foreach (var rectInfo in data.RectInfos)
            {
                WriteRectangleXml(writer, rectInfo);
            }

            writer.WriteEndElement();
        }
        private static void WriteRectanglesXml(XmlWriter writer, PinboardData data)
        {
            writer.WriteStartElement("Rectangles");

            foreach (var rectInfo in data.RectInfos)
            {
                WriteRectangleXml(writer, rectInfo);
            }

            writer.WriteEndElement();
        }
Esempio n. 8
0
        private void WriteRectanglesXml(XmlWriter writer, PinboardData data)
        {
            writer.WriteStartElement("Rectangles");

            for (nuint i = 0; i < data.Rectangles.Count; i++)
            {
                var rectInfo = data.Rectangles.GetItem<PinboardData.RectangleInfo>(i);
                WriteRectangleXml(writer, rectInfo);
            }

            writer.WriteEndElement();
        }
Esempio n. 9
0
        private static PinboardData ReadPinboardXml(XmlReader reader)
        {
            PinboardData data = new PinboardData();

            reader.ReadStartElement("Pinboard");
            reader.MoveToContent();
            data.ScreenRectInfo = ReadRectangleXml(reader);

            data.RectInfos = ReadRectanglesXml(reader);

            reader.ReadEndElement();
            reader.MoveToContent();

            return(data);
        }
        private static PinboardData ReadPinboardXml(XmlReader reader)
        {
            PinboardData data = new PinboardData();

            reader.ReadStartElement("Pinboard");
            reader.MoveToContent();
            data.ScreenRectInfo = ReadRectangleXml(reader);

            data.RectInfos = ReadRectanglesXml(reader);

            reader.ReadEndElement();
            reader.MoveToContent();

            return data;
        }
Esempio n. 11
0
        private PinboardData ReadPinboardXml()
        {
            PinboardData data = new PinboardData();

            reader.ReadStartElement("Pinboard");

            // TODO: Check that version is 2

            reader.MoveToContent();
            data.ScreenRectangle = ReadRectangleXml();

            data.Rectangles = ReadRectanglesXml();

            reader.ReadEndElement();
            reader.MoveToContent();

            return data;
        }
Esempio n. 12
0
        public override bool ReadFromUrl(NSUrl url, string typeName, out NSError outError)
        {
            outError = null;

            try
            {
                unsafe
                {
                    this.Pinboard = new PinboardDataReaderV1().ReadFromUrl(url.AbsoluteString);
                }
            }
            catch
            {
                // TODO: Set pinboard specific error here
                outError = NSError.FromDomain(NSError.OsStatusErrorDomain, -4);
                return false;
            }

            return true;
        }
Esempio n. 13
0
        private PinboardData ReadPinboardXml()
        {
            PinboardData data = new PinboardData();

            var format = reader.GetAttribute("Format");

            if (format == null || format != "1")
                // TODO: Don't throw exception, return null with an error code
                throw new FormatException(String.Format("Pinboard "));

            reader.ReadStartElement("Pinboard");

            reader.MoveToContent();
            data.ScreenRectangle = ReadRectangleXml();

            data.Rectangles = ReadRectanglesXml(data.ScreenRectangle);

            reader.ReadEndElement();
            reader.MoveToContent();

            return data;
        }
Esempio n. 14
0
 public void WriteXml(XmlWriter writer, PinboardData data)
 {
     WritePinboardXml(writer, data);
 }
Esempio n. 15
0
        private void DrawRectangle(CGContext g, PinboardData.RectangleInfo rectInfo)
        {
            g.SetFillColor(rectInfo.Color);
            g.FillRect(rectInfo.Rectangle);

            float pw = 0.5f;
            CGColor rectBorderColor = new CGColor(0f, rectInfo.Color.Alpha);

            g.SetLineWidth(pw);
            g.SetStrokeColor(rectBorderColor);
            g.SetFillColor(rectInfo.Color);
            g.SetLineJoin(CGLineJoin.Miter);
            g.BeginPath();
            g.StrokeRect(rectInfo.Rectangle);

            int margin = 5;
            // TODO: Make the font configurable
            NSFont font = NSFont.FromFontName("Helvetica", 12f);
            NSObject[] objects = new NSObject[] { font, (NSNumber)0 };
            NSObject[] keys = new NSObject[] { NSAttributedString.FontAttributeName, NSAttributedString.LigatureAttributeName };
            NSDictionary attributes = NSDictionary.FromObjectsAndKeys(objects, keys);
            NSAttributedString attrString = new NSAttributedString(rectInfo.Name, attributes);

            attrString.DrawString(new RectangleF(rectInfo.X + margin, rectInfo.Y + margin, rectInfo.Width - 2 * margin, rectInfo.Height - 2 * margin));
        }
Esempio n. 16
0
 public static void WriteXml(XmlWriter writer, PinboardData data)
 {
     WritePinboardXml(writer, data);
 }