Exemple #1
0
        private void neueListeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Forms.DialogNewArmy dlgNewArmy = new Forms.DialogNewArmy();
            using (dlgNewArmy)
            {
                ClearView();
                DialogResult res = dlgNewArmy.ShowDialog(this);
                if (res == DialogResult.OK)
                {
                    foc = new ModelClasses.ForceOrgChart();

                    foc.Name = dlgNewArmy.ArmyName;
                    foc.IsStrictMatchPlay         = dlgNewArmy.IsStrictMatchedList;
                    foc.ArmyFactionForMatchedPlay = dlgNewArmy.SelectedFaction;

                    foc.DoCheckPointLimt  = dlgNewArmy.IsPointsLimited;
                    foc.DoCheckPowerlevel = dlgNewArmy.IsPowerlevelLimited;

                    foc.Powerlevel = dlgNewArmy.PowerleveLimit;
                    foc.PointLimit = dlgNewArmy.PointsLimit;

                    foc.Detachments  = new ModelClasses.Detachments();
                    foc.ExistingFile = false;

                    edited = true;
                    saved  = false;

                    ProgramRunningMode = RunMode.opened;
                    RefreshView();
                }
            }
        }
Exemple #2
0
        public void OpenFocFromDisk()
        {
            if (ProgramRunningMode != RunMode.empty && (edited || !saved))
            {
                DialogResult usersChoice = MessageBox.Show(this, "Es liegen ungesicherte Änderungen an der aktuellen Armee-Liste vor. Sollen die vor dem öffnen gespeichert werden?", "Vorsicht - ungesicherte Änderungen", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (usersChoice == DialogResult.Yes)
                {
                    Save();
                }
            }

            openFocFile.DefaultExt = "xml";
            openFocFile.FileName   = "";
            openFocFile.Filter     = "ArmyList XML (*.axml)|*.axml";

            DialogResult res = openFocFile.ShowDialog();

            if (res == DialogResult.OK)
            {
                if (openFocFile.FileName != null)
                {
                    foc = new ModelClasses.ForceOrgChart();
                    selectedDetachment = null;
                    ClearView();

                    armylistFilename = openFocFile.FileName;
                    try
                    {
                        ReadFoc(armylistFilename);
                        saved              = true;
                        edited             = false;
                        ProgramRunningMode = RunMode.opened;
                        RefreshView();
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(this, "Kann die Datei nicht einlesen: " + e.Message, "Auweia", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        saved              = false;
                        edited             = true;
                        ProgramRunningMode = RunMode.empty;
                    }
                }
            }

            RefreshView();
        }
Exemple #3
0
        public void ReadFoc(string path)
        {
            FileStream fs = null;

            foc = new ModelClasses.ForceOrgChart();

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(ModelClasses.ForceOrgChart));
                fs  = new FileStream(path, FileMode.Open);
                foc = (ModelClasses.ForceOrgChart)serializer.Deserialize(fs);
                fs.Close();
            }
            catch (Exception excp)
            {
                if (fs != null)
                {
                    fs.Dispose();
                }
                throw excp;
            }
        }