コード例 #1
0
        private void SaveSchema_Click(object sender, EventArgs e)
        {
            SaveFileDialog SaveDialog = new SaveFileDialog();

            SaveDialog.Filter      = "Designer (*.bd)|*.bd";
            SaveDialog.FilterIndex = 1;
            if (SaveDialog.ShowDialog() == DialogResult.OK)
            {
                FileStream      fStream    = File.Open(SaveDialog.FileName, FileMode.Create);
                BinaryFormatter bFormatter = new BinaryFormatter();
                AllDataToSave   data       = new AllDataToSave(projectElements, MaxHeight, MaxWidth);
                bFormatter.Serialize(fStream, data);
                fStream.Close();
                if (CultureInfo.CurrentUICulture.Name == "pl-PL")
                {
                    MessageBox.Show("Zapisano pomyślnie");
                }
                else
                {
                    MessageBox.Show("Save succesful");
                }
            }
            else
            {
                if (CultureInfo.CurrentUICulture.Name == "pl-PL")
                {
                    MessageBox.Show("Coś poszło nie tak");
                }
                else
                {
                    MessageBox.Show("It's something incorrect");
                }
            }
        }
コード例 #2
0
        private void OpenSchema_Click(object sender, EventArgs e)
        {
            OpenFileDialog SaveDialog = new OpenFileDialog();

            SaveDialog.Filter      = "Designer (*.bd)|*.bd";
            SaveDialog.FilterIndex = 1;
            if (SaveDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    FileStream      fStream    = File.Open(SaveDialog.FileName, FileMode.Open);
                    BinaryFormatter bFormatter = new BinaryFormatter();
                    AllDataToSave   dataToSave = bFormatter.Deserialize(fStream) as AllDataToSave;
                    projectElements = dataToSave.projectElements;
                    MaxHeight       = dataToSave.MaxHeight;
                    MaxWidth        = dataToSave.MaxWidth;
                    fStream.Close();
                    if (CultureInfo.CurrentUICulture.Name == "pl-PL")
                    {
                        MessageBox.Show("Otwarto pomyślnie");
                    }
                    else
                    {
                        MessageBox.Show("Open succesful");
                    }
                    Selected_Element = null;
                    RedrawBitmap();
                    Bitmapa.Refresh();
                }
                catch
                {
                    if (CultureInfo.CurrentUICulture.Name == "pl-PL")
                    {
                        MessageBox.Show("Coś poszło nie tak");
                    }
                    else
                    {
                        MessageBox.Show("It's something incorrect");
                    }
                }
            }
        }