コード例 #1
0
 public bool CreateEmptyFileWithType(Type tt)
 {
     ViewableFile vv = new ViewableFile(new EFEDiskFile(), tt, true);
     ViewedFiles.Add(vv);
     vv.DialogClosing += new ViewableFile.DialogClosingEventHandler(v_DialogClosing);
     vv.ShowDialog(Application.OpenForms[0]);
     foreach (var v in ViewedFiles)
     {
         if (vv != v && v.Dialog is IUseOtherFiles) ((IUseOtherFiles)v.Dialog).FileOpened(vv);
     }
     return true;
 }
コード例 #2
0
        public bool OpenFile(EFEFile File, EFEFile Parent = null)
        {
            foreach (var v in ViewedFiles)
            {
                if (v.File.Equals(File))
                {
                    MessageBox.Show("This file has already been opened!");
                    ((Form1)Application.OpenForms[0]).BringMDIWindowToFront(v.Dialog);
                    return false;
                }
            }
            Type[] formats = GetPossibleFormats(File);
            if (formats.Length == 0) return false;
            List<Type> Viewables = new List<Type>();
            foreach (Type t in formats)
            {
                if (t.GetInterfaces().Contains(typeof(IViewable))) Viewables.Add(t);
            }
            Type tt;
            if (Viewables.Count == 0) return false;
            else if (Viewables.Count == 1) tt = Viewables[0];
            else
            {
                MessageBox.Show("Multiple types match!");
                return false;
            }

            ViewableFile vv = new ViewableFile(File, tt);
            ViewedFiles.Add(vv);
            vv.DialogClosing += new ViewableFile.DialogClosingEventHandler(v_DialogClosing);
            vv.ShowDialog(Application.OpenForms[0]);
            if (Parent != null)
            {
                File.Parent = Parent;
                Parent.Children.Add(File);
            }

            foreach (var v in ViewedFiles)
            {
                if (vv != v && v.Dialog is IUseOtherFiles) ((IUseOtherFiles)v.Dialog).FileOpened(vv);
            }
            return true;
        }