Esempio n. 1
0
        public PresentationSpaceField(
            out LinkedListNode <PresentationSpacePixel> OutEndPixelNode,
            PresentationSpace InPs,
            LinkedListNode <PresentationSpacePixel> InPixelNode)
        {
            PresentationSpacePixel pixel = InPixelNode.Value;

            mPs                 = InPs;
            mLocation           = pixel.DisplayLocation;
            this.FieldAttribute = new FieldAttribute(pixel.Byte1);

            // store the character attributes found in the first character pixel.
            if (pixel.CharAttrByte != null)
            {
                mCharAttrByte = pixel.CharAttrByte;
            }

            // length runs from pixel after the attribute pixel to the next
            // attribute pixel.
            mLength = 0;
            StringBuilder sb = new StringBuilder();
            LinkedListNode <PresentationSpacePixel> node    = InPixelNode;
            LinkedListNode <PresentationSpacePixel> endNode = InPixelNode;

            while (true)
            {
                node = node.Next;
                if (node == null)
                {
                    break;
                }
                pixel = node.Value;
                if (pixel.IsFieldAttribute == true)
                {
                    break;
                }
                endNode = node;
                ++mLength;
                sb.Append(pixel.CharValue);

                if (sb.Length == 1)
                {
                    if (pixel.ColorAttrByte != null)
                    {
                        mColorAttrByte = pixel.ColorAttrByte;
                    }
                }
            }
            mText           = sb.ToString( );
            OutEndPixelNode = endNode;
        }
        public static XElement ToXElement(this PresentationSpace Space, XName Name)
        {
            if (Space == null)
            {
                return(new XElement(Name, null));
            }
            else
            {
                XElement xe = new XElement(Name,

                                           new XElement("Fields",
                                                        from c in Space.Fields
                                                        select c.ToXElement("Field")),

                                           Space.Dim.ToXElement("Dim"),
                                           Space.CursorLocation.ToXElement("CursorLocation")
                                           );
                return(xe);
            }
        }
        public static PresentationSpace PresentationSpaceOrDefault(
            this XElement Elem, XNamespace ns, PresentationSpace Default = null)
        {
            if (Elem == null)
            {
                return(Default);
            }
            else
            {
                var dim = Elem.Element("Dim").PresentationSpaceDimOrDefault(ns, null);
                var loc = Elem.Element("CursorLocation").DisplayLocationOrDefault(ns, null);

                var flds =
                    from sam in Elem.Element(ns + "Fields")
                    .Elements(ns + "Field")
                    select sam.PresentationSpaceFieldOrDefault(ns, null);

                var ps = new PresentationSpace(loc, dim, flds);
                return(ps);
            }
        }
        public static void WriteCaptureDoc(
            this PresentationSpace Space, string CaptureFolderPath, string LongName, string WindowText)
        {
            var xe = Space.ToXElement("PresentationSpace");

            XDocument xdoc = new XDocument(
                new XDeclaration("1.0", "utf-8", "yes"),
                new XComment("display session presentation space"),
                new XElement("ScreenCapture",
                             xe,
                             new XElement("LongName", LongName),
                             new XElement("WindowText", WindowText))
                );

            // setup the capture file name.
            var    nowDate  = DateTime.Now;
            string fullPath = CaptureFolderPath;

            // year name.
            {
                string yearName = nowDate.ToString("yyyy");
                fullPath = System.IO.Path.Combine(fullPath, yearName);
                Pather.AssureDirectoryExists(fullPath);
            }

            // month name.
            {
                string monthName = nowDate.ToString("MMMM");
                fullPath = System.IO.Path.Combine(fullPath, monthName);
                Pather.AssureDirectoryExists(fullPath);
            }

            // day name.
            {
                string dayName = nowDate.ToString("dd");
                fullPath = System.IO.Path.Combine(fullPath, dayName);
                Pather.AssureDirectoryExists(fullPath);
            }

            // hour name.
            {
                string hourName = nowDate.ToString("hh");
                fullPath = System.IO.Path.Combine(fullPath, hourName);
                Pather.AssureDirectoryExists(fullPath);
            }

            // session name.
            {
                fullPath = System.IO.Path.Combine(fullPath, LongName);
                Pather.AssureDirectoryExists(fullPath);
            }

            // file name.
            {
                string fileName = "Capture_" + LongName + "_" + nowDate.ToString("HH.mm.ss") + ".xml";
                fullPath = System.IO.Path.Combine(fullPath, fileName);
            }

            // save the document
            xdoc.Save(fullPath);
        }