Esempio n. 1
0
        private void SetCoords()
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Filter           = "Text file with coords (*.txt) | *.txt";
            fileDialog.InitialDirectory = Utilites.GuiResourcesPath;
            if (fileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            StreamReader stream = new StreamReader(fileDialog.FileName);
            string       line;

            while ((line = stream.ReadLine()) != null)
            {
                string[] s = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                if (s.Length != 3)
                {
                    continue;
                }

                string imageName = s[0];
                int    x = 0, y = 0;
                int.TryParse(s[1], out x);
                int.TryParse(s[2], out y);
                if (x < 0)
                {
                    x = 0;
                }
                if (y < 0)
                {
                    y = 0;
                }

                GUIObject obj = LoadedTree.FindByBackground(imageName);
                if (obj != null)
                {
                    obj.SetAbsolutePosition(x, y);
                    if (obj is GUIPanel)
                    {
                        ((GUIPanel)obj).SetBackgroundSize();
                    }
                }
            }
        }