예제 #1
0
        public void Load()
        {
            this._pipEntries = new BindingList <PIPEntry>();

            using (BinaryReader pip = new BinaryReader(File.OpenRead(_filePath)))
            {
                while (pip.BaseStream.Position < pip.BaseStream.Length)
                {
                    PIPEntry entry = new PIPEntry();

                    entry.Type = (PIPEntry.PipType)pip.ReadByte();
                    entry.X    = pip.ReadInt16();
                    entry.Y    = pip.ReadInt16();

                    switch (entry.Type)
                    {
                    case PIPEntry.PipType.TEXT:
                        entry.Size      = pip.ReadByte();
                        entry.Color     = pip.ReadInt16();
                        entry.BackColor = pip.ReadInt16();
                        break;

                    case PIPEntry.PipType.SUBMENUS:
                    case PIPEntry.PipType.SUBSCREENS:
                    case PIPEntry.PipType.IMAGE:
                        break;

                    case PIPEntry.PipType.LINE:
                    case PIPEntry.PipType.FILLRECT:
                    case PIPEntry.PipType.RECT:
                        entry.EndX  = pip.ReadInt16();
                        entry.EndY  = pip.ReadInt16();
                        entry.Color = pip.ReadInt16();
                        break;
                    }

                    var data = new StringBuilder();

                    while (pip.BaseStream.Position < pip.BaseStream.Length)
                    {
                        var nextChar = pip.ReadChar();

                        if (nextChar == (char)13)
                        {
                            pip.ReadChar(); // Om nom nom nom

                            break;
                        }
                        else
                        {
                            data.Append(nextChar);
                        }
                    }

                    entry.Data = data.ToString();

                    this._pipEntries.Add(entry);
                }
            }
        }
예제 #2
0
 public void RemoveEntry(PIPEntry entry)
 {
     if (this._pipEntries != null)
     {
         this._pipEntries.Remove(entry);
     }
 }
예제 #3
0
        private void renderSubScreens(PIPEntry entry, Graphics graphics)
        {
            using (Font font = new Font("Terminal", 7))
            {
                // Render Text
                var menuTitles = string.Join("  ", entry.Data.Split('|'));

                var brush = new SolidBrush(Color.Green);
                graphics.DrawString(menuTitles, font, brush, new PointF(entry.X, entry.Y));
            }
        }
예제 #4
0
        private void renderImage(PIPEntry entry, Graphics graphics)
        {
            string directory = Path.GetDirectoryName(_pipFile.FilePath);
            string path      = string.Format(@"{0}\{1}", directory, entry.Data);

            if (File.Exists(path))
            {
                Image image = Image.FromFile(path);

                graphics.DrawImage(image, new PointF(entry.X, entry.Y));
            }
        }
예제 #5
0
        public void MoveEntryDown(PIPEntry entry)
        {
            if (this._pipEntries.Count > 1)
            {
                var currentIndex = this._pipEntries.IndexOf(entry);

                if (currentIndex < (this._pipEntries.Count - 1))
                {
                    this._pipEntries.Remove(entry);
                    this._pipEntries.Insert(currentIndex + 1, entry);
                }
            }
        }
예제 #6
0
        private void renderText(PIPEntry entry, Graphics graphics)
        {
            using (Font font = new Font("Terminal", entry.Size * 7))
            {
                // Render Background
                var backgroundBrush = new SolidBrush(convert565ToColour(entry.BackColor));
                graphics.FillRectangle(backgroundBrush, new RectangleF(new PointF(entry.X, entry.Y), graphics.MeasureString(entry.Data, font)));

                // Render Text
                var brush = new SolidBrush(convert565ToColour(entry.Color));
                graphics.DrawString(entry.Data, font, brush, new PointF(entry.X, entry.Y));
            }
        }
예제 #7
0
        public void MoveEntryDown(PIPEntry entry)
        {
            if (this._pipEntries.Count > 1)
            {
                var currentIndex = this._pipEntries.IndexOf(entry);

                if (currentIndex < (this._pipEntries.Count - 1))
                {
                    this._pipEntries.Remove(entry);
                    this._pipEntries.Insert(currentIndex + 1, entry);
                }
            }
        }
예제 #8
0
        public void MoveEntryUp(PIPEntry entry)
        {
            if (this._pipEntries.Count > 1)
            {
                var currentIndex = this._pipEntries.IndexOf(entry);

                if (currentIndex > 0)
                {
                    this._pipEntries.Remove(entry);
                    this._pipEntries.Insert(currentIndex - 1, entry);
                }
            }
        }
예제 #9
0
        public void MoveEntryUp(PIPEntry entry)
        {
            if (this._pipEntries.Count > 1)
            {
                var currentIndex = this._pipEntries.IndexOf(entry);

                if (currentIndex > 0)
                {
                    this._pipEntries.Remove(entry);
                    this._pipEntries.Insert(currentIndex - 1, entry);
                }
            }
        }
예제 #10
0
        public void Save()
        {
            using (BinaryWriter pip = new BinaryWriter(File.Create(_filePath)))
            {
                for (int i = 0; i < this._pipEntries.Count; i++)
                {
                    if (i > 0)
                    {
                        // finish previous entry
                        pip.Write((char)13);
                        pip.Write((char)10);
                    }

                    PIPEntry entry = this._pipEntries[i];

                    pip.Write((byte)entry.Type);
                    pip.Write((Int16)entry.X);
                    pip.Write((Int16)entry.Y);

                    switch (entry.Type)
                    {
                    case PIPEntry.PipType.TEXT:
                        pip.Write((byte)entry.Size);
                        pip.Write((Int16)entry.Color);
                        pip.Write((Int16)entry.BackColor);
                        pip.Write(Encoding.ASCII.GetBytes(entry.Data));
                        break;

                    case PIPEntry.PipType.SUBMENUS:
                    case PIPEntry.PipType.SUBSCREENS:
                    case PIPEntry.PipType.IMAGE:
                        pip.Write(Encoding.ASCII.GetBytes(entry.Data));
                        break;

                    case PIPEntry.PipType.LINE:
                    case PIPEntry.PipType.FILLRECT:
                    case PIPEntry.PipType.RECT:
                        pip.Write((Int16)entry.EndX);
                        pip.Write((Int16)entry.EndY);
                        pip.Write((Int16)entry.Color);
                        break;
                    }
                }
            }
        }
예제 #11
0
        private void renderSubMenus(PIPEntry entry, Graphics graphics)
        {
            using (Font font = new Font("Terminal", 7))
            {
                // Render Text
                var menuTitles     = entry.Data.Split('|');
                var menuItemHeight = 20;
                var startX         = 20;
                var startY         = 55;

                foreach (string menuTitle in menuTitles)
                {
                    var brush = new SolidBrush(Color.Green);
                    graphics.DrawString(menuTitle, font, brush, new PointF(startX, startY));

                    startY += menuItemHeight;
                }
            }
        }
예제 #12
0
 private void renderRect(PIPEntry entry, Graphics graphics)
 {
     var pen = new Pen(convert565ToColour(entry.Color));
     graphics.DrawRectangle(pen, new Rectangle(entry.X, entry.Y, entry.EndX, entry.EndY));
 }
예제 #13
0
 public void RemoveEntry(PIPEntry entry)
 {
     if (this._pipEntries != null)
     {
         this._pipEntries.Remove(entry);
     }
 }
예제 #14
0
        private void renderSubScreens(PIPEntry entry, Graphics graphics)
        {
            using (Font font = new Font("Terminal", 7))
            {
                // Render Text
                var menuTitles = string.Join("  ", entry.Data.Split('|'));

                var brush = new SolidBrush(Color.Green);
                graphics.DrawString(menuTitles, font, brush, new PointF(entry.X, entry.Y));
            }
        }
예제 #15
0
        private void renderRect(PIPEntry entry, Graphics graphics)
        {
            var pen = new Pen(convert565ToColour(entry.Color));

            graphics.DrawRectangle(pen, new Rectangle(entry.X, entry.Y, entry.EndX, entry.EndY));
        }
예제 #16
0
        private void renderSubMenus(PIPEntry entry, Graphics graphics)
        {
            using (Font font = new Font("Terminal", 7))
            {
                // Render Text
                var menuTitles = entry.Data.Split('|');
                var menuItemHeight = 20;
                var startX = 20;
                var startY = 55;

                foreach (string menuTitle in menuTitles)
                {
                    var brush = new SolidBrush(Color.Green);
                    graphics.DrawString(menuTitle, font, brush, new PointF(startX, startY));

                    startY += menuItemHeight;
                }

            }
        }
예제 #17
0
 private void renderLine(PIPEntry entry, Graphics graphics)
 {
     var pen = new Pen(convert565ToColour(entry.Color));
     graphics.DrawLine(pen, new PointF(entry.X, entry.Y), new PointF(entry.EndX, entry.EndY));
 }
예제 #18
0
        private void renderImage(PIPEntry entry, Graphics graphics)
        {
            string directory = Path.GetDirectoryName(_pipFile.FilePath);
            string path = string.Format(@"{0}\{1}", directory, entry.Data);

            if (File.Exists(path))
            {
                Image image = Image.FromFile(path);

                graphics.DrawImage(image, new PointF(entry.X, entry.Y));
            }
        }
예제 #19
0
        private void renderText(PIPEntry entry, Graphics graphics)
        {
            using (Font font = new Font("Terminal", entry.Size * 7))
            {
                // Render Background
                var backgroundBrush = new SolidBrush(convert565ToColour(entry.BackColor));
                graphics.FillRectangle(backgroundBrush, new RectangleF(new PointF(entry.X, entry.Y), graphics.MeasureString(entry.Data, font)));

                // Render Text
                var brush = new SolidBrush(convert565ToColour(entry.Color));
                graphics.DrawString(entry.Data, font, brush, new PointF(entry.X, entry.Y));
            }
        }
예제 #20
0
        private void renderLine(PIPEntry entry, Graphics graphics)
        {
            var pen = new Pen(convert565ToColour(entry.Color));

            graphics.DrawLine(pen, new PointF(entry.X, entry.Y), new PointF(entry.EndX, entry.EndY));
        }
예제 #21
0
 private void renderFillRect(PIPEntry entry, Graphics graphics)
 {
     var brush = new SolidBrush(convert565ToColour(entry.Color));
     graphics.FillRectangle(brush, new Rectangle(entry.X, entry.Y, entry.EndX, entry.EndY));
 }
예제 #22
0
        private void renderFillRect(PIPEntry entry, Graphics graphics)
        {
            var brush = new SolidBrush(convert565ToColour(entry.Color));

            graphics.FillRectangle(brush, new Rectangle(entry.X, entry.Y, entry.EndX, entry.EndY));
        }
예제 #23
0
        public void Load()
        {
            this._pipEntries = new BindingList<PIPEntry>();

            using (BinaryReader pip = new BinaryReader(File.OpenRead(_filePath)))
            {
                while (pip.BaseStream.Position < pip.BaseStream.Length)
                {
                    PIPEntry entry = new PIPEntry();

                    entry.Type = (PIPEntry.PipType)pip.ReadByte();
                    entry.X = pip.ReadInt16();
                    entry.Y = pip.ReadInt16();

                    switch (entry.Type)
                    {
                        case PIPEntry.PipType.TEXT:
                            entry.Size = pip.ReadByte();
                            entry.Color = pip.ReadInt16();
                            entry.BackColor = pip.ReadInt16();
                            break;

                        case PIPEntry.PipType.SUBMENUS:
                        case PIPEntry.PipType.SUBSCREENS:
                        case PIPEntry.PipType.IMAGE:
                            break;

                        case PIPEntry.PipType.LINE:
                        case PIPEntry.PipType.FILLRECT:
                        case PIPEntry.PipType.RECT:
                            entry.EndX = pip.ReadInt16();
                            entry.EndY = pip.ReadInt16();
                            entry.Color = pip.ReadInt16();
                            break;
                    }

                    var data = new StringBuilder();

                    while (pip.BaseStream.Position < pip.BaseStream.Length)
                    {
                        var nextChar = pip.ReadChar();

                        if (nextChar == (char)13)
                        {
                            pip.ReadChar(); // Om nom nom nom

                            break;
                        }
                        else
                        {
                            data.Append(nextChar);
                        }
                    }

                    entry.Data = data.ToString();

                    this._pipEntries.Add(entry);
                }
            }
        }