Beispiel #1
0
        private void packForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult res      = DialogResult.Yes;
            var          packForm = (PackForm)sender;

            if (packForm.IsNew || packForm.IsNeedSave)
            {
                string message = String.Format("Save pack \"{0}\"?", Path.GetFileNameWithoutExtension(packForm.Text));
                res = DialogUtility.ShowConfirm(true, message);

                if (res == DialogResult.Yes && !SaveCurrentPack(false))
                {
                    res = DialogResult.Cancel;
                }
            }

            e.Cancel = (res == DialogResult.Cancel);
        }
Beispiel #2
0
        private void miNavigationNext_Click(object sender, System.EventArgs e)
        {
            var packForm = GetActivePack();

            if (ActiveMdiChild != null)
            {
                if (packForm.NextLevel())
                {
                    UpdateLevelIndex();
                }
                else
                {
                    DialogResult res = DialogUtility.ShowConfirm(true, "Current level is the last. Add new level?");

                    if (res == DialogResult.Yes)
                    {
                        miLevelsAdd_Click(sender, e);
                    }
                }
            }
        }
Beispiel #3
0
        private void OpenPack(string fileName, bool isShowDialog)
        {
            string formCaption = null;

            if (isShowDialog)
            {
                openPackDialog.InitialDirectory = _lastDirectory;

                if (openPackDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                fileName = openPackDialog.FileName;
                AddRecentPack(fileName);

                _lastDirectory = Path.GetDirectoryName(openPackDialog.FileName);
            }
            else if (!fileName.IsNullOrWhiteSpace())
            {
                if (!File.Exists(fileName))
                {
                    return;
                }

                var frmOpened = MdiChildren.FirstOrDefault(frm => frm.Text == fileName);
                if (frmOpened != null)
                {
                    frmOpened.Activate();
                    if (DialogUtility.ShowConfirm(true, "File is already opened, do you want to reopen it?") == DialogResult.Yes)
                    {
                        frmOpened.Close();

                        // проверяем, закрылось ли (могли предложить сохранить и закрытия не произошло)
                        if (MdiChildren.Contains(frmOpened))
                        {
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }
            else
            {
                int index = MdiChildren.Length;
                do
                {
                    formCaption = String.Format("Noname{0}", ++index);
                } while (MdiChildren.Any(frm => frm.Text == formCaption));
            }

            try
            {
                var packForm = new PackForm(_levelTemplatePath, fileName);

                packForm.MdiParent    = this;
                packForm.Activated   += packForm_Activated;
                packForm.FormClosing += packForm_FormClosing;
                packForm.Disposed    += packForm_Disposed;

                if (formCaption != null)
                {
                    packForm.Text = formCaption;
                }

                packForm.Show();
                UpdateFormState();
            }
            catch (Exception ex)
            {
                DialogUtility.ShowError("Error while opening pack: {0}", ex.Message);
            }
        }