示例#1
0
        public int Compare(object x, object y)
        {
            PodItem a = (PodItem)x;
            PodItem b = (PodItem)y;

            return(a.Name.CompareTo(b.Name));
        }
示例#2
0
        private void RunAction()
        {
            StackWrapper current = CurrentController;

            if (current.Controller.Items.Count == 0)
            {
                return;
            }

            PodItem item = (PodItem)current.Controller.Items[current.Index];

            //if (!item.IsLeaf)
            //    return;

            item.RunAction();
        }
示例#3
0
        private void MoveRight()
        {
            // Decide if we can move
            StackWrapper current = CurrentController;

            if (current.Controller.Items.Count == 0)
            {
                return;
            }

            PodItem item = (PodItem)current.Controller.Items[current.Index];

            if (item.IsLeaf)
            {
                return;
            }

            PodController child = item.GetChildController();

            if (child == null)
            {
                return;
            }

            child.Refresh();

            // Create graphics port
            Graphics g = this.CreateGraphics();

            // Get image of the current view
            Bitmap   bmp1  = new Bitmap(ClientRectangle.Width, ClientRectangle.Height);
            Graphics bmp1G = Graphics.FromImage(bmp1);

            GoPaint(bmp1G, ClientRectangle);

            // Add new controller to stack
            _stack.Add(new StackWrapper(child));

            // Get image of new view
            Bitmap   bmp2  = new Bitmap(ClientRectangle.Width, ClientRectangle.Height);
            Graphics bmp2G = Graphics.FromImage(bmp2);

            GoPaint(bmp2G, ClientRectangle);

            // Animate transition between views
            Pen pen = new Pen(Color.Gray, 3);

            for (int i = 1; i < 4; i++)
            {
                int x = ClientRectangle.Width * (5 - i) / 5;

                g.DrawImage(bmp1, x - ClientRectangle.Width, 0);
                g.DrawImage(bmp2, x, 0);
                g.DrawLine(pen, x, 0, x, ClientRectangle.Height);

                Thread.Sleep(25);
            }

            pen.Dispose();

            // Clean up images
            bmp1G.Dispose();
            bmp1.Dispose();

            bmp2G.Dispose();
            bmp2.Dispose();

            g.Dispose();

            // Finally, draw new view
            Refresh();

            OnSelectedIndexChanged(EventArgs.Empty);
        }
示例#4
0
        private void GoPaint(Graphics g, Rectangle clipRect)
        {
            g.Clear(this.BackColor);

            Pen pen = new Pen(Color.White);

            StackWrapper current = CurrentController;

            if (current == null)
            {
                g.DrawString("No controller set", _font, pen.Brush, 5, 5);
            }
            else
            {
                int rows = this.Height / _font.Height;

                for (int i = 0; i < rows; i++)
                {
                    Pen rowPen = pen;
                    int index  = i + current.Scroll;

                    if (index >= current.Controller.Items.Count)
                    {
                        break;
                    }

                    PodItem item = (PodItem)current.Controller.Items[index];
                    int     y    = i * _font.Height;

                    // Selected item background
                    if (index == current.Index)
                    {
                        Rectangle bgRect = new Rectangle(0, y, this.Width, _font.Height);
                        g.FillRectangle(pen.Brush, bgRect);

                        rowPen = new Pen(Color.Black);
                    }

                    // Text
                    Rectangle textRect = new Rectangle(5, y, this.Width - 25, _font.Height);
                    g.DrawString(item.Name, _font, rowPen.Brush, textRect);

                    // Arrow
                    if (!item.IsLeaf)
                    {
                        Point[] points = new Point[3];

                        int xoffset = this.Width - 15;
                        int yoffset = (_font.Height / 2) - 5;

                        points[0] = new Point(xoffset, y + yoffset);
                        points[1] = new Point(xoffset, y + yoffset + 10);
                        points[2] = new Point(xoffset + 10, y + yoffset + 5);

                        g.FillPolygon(rowPen.Brush, points);
                    }

                    if (rowPen != pen)
                    {
                        rowPen.Dispose();
                    }
                }
            }

            pen.Dispose();
        }