コード例 #1
0
        private bool SaveToPicture(PictureMetaData pic, bool commit)
        {
            // todo: die worker und modelle können mehrfach verwendet werden!
            IptcWorker    iptcWorker    = new IptcWorker();
            ExifGpsWorker exifGpsWorker = new ExifGpsWorker();

            IptcModel    iptcModel    = iptcView.GetModel();
            ExifGpsModel exifGpsModel = exifGpsView.GetModel();

            bool somethingChanged = false;

            if (iptcWorker.ProcessFile(pic, iptcModel))
            {
                somethingChanged = true;
            }
            if (exifGpsWorker.ProcessFile(pic, exifGpsModel))
            {
                somethingChanged = true;
            }

            if (iptcModel.PendingUpdates)
            {
                iptcModel.UpdateSettings();
            }

            if (somethingChanged && commit)
            {
                if (!pic.SaveChanges())
                {
                    return(this.ShowFileVanishedMsg(pic.Filename));
                }
            }

            return(true);
        }
コード例 #2
0
        public override void SetModel(IptcModel m)
        {
            this.BeginUpdate();

            base.SetModel(m);

            suspendChechBoxUpdate         = true;
            this.bindingSource.DataSource = this.model;
            suspendChechBoxUpdate         = false;

            FillKeywordTree();

            this.EndUpdate();
        }
コード例 #3
0
        public void SaveToAll_Click(object sender, EventArgs e)
        {
            if (saveToAllWorker.IsBusy)
            {
                return;
            }

            IptcModel model = iptcView.GetModel();

            if (model.KeywordChecked)
            {
                if (model.KeywordsChecked.Count != 0 || model.KeywordsUnchecked.Count != 0)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("You are going to change the keywords of ALL selected files!");
                    sb.AppendLine();
                    if (model.KeywordsChecked.Count != 0)
                    {
                        string checkedKeywords = String.Join(", ", model.KeywordsChecked.ToArray());
                        sb.Append("Adding ");
                        sb.AppendLine(checkedKeywords);
                    }
                    if (model.KeywordsUnchecked.Count != 0)
                    {
                        string uncheckedKeywords = String.Join(", ", model.KeywordsUnchecked.ToArray());
                        sb.Append("Removing ");
                        sb.AppendLine(uncheckedKeywords);
                    }
                    sb.AppendLine();
                    sb.Append("Are you sure?");

                    if (MessageBox.Show(sb.ToString(), mainForm.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                }
            }

            PauseOtherWorker();

            List <string> filenames = this.GetAllFileList(this.processFilesInSubdirectories);

            saveToAllWorker.RunWorkerAsync(filenames);
        }
コード例 #4
0
        public override RequestFileChangeResult RequestFileChange()
        {
            if (!askForFileSave)
            {
                return(RequestFileChangeResult.Close);
            }
            if (this.currentPicture == null)
            {
                return(RequestFileChangeResult.Close);
            }
            if (!this.currentPicture.ExistFile)
            {
                return(RequestFileChangeResult.Close);
            }
            IptcModel    iptcModel    = iptcView.GetModel();
            ExifGpsModel exifGpsModel = exifGpsView.GetModel();

            if (!iptcModel.PendingUpdates && !exifGpsModel.PendingUpdates)
            {
                return(RequestFileChangeResult.Close);
            }
            if (!isDataLoaded)
            {
                return(RequestFileChangeResult.Close);
            }

            DialogResult r = MessageBox.Show("Save changes to this picture?", "Iptc and Gps Editor", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (r == DialogResult.Cancel)
            {
                return(RequestFileChangeResult.DoNotClose);
            }

            if (r == DialogResult.Yes)
            {
                mainForm.WaitCursor(true);
                SaveToPicture(currentPicture, false);
                mainForm.WaitCursor(false);
                return(RequestFileChangeResult.CloseAndSave);
            }

            askForFileSave = false;
            return(RequestFileChangeResult.Close);
        }