Ejemplo n.º 1
0
        public void OpenFile(string filePath)
        {
            // Create a new instance of the child form.
            DataForm childForm = new DataForm();
            // Make it a child of this MDI form before showing it.
            childForm.MdiParent = this;
            childForm.Disposed += new EventHandler(childForm_Disposed);
            childFormNumber++;
            bool success = childForm.OpenFile(filePath);
            if (success)
            {
                if (this.childFormNumber == 1)
                    this.welcomeScreen.Hide();
                childForm.Show();
                childForm.WindowState = FormWindowState.Maximized;

                //add to recent items
                if (this.recentItem.Contains(childForm.FilePath))
                {
                    this.recentItem.RemoveAt(this.recentItem.IndexOf(childForm.FilePath));
                    this.recentItem.Add(childForm.FilePath);
                }
                else
                {
                    if (this.recentItem.Count == 10) this.recentItem.RemoveAt(0);
                    this.recentItem.Add(childForm.FilePath);
                }
                welcomeScreen.UpdateRecentItem();
                this.writeRecentListFile();
            }
            else
            {
                childForm.Dispose();
            }
        }
Ejemplo n.º 2
0
        private void ShowNewForm(object sender, EventArgs e)
        {
            // Create a new instance of the child form.
            DataForm childForm = new DataForm();
            // Make it a child of this MDI form before showing it.
            childForm.MdiParent = this;
            childForm.Disposed += new EventHandler(childForm_Disposed);
            childForm.saveAsEvent += new SaveAsEventHandler(childForm_saveAsEvent);
            childFormNumber++;
            bool success = childForm.CrateNewData();
            if (success)
            {
                if (this.childFormNumber == 1)
                    this.welcomeScreen.Hide();

                childForm.Show();
                childForm.WindowState = FormWindowState.Maximized;

            }
            else
            {
                childForm.Dispose();
            }
        }