Exemplo n.º 1
0
 public NewSrcpServer(ServerConnection connection) : this(connection, connection.Started)
 {
 }
Exemplo n.º 2
0
        static string GetProtocolIntern(ServerConnection connection, string protocol, int address, int steps)
        {
            string protocolIntern = protocol;

            if (connection.SrcpVersion >= ServerConnection.Version8)
            {
                if (protocol == "M 4")
                {
                    protocolIntern = "M 2";
                }
            }
            else
            {
                if (protocol == "P")
                {
                    protocolIntern = "PS";
                }
                else
                {
                    protocolIntern = protocol.Replace(" ", "");
                    if (protocolIntern.StartsWith("M"))
                    {
                        if (protocolIntern.EndsWith("2") || protocolIntern.EndsWith("4"))
                        {
                            if (steps == 27)
                            {
                                protocolIntern = "M5";
                            }
                            else if (steps == 28)
                            {
                                protocolIntern = "M3";
                            }
                            else if (steps == 14 && address > 80)
                            {
                                protocolIntern = "M4";
                            }
                        }
                    }
                    if (protocolIntern.StartsWith("N"))
                    {
                        if (protocolIntern.EndsWith("1"))
                        {
                            if (steps > 28)
                            {
                                protocolIntern = "N2";
                            }
                        }
                        if (protocolIntern.EndsWith("2"))
                        {
                            if (steps > 28)
                            {
                                protocolIntern = "N4";
                            }
                            else
                            {
                                protocolIntern = "N3";
                            }
                        }
                    }
                }
            }
            return(protocolIntern);
        }
Exemplo n.º 3
0
        private void buttonOk_Click(object sender, System.EventArgs e)
        {
            Control control = null;

            try
            {
                control = textBoxName;
                string name = textBoxName.Text;
                if (name == "")
                {
                    throw new LocalizedException("EnterAName");
                }

                if (ServerConnection.ServerConnections.Contains(name))
                {
                    if (DialogResult.No == MessageBox.Show(this, LocalizedString.Format("NameAlreadyExist", name), null, MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    {
                        textBoxName.Focus();
                        return;
                    }
                }
                control = textBoxServer;
                string server = textBoxServer.Text;
                if (server == "")
                {
                    throw new LocalizedException("EnterAServer");
                }

                control = textBoxPort;
                int port;
                try
                {
                    port = int.Parse(textBoxPort.Text);
                    if (port < 1 || port > 65535)
                    {
                        throw new LocalizedException("PortMustBetween1And65535");
                    }
                }
                catch
                {
                    throw new LocalizedException("PortMustBetween1And65535");
                }
                control = textBoxSrcpServerPath;
                string srcpServerPath = string.Empty;
                if (checkBoxAutoStartSRCPServer.Checked)
                {
                    srcpServerPath = textBoxSrcpServerPath.Text;
                    if (srcpServerPath == "")
                    {
                        throw new LocalizedException("EnterLocalPathToSRCPServer");
                    }

                    if (!File.Exists(srcpServerPath))
                    {
                        throw new LocalizedException("SRCPServerDoesNotExist", srcpServerPath);
                    }
                }

                control = null;
                if (Connection != null)
                {
                    ServerConnection.ServerConnections.Remove(Connection.Name);
                }

                Connection = new ServerConnection(name, server, port, checkBoxAutoStartSRCPServer.Checked, checkBoxAutostopSRCPServer.Checked, srcpServerPath, start);

                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                if (control != null)
                {
                    control.Focus();
                }
                LocalizedException.ShowMessage(this, ex);
                return;
            }
        }
Exemplo n.º 4
0
 public SrcpGenericLoc(ServerConnection connection) : base(connection)
 {
 }