当前位置: 首页>>代码示例>>C#>>正文


C# MSG类代码示例

本文整理汇总了C#中MSG的典型用法代码示例。如果您正苦于以下问题:C# MSG类的具体用法?C# MSG怎么用?C# MSG使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MSG类属于命名空间,在下文中一共展示了MSG类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowStudentInfo

        public static void ShowStudentInfo(int id, string ip, int port)
        {
            Student student = null;
            TcpClient eClient = new TcpClient();
            try
            {
                eClient = new TcpClient(ip, port);
                using (NetworkStream writerStream = eClient.GetStream())
                {
                    MSG message = new MSG();
                    message.stat = STATUS.GET_ACCOUNT_BY_ID;
                    BinaryFormatter formatter = new BinaryFormatter();
                    formatter.Serialize(writerStream, message);
                    formatter.Serialize(writerStream, id);
                    student = (Student)formatter.Deserialize(writerStream);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                eClient.Close();
            }

            if (student == null)
            {
                throw new ArgumentException(string.Format("Студента з id = {0} не iснує", id));
            }

            StudentInfoWindow sw = new StudentInfoWindow(string.Format("{0} {1} {2}", student.Lastname, student.Firstname, student.Patronymic),
                student.Group, student.Faculty, student.PhoneNumber, student.Email, student.Address, student.AverageMark);
            sw.ShowDialog();
        }
开发者ID:senioroman4uk,项目名称:courseWork,代码行数:35,代码来源:StudentInfo.cs

示例2: UpdateSpecialities

 private void UpdateSpecialities()
 {
     SpecialityGrid.Items.Clear();
     try
     {
         Configuration config = (App.Current as App).config;
         using (TcpClient eClient = new TcpClient(config.IP.ToString(), config.Port))
         {
             using (NetworkStream writerStream = eClient.GetStream())
             {
                 MSG message = new MSG();
                 message.stat = STATUS.GET_SPECIALITIES;
                 BinaryFormatter formatter = new BinaryFormatter();
                 formatter.Serialize(writerStream, message);
                 if ((bool)formatter.Deserialize(writerStream))
                 {
                     _specialityCollection = (List<Speciality>)formatter.Deserialize(writerStream);
                 }
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
     foreach (var speciality in _specialityCollection)
     {
         SpecialityGrid.Items.Add(speciality);
     }
 }
开发者ID:senioroman4uk,项目名称:courseWork,代码行数:30,代码来源:SpecialityControlPage.xaml.cs

示例3: CheckMessage

        void CheckMessage(MSG msg)
        {
            if (msg.message == ".fire")
            {
                KeyValuePair<int, int> stat = new KeyValuePair<int, int>(0, 0);
                if (!stats.TryGetValue(msg.from, out stat))
                {

                }
                if (bullet == position)
                {
                    stats[msg.from] = new KeyValuePair<int, int>(stat.Key + 1, stat.Value);
                    irc.SendMessage(msg.to, msg.from + "'s brains are all over the walls!");
                    irc.KickUser(msg.to, msg.from, "You dead foo...");
                    Reload();
                    irc.SendMessage(msg.to, "Reloading");
                    return;
                }
                else
                {
                    stats[msg.from] = new KeyValuePair<int, int>(stat.Key, stat.Value + 1);
                    irc.SendMessage(msg.to, msg.from + " is lucky...this time.");
                    position++;
                }
            }
            else if (msg.message == ".reload")
            {
                Reload();
                irc.SendMessage(msg.to, "Reloading");
            }
        }
开发者ID:bwall,项目名称:bwall-s-smaller-projects,代码行数:31,代码来源:Roulette.cs

示例4: InitStudentTable

 public List<Student> InitStudentTable()
 {
     try
     {
         Configuration config = (App.Current as App).config;
         using (TcpClient eClient = new TcpClient(config.IP.ToString(), config.Port))
         {
             using (NetworkStream writerStream = eClient.GetStream())
             {
                 MSG message = new MSG();
                 message.stat = STATUS.GET_STUDENTS;
                 BinaryFormatter formatter = new BinaryFormatter();
                 formatter.Serialize(writerStream, message);
                 formatter.Serialize(writerStream, (App.Current as App).instr.InstructorId);
                 bool fl = (bool)formatter.Deserialize(writerStream);
                 if (fl)
                 {
                     _studentsCollection = (List<Student>)formatter.Deserialize(writerStream);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Помилка", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     return _studentsCollection;
 }
开发者ID:senioroman4uk,项目名称:courseWork,代码行数:28,代码来源:StudentControlPage.xaml.cs

示例5: AuthedCommand

 public override void AuthedCommand(MSG msg, int operLevel)
 {
     try
     {
         if (operLevel == 0)
         {
             msg.message = msg.message.Substring(msg.message.IndexOf(' ') + 1);
             if (msg.message.ToLower().StartsWith("register"))
             {
                 lastOper = msg.from;
                 irc.SendMessage("nickserv", msg.message);
                 if (msg.message.Split(' ').Length > 1)
                     logins[msg.to] = msg.message.Split(' ')[1];
             }
             else if (msg.message.ToLower().StartsWith("identify"))
             {
                 lastOper = msg.from;
                 irc.SendMessage("nickserv", msg.message);
                 if (msg.message.Split(' ').Length > 1)
                     logins[msg.to] = msg.message.Split(' ')[1];
             }
         }
     }
     catch { }
 }
开发者ID:bwall,项目名称:bwall-s-smaller-projects,代码行数:25,代码来源:NickServLogin.cs

示例6: RegisterButton_Click

        private void RegisterButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (PasswordBox.Password != PasswordRepeatBox.Password)
                    throw new Exception("Паролі не співпадають");
                Instructor instructor = new Instructor(LoginBox.Text, PasswordBox.Password, FirstNameBox.Text, LastNameBox.Text,
                    SecondNameBox.Text);
                Configuration config = (App.Current as App).config;
                using (TcpClient eClient = new TcpClient(config.IP.ToString(), config.Port))
                {
                    using (NetworkStream writerStream = eClient.GetStream())
                    {
                        MSG message = new MSG();
                        message.stat = STATUS.ADD_INSTRUCTOR;
                        BinaryFormatter formatter = new BinaryFormatter();
                        formatter.Serialize(writerStream, message);
                        formatter.Serialize(writerStream, instructor);
                        bool fl = (bool)formatter.Deserialize(writerStream);
                        if (!fl)
                            MessageBox.Show("Помилка додавання облікового запису");
                        else
                        {
                            NavigationService nav = NavigationService.GetNavigationService(this);
                            nav.Navigate(new System.Uri("StartPage.xaml", UriKind.RelativeOrAbsolute));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
开发者ID:senioroman4uk,项目名称:courseWork,代码行数:35,代码来源:RegisterPage.xaml.cs

示例7: Main

	static void Main ()
	{
		InstructionsForm instructionsForm = new InstructionsForm ();
		instructionsForm.Show ();

		NativeWindow nw = new NativeWindow ();

		CreateParams cp = new CreateParams ();

		cp.Caption = "bug #80817";
		cp.X = 100;
		cp.Y = 100;
		cp.Width = 400;
		cp.Height = 600;
		cp.ClassStyle = (int) (ClassStyle.CS_VREDRAW | ClassStyle.CS_HREDRAW);
		cp.Style = (int) WindowStyles.WS_OVERLAPPEDWINDOW;

		// create the window.
		nw.CreateHandle (cp);
		ShowWindow (nw.Handle, WindowPlacementFlags.SW_SHOWNORMAL);
		UpdateWindow (nw.Handle);

		MSG msg = new MSG ();

		while (GetMessage (ref msg, 0, 0, 0) > 0) {
			TranslateMessage (ref msg);
			DispatchMessage (ref msg);
		}
	}
开发者ID:mono,项目名称:gert,代码行数:29,代码来源:MainForm.cs

示例8: InitGroupTable

 public Dictionary<GroupRow, int> InitGroupTable()
 {
     _groupsCollection.Clear();
     foreach (var faculty in EnumDecoder.StringToFaculties)
     {
         try
         {
             Configuration config = (App.Current as App).config;
             using (TcpClient eClient = new TcpClient(config.IP.ToString(), config.Port))
             {
                 using (NetworkStream writerStream = eClient.GetStream())
                 {
                     MSG message = new MSG();
                     message.stat = STATUS.GET_GROUP_BY_FACULTY;
                     BinaryFormatter formatter = new BinaryFormatter();
                     formatter.Serialize(writerStream, message); 
                     formatter.Serialize(writerStream, faculty.Value);
                     bool fl = (bool)formatter.Deserialize(writerStream);
                     if (fl)
                     {
                         foreach (var group in (Dictionary<string, int>)formatter.Deserialize(writerStream))
                         {
                             _groupsCollection.Add(new GroupRow(group.Key, faculty.Key), group.Value);
                         }
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Помилка", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     return _groupsCollection;
 }
开发者ID:senioroman4uk,项目名称:courseWork,代码行数:35,代码来源:GroupControlPage.xaml.cs

示例9: YoutubeSearch

 void YoutubeSearch(object o)
 {
     try
     {
         MSG msg = new MSG(((MSG)o).ToString());
         WebClient wc = new WebClient();
         string str = wc.DownloadString("http://gdata.youtube.com/feeds/api/videos?fields-language=r2&q=" + Uri.EscapeUriString(msg.message.Substring(".youtube ".Length)) + "&fields=entry(media:group(media:title,media:content[@type='application/x-shockwave-flash'](@url)))&max-results=3");
         XmlDocument doc = new XmlDocument();
         str = str.Substring(str.IndexOf('>') + 1).Replace("media:", "");
         str = "<feed>" + str.Substring(str.IndexOf('>') + 1);
         doc.LoadXml(str);
         XmlNodeList nodeList = doc.DocumentElement.SelectNodes("//group");
         foreach (XmlNode node in nodeList)
         {
             if (node.ChildNodes[0].Attributes["url"] != null && !string.IsNullOrEmpty(node.ChildNodes[1].InnerText))
             {
                 string url = node.ChildNodes[0].Attributes["url"].Value;
                 url = url.Substring(0, url.IndexOf('?'));
                 url = url.Substring(url.Length - (11));
                 irc.SendMessage(msg.to, "(" + msg.message.Substring(".youtube ".Length) + ") * http://www.youtube.com/watch?v=" + url + " * - " + node.ChildNodes[1].InnerText);
             }
         }
     }
     catch { }
 }
开发者ID:bwall,项目名称:bwall-s-smaller-projects,代码行数:25,代码来源:Search.cs

示例10: CheckMessage

 void CheckMessage(MSG msg)
 {
     if (msg.message.StartsWith(".udict") && msg.message.Split(' ').Length > 1)
     {
         Thread t = new Thread(new ParameterizedThreadStart(GetUDef));
         t.Start(msg);
     }
 }
开发者ID:bwall,项目名称:bwall-s-smaller-projects,代码行数:8,代码来源:UDict.cs

示例11: AuthedCommand

 public override void AuthedCommand(MSG msg, int operLevel)
 {
     msg.message = msg.message.Substring(msg.message.IndexOf(' ') + 1);
     if (msg.message.StartsWith("add ") && msg.message.Split(' ').Length == 3)
     {
         oplist.Add(msg.message.Split(' ')[1], msg.message.Split(' ')[2]);
         EncFile.AppendText(server.Data + Path.DirectorySeparatorChar + "autoop.db", msg.message.Split(' ')[1] + " " + msg.message.Split(' ')[2] + "\n");
     }
 }
开发者ID:bwall,项目名称:bwall-s-smaller-projects,代码行数:9,代码来源:Class1.cs

示例12: irc_OnMSGRecvd

 void irc_OnMSGRecvd(MSG msg)
 {
     if (msg.message.ToLower().StartsWith(".decode "))
     {
         lastMeme[msg.fromUser + '@' + msg.fromHost] = DateTime.Now;
         Thread t = new Thread(new ParameterizedThreadStart(GenerateImage));
         t.Start(msg);
     }
 }
开发者ID:bwall,项目名称:bwall-s-smaller-projects,代码行数:9,代码来源:BrakMeme.cs

示例13: AuthedCommand

 public virtual void AuthedCommand(MSG msg, int operLevel)
 {
     msg.message = msg.message.Substring(msg.message.IndexOf(' ') + 1);
     if (msg.message.StartsWith("value "))
     {
         string s = GetPrivateValue(msg.message.Substring(msg.message.IndexOf(' ') + 1));
         if (!string.IsNullOrEmpty(s))
             irc.SendMessage(msg.from, msg.message.Substring(msg.message.IndexOf(' ') + 1) + " = " + s);
     }
 }
开发者ID:bwall,项目名称:bwall-s-smaller-projects,代码行数:10,代码来源:Module.cs

示例14: irc_OnPMRecvd

 void irc_OnPMRecvd(MSG msg)
 {
     //op channel pass
     if (msg.message.StartsWith("op ") && msg.message.Split(' ').Length == 3)
     {
         if (oplist.ContainsKey(msg.from) && oplist[msg.from] == msg.message.Split(' ')[2])
         {
             irc.SetChannelModes(msg.message.Split(' ')[1], "+o", msg.from);
         }
     }
 }
开发者ID:bwall,项目名称:bwall-s-smaller-projects,代码行数:11,代码来源:Class1.cs

示例15: messageEnabled

 static bool messageEnabled(MSG msg)
 {
     // WITHDRAWAL: INVALID_FROM_ACCT MAX_DAILY_WITHDRAWAL INVALID_ACCT_BALANCE
     // TRANSFER: INVALID_FROM_ACCT INVALID_TO_ACCT SAME_ACCOUNT INVALID_ACCT_BALANCE
     return
         msg != MSG.MAX_DAILY_WITHDRAWAL && msg != MSG.INVALID_FROM_ACCT && msg != MSG.INVALID_TO_ACCT && msg != MSG.SAME_ACCOUNT && msg != MSG.INVALID_ACCT_BALANCE ||
         msg == MSG.INVALID_FROM_ACCT ||
         msg == MSG.MAX_DAILY_WITHDRAWAL && !Session.hasMessage(MSG.INVALID_FROM_ACCT) ||
         msg == MSG.INVALID_TO_ACCT && !Session.hasMessage(MSG.INVALID_FROM_ACCT) ||
         msg == MSG.SAME_ACCOUNT && !Session.hasMessage(MSG.INVALID_FROM_ACCT) && !Session.hasMessage(MSG.INVALID_TO_ACCT) ||
         msg == MSG.INVALID_ACCT_BALANCE && !Session.hasMessage(MSG.MAX_DAILY_WITHDRAWAL) && !Session.hasMessage(MSG.INVALID_TO_ACCT) && !Session.hasMessage(MSG.SAME_ACCOUNT);
 }
开发者ID:BackupTheBerlios,项目名称:nmodelrs-svn,代码行数:12,代码来源:Test.cs


注:本文中的MSG类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。