Пример #1
0
 void SelectedAddTab(object sender, TabControlCancelEventArgs args)
 {
     if (args.TabPage.Name == "+")
     {
         Console.WriteLine("adding!");
         InputBox box = new InputBox {
             Input = "New Formation"
         };
         if (box.ShowDialog() == DialogResult.OK)
         {
             tabControl.TabPages.Remove(args.TabPage);
             Groupformation newFormation = new Groupformation {
                 Name = box.Input
             };
             EditedFile.Formations.Add(newFormation);
             TabPage page = CreatePage(newFormation);
             tabControl.TabPages.Add(page);
             tabControl.TabPages.Add(args.TabPage);
             tabControl.SelectTab(page);
         }
         args.Cancel = true;
     }
     else
     {
         Console.WriteLine("selected {0}", args.TabPage.Name);
     }
 }
Пример #2
0
        public GroupformationFile Decode(Stream stream)
        {
            List <Groupformation> formations;

            using (BinaryReader reader = new BinaryReader(stream))
            {
                uint formationCount = reader.ReadUInt32();
                formations = new List <Groupformation>((int)formationCount);
                for (int j = 0; j < formationCount; j++)
                {
                    Groupformation formation = new Groupformation();
                    formation.Name     = IOFunctions.ReadCAString(reader);
                    formation.Priority = reader.ReadSingle();
                    formation.Purpose  = reader.ReadUInt32();
                    // Console.WriteLine("reading formation {0}, purpose {1}", formation.Name, formation.Purpose);
                    formation.Minima   = ReadList <Minimum>(reader, ReadMinimum);
                    formation.Factions = ReadList <string>(reader, IOFunctions.ReadCAString);
                    formation.Lines    = ReadList <Line>(reader, ReadLine);
                    formations.Add(formation);
                }
            }
            GroupformationFile formationFile = new GroupformationFile {
                Formations = formations
            };

            return(formationFile);
        }
Пример #3
0
        TabPage CreatePage(Groupformation formation)
        {
            TabPage tabPage = new TabPage(formation.Name)
            {
                Dock       = DockStyle.Fill,
                AutoScroll = true
            };
            GroupformationEditorControl editor = new GroupformationEditorControl {
                Dock            = DockStyle.Fill,
                EditedFormation = formation
            };

            tabPage.Controls.Add(editor);
            Editors.Add(editor);
            return(tabPage);
        }