Exemplo n.º 1
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);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void WriteUISettingsTo(Stream s)
        {
            BinaryWriter bW = new BinaryWriter(s);

            bW.Write((byte)2); //version

            //form location
            bW.Write(this.Location.X);
            bW.Write(this.Location.Y);

            //form size
            bool maximized = this.WindowState == FormWindowState.Maximized;
            Size size;

            if (maximized)
            {
                size = new Size(960, 540);
            }
            else
            {
                size = this.Size;
            }

            bW.Write(size.Width);
            bW.Write(size.Height);

            //form maximized
            if (maximized)
            {
                bW.Write((byte)1);
            }
            else
            {
                bW.Write((byte)0);
            }

            //form main container splitter position
            bW.Write(mainContainer.Width - mainContainer.SplitterDistance);


            //write first chat panel settings
            bool panelFound = false;

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

                if (panel != null)
                {
                    bW.Write((byte)1);
                    panel.WriteSettingsTo(bW);

                    panelFound = true;
                    break;
                }
            }

            if (!panelFound)
            {
                bW.Write((byte)0);
            }
        }