private void LoadConfig() { // wczytanie listy paneli string dir = PanelsDirectory; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } if (_tmpForm == null) { _tmpForm = new ParentForm(); } string [] files = Directory.GetFiles(dir, "*.xml"); _panels.Clear(); for (int i = 0; i < files.Length; i++) { PanelConfiguration panel = PanelConfiguration.Load(files[i]); if (panel != null) { panel.Parent = _tmpForm; _panels.Add(panel); } } }
private PanelConfiguration GetPanel(string name) { PanelConfiguration result = _panels.Find(delegate(PanelConfiguration o) { return(o.Name == name); }); if (result == null) { throw new Exception(string.Format("Nie znaleziono panelu o nazwie '{0}'.", name)); } return(result); }
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); }
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); } } }