예제 #1
0
        public ExifToolResponse SetExifInto(string path, Dictionary <string, string> data, bool overwriteOriginal = true)
        {
            // Check the arguments for null
            if (data == null)
            {
                // this should not happen
                TracePrint.PrintStackTrace(1);
                // throw new ArgumentNullException(nameof(data));
                // try this to indicate the failure case
                return(new ExifToolResponse(false, "data dictionary is null"));
            }

            if (!File.Exists(path))
            {
                return(new ExifToolResponse(false, $"'{path}' not found"));
            }

            var cmd = new StringBuilder();

            foreach (KeyValuePair <string, string> kv in data)
            {
                cmd.AppendFormat("-{0}={1}\n", kv.Key, kv.Value);
            }

            if (overwriteOriginal)
            {
                cmd.Append("-overwrite_original\n");
            }

            cmd.Append(path);
            var cmdRes = this.SendCommand(cmd.ToString());

            //if failed return as it is, if it's success must check the response
            return(cmdRes ? new ExifToolResponse(cmdRes.Result) : cmdRes);
        }
예제 #2
0
        public DataEntryChoice(ControlRow control, DataEntryControls styleProvider)
            : base(control, styleProvider, ControlContentStyleEnum.ChoiceComboBox, ControlLabelStyleEnum.DefaultLabel)
        {
            // The behaviour of the combo box
            this.ContentControl.Focusable           = true;
            this.ContentControl.IsEditable          = false;
            this.ContentControl.IsTextSearchEnabled = true;

            // Callback used to allow Enter to select the highlit item
            this.ContentControl.PreviewKeyDown += this.ContentCtl_PreviewKeyDown;

            // Add items to the combo box. If we have an  EmptyChoiceItem, then  add an 'empty string' to the end
            // Check the arguments for null
            List <string> choiceList;
            bool          includesEmptyChoice;

            if (control == null)
            {
                // this should not happen
                TracePrint.PrintStackTrace(1);
                choiceList          = new List <string>();
                includesEmptyChoice = true;
            }
            else
            {
                choiceList = control.GetChoices(out includesEmptyChoice);
            }
            ComboBoxItem cbi;

            foreach (string choice in choiceList)
            {
                cbi = new ComboBoxItem()
                {
                    Content = choice
                };
                this.ContentControl.Items.Add(cbi);
            }
            if (includesEmptyChoice)
            {
                // put empty choice at the beginning of the control below a separator for visual clarity
                cbi = new ComboBoxItem()
                {
                    Content = String.Empty
                };
                this.ContentControl.Items.Insert(0, cbi);
            }
            // We include an invisible ellipsis menu item. This allows us to display an ellipsis in the combo box text field
            // when multiple images with different values are selected
            cbi = new ComboBoxItem()
            {
                Content = Constant.Unicode.Ellipsis
            };
            this.ContentControl.Items.Insert(0, cbi);
            ((ComboBoxItem)this.ContentControl.Items[0]).Visibility = System.Windows.Visibility.Collapsed;
            this.ContentControl.SelectedIndex = 1;
        }
        // Get the root folder name from the database, and check to see if its the same as the actual root folder.
        // If not, ask the user if he/she wants to update the database.
        private void CheckAndCorrectRootFolder(FileDatabase fileDatabase)
        {
            // Check the arguments for null
            if (fileDatabase == null)
            {
                // this should not happen
                // System.Diagnostics.Debug.Print("The fielDatabase was null and it shouldn't be");
                TracePrint.PrintStackTrace(1);
                // No-op
                return;
            }
            List <object> allRootFolderPaths = fileDatabase.GetDistinctValuesInColumn(Constant.DBTables.FileData, Constant.DatabaseColumn.Folder);

            if (allRootFolderPaths.Count < 1)
            {
                // System.Diagnostics.Debug.Print("Checking the root folder name in the database, but no entries were found. Perhaps the database is empty?");
                return;
            }

            // retrieve and compare the db and actual root folder path names. While there really should be only one entry in the allRootFolderPaths,
            // we still do a check in case there is more than one. If even one entry doesn't match, we use that entry to ask the user if he/she
            // wants to update the root folder to match the actual location of the root folder containing the template, data and image files.
            string actualRootFolderName = fileDatabase.FolderPath.Split(Path.DirectorySeparatorChar).Last();

            foreach (string databaseRootFolderName in allRootFolderPaths)
            {
                if (databaseRootFolderName.Equals(actualRootFolderName))
                {
                    continue;
                }
                else
                {
                    // We have at least one entry where there is a mismatch between the actual root folder and the stored root folder
                    // Consequently, ask the user if he/she wants to update the db entry
                    Dialog.UpdateRootFolder renameRootFolderDialog;
                    renameRootFolderDialog = new Dialog.UpdateRootFolder(this, databaseRootFolderName, actualRootFolderName);
                    bool?result = renameRootFolderDialog.ShowDialog();
                    if (result == true)
                    {
                        ColumnTuple columnToUpdate = new ColumnTuple(Constant.DatabaseColumn.Folder, actualRootFolderName);
                        fileDatabase.UpdateFiles(columnToUpdate);
                    }
                    return;
                }
            }
        }
예제 #4
0
        public ExifToolResponse(string response)
        {
            // Check the arguments for null
            if (response == null)
            {
                // this should not happen
                TracePrint.PrintStackTrace(1);
                // throw new ArgumentNullException(nameof(response));
                // Treat it as a failure case?
                this.IsSuccess = false;
                this.Result    = String.Empty;
                return;
            }

            this.IsSuccess = response.ToLowerInvariant().Contains(ExifToolWrapper.SuccessMessage);
            this.Result    = response;
        }
예제 #5
0
        // Transform the XML string (stored in the ImageSetTable) into a QuickPasteEntries data structure
        // Compare it to the actual controls, and alter the data structure if needed
        public static List <QuickPasteEntry> QuickPasteEntriesFromXML(FileDatabase fileDatabase, string xml)
        {
            List <QuickPasteEntry> quickPasteEntries = new List <QuickPasteEntry>();

            // Check the arguments for null
            if (fileDatabase == null)
            {
                // this should not happen
                TracePrint.PrintStackTrace(1);
                return(quickPasteEntries);
                // Not sure if the above return is effective. We could do the following instead
                // throw new ArgumentNullException(nameof(fileDatabase));
            }

            XDocument xDocument = XDocument.Parse(xml);

            IEnumerable entries =
                from r in xDocument.Descendants("Entry")
                select new QuickPasteEntry
            {
                Title = (string)r.Element("Title"),
                Items = (from v in r.Elements("Item")
                         select new QuickPasteItem
                {
                    DataLabel = (string)v.Element("DataLabel"),
                    Label = (string)v.Element("Label"),
                    Value = (string)v.Element("Value"),
                    Use = (bool)v.Element("Use"),
                    ControlType = (string)v.Element("ControlType")
                }).ToList()
            };


            foreach (QuickPasteEntry quickPasteEntry in entries)
            {
                quickPasteEntries.Add(quickPasteEntry);
            }
            quickPasteEntries = CheckAndSyncQuickPasteItemIfNeeded(fileDatabase, quickPasteEntries);
            return(quickPasteEntries);
        }
        public void LayoutAnchorable_PropertyChanging(object sender, System.ComponentModel.PropertyChangingEventArgs e)
        {
            // Check the arguments for null
            if (sender == null || e == null)
            {
                // this should not happen
                TracePrint.PrintStackTrace(1);
                // throw new ArgumentNullException(nameof(sender));
                // Try treating this as a no-op instead of a throw
                return;
            }

            LayoutAnchorable la = sender as LayoutAnchorable;

            if (la.ContentId == "ContentIDDataEntryControlPanel" && (e.PropertyName == Constant.AvalonDockValues.FloatingWindowFloatingHeightProperty || e.PropertyName == Constant.AvalonDockValues.FloatingWindowFloatingWidthProperty))
            {
                this.DockingManager_FloatingDataEntryWindowLimitSize();
            }
            // SAULXXX NOT SURE WHY I ADDED THIS HERE< BUT IT SEEMS TO HIDE THE FINDBOX WHEN THE USER FIRST INVOKES IT
            // IF IT BEHAVES OK< DELETE THIS COMMENTED OUT LINE
            // this.FindBoxSetVisibility(false);
        }