コード例 #1
0
ファイル: Chooser.cs プロジェクト: drilus/Proxy-Printer
 private void Chooser_Load(object sender, EventArgs e)
 {
     //label2.Text = CardName;
     Guid card = Guid.Empty;
     string[] list = new string[SetList.Count];
     int i = 0;
     foreach (CardModel Card in SetList)
     {
         Set CardSet = Card.Set;
         list[i] = CardSet.Name;
         i++;
     }
     List<string> unique = new List<string>();
     unique.AddRange(list.Distinct());
     comboChooser.Sorted = true;
     foreach (string setname in unique) { comboChooser.Items.Add(setname); }
     comboChooser.Text = comboChooser.Items[0].ToString();
     // Default Image
     GamesRepository proxy = new GamesRepository();
     Game mygame = proxy.Games[GameIndex];
     card = SetList[0].Id;
     label2.Text = SetList[0].Name;
     BitmapImage img = new BitmapImage();
     System.Windows.Controls.Image CardImage = new System.Windows.Controls.Image();
     mtgPicture1.Image = SourceConvert.BitmapFromUri(img != null ? CardModel.GetPictureUri(mygame,
         mygame.GetCardById(card).Set.Id, mygame.GetCardById(card).ImageUri) : mygame.GetCardBackUri());
     selectedCard = card;
 }
コード例 #2
0
ファイル: Patch.cs プロジェクト: kellyelton/octgnwlobby
        public void Apply(GamesRepository repository, bool patchInstalledSets, string patchFolder)
        {
            if (!patchInstalledSets && patchFolder == null) return;

              using (var package = Package.Open(filename, FileMode.Open, FileAccess.Read))
              {
            ReadPackageDescription(package);

            // Get the list of sets to potentially patch
            game = repository.Games.FirstOrDefault(g => g.Id == gameId);
            var installedSets = game.Sets.Select(s => s.packageName).ToList();
            List<string> uninstalledSets;

            if (patchFolder != null)
            {
              string[] files = Directory.GetFiles(patchFolder, "*.o8s");
              uninstalledSets = files.Except(installedSets).ToList();
              if (!patchInstalledSets)
            installedSets = files.Intersect(installedSets).ToList();
            }
            else
              uninstalledSets = new List<string>(0);

            current = 0;
            max = installedSets.Count + uninstalledSets.Count;
            OnProgress();

            foreach (string set in installedSets)
              SafeApply(package, set, true);

            foreach (string set in uninstalledSets)
              SafeApply(package, set, false);
              }
        }
コード例 #3
0
        public void Apply(GamesRepository repository, bool patchInstalledSets, string patchFolder)
        {
            if (!patchInstalledSets && patchFolder == null)
            {
                return;
            }

            using (Package package = Package.Open(_filename, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                ReadPackageDescription(package);

                // Get the list of sets to potentially patch
                _game = repository.Games.FirstOrDefault(g => g.Id == _gameId);
                if (_game == null)
                {
                    return;
                }
                List <string> installedSets = _game.Sets.Select(s => s.PackageName).ToList();
                List <string> uninstalledSets;

                if (patchFolder != null)
                {
                    string[] files = Directory.GetFiles(patchFolder, "*.o8s");
                    uninstalledSets = files.Except(installedSets).ToList();
                    if (!patchInstalledSets)
                    {
                        installedSets = files.Intersect(installedSets).ToList();
                    }
                }
                else
                {
                    uninstalledSets = new List <string>(0);
                }

                _current = 0;
                _max     = installedSets.Count + uninstalledSets.Count;
                OnProgress();

                foreach (string set in installedSets)
                {
                    SafeApply(package, set, true);
                }

                foreach (string set in uninstalledSets)
                {
                    SafeApply(package, set, false);
                }

                if (SimpleDataTableCache.CacheExists())
                {
                    SimpleDataTableCache.ClearCache();
                }
            }
        }
コード例 #4
0
ファイル: Deck.cs プロジェクト: haplo63/OCTGN
        public static Deck Load(string file, GamesRepository repository)
        {
            if (repository == null) throw new ArgumentNullException("repository");

            Guid gameId;
            XDocument doc = LoadDoc(file, out gameId);

            Game game = repository.Games.FirstOrDefault(g => g.Id == gameId);
            if (game == null) throw new UnknownGameException(gameId);

            return LoadCore(doc, game);
        }
コード例 #5
0
ファイル: Set.cs プロジェクト: YoshiEnVerde/OCTGN
 public Set(string packageName, XmlReader reader, GamesRepository repository)
 {
     this.PackageName = packageName;
     Name = reader.GetAttribute("name");
     Id = new Guid(reader.GetAttribute("id"));
     var gameId = new Guid(reader.GetAttribute("gameId"));
     Game = repository.Games.First(g => g.Id == gameId);
     GameVersion = new Version(reader.GetAttribute("gameVersion"));
       Version ver;
       Version.TryParse(reader.GetAttribute("version"), out ver);
       Version = ver ?? new Version(0, 0);
     reader.ReadStartElement("set");
 }
コード例 #6
0
ファイル: DeckLoader.cs プロジェクト: Gravecorp/Proxy-Printer
 private void btnLoadDeck_Click(object sender, EventArgs e)
 {
     listDeckList.Items.Clear();
     GamesRepository proxy = new GamesRepository();
     Game mygame = proxy.Games[GameIndex];
     openFileDialog1.Filter = "OCTGN deck files (*.o8d) | *.o8d";
     openFileDialog1.InitialDirectory = mygame != null ? mygame.DefaultDecksPath : null;
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         Deck newDeck;
         try
         {
             newDeck = Deck.Load(openFileDialog1.FileName, proxy);
         }
         catch (DeckException ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         catch (Exception ex)
         {
             MessageBox.Show("OCTGN couldn't load the deck.\r\nDetails:\r\n\r\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         for (int I = 0; I < newDeck.Sections[0].Cards.Count; I++ )
         {
             ListViewItem card = new ListViewItem();
             card.Text = newDeck.Sections[0].Cards[I].Card.Name;
             Set cardSet = newDeck.Sections[0].Cards[I].Card.Set;
             card.SubItems.Add(cardSet.Name);
             card.SubItems.Add(newDeck.Sections[0].Cards[I].Quantity.ToString());
             card.SubItems.Add(newDeck.Sections[0].Cards[I].Card.Id.ToString());
             listDeckList.Items.Add(card);
         }
         if (checkBox1.Checked == true)
         {
             for (int I = 0; I < newDeck.Sections[1].Cards.Count; I++)
             {
                 ListViewItem card = new ListViewItem();
                 card.Text = newDeck.Sections[1].Cards[I].Card.Name;
                 Set cardSet = newDeck.Sections[1].Cards[I].Card.Set;
                 card.SubItems.Add(cardSet.Name);
                 card.SubItems.Add(newDeck.Sections[1].Cards[I].Quantity.ToString());
                 card.SubItems.Add(newDeck.Sections[1].Cards[I].Card.Id.ToString());
                 listDeckList.Items.Add(card);
             }
         }
     }
 }
コード例 #7
0
ファイル: Main.cs プロジェクト: drilus/OCTGN-Deck-Converter
        private void btnOpen_Click(object sender, EventArgs e)
        {
            GamesRepository mygame = new Octgn.Data.GamesRepository();
            OpenFileDialog dialogue = new OpenFileDialog();
            dialogue.Filter = "OCTGN deck files (*.o8d) | *.o8d";
            dialogue.Filter += "| Magic Workstation files (*.mwDeck) | *.mwDeck";
            dialogue.Filter += "| MTGO/Apprentice files (*.dec) | *.dec";
            dialogue.InitialDirectory = mygame.Games[gameindex].DefaultDecksPath;
            gamepath = mygame.Games[gameindex].DefaultDecksPath;

            if (dialogue.ShowDialog() == DialogResult.OK)
                input = dialogue.FileName;
            if (dialogue.FileName == string.Empty)
                return;
            extension = Path.GetExtension(input);
            textBox2.Text = input;
            textBox1.Clear();
        }
コード例 #8
0
        public static Deck Load(string file, GamesRepository repository)
        {
            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }

            Guid      gameId;
            XDocument doc = LoadDoc(file, out gameId);

            Game game = repository.Games.FirstOrDefault(g => g.Id == gameId);

            if (game == null)
            {
                throw new UnknownGameException(gameId);
            }

            return(LoadCore(doc, game));
        }
コード例 #9
0
ファイル: Set.cs プロジェクト: bejumi/OCTGN
 public Set(string packageName, XmlReader reader, GamesRepository repository)
 {
     PackageName = packageName;
     Name = reader.GetAttribute("name");
     string gaid = reader.GetAttribute("id");
     if (gaid != null) Id = new Guid(gaid);
     string gi = reader.GetAttribute("gameId");
     if (gi != null)
     {
         var gameId = new Guid(gi);
         Game = repository.Games.First(g => g.Id == gameId);
     }
     string gv = reader.GetAttribute("gameVersion");
     if (gv != null) GameVersion = new Version(gv);
     Version ver;
     Version.TryParse(reader.GetAttribute("version"), out ver);
     Version = ver ?? new Version(0, 0);
     reader.ReadStartElement("set");
 }
コード例 #10
0
        private void Form1_Load(object sender, EventArgs e)
        {
            GamesRepository mygame    = new Octgn.Data.GamesRepository();
            int             gamecount = mygame.Games.Count;

            if (gamecount > 1)
            {
                GameSelection chooserForm = new GameSelection();
                chooserForm.gameList = new string[gamecount];
                for (int i = 0; i < gamecount; i++)
                {
                    chooserForm.gameList[i] = mygame.Games[i].Name;
                }
                chooserForm.ShowDialog();
                gameindex = chooserForm.GameIndex;
            }

            Game octgnGame = proxy.Games[gameindex];

            try
            {
                // Retrieve Card Image
                System.Windows.Controls.Image CardImage = new System.Windows.Controls.Image();
                BitmapImage src = new BitmapImage();
                src.BeginInit();
                src.UriSource   = octgnGame.GetCardBackUri();
                src.CacheOption = BitmapCacheOption.OnLoad;
                src.EndInit();
                pictureBox1.Image = SourceConvert.BitmapSourceToBitmap(src);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            // Default Page Setups
            printDocument1.DefaultPageSettings.Landscape = true;
            Margins margins = new Margins(25, 25, 25, 25); // 100ths of an inch. Ex. 25 = 0.25, 150 = 1.5

            printDocument1.DefaultPageSettings.Margins = margins;
            groupBox2.Focus();
            txtSearch.Focus();
        }
コード例 #11
0
ファイル: Main.cs プロジェクト: drilus/Proxy-Printer
        private void Form1_Load(object sender, EventArgs e)
        {
            GamesRepository mygame = new Octgn.Data.GamesRepository();
            int gamecount = mygame.Games.Count;
            if (gamecount > 1)
            {
                GameSelection chooserForm = new GameSelection();
                chooserForm.gameList = new string[gamecount];
                for (int i = 0; i < gamecount; i++) { chooserForm.gameList[i] = mygame.Games[i].Name; }
                chooserForm.ShowDialog();
                gameindex = chooserForm.GameIndex;
            }

            Game octgnGame = proxy.Games[gameindex];
            try
            {
                // Retrieve Card Image
                System.Windows.Controls.Image CardImage = new System.Windows.Controls.Image();
                BitmapImage src = new BitmapImage();
                src.BeginInit();
                src.UriSource = octgnGame.GetCardBackUri();
                src.CacheOption = BitmapCacheOption.OnLoad;
                src.EndInit();
                pictureBox1.Image = SourceConvert.BitmapSourceToBitmap(src);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            // Default Page Setups
            printDocument1.DefaultPageSettings.Landscape = true;
            Margins margins = new Margins(25,25,25,25); // 100ths of an inch. Ex. 25 = 0.25, 150 = 1.5
            printDocument1.DefaultPageSettings.Margins = margins;
            groupBox2.Focus();
            txtSearch.Focus();
        }
コード例 #12
0
ファイル: Main.cs プロジェクト: drilus/Proxy-Printer
        private void btnLoadDeck_Click(object sender, EventArgs e)
        {
            DeckLoader LoadDeck = new DeckLoader();
            LoadDeck.GameIndex = gameindex;
            LoadDeck.ShowDialog();

            if (LoadDeck.cancelled == false)
            {
                richTextBox1.ReadOnly = false;
                PictureBox ProxyImage = new PictureBox();

                // Open database for image retrieval
                GamesRepository proxy = new GamesRepository();
                Game mygame = proxy.Games[gameindex];

                foreach (ProxyList myList in LoadDeck.guidList)
                {
                    // Resize image for mock layout
                    Size mockSize = new Size();
                    mockSize.Width = 384 / 3;
                    mockSize.Height = 544 / 3;
                    // Resize image for real layout
                    Size realSize = new Size();
                    realSize.Width = 240;
                    realSize.Height = 335; // 340

                    // Load Image
                    Guid CardID = Guid.Empty;
                    Guid.TryParse(myList.GUID, out CardID);
                    try
                    {
                        // Retrieve Card Image
                        BitmapImage img = new BitmapImage();
                        System.Windows.Controls.Image CardImage = new System.Windows.Controls.Image();
                        ProxyImage.Image = SourceConvert.BitmapFromUri(CardModel.GetPictureUri(mygame,
                            mygame.GetCardById(CardID).Set.Id, mygame.GetCardById(CardID).ImageUri)
                            ?? mygame.GetCardBackUri());
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    for (int I = 0; I < Convert.ToInt16(myList.Quantity); I++)
                    {
                        // Mock Page
                        Clipboard.SetImage(resizeImage(ProxyImage.Image, mockSize));
                        richTextBox1.Paste();
                        // Real Page
                        Clipboard.SetImage(resizeImage(ProxyImage.Image, realSize));
                        richTextBox2.Paste();
                        // Add spacing
                        richTextBox1.AppendText(" "); // Mock
                        richTextBox2.AppendText(" "); // Real
                    }
                }
                // Center all images
                richTextBox1.SelectAll();
                richTextBox1.SelectionAlignment = HorizontalAlignment.Center;
                richTextBox1.Select(0, 0);
                richTextBox2.SelectAll();
                richTextBox2.SelectionAlignment = HorizontalAlignment.Center;
                richTextBox2.Select(0, 0);

                Clipboard.Clear();
                txtSearch.Focus();
                txtSearch.SelectAll();

                //mygame.CloseDatabase();
                richTextBox1.ReadOnly = true;
            }
            // End
        }
コード例 #13
0
ファイル: Chooser.cs プロジェクト: drilus/Proxy-Printer
 private void comboChooser_SelectionChangeCommitted(object sender, EventArgs e)
 {
     // Look up picture for selected Set
     Guid card = Guid.Empty;
     string name = comboChooser.Items[comboChooser.SelectedIndex].ToString();
     foreach (CardModel Card in SetList)
     {
         if (name == Card.Set.Name) { card = Card.Id; }
     }
     GamesRepository proxy = new GamesRepository();
     Game mygame = proxy.Games[GameIndex];
     BitmapImage img = new BitmapImage();
     System.Windows.Controls.Image CardImage = new System.Windows.Controls.Image();
     mtgPicture1.Image = SourceConvert.BitmapFromUri(img != null ? CardModel.GetPictureUri(mygame,
         mygame.GetCardById(card).Set.Id, mygame.GetCardById(card).ImageUri) : mygame.GetCardBackUri());
     selectedCard = card;
 }
コード例 #14
0
        protected override void OnStartup(StartupEventArgs e)
        {
            /*if (!System.Diagnostics.Debugger.IsAttached)
                AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs args)
                {
                    Exception ex = args.ExceptionObject as Exception;
                    var wnd = new ErrorWindow(ex);
                    wnd.ShowDialog();
                    ErrorLog.WriteError(ex, "Unhandled Exception main", false);
                    if (ErrorLog.CheckandUpload())
                        MessageBox.Show("Uploaded error log.");
                };
            AppDomain.CurrentDomain.ProcessExit += delegate(object sender, EventArgs ea)
            {
                if (ErrorLog.CheckandUpload())
                    MessageBox.Show("Uploaded error log.");
            };
            Updates.PerformHouskeeping();
            */

            string proc = Process.GetCurrentProcess().ProcessName;
            Process[] processes = Process.GetProcessesByName(proc);
            if (processes.Length > 1)
            {
                HardShutDown();
                return;
            }
            if (isOctgnRunning)
            {
                MessageBox.Show("You must shut down OCTGN BEFORE you run this program!");
                HardShutDown();
                return;
            }
            Exit += new ExitEventHandler(App_Exit);
            ochecker = new Thread(new ThreadStart(delegate()
                {
                    int a = 0;
                    while (a == 0)
                    {
                        Thread.Sleep(1000);

                        if (isOctgnRunning)
                        {
                            try
                            {
                                App.Current.Dispatcher.Invoke
                                (
                                    System.Windows.Threading.DispatcherPriority.Normal,
                                    new Action
                                    (
                                        delegate()
                                        {
                                            MainWindow.IsEnabled = false;
                                        }
                                    )
                                );
                                //App.Current.MainWindow.IsEnabled = false;
                                MessageBox.Show("You must shut down OCTGN BEFORE you run this program!");
                            }
                            catch { }
                        }
                        else
                        {
                            App.Current.Dispatcher.Invoke
                            (
                                System.Windows.Threading.DispatcherPriority.Normal,
                                new Action
                                (
                                    delegate()
                                    {
                                        if (!MainWindow.IsEnabled)
                                            MainWindow.IsEnabled = true;
                                    }
                                )
                            );
                        }
                    }
                }
            ));
            ochecker.Start();
            GamesRepository = new Octgn.Data.GamesRepository();
            Relationships = new List<Relationship>();
            DebugWindow = new DebugWindow();
            #if(DEBUG)
            DebugWindow.Show();
            App.Current.MainWindow = MainWindow;
            #endif
            base.OnStartup(e);
        }
コード例 #15
0
 public void OnLoad(GamesRepository games)
 {
     // I'm showing a message box, but don't do this, unless it's for updates or something...but don't do it every time as it pisses people off.
     MessageBox.Show("Hello!");
 }
コード例 #16
0
ファイル: DeckLoader.cs プロジェクト: Gravecorp/Proxy-Printer
 private void listDeckList_KeyUp(object sender, KeyEventArgs e)
 {
     if ((e.KeyData == Keys.Down) || (e.KeyData == Keys.Up))
     {
         // Selected Card Image
         GamesRepository proxy = new GamesRepository();
         Game mygame = proxy.Games[GameIndex];
         Guid card = Guid.Empty;
         string guid = listDeckList.Items[listDeckList.SelectedItems[0].Index].SubItems[3].Text;
         Guid.TryParse(guid, out card);
         try
         {
             BitmapImage img = new BitmapImage();
             System.Windows.Controls.Image CardImage = new System.Windows.Controls.Image();
             mtgPicture1.Image = SourceConvert.BitmapFromUri(img != null ? CardModel.GetPictureUri(mygame,
                 mygame.GetCardById(card).Set.Id, mygame.GetCardById(card).ImageUri) : mygame.GetCardBackUri());
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
コード例 #17
0
ファイル: Main.cs プロジェクト: drilus/OCTGN-Deck-Converter
 private void Main_Load(object sender, EventArgs e)
 {
     GamesRepository mygame = new Octgn.Data.GamesRepository();
     int gamecount = mygame.Games.Count;
     string mtg = "Magic The Gathering";
     int loop = 0;
     try
     {
         while (loop <= gamecount - 1)
         {
             if (mtg == mygame.Games[gamecount].Name)
             {
                 gameindex = gamecount;
                 break;
             }
             else
                 MessageBox.Show("Magic The Gathering not found");
             loop++;
         }
     }
     catch
     {
     }
 }
コード例 #18
0
ファイル: Main.cs プロジェクト: drilus/OCTGN-Deck-Converter
        private void ConvertOCTGN()
        {
            textBox1.Text += "// Deck file for Magic Workstation (http://www.magicworkstation.com)" + Environment.NewLine;
            textBox1.Text += Environment.NewLine;
            textBox1.Text += "// OCTGN conversion" + Environment.NewLine;

            GamesRepository mygame = new Octgn.Data.GamesRepository();

            XmlTextReader reader = new XmlTextReader(input);
            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element: // The node is an element.
                        while (reader.MoveToNextAttribute()) // Read the attributes.
                        {
                            if (reader.Value == "Sideboard")
                                if (reader.IsEmptyElement == false)
                                {
                                    sideboard = true;
                                    textBox1.Text += Environment.NewLine;
                                    textBox1.Text += "// Sideboard" + Environment.NewLine;
                                }

                            if (reader.Name == "game")
                                gameid = reader.Value;

                            if (reader.Name == "qty")
                                if (sideboard != true)
                                    textBox1.Text += "    " + reader.Value;
                                else textBox1.Text += "SB: " + reader.Value;

                            if (reader.Name == "id")
                            {
                                Guid setid = Guid.Parse(reader.Value);
                                string temp = mygame.Games[gameindex].GetCardById(setid).Set.Name;

                                #region MWS Set Abbreviations
                                // Switch to abbriviations
                                if (temp == "Alliances")
                                    temp = "AL";
                                if (temp == "Antiquities")
                                    temp = "5e";
                                if (temp == "Apocalypse")
                                    temp = "AP";
                                if (temp == "Arabian Nights")
                                    temp = "AN";
                                if (temp == "Betrayers of Kamigawa")
                                    temp = "BOK";
                                if (temp == "Champions of Kamigawa")
                                    temp = "CHK";
                                if (temp == "Coldsnap")
                                    temp = "CS";
                                if (temp == "Dark Ascension")
                                    temp = "DKA";
                                if (temp == "Darksteel")
                                    temp = "DS";
                                if (temp == "Dissension")
                                    temp = "DIS";
                                if (temp == "Duel Decks: Divine vs. Demonic")
                                    temp = "DDC";
                                if (temp == "Duel Decks: Elves vs. Goblins")
                                    temp = "EVG";
                                if (temp == "Duel Decks: Garruk vs. Liliana")
                                    temp = "DDD";
                                if (temp == "Duel Decks: Jace vs. Chandra")
                                    temp = "DD2";
                                if (temp == "Duel Decks: Phyrexia vs. The Coalition")
                                    temp = "DDE";
                                if (temp == "Eighth Edition")
                                    temp = "8E";
                                if (temp == "Exodus")
                                    temp = "EX";
                                if (temp == "Fallen Empires")
                                    temp = "FE";
                                if (temp == "Fifth Dawn")
                                    temp = "FD";
                                if (temp == "Fifth Edition")
                                    temp = "5E";
                                if (temp == "Fourth Edition")
                                    temp = "4E";
                                if (temp == "From the Vault: Dragons")
                                    temp = "DRB";
                                if (temp == "From the Vault: Exiled")
                                    temp = "V09";
                                if (temp == "From the Vault: Relics")
                                    temp = "V10";
                                if (temp == "Future Sight")
                                    temp = "FUT";
                                if (temp == "Guildpact")
                                    temp = "GP";
                                if (temp == "Homelands")
                                    temp = "HL";
                                if (temp == "Ice Age")
                                    temp = "IA";
                                if (temp == "Innistrad")
                                    temp = "INN";
                                if (temp == "Invasion")
                                    temp = "IN";
                                if (temp == "Judgment")
                                    temp = "JU";
                                if (temp == "Legends")
                                    temp = "LG";
                                if (temp == "Legions")
                                    temp = "LE";
                                if (temp == "Limited Edition Alpha")
                                    temp = "A";
                                if (temp == "Limited Edition Beta")
                                    temp = "B";
                                if (temp == "Mercadian Masques")
                                    temp = "MM";
                                if (temp == "Mirage")
                                    temp = "MI";
                                if (temp == "Mirrodin")
                                    temp = "MR";
                                if (temp == "Nemesis")
                                    temp = "NE";
                                if (temp == "New Phyrexia")
                                    temp = "NPH";
                                if (temp == "Ninth Edition")
                                    temp = "9E";
                                if (temp == "Odyssey")
                                    temp = "OD";
                                if (temp == "Onslaught")
                                    temp = "ON";
                                if (temp == "Planar Chaos")
                                    temp = "PLC";
                                if (temp == "Planeshift")
                                    temp = "PS";
                                if (temp == "Prophecy")
                                    temp = "PY";
                                if (temp == "Ravnica: City of Guilds")
                                    temp = "RAV";
                                if (temp == "Revised Edition")
                                    temp = "R";
                                if (temp == "Saviors of Kamigawa")
                                    temp = "SOK";
                                if (temp == "Scourge")
                                    temp = "SC";
                                if (temp == "Seventh Edition")
                                    temp = "7E";
                                if (temp == "Classic Sixth Edition")
                                    temp = "6E";
                                if (temp == "Stronghold")
                                    temp = "SH";
                                if (temp == "Tempest")
                                    temp = "TE";
                                if (temp == "Tenth Edition")
                                    temp = "10E";
                                if (temp == "The Dark")
                                    temp = "DK";
                                if (temp == "Time Spiral")
                                    temp = "TSP";
                                if (temp == "Torment")
                                    temp = "TO";
                                if (temp == "Unglued")
                                    temp = "UG";
                                if (temp == "Unhinged")
                                    temp = "UNH";
                                if (temp == "Unlimited Edition")
                                    temp = "U";
                                if (temp == "Urza's Destiny")
                                    temp = "UD";
                                if (temp == "Urza's Legacy")
                                    temp = "UL";
                                if (temp == "Urza's Saga")
                                    temp = "US";
                                if (temp == "Visions")
                                    temp = "VI";
                                if (temp == "Weatherlight")
                                    temp = "WL";
                                if (temp == "Alara Reborn")
                                    temp = "ARB";
                                if (temp == "Conflux")
                                    temp = "CFX";
                                if (temp == "Eventide")
                                    temp = "EVE";
                                if (temp == "Lorwyn")
                                    temp = "LRW";
                                if (temp == "Magic 2010")
                                    temp = "M10";
                                if (temp == "Magic 2011")
                                    temp = "M11";
                                if (temp == "Magic 2012")
                                    temp = "M12";
                                if (temp == "Morningtide")
                                    temp = "MOR";
                                if (temp == "Rise of the Eldrazi")
                                    temp = "ROE";
                                if (temp == "Scars of Mirrodin")
                                    temp = "SOM";
                                if (temp == "Shadowmoor")
                                    temp = "SHM";
                                if (temp == "Shards of Alara")
                                    temp = "ALA";
                                if (temp == "Worldwake")
                                    temp = "WWK";
                                if (temp == "Zendikar")
                                    temp = "ZEN";
                                if (temp == "Mirrodin Besieged")
                                    temp = "MBS";
                                #endregion

                                textBox1.Text += " " + "[" + temp + "]" + " " + mygame.Games[gameindex].GetCardById(setid).Name;
                            }
                        }

                        break;
                    case XmlNodeType.EndElement: //Display the end of the element.
                        textBox1.Text += Environment.NewLine;
                        break;
                }
            }
        }
コード例 #19
0
ファイル: Main.cs プロジェクト: drilus/OCTGN-Deck-Converter
        private void ConvertMWS()
        {
            GamesRepository mygame = new Octgn.Data.GamesRepository();
            Game game = mygame.Games[gameindex];
            Deck newDeck = new Deck(mygame.Games[gameindex]);
            int i = 0; // Decks have 4 sections. Main = 0, Sideboard = 1, Command Zone = 2, and Plains/Schemes = 3

            TextReader reader = new StreamReader(textBox2.Text);
            string line = "";
            while ((line = reader.ReadLine()) != null)
            {
                i = 0;
                if (line != "")
                {
                    if (!line.Contains("//"))
                    {
                        if (line.Remove(3) == "SB:")
                        {
                            i = 1;
                            line = line.Remove(0, 3);
                        }

                        if ((line.Contains('[')) && (line.Contains(']')))
                        {
                            int count = line.IndexOf('[');
                            line = line.Remove(count, line.IndexOf(']') - count + 1);
                        }

                        line = line.Trim();
                        var quantity = line.Remove(line.IndexOf(' ')).Trim();
                        var name = line.Remove(0, line.IndexOf(' ') + 1).Trim();
                        newDeck.Sections[i].Cards.Add(new Deck.Element { Card = game.GetCardByName(name) ?? game.GetCardByName("Swamp"), Quantity = Convert.ToByte(quantity) });
                    }
                }
            }
            deck = newDeck;
        }
コード例 #20
0
ファイル: Set.cs プロジェクト: 0M3G4/OCTGN
        public static Set SetFromFile(string filename, GamesRepository repo)
        {
            using (Package package = Package.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                PackageRelationship defRelationship =
                    package.GetRelationshipsByType("http://schemas.octgn.org/set/definition").First();
                PackagePart definition = package.GetPart(defRelationship.TargetUri);

                var settings = new XmlReaderSettings { ValidationType = ValidationType.Schema, IgnoreWhitespace = true };
                using (
                    Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream(typeof(GamesRepository),
                                                                                         "CardSet.xsd"))
                    //CardSet.xsd determines the "attributes" of a card (name, guid, alternate, dependent)
                    if (s != null)
                        using (XmlReader reader = XmlReader.Create(s))
                            settings.Schemas.Add(null, reader);

                // Read the cards
                using (XmlReader reader = XmlReader.Create(definition.GetStream(), settings))
                {
                    reader.ReadToFollowing("set"); // <?xml ... ?>

                    return new Set(filename, reader, repo);
                }
            }
        }
コード例 #21
0
ファイル: DeckLoader.cs プロジェクト: Gravecorp/Proxy-Printer
 private void DeckLoader_Load(object sender, EventArgs e)
 {
     // Default Image
     GamesRepository proxy = new GamesRepository();
     Game mygame = proxy.Games[GameIndex];
     try
     {
         // Retrieve Card Image
         System.Windows.Controls.Image CardImage = new System.Windows.Controls.Image();
         BitmapImage src = new BitmapImage();
         src.BeginInit();
         src.UriSource = mygame.GetCardBackUri();
         src.CacheOption = BitmapCacheOption.OnLoad;
         src.EndInit();
         mtgPicture1.Image = SourceConvert.BitmapSourceToBitmap(src);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 /// <summary>
 /// Happens when the Deck Editor is opened.
 /// </summary>
 /// <param name="games">Game repository.</param>
 public void OnLoad(GamesRepository games)
 {
     // Nothing special to handle here
 }