Example #1
0
        private void ReadUISettingsFrom(Stream s)
        {
            BinaryReader bR = new BinaryReader(s);

            byte version = bR.ReadByte();

            switch (version) //version
            {
            case 1:
            case 2:
                //form location
                this.Location = new Point(bR.ReadInt32(), bR.ReadInt32());

                //form size
                this.Size = new Size(bR.ReadInt32(), bR.ReadInt32());

                //form maximized
                if (Convert.ToBoolean(bR.ReadByte()))
                {
                    this.WindowState = FormWindowState.Maximized;
                }

                //form main container splitter position
                if (version > 1)
                {
                    mainContainer.SplitterDistance = mainContainer.Width - bR.ReadInt32();
                }

                //first chat panel settings
                if (Convert.ToBoolean(bR.ReadByte()))
                {
                    foreach (Control ctrl in mainContainer.Panel2.Controls)
                    {
                        MeshNetworkPanel panel = ctrl as MeshNetworkPanel;

                        if (panel != null)
                        {
                            panel.ReadSettingsFrom(bR);
                            break;
                        }
                    }
                }
                break;

            default:
                throw new Exception("Settings format version not supported.");
            }
        }
Example #2
0
        private void chatPanel_SettingsModified(object sender, EventArgs e)
        {
            MeshNetworkPanel senderPanel = sender as MeshNetworkPanel;

            using (MemoryStream mS = new MemoryStream())
            {
                senderPanel.WriteSettingsTo(mS);

                foreach (Control ctrl in mainContainer.Panel2.Controls)
                {
                    MeshNetworkPanel panel = ctrl as MeshNetworkPanel;

                    if ((panel != null) && !panel.Equals(sender))
                    {
                        mS.Position = 0;
                        panel.ReadSettingsFrom(mS);
                    }
                }
            }
        }