Esempio n. 1
0
        private void UpdatePicBoxPosition()
        {
            ImgPositionSet imgSet = Common.GlobalPrizeSystem.GetImgPositionSet();

            if (imgSet != null)
            {
                pictureBox1.Width  = imgSet.Width;
                pictureBox1.Height = imgSet.Height;

                tBoxImgWidth.Text  = imgSet.Width.ToString();
                tBoxImgHeight.Text = imgSet.Height.ToString();
                tBoxHOffset.Text   = imgSet.Hoffset.ToString();
                tBoxVOffset.Text   = imgSet.VoffSet.ToString();
            }

            int nOffset = 0;

            if (this.Height <= 768)
            {
                nOffset = 50;
            }
            else
            {
                nOffset = 0;
            }

            pictureBox1.Location = new Point(this.Width / 2 - pictureBox1.Width / 2 + imgSet.Hoffset, this.Height / 2 - pictureBox1.Height / 2 + nOffset + imgSet.VoffSet);

            lblPrizeName.Location     = new Point(pictureBox1.Location.X + pictureBox1.Width + 20, pictureBox1.Location.Y + pictureBox1.Height / 4);
            lblPrizeGenerate.Location = new Point(pictureBox1.Location.X + pictureBox1.Width + 40, pictureBox1.Location.Y + pictureBox1.Height - (pictureBox1.Height / 4));
        }
Esempio n. 2
0
        public Dictionary <int, List <int> > mapPrizeInSet = null; //内定,你懂的
        #endregion

        #region 初始化

        public PrizeSystem()
        {
            this.mapPerson = new Dictionary <int, Person>();
            this.mapRank   = new Dictionary <int, Rank>();
            this.mapPrize  = new Dictionary <int, List <int> >();

            sysSet         = new SystemSet();
            imgPositionSet = new ImgPositionSet();

            mapPrizeInSet = new Dictionary <int, List <int> >();
        }
Esempio n. 3
0
        private void btnSetImg_Click(object sender, EventArgs e)
        {
            try
            {
                ImgPositionSet imgSet = new ImgPositionSet();
                imgSet.Height  = Convert.ToInt32(tBoxImgHeight.Text);
                imgSet.Width   = Convert.ToInt32(tBoxImgWidth.Text);
                imgSet.VoffSet = Convert.ToInt32(tBoxVOffset.Text);
                imgSet.Hoffset = Convert.ToInt32(tBoxHOffset.Text);

                Common.GlobalPrizeSystem.UpdateImgPositionSet(imgSet);
                UpdatePicBoxPosition();
            }
            catch (Exception ex)
            {
                MessageBox.Show("只能输入数字!");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 反序列化填充数据
        /// </summary>
        /// <param name="m_mapPerson"></param>
        /// <param name="m_mapRank"></param>
        /// <param name="m_mapPrize"></param>
        /// <returns></returns>
        public Boolean Initialize(ref Dictionary <int, Person> m_mapPerson, ref Dictionary <int, Rank> m_mapRank, ref Dictionary <int, List <int> > m_mapPrize
                                  , ref SystemSet m_systemSet, ref ImgPositionSet m_imgPositionSet, ref Dictionary <int, List <int> > m_mapPrizeInSet)
        {
            Loger.Debug(" >>> Controller Initialize start <<< ");
            try
            {
                bool bExists = false;
                m_mapPerson = Loger.DeSerialize <Dictionary <int, Person> >(Config.PathPerson, out bExists);
                if (!bExists)
                {
                    m_mapPerson = new Dictionary <int, Person>();
                    Loger.Debug("person dat is not exist.");
                }

                bExists   = false;
                m_mapRank = Loger.DeSerialize <Dictionary <int, Rank> >(Config.PathRank, out bExists);
                if (!bExists)
                {
                    m_mapRank = new Dictionary <int, Rank>();
                    Loger.Debug("rank dat is not exist.");
                }

                bExists    = false;
                m_mapPrize = Loger.DeSerialize <Dictionary <int, List <int> > >(Config.PathPrize, out bExists);
                if (!bExists)
                {
                    m_mapPrize = new Dictionary <int, List <int> >();
                    Loger.Debug("prize dat is not exist.");
                }

                bExists     = false;
                m_systemSet = Loger.DeSerialize <SystemSet>(Config.PathSysSet, out bExists);
                if (!bExists)
                {
                    m_systemSet = new SystemSet();
                    Loger.Debug("systemSet dat is not exist.");
                }

                bExists          = false;
                m_imgPositionSet = Loger.DeSerialize <ImgPositionSet>(Config.PathImgPositionSet, out bExists);
                if (!bExists)
                {
                    m_imgPositionSet = new ImgPositionSet();
                    Loger.Debug("ImgPositionSet dat is not exist.");
                }

                #region 内定
                string fileSc = Config.PathConfig + @"\config.xml";
                if (File.Exists(fileSc))
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(fileSc);
                    XmlNode root       = null;
                    XmlNode SingleNode = null;
                    root = doc.SelectSingleNode("/RankSet");

                    SingleNode = root;
                    m_mapPrizeInSet.Clear();

                    Loger.Debug(" child count = " + SingleNode.ChildNodes.Count);

                    foreach (XmlNode child in SingleNode.ChildNodes) //遍历设置项
                    {
                        if (child.Name.ToLower() == "rank")          //找到rank行
                        {
                            #region 搜索对应奖项
                            string strRankName = XmlUtils.GetXmlAttributeValue(child, "name", "");

                            bool bRankExist = false;
                            int  nRankId    = 0;
                            foreach (var data in m_mapRank)             //遍历奖项列表
                            {
                                if (data.Value.RankName == strRankName) //奖项列表中存在设置的奖项
                                {
                                    bRankExist = true;
                                    nRankId    = data.Value.RankId;
                                    break;
                                }
                            }
                            if (!bRankExist)
                            {
                                continue;
                            }
                            #endregion

                            string   strPrizeSet = XmlUtils.GetXmlAttributeValue(child, "Set", ""); //获取set组
                            string[] arrPrizeSet = strPrizeSet.Split(',');
                            if (arrPrizeSet.Length <= 0)
                            {
                                continue;
                            }

                            foreach (var s in arrPrizeSet)
                            {
                                foreach (var p in Common.GlobalPrizeSystem.mapPerson) //遍历人员列表
                                {
                                    if (s == p.Value.PersonName)
                                    {
                                        if (!m_mapPrizeInSet.ContainsKey(nRankId))
                                        {
                                            m_mapPrizeInSet.Add(nRankId, new List <int>());
                                        }
                                        m_mapPrizeInSet[nRankId].Add(p.Key);

                                        break;
                                    }
                                }
                            }
                            Loger.Debug("m_mapPrizeInSet count = " + m_mapPrizeInSet.Count);
                        }
                    }
                }
                else
                {
                    Loger.Debug("PrizeInSet file not exist ");
                }
                #endregion

                Loger.Debug(" <<< Controller Initialize successed.>>> ");
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }