예제 #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            RecipeManagerData data = null;

            if (!File.Exists($@"{filePath}"))
            {
                DialogResult res = MessageBox.Show($"File '{filePath}' was not found. Would you like to load data from different location?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (res == DialogResult.Yes)
                {
                    OpenFileDialog openFile = new OpenFileDialog();
                    openFile.Filter      = "Xml (*.dat)|*.dat|All Files (*.*)|*.*";
                    openFile.FilterIndex = 1;
                    if (openFile.ShowDialog() == DialogResult.OK)
                    {
                        filePath = openFile.FileName;
                        data     = RecipeDataManager.LoadData(filePath);
                    }
                }
            }
            else
            {
                data = RecipeDataManager.LoadData(filePath);
            }

            _storage.SetData(data);
        }
예제 #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            RecipeManagerData data = null;

            if (!File.Exists($@"{filePath}"))
            {
                DialogResult res = MessageBox.Show($"Файл '{filePath}' не найден. Возможно файл поменял своё расположение?", "Подтверждение", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (res == DialogResult.Yes)
                {
                    OpenFileDialog openFile = new OpenFileDialog();
                    openFile.Filter      = "Xml (*.dat)|*.dat|All Files (*.*)|*.*";
                    openFile.FilterIndex = 1;
                    if (openFile.ShowDialog() == DialogResult.OK)
                    {
                        filePath = openFile.FileName;
                        data     = RecipeDataManager.LoadData(filePath);
                    }
                }
            }
            else
            {
                data = RecipeDataManager.LoadData(filePath);
            }

            _storage.SetData(data);
        }