Exemplo n.º 1
0
        private void SetArea(object args, EventArgs e)
        {
            string areaName = (string)((object[])args)[0];

            if (!_pictureBoxes.ContainsKey(areaName))
            {
                return;
            }

            string    name = (string)((object[])args)[1];
            PanelArea area = Array.Find <PanelArea>(_areas, delegate(PanelArea o)
            {
                return(o.Name == areaName);
            });

            if (area != null)
            {
                PanelImage image = Array.Find <PanelImage>(area.Images, delegate(PanelImage o)
                {
                    return(o.Name == name);
                });
                if (image != null)
                {
                    _pictureBoxes[areaName].Image = image.LoadImage();
                }
            }
        }
Exemplo n.º 2
0
        public static PanelArea Load(XmlNode node, string dir)
        {
            PanelArea area = new PanelArea();

            area.Name      = node.Attributes["name"].Value;
            area.Left      = int.Parse(node.Attributes["left"].Value);
            area.Top       = int.Parse(node.Attributes["top"].Value);
            area.Width     = int.Parse(node.Attributes["width"].Value);
            area.Height    = int.Parse(node.Attributes["height"].Value);
            area.Clickable = bool.Parse(node.Attributes["clickable"].Value);
            area.Order     = int.Parse(node.Attributes["order"].Value);
            List <PanelImage> images = new List <PanelImage>();
            XmlNodeList       nodes  = node.SelectNodes("image");

            foreach (XmlNode node2 in nodes)
            {
                images.Add(PanelImage.Load(node2, dir));
            }
            area.Images = images.ToArray();
            return(area);
        }
Exemplo n.º 3
0
        public static PanelConfiguration Load(string fileName)
        {
            XmlDocument xml = new XmlDocument();

            xml.Load(fileName);
            XmlNode node = xml.SelectSingleNode("/panel");

            if (node != null)
            {
                PanelConfiguration panel = new PanelConfiguration();
                panel.Name        = node.Attributes["name"].Value;
                panel.ShowCaption = bool.Parse(node.Attributes["showCaption"].Value);
                panel.Width       = int.Parse(node.Attributes["width"].Value);
                panel.Height      = int.Parse(node.Attributes["height"].Value);
                panel.Top         = int.Parse(node.Attributes["top"].Value);
                panel.Left        = int.Parse(node.Attributes["left"].Value);
                XmlNodeList       backgroundImagesNodes = node.SelectNodes("background/image");
                List <PanelImage> backgroundImages      = new List <PanelImage>();
                foreach (XmlNode node2 in backgroundImagesNodes)
                {
                    backgroundImages.Add(PanelImage.Load(node2, Path.GetDirectoryName(fileName)));
                }
                panel.Background = backgroundImages.ToArray();
                XmlNodeList      areasNodes = node.SelectNodes("area");
                List <PanelArea> areas      = new List <PanelArea>();
                foreach (XmlNode node3 in areasNodes)
                {
                    areas.Add(PanelArea.Load(node3, Path.GetDirectoryName(fileName)));
                }
                areas.Sort(delegate(PanelArea left, PanelArea right)
                {
                    return(left.Order.CompareTo(right.Order));
                });
                panel.Areas = areas.ToArray();
                return(panel);
            }
            return(null);
        }
Exemplo n.º 4
0
        public PanelForm(PanelConfiguration configuration)
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            //
            // TODO: Add constructor code after the InitializeComponent() call.
            //

            _configuration = configuration;
            _background    = _configuration.Background;
            _areas         = _configuration.Areas;

            Text       = _configuration.Name;
            ClientSize = new Size(_configuration.Width, _configuration.Height);
            if (_configuration.ShowCaption)
            {
                FormBorderStyle = FormBorderStyle.FixedToolWindow;
            }
            else
            {
                FormBorderStyle = FormBorderStyle.None;
            }
            this.StartPosition = FormStartPosition.Manual;
            Location           = new Point(_configuration.Left, _configuration.Top);

            // ustawienie domyślnego tła
            PanelImage image = Array.Find <PanelImage>(_background, delegate(PanelImage o)
            {
                return(o.Default);
            });

            if (image != null)
            {
                BackgroundImage = image.LoadImage();
            }

            // utworzenie obszarów
            for (int i = 0; i < _areas.Length; i++)
            {
                PanelArea area = _areas[i];
                if (area.Images != null && area.Images.Length > 0)
                {
                    PictureBox picture = new PictureBox();
                    picture.Left      = area.Left;
                    picture.Top       = area.Top;
                    picture.Width     = area.Width;
                    picture.Height    = area.Height;
                    picture.SizeMode  = PictureBoxSizeMode.StretchImage;
                    picture.Visible   = true;
                    picture.Tag       = area;
                    picture.BackColor = Color.Transparent;
                    Controls.Add(picture);
                    PanelImage image2 = Array.Find <PanelImage>(area.Images, delegate(PanelImage o)
                    {
                        return(o.Default);
                    });
                    if (image2 != null)
                    {
                        picture.Image = image2.LoadImage();
                    }

                    _pictureBoxes.Add(area.Name, picture);
                }
            }
        }