Exemplo n.º 1
0
        //------------------------------[Constructor]------------------------------

        /// <summary>Constructs a mainform with the specified title for a SwitchboardServer with the specified configuration</summary>
        /// <param name="MainFormTitle">Title of this window</param>
        /// <param name="icon">Icon of this form</param>
        /// <param name="Config">Configuration of the SwitchboardServer this window will run.</param>
        public MainForm(string MainFormTitle, System.Drawing.Icon icon, SwitchboardConfiguration Config)
        {
            InitializeComponent();
            Text            = MainFormTitle;
            Icon            = icon;
            TitleLabel.Text = MainFormTitle;
            ConnectionDetailsButton.Enabled = false;
            DisconnectButton.Enabled        = false;

            this.Config = Config;

            ConnectionsListView.Items.Clear();
            ConnectionsListView.Enabled       = false;
            ConnectionsListView.FullRowSelect = true;
            ConnectionsListView.MultiSelect   = false;
        }
Exemplo n.º 2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            SwitchboardConfiguration Config = new SwitchboardConfiguration {
                ServerName            = "LBL+ Server",
                ServerVersion         = "1.0",
                DefaultIP             = "127.0.0.1",
                DefaultPort           = 909,
                AllowAnonymousDefault = true,
                MultiLoginDefault     = true,
                DefaultWelcome        = "Bonjour. Welcome to the server.",
                ServerExtensions      = GetExtensions
            };

            Launcher.Launch("LBL+ Server", Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location), Config);
        }
Exemplo n.º 3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //Most of these values are the default ones within the configuration class itself, but they're here to show u what u can modify.
            SwitchboardConfiguration ExampleConfig = new SwitchboardConfiguration {
                ServerName            = "Colloquor Server",
                ServerVersion         = "2.0",
                DefaultIP             = "127.0.0.1",
                DefaultPort           = 909,
                AllowAnonymousDefault = true,
                MultiLoginDefault     = true,
                DefaultWelcome        = "Bonjour. Welcome to the server.",
                ServerExtensions      = GetExtensions
            };

            //                                 [This huge bit of thing gets the icon from the program you're running it from for consistency]
            Launcher.Launch("Colloquor Server", Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location), ExampleConfig);
        }
Exemplo n.º 4
0
        //------------------------------[Constructor]------------------------------

        public ServerSettingsForm(ref SwitchboardConfiguration Config)
        {
            InitializeComponent();

            this.Config = Config;

            UsersListview.Items.Clear();
            ExtensionsListview.Items.Clear();

            UsersListview.FullRowSelect      = true;
            UsersListview.MultiSelect        = false;
            ExtensionsListview.FullRowSelect = true;
            ExtensionsListview.MultiSelect   = false;

            //Load Main Settings from SwitchboardServer.cfg
            if (!File.Exists("SwitchboardServer.cfg"))
            {
                //Show a brief little welcome message!
                MessageBox.Show("Welcome to Switchboard! We'll just put the default configuration values here, and then you can be on your way. \n\n Thanks for using Switchboard", "Welcome!", MessageBoxButtons.OK, MessageBoxIcon.Information);

                //Get the default values
                LoadDefault();
            }
            else
            {
                try {
                    string[] Settings = File.ReadAllLines("SwitchboardServer.cfg")[0].Split(':');
                    IPTextbox.Text             = Settings[0];
                    PortTextbox.Text           = Settings[1];
                    AnonymousCheckbox.Checked  = bool.Parse(Settings[2]);
                    MultiLoginCheckbox.Checked = bool.Parse(Settings[3]);
                } catch (Exception e) {
                    MessageBox.Show("There was a problem interpretting your config file. Default values were loaded instead. \n\n" + e.Message + "\n" + e.StackTrace, "oopsie", MessageBoxButtons.OK, MessageBoxIcon.Error);;
                    LoadDefault();
                }
            }

            //Load Users the same way the server does.
            Users = new List <SwitchboardUser>();
            if (File.Exists("SwitchboardUsers.txt"))
            {
                //Read all lines from the file
                string[] UserStrings = File.ReadAllLines("SwitchboardUsers.txt");

                //For each userstring, add a new user
                foreach (string UserString in UserStrings)
                {
                    Users.Add(new ManageableUser(UserString));
                }

                UpdateUserListView();
            }

            //Load extensions and display them.
            Extensions = Config.ServerExtensions();
            foreach (SwitchboardExtension extension in Extensions)
            {
                ListViewItem NLI = new ListViewItem(extension.GetName());
                NLI.SubItems.Add(extension.GetVersion());
                ExtensionsListview.Items.Add(NLI);
            }

            //Load Welcome.txt
            if (File.Exists("Welcome.txt"))
            {
                WelcomeBox.Text = File.ReadAllText("Welcome.txt");
            }
            else
            {
                WelcomeBox.Text = Config.DefaultWelcome;
            }
        }