private void InitButtons(typeMessage tpMessage) { try { switch (tpMessage) { case typeMessage.Dialog: break; case typeMessage.DialogAcceptCancel: btnPrincipal.Visible = true; btnSecondary.Visible = true; btnPrincipal.Text = "Aceptar"; btnSecondary.ButtonText = "Cancelar"; break; case typeMessage.DialogOk: btnPrincipal.Visible = true; btnPrincipal.Text = "Aceptar"; btnPrincipal.Location = btnSecondary.Location; break; case typeMessage.DialogYesNo: btnPrincipal.Visible = true; btnSecondary.Visible = true; btnPrincipal.Text = "Si"; btnSecondary.ButtonText = "No"; break; } } catch { } }
/// <summary> /// Отправляемое сообщение. Тип и имя сообщения присваиваются автоматически. /// </summary> /// <param name="_priority">Приоритет сообщения {0..31}</param> /// <param name="_descriptor">Дескриптор {0..255 - Служебные, 256..1279 - Команды, 1280..1295 - Подтверждения}</param> /// <param name="_time_periodic">Время периодичности сообщения, мс. 0 - спорадическое сообщение</param> /// <param name="_dataNum">Количество байт данных. 0 - при отсутствии</param> public Message(byte _priority, ushort _descriptor, ushort _time_periodic, byte _dataNum) { if (_descriptor > 0 && _descriptor <= 255) { type = typeMessage.SERVICE; } else if (_descriptor > 255 && _descriptor <= 1279) { type = typeMessage.COMMAND; } else if (_descriptor > 1279 && _descriptor <= 1295) { type = typeMessage.ACK; } else if (_descriptor > 1295 && _descriptor <= 2047) { type = typeMessage.BROADCAST; } else if (_descriptor > 2047 && _descriptor <= 4095) { type = typeMessage.OTHER; } name = ((DESCRIPTORS)_descriptor).ToString(); priority = _priority; descriptor = _descriptor; switch (type) //проверка и установка дескриптора на соответствующий типу сообщения диапазон { case typeMessage.SERVICE: if (_descriptor > 255) { descriptor = 255; } break; //знак проверяется типом переменной case typeMessage.COMMAND: if (_descriptor < 256 || _descriptor > 1279) { descriptor = 1279; } break; case typeMessage.ACK: if (_descriptor < 1280 || _descriptor > 1295) { descriptor = 1295; } break; } time_periodic = _time_periodic; //data = new byte[0]; data = new byte[_dataNum]; }
public Project ParseDataToProject(typeMessage type, string data) { string[] parts; switch (type) { case typeMessage.MSG_ADDTIME: parts = data.Split(SEPdata); return(new Project(parts[0], parts[1])); break; default: return(null); break; } }
public ClientData ParseDataToClientData(typeMessage type, string data) { string[] parts; ClientData tmp; string address; int port; IPEndPoint clientAddress; switch (type) { case typeMessage.MSG_CONNECT: parts = data.Split(SEPdata); tmp = new ClientData(parts[1], (ClientStati)Convert.ToInt32(parts[2])); return(tmp); break; case typeMessage.MSG_CONNECTRESPONSE: parts = data.Split(SEPdata); address = parts[3].Split(':')[0]; port = Convert.ToInt32(parts[3].Split(':')[1]); clientAddress = new IPEndPoint(IPAddress.Parse(address), port); tmp = new ClientData(parts[1], Convert.ToInt32(parts[0]), (ClientStati)Convert.ToInt32(parts[2]), clientAddress); return(tmp); break; case typeMessage.MSG_HEARTBEAT: parts = data.Split(SEPdata); address = parts[3].Split(':')[0]; port = Convert.ToInt32(parts[3].Split(':')[1]); clientAddress = new IPEndPoint(IPAddress.Parse(address), port); tmp = new ClientData(parts[1], Convert.ToInt32(parts[0]), (ClientStati)Convert.ToInt32(parts[2]), clientAddress); return(tmp); break; default: return(null); break; } }
public int ParseDataToHashValue(typeMessage type, string data) { string[] parts; switch (type) { case typeMessage.MSG_CONNECT: return(0); break; case typeMessage.MSG_CONNECTRESPONSE: parts = data.Split(SEPdata); return(Convert.ToInt32(parts[4])); break; case typeMessage.MSG_HEARTBEAT: default: return(0); break; } }
/// <summary> /// Creates the header of the message. /// </summary> /// <param name="type">Type of the message.</param> /// <returns>The header as 'string'.</returns> private string createMsgHeader(typeMessage type) { return(((int)type).ToString() + SEPdata + myID.ToString()); }
public LogMessage(string _message, typeMessage _type) { message = _message.Trim(); type = _type; }
public MessageHttpResponse(string code, string message, typeMessage type) { this.messages = new List <ValidationMessage>(); this.messages.Add(new ValidationMessage(code, message)); this.type = type; }
public void SendRequest(typeMessage Type, string message) { if ((int)Type == 0) { Exit(); MessageBox.Show("Mensaje enviado", "mensaje para desconectar", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if ((int)Type == 1) { message = getMessage(message); if (message == "1") { MessageBox.Show("El mensaje no tiene contenido", "El mensaje no ha sido enviado", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (message == "2") { MessageBox.Show("El mensaje es extenso", "El mensaje no ha sido enviado", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } SendString(message); MessageBox.Show("Mensaje enviado", "se ha enviado un mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if ((int)Type == 4) { SendString((int)typeMessage.login + "|" + this.Alias + "|0"); } else { message = getPathSearch(message); if (message == "1") { MessageBox.Show("El path es a buscar es demasiado largo", "El mensaje no ha sido enviado", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (message == "2") { MessageBox.Show("No se ha escrito el path", "El mensaje no ha sido enviado", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { SendString(message); } MessageBox.Show("Mensaje enviado", "mensaje para buscar path", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public static mdMessageBox messageBox(IWin32Window owner, string message, string tittle, typeMessage buttons, typeIcon icon) { MessageBeep(0); mdMessageBox mdMessage = new mdMessageBox(); mdMessage.tpMessage = buttons; mdMessage.ShowInTaskbar = false; mdMessage.lblTypeMessage.Text = tittle; mdMessage.lblMessage.Text = message; mdMessage.InitButtons(buttons); mdMessage.InitIcon(icon); mdMessage.Size = mdMessage.MessageSize(message, mdMessage, buttons); mdMessage.ShowDialog(/*owner*/); return(mdMessage); }
private Size MessageSize(string message, mdMessageBox mdMessageBoxObject, typeMessage button) { Graphics g = mdMessageBoxObject.CreateGraphics(); int width = 337; int height = 214; SizeF size = g.MeasureString(message, new System.Drawing.Font("Microsoft Sans Serif", 14)); if (size.Width > 337) { string[] groups = (from Match m in Regex.Matches(message, ".{1,180}") select m.Value).ToArray(); int lines = groups.Length + 1; //width = (int)size.Width/* + 20*/; if ((int)size.Width <= 1000) { width = ((int)size.Width > 900 ? 800 : (int)size.Width); } else { width = 1200; } if (button != typeMessage.Dialog) { height += ((int)(size.Height + 0) * lines) + 44; } } else { string[] groups = (from Match m in Regex.Matches(message, ".{1,180}") select m.Value).ToArray(); int lines = groups.Length + 1; if (button != typeMessage.Dialog) { height += ((int)(size.Height + 0) * lines) + 44; } } //if (message.Length < 50) //{ // if ((int)size.Width > 350) // { // width = (int)size.Width; // } //} //else //{ // string[] groups = (from Match m in Regex.Matches(message, ".{1,180}") select m.Value).ToArray(); // int lines = groups.Length + 1; // if ((int)size.Width <= 1000) // { // width = ((int)size.Width > 900 ? 800 : (int)size.Width); // } // else // { // width = 1200; // } // height += (int)(size.Height + 0) * lines; //} return(new Size(width, height)); }