Example #1
0
 //获取请求
 public void Get_Friendreq()
 {
     try
     {
         Bw.Write("getfriendreq");
     }
     catch
     {
         MessageBox.Show("获取好友列表失败");
     }
 }
Example #2
0
 public void Get_Putmureq()
 {
     try
     {
         Bw.Write("getputmureq");
     }
     catch
     {
         MessageBox.Show("获取发送的群组申请列表失败");
     }
 }
Example #3
0
 private void Get_muGroups()
 {
     try
     {
         Bw.Write("getmugroups");
     }
     catch
     {
         MessageBox.Show("获取群组分组失败");
     }
 }
Example #4
0
 private void Get_mutualchat()
 {
     try
     {
         Bw.Write("getmutualchat");
     }
     catch
     {
         MessageBox.Show("获取群聊信息失败");
     }
 }
Example #5
0
 //获取列表
 private void Get_Friend()
 {
     try
     {
         Bw.Write("getfriends");
     }
     catch
     {
         MessageBox.Show("获取好友列表失败");
     }
 }
Example #6
0
 private void Get_Groups()
 {
     try
     {
         Bw.Write("getgroups");
     }
     catch
     {
         MessageBox.Show("获取好友分组失败");
     }
 }
Example #7
0
 private void btn_Send_Click(object sender, EventArgs e)
 {
     try
     {                                       //通过TCP协议向服务器发送群发消息
         string temp = this.tb_SendMsg.Text; //保存TextBox文本
         Bw.Write("barchmsg#" + Username + "#" + temp);
         Bw.Flush();
         AddMessage("barchmsg#" + Username + '#' + temp, false);
         this.tb_SendMsg.Clear();
     }
     catch
     { }
 }
Example #8
0
        private void loadmunoread()
        {
            string sndmsg = "getmunoread#";

            try
            {
                Bw.Write(sndmsg);
            }
            catch
            {
                MessageBox.Show("获取消息失败");
            }
        }
Example #9
0
        //修改属性

        /*private void mustate(string GID,string groupname,string sign)
         * {
         *  foreach (ListViewItem item in this.lv_group.Items)
         *  {
         *      if (item.Text == GID)
         *      {
         *          item.SubItems[1].Text = groupname;
         *          item.SubItems[4].Text = sign;
         *      }
         *  }
         * }
         * private void state(string UID,string username,string sign)
         * {
         *
         * }*/
        //关闭窗口
        private void list_FormClosed(object sender, FormClosedEventArgs e)
        {
            try
            {
                string sendmsg = "logout#" + UID;
                Bw.Write(sendmsg);
                Bw.Flush();
                iswork = false;
                Br.Close();
                Bw.Close();
            }
            catch
            { }
            Application.Exit();
        }
Example #10
0
        private void bt_send_Click(object sender, EventArgs e)
        {
            if (cb_group.Text == "")
            {
                lb_state.Text = "分组不能为空";
                return;
            }
            String sndmsg = "cgmugroup#";

            sndmsg += GID;
            sndmsg += "#";
            sndmsg += cb_group.Text;
            Bw.Write(sndmsg);
            this.Close();
        }
Example #11
0
        private void delmuToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.lv_group.SelectedItems.Count == 0)
            {
                return;
            }
            ListViewItem lvitm  = this.lv_group.SelectedItems[0];
            DialogResult result = MessageBox.Show("确定解散该群吗?", "提示:", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                Bw.Write("delmu#" + lvitm.SubItems[0].Text);
            }
            else
            {
                return;
            }
        }
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            startCalculatingLock = true;
            int iterationsLeft = mainWindow.UserDefinedLFSRIterations;

            if (calculatingStoppedAt > 0)
            {
                iterationsLeft = calculatingStoppedAt;
            }
            if (pauseCalculatingLock || stopCalculatingLock)
            {
                pauseCalculatingLock = false;
                stopCalculatingLock  = false;
            }
            string       startButtonContent = (string)e.Argument;
            int          bitListCount       = bitViewModel.Bits.Count;
            int          sum;
            bool         saveGeneratedValue = false;
            int          counter            = 0;
            StreamWriter tw = new StreamWriter(mainWindow.FileManagement.Files[0]);

            tw.Dispose();
            BinaryWriter Bw = new BinaryWriter(File.Open(mainWindow.FileManagement.Files[0], FileMode.OpenOrCreate));

            Bw.Dispose();
            if (startButtonContent.Equals("Resume"))
            {
                if (mainWindow.FileManagement.Extension.Equals(".txt"))
                {
                    tw = File.AppendText(mainWindow.FileManagement.Files[0]);
                }
                else
                {
                    Bw = new BinaryWriter(File.Open(mainWindow.FileManagement.Files[0], FileMode.Append));
                }
            }
            else
            {
                iterationsLeft = mainWindow.UserDefinedLFSRIterations;
                if (mainWindow.FileManagement.Extension.Equals(".txt"))
                {
                    tw = new StreamWriter(mainWindow.FileManagement.Files[0]);
                }
                else
                {
                    Bw = new BinaryWriter(File.Open(mainWindow.FileManagement.Files[0], FileMode.OpenOrCreate));
                }
                this.Dispatcher.Invoke(() => { userDefinedProgressBar.Maximum = iterationsLeft; });
            }
            int           progress   = iterationsLeft;
            StringBuilder byteToSave = new StringBuilder();

            while (!pauseCalculatingLock && !stopCalculatingLock && iterationsLeft > 0)
            {
                if (saveGeneratedValue == true && cyclesUntilSavingCheck.Equals(0))
                {
                    if (mainWindow.FileManagement.Extension.Equals(".bin"))
                    {
                        if (byteToSave.Length == 0)
                        {
                            this.Dispatcher.Invoke(() =>
                            {
                                Bw.Write(Convert.ToByte(byteToSave.ToString(), 2));
                            });
                            byteToSave.Clear();
                        }
                        else
                        {
                            byteToSave.Append(bitViewModel.Bits[bitListCount - 1].BitValue);
                        }
                    }
                    else
                    {
                        this.Dispatcher.Invoke(() =>
                        {
                            tw.Write(bitViewModel.Bits[bitListCount - 1].BitValue);
                        });
                    }
                    (sender as BackgroundWorker).ReportProgress(0);
                    iterationsLeft--;
                    saveGeneratedValue = false;
                }
                sum = 0;
                for (int i = 0; i < bitListCount; i++)
                {
                    if (bitViewModel.Bits[i].BitState.Equals("On") && bitViewModel.Bits[i].BitValue.Equals(1))
                    {
                        sum++;
                    }
                }
                sum = sum % 2;
                for (int i = bitListCount - 1; i > 0; i--)
                {
                    bitViewModel.Bits[i].BitValue = bitViewModel.Bits[i - 1].BitValue;
                }
                bitViewModel.Bits[0].BitValue = sum;
                if (cyclesUntilSavingCheck.Equals(0) && bitViewModel.Bits[bitListCount - 1].BitValue.Equals(0))
                {
                    cyclesUntilSavingCheck = mainWindow.NewCyclesAtZero;
                }
                if (cyclesUntilSavingCheck.Equals(0) && bitViewModel.Bits[bitListCount - 1].BitValue.Equals(1))
                {
                    cyclesUntilSavingCheck = mainWindow.NewCyclesAtOne;
                    counter++;
                    saveGeneratedValue = true;
                }
                cyclesUntilSavingCheck--;
            }
            if (iterationsLeft == 0)
            {
                this.Dispatcher.Invoke(() =>
                {
                    startButton.Content          = "Start";
                    startButton.IsEnabled        = true;
                    userDefinedProgressBar.Value = 0;
                });
            }
            else
            {
                calculatingStoppedAt = iterationsLeft;
            }
            tw.Close();
            Bw.Close();
            startCalculatingLock = false;
        }
Example #13
0
 private void bt_change_Click(object sender, EventArgs e)
 {
     Bw.Write("userstate#" + tb_username.Text + "#" + tb_sign.Text);
 }
Example #14
0
 private void bt_send_Click(object sender, EventArgs e)
 {
     Bw.Write("mustate#" + GID + "#" + tb_grpname.Text + "#" + tb_grpsign.Text);
 }