Beispiel #1
0
 bool CreateFileButtons(int Y)
 {
     string[] Files = Directory.GetFiles(FilePath);
     for (int i = 0; i < Files.Length; i++)
     {
         string     Text = Path.GetFileName(Files[i]);
         GuiElement G    = new GuiElement(GuiElement.Type.Button, new Rectangle(Form1.PB.Width - 140, Y + i * 50, 120, 30), Text);
         FileButtons.Add(G);
         G.ButtonEvent = FileEvent;
     }
     return(Files.Length > 0);
 }
Beispiel #2
0
 public FileHandler()
 {
     SaveButton               = new GuiElement(GuiElement.Type.Button, new Rectangle(Form1.PB.Size.Width - 140, 20, 120, 30), "Save");
     LoadButton               = new GuiElement(GuiElement.Type.Button, new Rectangle(Form1.PB.Size.Width - 140, 70, 120, 30), "Load");
     CancelButton             = new GuiElement(GuiElement.Type.Button, new Rectangle(Form1.PB.Size.Width - 280, 20, 120, 30), "Cancel");
     TextBox                  = new GuiElement(GuiElement.Type.WriteText, new Rectangle(Form1.PB.Size.Width - 140, 70, 120, 30), "");
     SaveButton.ButtonEvent   = SaveEvent;
     LoadButton.ButtonEvent   = LoadEvent;
     CancelButton.ButtonEvent = CancelEvent;
     FilePath                 = Path.Combine(Form1.StartPath, "Saves");
     if (!Directory.Exists(FilePath))
     {
         Directory.CreateDirectory(FilePath);
     }
 }
Beispiel #3
0
        void FileEvent(object sender, EventArgs e)
        {
            GuiElement Pressed = sender as GuiElement;

            if (LoadState)
            {
                Load(Path.Combine(FilePath, Pressed.Text));
                LoadState = false;
                LoadButton.ButtonTimer = 0;
                FileButtons            = new List <GuiElement>();
                TextBox.Text           = Pressed.Text;
            }
            else if (SaveState)
            {
                TextBox.Text = Pressed.Text;
            }
            CancelButton.ButtonTimer = 0;
        }
        void UpdateFamilyList()
        {
            UpdateFamily = false;
            FamilyButtons.Clear();

            if (Families.Count > 0)
            {
                int X  = Form1.PB.Size.Width - 300;
                int Y  = 20;
                int dy = 50;
                int i  = 1;
                FamilyButtons.Add(new GuiElement(GuiElement.Type.TextBox, new Rectangle(X, Y, 140, 30), "Families:"));
                foreach (var F in Families)
                {
                    GuiElement Button = new GuiElement(GuiElement.Type.Button, new Rectangle(X, Y + dy * i, 140, 30), F.Root.Name + ":" + F.FamilyMembersAlive.ToString());
                    FamilyButtons.Add(Button);
                    Button.ButtonEvent = FamilyButtonEvent;
                    i++;
                }
            }
        }
Beispiel #5
0
 bool getPressButton(GuiElement E)
 {
     return(Form1.MousePos.X >= E.Rect.X && Form1.MousePos.X <= E.Rect.X + E.Rect.Width &&
            Form1.MousePos.Y >= E.Rect.Y && Form1.MousePos.Y <= E.Rect.Y + E.Rect.Height);
 }