Esempio n. 1
0
 private void UpdateAdvList(ADVLIST advList)
 {
     this.listViewAdvList.BeginUpdate();
     this.listViewAdvList.Items.Clear();
     for (int i = 0; i < advList.count; ++i)
     {
         ListViewItem item = new ListViewItem(advList.adv[i].title);
         int          k    = advList.adv[i].map.LastIndexOf('\\');
         if (k >= 0)
         {
             advList.adv[i].map = advList.adv[i].map.Substring(k + 1);
         }
         item.SubItems.Add(advList.adv[i].map);
         item.SubItems.Add(advList.adv[i].creator);
         item.SubItems.Add(advList.adv[i].ip);
         item.SubItems.Add(advList.adv[i].location);
         this.listViewAdvList.Items.Add(item);
     }
     this.listViewAdvList.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
     this.listViewAdvList.EndUpdate();
 }
Esempio n. 2
0
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == 0x004A)
            {
                try
                {
                    COPYDATASTRUCT cds     = new COPYDATASTRUCT();
                    Type           cdsType = cds.GetType();
                    cds = (COPYDATASTRUCT)m.GetLParam(cdsType);
                    uint   flag = (uint)cds.dwData;
                    byte[] data = new byte[cds.cbData];
                    Marshal.Copy(cds.lpData, data, 0, cds.cbData);

                    if (flag == 1)
                    {
                        UpdateMessage(Encoding.Unicode.GetString(data));
                    }
                    else if (flag == 2)
                    {
                        int    size = Marshal.SizeOf(typeof(ROOM));
                        IntPtr ptr  = Marshal.AllocHGlobal(size);
                        Marshal.Copy(data, 0, ptr, size);
                        ROOM room = (ROOM)Marshal.PtrToStructure(ptr, typeof(ROOM));
                        Marshal.FreeHGlobal(ptr);

                        UpdatePlayerList(room);

                        this.panelInRoom.Visible  = true;
                        this.panelOutRoom.Visible = false;
                    }
                    else if (flag == 3)
                    {
                        int    size = Marshal.SizeOf(typeof(ADVLIST));
                        IntPtr ptr  = Marshal.AllocHGlobal(size);
                        Marshal.Copy(data, 0, ptr, size);
                        ADVLIST advList = (ADVLIST)Marshal.PtrToStructure(ptr, typeof(ADVLIST));
                        Marshal.FreeHGlobal(ptr);

                        UpdateAdvList(advList);

                        this.panelInRoom.Visible  = false;
                        this.panelOutRoom.Visible = true;

                        if (this.checkBoxAutoJoin.Checked)
                        {
                            for (int i = 0; i < advList.count; ++i)
                            {
                                if (advList.adv[i].title.IndexOf(this.textBoxTitleContain.Text, StringComparison.OrdinalIgnoreCase) >= 0 &&
                                    advList.adv[i].map.IndexOf(this.textBoxMapContain.Text, StringComparison.OrdinalIgnoreCase) >= 0)
                                {
                                    JoinGame(advList.adv[i].title);
                                }
                            }
                        }
                    }
                    else if (flag == 4)
                    {
                        //W3_NOTHING 0
                        //W3_LOBBY 1
                        //W3_FAKE 2 // i don't know what is this...
                        //W3_LOADING 3
                        //W3_INGAME 4
                        //W3_PAUSEDGAME 6
                        int backupGameState = GameState;
                        GameState = BitConverter.ToInt32(data, 0);
                        if (backupGameState == 1 && GameState == 0) // 从房间中退出
                        {
                            UpdateMessage("[已离开房间]");
                            ActiveWC3();
                        }
                        else if (GameState == 1) // 进入房间
                        {
                            this.listBoxMessage.Items.Clear();
                            this.panelInRoom.Visible      = true;
                            this.panelOutRoom.Visible     = false;
                            this.checkBoxAutoJoin.Checked = false;
                            this.checkBoxAutoTry.Checked  = false;
                            ActiveWC3();
                        }
                        else if (GameState == 3) // 开始载入
                        {
                            UpdateMessage("[已开始载入]");
                        }
                        else if (GameState == 4) // 开始游戏
                        {
                            UpdateMessage("[已开始游戏]");
                            ActiveWC3();
                        }
                    }
                }
                catch (Exception e)
                {
                    //MessageBox.Show(e.ToString());
                }
            }
            else if (m.Msg == 0x0112)
            {
                if (m.WParam.ToInt32() == 0x123)
                {
                    IntPtr hMenu = GetSystemMenu(this.Handle, false);
                    CheckMenuItem(hMenu, 0x123, this.TopMost ? (uint)0 : 0x00000008);
                    this.TopMost = !this.TopMost;
                }
                else if (m.WParam.ToInt32() == 0x124)
                {
                    System.Diagnostics.Process.Start("http://blog.nxun.com/2011/war3-bn-helper/");
                }
                else
                {
                    base.WndProc(ref m);
                }
            }
            else
            {
                base.WndProc(ref m);
            }
        }
Esempio n. 3
0
 private void UpdateAdvList(ADVLIST advList)
 {
     this.listViewAdvList.BeginUpdate();
     this.listViewAdvList.Items.Clear();
     for (int i = 0; i < advList.count; ++i)
     {
         ListViewItem item = new ListViewItem(advList.adv[i].title);
         int k = advList.adv[i].map.LastIndexOf('\\');
         if (k >= 0)
             advList.adv[i].map = advList.adv[i].map.Substring(k + 1);
         item.SubItems.Add(advList.adv[i].map);
         item.SubItems.Add(advList.adv[i].creator);
         item.SubItems.Add(advList.adv[i].ip);
         item.SubItems.Add(advList.adv[i].location);
         this.listViewAdvList.Items.Add(item);
     }
     this.listViewAdvList.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
     this.listViewAdvList.EndUpdate();
 }