예제 #1
0
파일: Share.cs 프로젝트: HJfod/gdtools
            public void AddImport(string file)
            {
                Elem.BorderPanel Level = new Elem.BorderPanel();

                EventHandler ImportThis = (object s, EventArgs e) => {
                    RefreshDiv.Visible = true;
                    string res = GDTools.ImportLevel(file);
                    if (res != null)
                    {
                        MessageBox.Show($"Error: {res}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        Level.Dispose();
                    }
                };

                EventHandler CloseThis = (object s, EventArgs e) => Level.Dispose();

                ContextMenuStrip CM = new ContextMenuStrip();

                CM.Items.Add(new ToolStripMenuItem("Import", null, ImportThis));
                CM.Items.Add(new ToolStripMenuItem("Cancel", null, CloseThis));

                Level.ContextMenuStrip = CM;

                dynamic LevelInfo = GDTools.GetLevelInfo(file);

                string Info = "";

                foreach (PropertyInfo i in LevelInfo.GetType().GetProperties())
                {
                    if (i.Name != "Name" && i.Name != "Creator")
                    {
                        Info += $"{i.Name.Replace("_", " ")}: {i.GetValue(LevelInfo)}\n";
                    }
                }

                Level.Controls.Add(new Elem.Text($"{LevelInfo.Name} by {LevelInfo.Creator}"));

                FlowLayoutPanel x = new FlowLayoutPanel();

                x.AutoSize = true;
                x.Controls.Add(new Elem.But("Info", (s, e) => {
                    MessageBox.Show(Info, $"Info for {LevelInfo.Name}");
                }));
                x.Controls.Add(new Elem.But("Import", ImportThis));
                x.Controls.Add(new Elem.But("Close", CloseThis));

                Level.Controls.Add(x);

                ImportLeveLArea.Controls.Add(Level);
            }