コード例 #1
0
        public static void Serialize(ProgramParam data, string FileName)
        {
            FileStream fs = new FileStream(FileName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
            BinaryFormatter bf = new BinaryFormatter();

            //сериализация
            bf.Serialize(fs, data);
            fs.Close();
        }
コード例 #2
0
        private void MainWindow_FormClosed(object sender, FormClosedEventArgs e)
        {
            ProgramParam param = new ProgramParam();

            // восстановление состояния графика
            param.DrawItemText = gantChart1.DrawItemText;

            param.TaskColorFill = gantChart1.TaskColorFill;
            param.TaskColorFillOrder = gantChart1.TaskColorFillOrder;
            param.TaskColorPerimeter = gantChart1.TaskColorPerimeter;
            param.TaskColorFillAlert = gantChart1.TaskColorFillAlert;
            param.ConfColor1 = gantChart1.ConfColor1;
            param.ConfColor2 = gantChart1.ConfColor2;
            param.ServColor1 = gantChart1.ServColor1;
            param.ServColor2 = gantChart1.ServColor2;

            param.TaskColorFillShadow = gantChart1.TaskColorFillShadow;
            param.TaskColorFillOrderShadow = gantChart1.TaskColorFillOrderShadow;
            param.ConfColor1Shadow = gantChart1.ConfColor1Shadow;
            param.ConfColor2Shadow = gantChart1.ConfColor2Shadow;
            param.ServColor1Shadow = gantChart1.ServColor1Shadow;
            param.ServColor2Shadow = gantChart1.ServColor2Shadow;
            param.AllPerimeterColorShadow = gantChart1.AllPerimeterColorShadow;

            // восстановление состояния окна
            if (this.WindowState == FormWindowState.Normal)
            {
                param.LastWindowWidth = this.Width;
                param.LastWindowHeight = this.Height;
                param.LastWindowPosX = this.Left;
                param.LastWindowPosY = this.Top;
            }
            else
            {
                param.LastWindowWidth = -1;
                param.LastWindowHeight = -1;
                param.LastWindowPosX = -1;
                param.LastWindowPosY = -1;
            }
            param.FormSate = this.WindowState;
            ProgramParamSerializer.Serialize(param, ProgramConfigPath);
        }
コード例 #3
0
 public static void Deserialize(out ProgramParam data, string FileName)
 {
     FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read);
     BinaryFormatter bf = new BinaryFormatter();
     data = (ProgramParam)bf.Deserialize(fs);
     fs.Close();
 }