Esempio n. 1
0
        void ShowExport()
        {
            ExportData data = ExportData.DataFromDBs();

            ImportExportDialog ied = new ImportExportDialog(this, data, true);

            ied.Show();
            ied.DialogComplete += (sender, e) =>
            {
                FileDialog.CheckFilePermission(this, () =>
                {
                    FileDialog fd = new FileDialog(this, new List <string>()
                    {
                        ".cmx"
                    }, false);
                    fd.Text = "export.cmx";
                    fd.Show();

                    fd.DialogComplete += (object s, FileDialog.FileDialogEventArgs ea) =>
                    {
                        string name     = ea.Filename;
                        string fullname = Path.Combine(fd.Folder, name);

                        FileInfo file = new FileInfo(fullname);

                        fullname = fullname.TrimEnd('.') + ".cmx";

                        XmlLoader <ExportData> .Save(e.Data, fullname);
                    };
                });
            };
        }
        void SavePressed(LinearLayout cl, bool monsters)
        {
            FileDialog.CheckFilePermission(Activity, () =>
            {
                FileDialog fd      = new FileDialog(cl.Context, _Extensions, false);
                fd.DialogComplete += (object s, FileDialog.FileDialogEventArgs ea) =>
                {
                    string name = ea.Filename;
                    if (!name.EndsWith(".cmpt", StringComparison.CurrentCultureIgnoreCase))
                    {
                        name = name + ".cmpt";
                    }
                    string fullname = Path.Combine(fd.Folder, name);

                    XmlListLoader <Character> .Save(new List <Character>(_CombatState.Characters.Where((a) => a.IsMonster == monsters)), fullname);
                };
                fd.Show();
            });
        }
Esempio n. 3
0
        void ShowImport()
        {
            FileDialog.CheckFilePermission(this, () =>
            {
                FileDialog fd = new FileDialog(this, new List <string>()
                {
                    ".cmx"
                }, true);
                fd.Show();

                fd.DialogComplete += (object s, FileDialog.FileDialogEventArgs ea) =>
                {
                    string name     = ea.Filename;
                    string fullname = Path.Combine(fd.Folder, name);

                    FileInfo file = new FileInfo(fullname);
                    ShowImportDialog(fullname);
                };
            });
        }
        void LoadPressed(LinearLayout cl, bool monsters)
        {
            FileDialog.CheckFilePermission(Activity, () =>
            {
                FileDialog fd = new FileDialog(cl.Context, _Extensions, true);
                fd.Show();

                fd.DialogComplete += (object s, FileDialog.FileDialogEventArgs ea) =>
                {
                    string name     = ea.Filename;
                    string fullname = Path.Combine(fd.Folder, name);

                    FileInfo file = new FileInfo(fullname);

                    if (String.Compare(".por", file.Extension, true) == 0 || String.Compare(".rpgrp", file.Extension, true) == 0)
                    {
                        List <Monster> importmonsters = Monster.FromFile(fullname);

                        if (importmonsters != null)
                        {
                            foreach (Monster m in importmonsters)
                            {
                                Character ch = new Character(m, false);
                                ch.IsMonster = monsters;
                                _CombatState.AddCharacter(ch);
                            }
                        }
                    }
                    else
                    {
                        List <Character> l = XmlListLoader <Character> .Load(fullname);
                        foreach (var c in l)
                        {
                            c.IsMonster = monsters;
                            _CombatState.AddCharacter(c);
                        }
                    }
                };
            });
        }