示例#1
0
        public SauceInfoDialog(EtoFileInfo file, Document document, bool readOnly = false, bool directSave = true)
        {
            this.directSave = directSave;
            this.file       = file;
            this.document   = document;
            //DisplayMode = DialogDisplayMode.Attached;
            MinimumSize = new Size(400, 500);
            if (file == null && document == null)
            {
                throw new ArgumentException("Must specify either file or document argument");
            }
            Resizable = true;
            Title     = "Sauce Metadata";

            allowRemove = !readOnly;
            allowSave   = !readOnly;
            if (document != null)
            {
                if (document.Sauce != null)
                {
                    sauce = new SauceInfo(document.Sauce);
                }
            }
            else if (file != null)
            {
                using (var stream = file.OpenRead())
                {
                    sauce = SauceInfo.GetSauce(stream);
                }
                if (file.ReadOnly)
                {
                    allowRemove = false;
                    allowSave   = false;
                }
            }

            if (sauce == null)
            {
                sauce = new SauceInfo();
                if (document != null)
                {
                    document.FillSauce(sauce, document.LoadedFormat);
                }
                allowRemove = false;
            }

            CreateControls();
            UpdateDataType();
        }
示例#2
0
        public bool LoadFile(EtoFileInfo file)
        {
            //if (FileModifiedDialog.Show(this) != DialogResult.Ok) return true;

            Format format = Settings.Infos.FindFormat(file.Name, "character", "ansi");

            if (format != null)
            {
                try
                {
                    var stream = file.OpenRead();
                    this.LoadFile(file.FullName, stream, format);
                    //this.FileList.Initialize(fileName);
                }
                catch (Exception e)
                {
                    MessageBox.Show(Generator, this, string.Format("Unable to load the selected file ({0})", e.ToString()));
                    Console.WriteLine(e.ToString());
                }
                return(true);
            }
            return(false);
        }