Ejemplo n.º 1
0
        private static bool GetSleeveByID(string idType, int id, Component parent)
        {
            var sleeves = _db.Fetch <SleeveModel>("SELECT * FROM sleeve WHERE " + idType + " = " + id +
                                                  " ORDER BY number");

            if (!sleeves.Any())
            {
                return(false);
            }

            var depth    = parent.Depth + 1;
            var position = 1;

            foreach (var sleeve in sleeves)
            {
                var comp = new Sleeve("sleeve", sleeve);
                comp.Depth    = depth;
                comp.Position = position;
                var ftd             = Utils.GetTitleDate(sleeve.title, sleeve.number, "Sleeve");
                var structuralTitle = "Sleeve " + sleeve.number;
                comp.isArchivalObject = ftd.title != structuralTitle;

                sleeve.SleeveTitleDate = ftd;
                sleeve.number          = sleeve.number.Trim();

                GetItemByID("sleeveID", sleeve.id, comp);

                parent.Add(comp);
                position++;
            }

            return(true);
        }
Ejemplo n.º 2
0
        public void TestSleeveDimensions()
        {
            Sleeve sleeve = new Sleeve(10, 20);

            Assert.AreEqual(20, sleeve.Length);
            Assert.AreEqual(10, sleeve.Width);
        }
Ejemplo n.º 3
0
        public void TestSleeve0Length()
        {
            Sleeve sleeve = new Sleeve(null, 0);

            Assert.AreEqual(0, sleeve.Length);
            Assert.AreEqual(null, sleeve.Width);
        }
Ejemplo n.º 4
0
        public void TestSleeveScale()
        {
            Sleeve sleeve = new Sleeve(10, 20);

            sleeve.StitchCount(6);
            Assert.AreEqual(60, sleeve.Width);
            Assert.AreEqual(20, sleeve.Length);
        }
Ejemplo n.º 5
0
 private void ListBox_playerSleeve_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Delete && listBox_playerSleeve.SelectedIndex > -1)
     {
         Sleeve selectedSleeve = (Sleeve)listBox_playerSleeve.Items[listBox_playerSleeve.SelectedIndex];
         System.IO.File.Delete(selectedSleeve.FullName);
         PopulateSleeveLists();
     }
 }
Ejemplo n.º 6
0
 public void EditSleeve(Sleeve sleeve)
 {
     using (var context = new ManufacturingDataContext(_connectionString))
     {
         var original = context.Sleeves.Where(i => i.Id == sleeve.Id).FirstOrDefault();
         original.Name       = sleeve.Name.ToUpper();
         original.ModifiedOn = DateTime.Now;
         context.SubmitChanges();
     }
 }
Ejemplo n.º 7
0
        /// <summary>Loads a player deck.</summary>
        /// <param name="id">An array containing the loaded CardIdentity ids.</param>
        /// <param name="type">An array containing the corresponding CardModel guids (encrypted).</param>
        /// <param name="group">An array indicating the group the cards must be loaded into.</param>
        public void LoadDeck(int[] id, Guid[] type, Group[] group, string[] size, string sleeve, bool limited)
        {
            if (id.Length != type.Length || id.Length != group.Length)
            {
                Program.GameMess.Warning("[LoadDeck] Protocol violation: inconsistent arrays sizes.");
                return;
            }

            if (id.Length == 0)
            {
                return;                   // Loading an empty deck --> do nothing
            }
            var who = Player.Find((byte)(id[0] >> 16));

            if (who == null)
            {
                Program.GameMess.Warning("[LoadDeck] Player not found.");
                return;
            }
            WriteReplayAction(who.Id);

            if (limited)
            {
                Program.GameMess.System("{0} loads a limited deck.", who);
            }
            else
            {
                Program.GameMess.System("{0} loads a deck.", who);
            }

            if (!IsLocalPlayer(who))
            {
                try {
                    var sleeveObj = Sleeve.FromString(sleeve);

                    who.SetSleeve(sleeveObj);
                } catch (SleeveException ex) {
                    Log.Warn(ex.Message, ex);

                    Program.GameMess.Warning($"There was an error loading {0}'s deck sleeve: " + ex.Message, who);
                } catch (Exception ex) {
                    Log.Warn(ex.Message, ex);

                    Program.GameMess.Warning($"There was an unknown error loading {0}'s deck sleeve.", who);
                }
            }

            CreateCard(id, type, group, size);
            Log.Info("LoadDeck Starting Task to Fire Event");
            Program.GameEngine.EventProxy.OnLoadDeck_3_1_0_0(who, @group.Distinct().ToArray());
            Program.GameEngine.EventProxy.OnLoadDeck_3_1_0_1(who, @group.Distinct().ToArray());
            Program.GameEngine.EventProxy.OnDeckLoaded_3_1_0_2(who, @group.Distinct().ToArray());
        }
Ejemplo n.º 8
0
 private void ListBox_opponentSleeve_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBox_opponentSleeve.SelectedIndex > -1)
     {
         Sleeve selectedSleeve = (Sleeve)listBox_opponentSleeve.Items[listBox_opponentSleeve.SelectedIndex];
         using (Bitmap selectedSleeveBitmap = new Bitmap(selectedSleeve.FullName)) {
             pictureBox_opponent.Image = new Bitmap(selectedSleeveBitmap);
         }
         System.IO.File.Copy($@"{projectIgnisFolderPath}\cover2.png", $@"{projectIgnisFolderPath}\cover2.bak.png", true);
         System.IO.File.Copy(selectedSleeve.FullName, $@"{projectIgnisFolderPath}\cover2.png", true);
     }
 }
Ejemplo n.º 9
0
        public void RefreshList()
        {
            IsLoading = true;
            try
            {
                var sleeves = Sleeve.GetSleeves().ToArray();

                SetList(sleeves);
            }
            catch (Exception e)
            {
                Log.Error("RefreshList", e);
            }
            finally
            {
                IsLoading = false;
            }
        }
Ejemplo n.º 10
0
        public static void Save(this IDeck deck, Game game, string path)
        {
            try
            {
                using (var fs = File.Open(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
                {
                    var settings = new XmlWriterSettings();
                    settings.Indent          = true;
                    settings.NewLineHandling = NewLineHandling.Entitize;

                    var writer = XmlWriter.Create(fs, settings);

                    writer.WriteStartDocument(true);
                    {
                        writer.WriteStartElement("deck");
                        writer.WriteAttributeString("game", game.Id.ToString());

                        // Write Sections
                        foreach (var section in deck.Sections)
                        {
                            writer.WriteStartElement("section");
                            writer.WriteAttributeString("name", section.Name);
                            writer.WriteAttributeString("shared", section.Shared.ToString());
                            foreach (var c in section.Cards)
                            {
                                writer.WriteStartElement("card");
                                writer.WriteAttributeString("qty", c.Quantity.ToString());
                                writer.WriteAttributeString("id", c.Id.ToString());
                                writer.WriteString(c.Name);
                                writer.WriteEndElement();
                            }
                            writer.WriteEndElement();
                        }
                        { // Write Notes
                            writer.WriteStartElement("notes");
                            writer.WriteCData(deck.Notes);
                            writer.WriteEndElement();
                        }
                        { // Write Sleeve
                            if (deck.Sleeve != null)
                            {
                                writer.WriteStartElement("sleeve");
                                var sleeveString = Sleeve.ToString(deck.Sleeve);
                                writer.WriteValue(sleeveString);
                                writer.WriteEndElement();
                            }
                        }

                        writer.WriteEndElement();
                    }
                    writer.WriteEndDocument();
                    writer.Flush();
                    writer.Close();
                }
                // assume players will want to play with their new deck
                Prefs.LastHostedGameType = game.Id;
            }
            catch (PathTooLongException)
            {
                throw new UserMessageException(L.D.Exception__CanNotSaveDeckPathTooLong_Format, path);
            }
            catch (IOException e)
            {
                Log.Error(String.Format("Problem saving deck to path {0}", path), e);
                throw new UserMessageException(L.D.Exception__CanNotSaveDeckIOError_Format, path, e.Message);
            }
            catch (Exception e)
            {
                Log.Error(String.Format("Problem saving deck to path {0}", path), e);
                throw new UserMessageException(L.D.Exception__CanNotSaveDeckUnspecified_Format, path);
            }
        }
Ejemplo n.º 11
0
        public static IDeck Load(this IDeck deck, Game game, string path, bool cloneCards = true)
        {
            var ret = new Deck();

            ret.Sections = new List <ISection>();
            try
            {
                var cards = game.Sets().SelectMany(x => x.Cards).ToArray();
                using (var fs = File.Open(path, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
                {
                    var doc    = XDocument.Load(fs);
                    var gameId = Guid.Parse(doc.Descendants("deck").First().Attribute("game").Value);
                    var shared = doc.Descendants("deck").First().Attr <bool>("shared");
                    foreach (var sectionelem in doc.Descendants("section"))
                    {
                        var section = new Section();
                        section.Cards  = new List <IMultiCard>();
                        section.Name   = sectionelem.Attribute("name").Value;
                        section.Shared = sectionelem.Attr <bool>("shared");
                        // On old style decks, if it's shared, then all subsequent sections are shared
                        if (shared)
                        {
                            section.Shared = true;
                        }
                        foreach (var cardelem in sectionelem.Descendants("card"))
                        {
                            var cardId = Guid.Parse(cardelem.Attribute("id").Value);
                            var cardq  = Int32.Parse(cardelem.Attribute("qty").Value);
                            var card   = cards.FirstOrDefault(x => x.Id == cardId);
                            if (card == null)
                            {
                                var cardN = cardelem.Value;
                                card = cards.FirstOrDefault(x => x.Name.Equals(cardN, StringComparison.CurrentCultureIgnoreCase));
                                if (card == null)
                                {
                                    throw new UserMessageException(L.D.Exception__CanNotLoadDeckCardNotInstalled_Format, path, cardId, cardN);
                                }
                            }
                            (section.Cards as IList <IMultiCard>).Add(card.ToMultiCard(cardq, cloneCards));
                        }
                        if (section.Cards.Any())
                        {
                            (ret.Sections as List <ISection>).Add(section);
                        }
                    }
                    // Add deck notes
                    var notesElem = doc.Descendants("notes").FirstOrDefault();
                    if (notesElem != null)
                    {
                        var cd = (notesElem.FirstNode as XCData);
                        if (cd != null)
                        {
                            ret.Notes = cd.Value.Clone() as string;
                        }
                    }
                    if (ret.Notes == null)
                    {
                        ret.Notes = "";
                    }

                    // Add all missing sections so that the game doesn't get pissed off
                    {
                        var combinedList =
                            game.DeckSections.Select(x => x.Value).Concat(game.SharedDeckSections.Select(y => y.Value));
                        foreach (var section in combinedList)
                        {
                            if (ret.Sections.Any(x => x.Name.Equals(section.Name, StringComparison.InvariantCultureIgnoreCase) && x.Shared == section.Shared) == false)
                            {
                                // Section not defined in the deck, so add an empty version of it.
                                (ret.Sections as List <ISection>).Add(
                                    new Section
                                {
                                    Name   = section.Name.Clone() as string,
                                    Cards  = new List <IMultiCard>(),
                                    Shared = section.Shared
                                });
                            }
                        }
                    }

                    // Add card sleeve
                    {
                        var sleeveElem = doc.Descendants("sleeve").FirstOrDefault();
                        if (sleeveElem != null)
                        {
                            var sleeveString = sleeveElem.Value;

                            if (!string.IsNullOrWhiteSpace(sleeveString))
                            {
                                try {
                                    ret.Sleeve = Sleeve.FromString(sleeveString);
                                } catch (SleeveException ex) {
                                    throw new UserMessageException(ex.Message, ex);
                                }
                            }
                        }
                    }

                    ret.GameId   = gameId;
                    ret.IsShared = shared;
                }
                // This is an old style shared deck file, we need to convert it now, for posterity sake.
                if (ret.IsShared)
                {
                    ret.IsShared = false;
                    ret.Save(game, path);
                }
                deck = ret;
                return(deck);
            }
            catch (UserMessageException)
            {
                throw;
            }
            catch (FormatException e)
            {
                Log.Error(String.Format("Problem loading deck from path {0}", path), e);
                throw new UserMessageException(L.D.Exception__CanNotLoadDeckCorrupt_Format, path);
            }
            catch (NullReferenceException e)
            {
                Log.Error(String.Format("Problem loading deck from path {0}", path), e);
                throw new UserMessageException(L.D.Exception__CanNotLoadDeckCorrupt_Format, path);
            }
            catch (XmlException e)
            {
                Log.Error(String.Format("Problem loading deck from path {0}", path), e);
                throw new UserMessageException(L.D.Exception__CanNotLoadDeckCorrupt_Format, path);
            }
            catch (FileNotFoundException)
            {
                throw new UserMessageException(L.D.Exception__CanNotLoadDeckFileNotFound_Format, path);
            }
            catch (IOException e)
            {
                Log.Error(String.Format("Problem loading deck from path {0}", path), e);
                throw new UserMessageException(L.D.Exception__CanNotLoadDeckIOError_Format, path, e.Message);
            }
            catch (Exception e)
            {
                Log.Error(String.Format("Problem loading deck from path {0}", path), e);
                throw new UserMessageException(L.D.Exception__CanNotLoadDeckUnspecified_Format, path);
            }
        }
Ejemplo n.º 12
0
        public void UpdateSleeve(Sleeve sleeve)
        {
            var repo = new ItemRepository(Properties.Settings.Default.ManufacturingConStr);

            repo.EditSleeve(sleeve);
        }
Ejemplo n.º 13
0
        //上传西服上衣尺码表
        public static bool Import_Excel_jacket(DataTable table, string size_code, string gender, out string errmsg)
        {
            using (var db = SugarDao.GetInstance())
                try
                {
                    db.CommandTimeOut = 3000;                    //设置超时时间

                    List <CoatSize> list = new List <CoatSize>();

                    db.BeginTran();

                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        #region 处理不符合要求得数据

                        DataRow row = table.Rows[i];

                        row.BeginEdit();

                        for (int a = 0; a < table.Columns.Count; a++)
                        {
                            if (row[a].ToString().IndexOf("....") > 0)
                            {
                                row[a] = row[a].ToString().Replace("....", ".");
                            }
                            if (row[a].ToString().IndexOf("...") > 0)
                            {
                                row[a] = row[a].ToString().Replace("...", ".");
                            }
                            if (row[a].ToString().IndexOf("..") > 0)
                            {
                                row[a] = row[a].ToString().Replace("..", ".");
                            }
                        }

                        row.EndEdit();

                        #endregion
                        if (!string.IsNullOrEmpty(gender))
                        {
                            object ruid;
                            if (gender == "男")
                            {
                                XF_SY_NAN_CodeSize cs = new XF_SY_NAN_CodeSize();

                                cs.Height = Convert.ToDecimal(table.Rows[i]["Height"]);

                                cs.FrontLength = table.Rows[i]["FrontLength"] + "";

                                cs.NetBust = table.Rows[i]["NetBust"] + "";

                                cs.FinishedBust = Convert.ToDecimal(table.Rows[i]["FinishedBust"]);

                                cs.InWaist = Convert.ToDecimal(table.Rows[i]["InWaist"]);

                                cs.FinishedHem_NoFork = Convert.ToDecimal(table.Rows[i]["FinishedHem_NoFork"]);

                                cs.FinishedHem_SplitEnds = Convert.ToDecimal(table.Rows[i]["FinishedHem_SplitEnds"]);

                                cs.ShoulderWidth = Convert.ToDecimal(table.Rows[i]["ShoulderWidth"]);

                                cs.Size_Code = size_code;

                                cs.Height = Convert.ToDecimal(table.Rows[i]["Height"]);

                                ruid = db.Insert(cs, true);
                            }
                            else
                            {
                                XF_SY_NU_CodeSize cs = new XF_SY_NU_CodeSize();

                                cs.Height = Convert.ToDecimal(table.Rows[i]["Height"]);

                                cs.FrontLength = table.Rows[i]["FrontLength"] + "";

                                cs.NetBust = table.Rows[i]["NetBust"] + "";

                                cs.FinishedBust = Convert.ToDecimal(table.Rows[i]["FinishedBust"]);

                                cs.InWaist = Convert.ToDecimal(table.Rows[i]["InWaist"]);

                                cs.FinishedHem_NoFork = Convert.ToDecimal(table.Rows[i]["FinishedHem_NoFork"]);

                                cs.SleeveWidth = Convert.ToDecimal(table.Rows[i]["SleeveWidth"]);

                                cs.ShoulderWidth = Convert.ToDecimal(table.Rows[i]["ShoulderWidth"]);

                                cs.Size_Code = table.Rows[i]["Size_Code"] + "";

                                cs.Height = Convert.ToDecimal(table.Rows[i]["Height"]);

                                ruid = db.Insert(cs, true);
                            }


                            string req = table.Rows[i]["FK_Sleeve_ID"] + "";

                            if (req.IndexOf("      ") > 0)
                            {
                                req = req.Replace("      ", "^");
                            }

                            if (req.IndexOf("     ") > 0)
                            {
                                req = req.Replace("     ", "^");
                            }

                            if (req.IndexOf("    ") > 0)
                            {
                                req = req.Replace("    ", "^");
                            }

                            if (req.IndexOf("   ") > 0)
                            {
                                req = req.Replace("   ", "^");
                            }

                            if (req.IndexOf("  ") > 0)
                            {
                                req = req.Replace("  ", "^");
                            }

                            req = req.Replace(" ", "^");

                            req = req.Replace(":", ";");

                            string[] sleeve_arrey = req.Split('^');

                            Sleeve see = new Sleeve();
                            see.FK_CoatSize_ID = Convert.ToInt32(ruid);
                            see.Code           = sleeve_arrey[0].Split(';')[0];
                            see.Length         = Convert.ToDecimal(sleeve_arrey[0].Split(';')[1]);
                            db.Insert(see);
                        }
                    }

                    db.CommitTran();
                    errmsg = "";
                    return(true);
                }
                catch (Exception ex)
                {
                    db.RollbackTran();                    //回滚事务
                    errmsg = ex.Message;
                    return(false);
                }
        }
Ejemplo n.º 14
0
 protected virtual void FireOnClose(Sleeve sleeve) => OnClose?.Invoke(sleeve);
Ejemplo n.º 15
0
 public void TestSleeveWidthNotNegative()
 {
     Sleeve sleeve = new Sleeve(-1, 20);
 }
Ejemplo n.º 16
0
        public SleeveViewModel(Sleeve sleeve)
        {
            this.Name = sleeve.Name;

            Sleeve = sleeve;
        }
Ejemplo n.º 17
0
        //Temporarily store group visibility information for LoadDeck. //bug (google) #20

        public void LoadDeck(IDeck deck, bool limited)
        {
            var def    = Program.GameEngine.Definition;
            int nCards = deck.CardCount();
            var ids    = new int[nCards];
            var keys   = new Guid[nCards];
            var cards  = new Card[nCards];
            var groups = new Play.Group[nCards];
            var sizes  = new string[nCards];
            var gtmps  = new List <GrpTmp>(); //for temp groups visibility
            int j      = 0;

            foreach (var section in deck.Sections)
            {
                { // Add cards to LoadedCards deck
                    if (!LoadedCards.Sections.Any(x => x.Name == section.Name))
                    {
                        // Add section
                        ((ObservableCollection <ObservableSection>)LoadedCards.Sections).Add(new ObservableSection()
                        {
                            Name   = section.Name,
                            Shared = section.Shared,
                            Cards  = new ObservableCollection <ObservableMultiCard>()
                        });
                    }

                    var loadedCardsSection = LoadedCards.Sections.Single(x => x.Name == section.Name);

                    foreach (var card in section.Cards)
                    {
                        var existingCard = loadedCardsSection.Cards.FirstOrDefault(x => x.Id == card.Id);
                        if (existingCard != null)
                        {
                            existingCard.Quantity += card.Quantity;
                        }
                        else
                        {
                            var newCard = new ObservableMultiCard(card);
                            loadedCardsSection.Cards.AddCard(newCard);
                        }
                    }
                }

                DeckSection sectionDef = null;
                sectionDef = section.Shared ? def.SharedDeckSections[section.Name] : def.DeckSections[section.Name];
                if (sectionDef == null)
                {
                    throw new InvalidFileFormatException("Invalid section '" + section.Name + "' in deck file.");
                }
                var        player = section.Shared ? Player.GlobalPlayer : Player.LocalPlayer;
                Play.Group group  = player.Groups.First(x => x.Name == sectionDef.Group.Name); //TODO: match directly to SectionDef Group instead of name matching

                //In order to make the clients know what the card is (if visibility is set so that they can see it),
                //we have to set the visibility to Nobody, and then after the cards are sent, set the visibility back
                //to what it was. //bug (google) #20
                var gt = new GrpTmp(group, group.Visibility, group.Viewers.ToList());
                if (!gtmps.Contains(gt))
                {
                    gtmps.Add(gt);
                    group.SetVisibility(false, false);
                }

                foreach (IMultiCard element in section.Cards)
                {
                    //DataNew.Entities.Card mod = Definition.GetCardById(element.Id);
                    for (int i = 0; i < element.Quantity; i++)
                    {
                        //for every card in the deck, generate a unique key for it, ID for it
                        var id   = element.GenerateCardId();
                        var card = new Card(player, id, new DataNew.Entities.Card(element), true, element.Size.Name);
                        //   var card = element.ToPlayCard(player);
                        ids[j]  = card.Id;
                        keys[j] = card.Type.Model.Id;
                        //keys[j] = card.GetEncryptedKey();
                        groups[j]  = group;
                        sizes[j]   = card.Size.Name;
                        cards[j++] = card;
                        group.AddAt(card, group.Count);

                        DeckStats.AddCard(card);
                    }

                    // Load images in the background
                    string pictureUri = element.GetPicture();
                    Dispatcher.CurrentDispatcher.BeginInvoke(
                        new Func <string, BitmapImage>(ImageUtils.CreateFrozenBitmap),
                        DispatcherPriority.Background, pictureUri);
                }
            }

            string sleeveString = null;

            if (deck.Sleeve != null)
            {
                try {
                    var loadSleeve = true;

                    if (!IsLocal)
                    {
                        var isSubscriber = SubscriptionModule.Get().IsSubscribed;

                        if (isSubscriber == null)
                        {
                            loadSleeve = false;

                            Log.Warn("Can't set deck sleeve, unable to determin if user is a subscriber.");

                            Program.GameMess.Warning($"Deck sleeve can not be loaded, subscriber status is unknown.");
                        }
                        else if (isSubscriber == false)
                        {
                            loadSleeve = false;

                            Log.Warn("Not authorized to use deck sleeve.");

                            Program.GameMess.Warning($"Deck sleeve can not be used, you're not a subscriber.");
                        }
                    }

                    if (loadSleeve)
                    {
                        Player.LocalPlayer.SetSleeve(deck.Sleeve);

                        sleeveString = Sleeve.ToString(deck.Sleeve);
                    }
                    else
                    {
                        Log.Info("Sleeve will not be loaded.");
                    }
                } catch (Exception ex) {
                    Log.Warn(ex.Message, ex);

                    Program.GameMess.Warning($"There was an error loading the decks sleeve.");
                }
            }

            Program.Client.Rpc.LoadDeck(ids, keys, groups, sizes, sleeveString ?? string.Empty, limited);
            //reset the visibility to what it was before pushing the deck to everybody. //bug (google) #20
            foreach (GrpTmp g in gtmps)
            {
                switch (g.Visibility)
                {
                case GroupVisibility.Everybody:
                    g.Group.SetVisibility(true, false);
                    break;

                case GroupVisibility.Nobody:
                    g.Group.SetVisibility(false, false);
                    break;

                default:
                    foreach (Player p in g.Viewers)
                    {
                        g.Group.AddViewer(p, false);
                    }
                    break;
                }
            }
            gtmps.Clear();
            gtmps.TrimExcess();
        }
Ejemplo n.º 18
0
    private void ShellDropping()
    {
        Sleeve newSleeve = Instantiate(_shell, transform.position + _positionSleeve, transform.rotation);

        newSleeve.Direction = -transform.forward;
    }