Example #1
0
        /// <summary>
        /// 解析战旗弹幕
        /// </summary>
        /// <param name="content"></param>
        //protected void ParseZqContent(string content)
        //{
        //    int nindex, nIndex;
        //    if ((nindex = content.IndexOf('{')) != -1 && (nIndex = content.IndexOf('}')) != -1)
        //    {
        //        string substr = content.Substring(nindex, nIndex - nindex + 1);

        //        JsonReader reader = new JsonTextReader(new StringReader(substr));


        //    }
        //}

        /// <summary>
        /// 抽奖线程
        /// </summary>
        private void UpdateLotteryManList()
        {
            string level;
            string scriptId;
            string scriptUid;
            string content;
            string scriptName;

            Action update = delegate
            {
                info.Text = "参与抽奖的人数:" + mCountPrizeList.Count;
            };

            while (mCount)
            {
                CppInterface.LoadScriptMsg((int)mLiveType, out level, out scriptId, out scriptUid, out content, out scriptName);

                if (level != null && level.Length > 0)
                {
                    long uid   = long.Parse(scriptUid.ToString());
                    bool bFind = mCountPrizeList.Any <LiveScript>(P => P.UID == uid);
                    if (bFind == false)
                    {
                        LiveScript livescript = new LiveScript();
                        livescript.LEVEL   = int.Parse(level.ToString());
                        livescript.ID      = long.Parse(scriptId.ToString());
                        livescript.UID     = long.Parse(scriptUid.ToString());
                        livescript.CONTENT = content.ToString();
                        livescript.NAME    = scriptName.ToString();

                        mCountPrizeList.Add(livescript);
                        this.Dispatcher.BeginInvoke(update);
                    }
                }
                level = null;
            }
            CppInterface.CloseNetDevice();
        }
Example #2
0
        /// <summary>
        /// 开始统计人数按钮响应函数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CountHandler(object sender, RoutedEventArgs e)
        {
            if (mCount == false)
            {
                int index = NetDevice.SelectedIndex;
                if (CppInterface.OpenNetDevice(index))
                {
                    if (mLotteryThread.IsAlive)
                    {
                        mLotteryThread.Join();
                    }

                    mCountPrizeList.Clear();
                    CountBtn.Content = "停止统计";
                    mCount           = true;
                    mLotteryThread.Start();
                }
            }
            else
            {
                CountBtn.Content = "开始统计";
                mCount           = false;
            }
        }
Example #3
0
        /// <summary>
        /// 初始化对话框
        /// </summary>
        protected void initView()
        {
            string[] netdevice = CppInterface.LoadNetDevice();
            NetDevice.ItemsSource = netdevice;

            if (File.Exists("config.ini"))
            {
                StreamReader sr       = new StreamReader("config.ini", Encoding.Default);
                String       selIndex = sr.ReadLine();
                if (selIndex != null)
                {
                    int index = int.Parse(selIndex);
                    if (index >= 0 && index < netdevice.Length)
                    {
                        NetDevice.SelectedIndex = index;
                    }
                }
                sr.Close();
            }

            List <LevelLimit> levelist = new List <LevelLimit>();

            if (mLiveType == LiveType.ZhanQi)
            {
                for (int i = 0; i < 25; i++)
                {
                    LevelLimit levellimit = new LevelLimit();
                    levellimit.Leveltext = i.ToString();
                    levellimit.Levelgif  = "res/image/" + i.ToString() + ".gif";

                    levelist.Add(levellimit);
                }
            }
            else
            {
                for (int i = 0; i < 21; i++)
                {
                    LevelLimit levellimit = new LevelLimit();
                    levellimit.Leveltext = i.ToString();
                    levellimit.Levelgif  = "res/image/medal_" + i.ToString() + ".gif";

                    levelist.Add(levellimit);
                }
            }

            ComboBoxLevelLimit.ItemsSource = levelist;

            mprizeItems = new ObservableCollection <string>(CppInterface.LoadLottteryIni());
            //foreach (string prize in mprizeItems)
            //{
            //    prizeSet.Items.Add(prize);
            //}
            prizeSet.ItemsSource   = mprizeItems;
            prizeSet.SelectedIndex = 0;

            mHitPrizeList            = new ObservableCollection <LotteryScript>();
            HitPrizeList.ItemsSource = mHitPrizeList;

            mCountPrizeList = new ObservableCollection <LiveScript>();
            mLotteryThread  = new Thread(UpdateLotteryManList);

            version.Text += System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
        }
Example #4
0
 /// <summary>
 /// 初始化截包接口
 /// </summary>
 /// <returns>
 /// 返回true初始化成功,返回false初始化失败
 /// </returns>
 protected bool init()
 {
     return(CppInterface.InitDll());
 }
Example #5
0
        /// <summary>
        /// 窗口关闭的时候,将奖品信息存储在本地
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnClosing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            string[] lotteryini = mprizeItems.ToArray();

            CppInterface.SaveLotteryIniInfo(lotteryini, lotteryini.Length);
        }