Example #1
0
 // Need to
 //-disable the menu when nothing is in it
 //-handle overview
 //-put in edit menu
 private void MenuItemRestoreDefaultValues_Click(object sender, RoutedEventArgs e)
 {
     // Retrieve the controls
     foreach (KeyValuePair <string, DataEntryControl> pair in this.DataEntryControls.ControlsByDataLabel)
     {
         DataEntryControl control = pair.Value;
         if (control.DataLabel == Constant.DatabaseColumn.File || control.DataLabel == Constant.DatabaseColumn.Folder || control.DataLabel == Constant.DatabaseColumn.RelativePath ||
             control.DataLabel == Constant.DatabaseColumn.Date || control.DataLabel == Constant.DatabaseColumn.Time || control.DataLabel == Constant.DatabaseColumn.DateTime || control.DataLabel == Constant.DatabaseColumn.UtcOffset)
         {
             // Ignore stock controls
             continue;
         }
         ControlRow imageDatabaseControl = this.templateDatabase.GetControlFromTemplateTable(control.DataLabel);
         if (this.MarkableCanvas.ThumbnailGrid.IsVisible == false && this.MarkableCanvas.ThumbnailGrid.IsGridActive == false)
         {
             // Only a single image is displayed: update the database for the current row with the control's value
             this.DataHandler.FileDatabase.UpdateFile(this.DataHandler.ImageCache.Current.ID, control.DataLabel, imageDatabaseControl.DefaultValue);
             System.Diagnostics.Debug.Print(control.DataLabel + ":" + control.Content + ":" + imageDatabaseControl.DefaultValue);
         }
         else
         {
             // Multiple images are displayed: update the database for all selected rows with the control's value
             this.DataHandler.FileDatabase.UpdateFiles(this.MarkableCanvas.ThumbnailGrid.GetSelected(), control.DataLabel, imageDatabaseControl.DefaultValue);
         }
         control.SetContentAndTooltip(imageDatabaseControl.DefaultValue);
     }
 }
Example #2
0
 // Place highlighted previews of the values to be copied atop the copyable controls
 // e.g., if the mouse is over the CopyPrevious button and we are not on the first row
 private void CopyPreviousValueSetPreviewsAsNeeded(int previousRow)
 {
     if (this.IsDisplayingSingleImage() &&
         this.CopyPreviousValuesButton != null &&
         this.CopyPreviousValuesButton.IsEnabled == true &&
         this.CopyPreviousValuesButton.IsMouseOver &&
         previousRow >= 0)
     {
         // Show the previews on the copyable controls
         foreach (KeyValuePair <string, DataEntryControl> pair in this.DataEntryControls.ControlsByDataLabel)
         {
             DataEntryControl control = pair.Value;
             if (control.Copyable)
             {
                 string previewValue = this.DataHandler.FileDatabase.FileTable[previousRow].GetValueDisplayString(control.DataLabel);
                 control.ShowPreviewControlValue(previewValue);
             }
         }
     }
     else
     {
         // Remove the preview from each control
         foreach (KeyValuePair <string, DataEntryControl> pair in this.DataEntryControls.ControlsByDataLabel)
         {
             DataEntryControl control = pair.Value;
             if (control.Copyable)
             {
                 control.HidePreviewControlValue();
             }
         }
     }
 }
Example #3
0
        // Unhighlight the data controls affected by the Quickpaste entry
        private void QuickPasteDataControlsUnHighlight(QuickPasteEntry quickPasteEntry)
        {
            this.FilePlayer_Stop(); // In case the FilePlayer is going
            int row = this.DataHandler.ImageCache.CurrentRow;

            if (!this.DataHandler.FileDatabase.IsFileRowInRange(row))
            {
                return; // This shouldn't happen, but just in case...
            }

            foreach (QuickPasteItem item in quickPasteEntry.Items)
            {
                // If the item wasn't used, then it wasn't highlit.
                if (item.Use == false)
                {
                    continue;
                }

                // Find the data entry control that matches the quickPasteItem's DataLael
                foreach (KeyValuePair <string, DataEntryControl> pair in this.DataEntryControls.ControlsByDataLabel)
                {
                    DataEntryControl control = pair.Value;
                    if (control.DataLabel == item.DataLabel)
                    {
                        control.Container.ClearValue(Control.BackgroundProperty);
                        control.HidePreviewControlValue();
                        break;
                    }
                }
            }
        }
Example #4
0
        // Highlight the data controls affected by the Quickpaste entry
        private void QuickPasteDataControlsHighlight(QuickPasteEntry quickPasteEntry)
        {
            this.FilePlayer_Stop(); // In case the FilePlayer is going
            int row = this.DataHandler.ImageCache.CurrentRow;

            if (!this.DataHandler.FileDatabase.IsFileRowInRange(row))
            {
                return; // This shouldn't happen, but just in case...
            }

            foreach (QuickPasteItem item in quickPasteEntry.Items)
            {
                if (item.Use == false)
                {
                    continue;
                }

                // Find the data entry control that matches the quickPasteItem's DataLael
                foreach (KeyValuePair <string, DataEntryControl> pair in this.DataEntryControls.ControlsByDataLabel)
                {
                    DataEntryControl control = pair.Value;
                    if (control.DataLabel == item.DataLabel)
                    {
                        control.ShowPreviewControlValue(item.Value);
                    }
                }
            }
        }
 // Determine whether system-supplied fields should be skipped over or not.
 private bool IsControlIncludedInTabOrder(DataEntryControl control)
 {
     if (control.DataLabel == Constant.DatabaseColumn.DateTime && this.State.TabOrderIncludeDateTime == false)
     {
         return(false);
     }
     else if (control.DataLabel == Constant.DatabaseColumn.DeleteFlag && this.State.TabOrderIncludeDeleteFlag == false)
     {
         return(false);
     }
     else if (control.DataLabel == Constant.DatabaseColumn.ImageQuality && this.State.TabOrderIncludeImageQuality == false)
     {
         return(false);
     }
     return(true);
 }
Example #6
0
        // Quickpast the given entry into the data control
        private void QuickPasteEntryPasteIntoDataControls(QuickPasteEntry quickPasteEntry, FlashEnum flash)
        {
            this.FilePlayer_Stop(); // In case the FilePlayer is going
            int row = this.DataHandler.ImageCache.CurrentRow;

            if (!this.DataHandler.FileDatabase.IsFileRowInRange(row))
            {
                return; // This shouldn't happen, but just in case...
            }

            foreach (QuickPasteItem item in quickPasteEntry.Items)
            {
                if (item.Use == false)
                {
                    continue;
                }

                // Find the data entry control that matches the quickPasteItem's DataLabel
                foreach (KeyValuePair <string, DataEntryControl> pair in this.DataEntryControls.ControlsByDataLabel)
                {
                    DataEntryControl control = pair.Value;
                    if (control.DataLabel == item.DataLabel)
                    {
                        // Changing a counter value does not trigger a ValueChanged event if the values are the same.
                        // which means multiple images may not be updated even if other images have the same value.
                        // To get around this, we set a bogus value and then the real value, which means that the
                        // ValueChanged event will be triggered. Inefficient, but seems to work.
                        if (this.IsDisplayingMultipleImagesInOverview() && control is DataEntryCounter counter)
                        {
                            counter.SetBogusCounterContentAndTooltip();
                        }

                        control.SetContentAndTooltip(item.Value);
                        if (flash == FlashEnum.FlashPreview)
                        {
                            control.FlashPreviewControlValue();
                        }
                        else
                        {
                            control.FlashContentControl();
                        }
                        break;
                    }
                }
            }
        }
        // Move the focus (usually because of tabbing or shift-tab)
        // It cycles between the data entry controls and the CopyPrevious button
        private void MoveFocusToNextOrPreviousControlOrCopyPreviousButton(bool moveToPreviousControl)
        {
            // identify the currently selected control
            // if focus is currently set to the canvas this defaults to the first or last control, as appropriate
            int  currentControl = moveToPreviousControl ? this.DataEntryControls.Controls.Count : -1;
            Type type;

            IInputElement focusedElement = FocusManager.GetFocusedElement(this);

            if (focusedElement != null)
            {
                type = focusedElement.GetType();

                // If we are moving the focus from outside to one of the controls in the data panel or the copy previous button,
                // then try to restore the focus to the last control that had the focus.
                if (Constant.Control.KeyboardInputTypes.Contains(type) == false && focusedElement != this.CopyPreviousValuesButton)
                {
                    if (this.lastControlWithFocus != null && this.lastControlWithFocus.IsEnabled == true)
                    {
                        Keyboard.Focus(this.lastControlWithFocus);
                        this.CopyPreviousValuesSetEnableStatePreviewsAndGlowsAsNeeded();
                        return;
                    }
                }

                // Otherwise, try to find the control that has the current focus
                if (Constant.Control.KeyboardInputTypes.Contains(type))
                {
                    if (DataEntryHandler.TryFindFocusedControl(focusedElement, out DataEntryControl focusedControl))
                    {
                        int index = 0;
                        foreach (DataEntryControl control in this.DataEntryControls.Controls)
                        {
                            if (Object.ReferenceEquals(focusedControl, control))
                            {
                                // We found it, so no need to look further
                                currentControl = index;
                                break;
                            }
                            ++index;
                        }
                    }
                }
            }

            // Then move to the next or previous control as available
            Func <int, int> incrementOrDecrement;

            if (moveToPreviousControl)
            {
                incrementOrDecrement = (int index) => { return(--index); };
            }
            else
            {
                incrementOrDecrement = (int index) => { return(++index); };
            }

            for (currentControl = incrementOrDecrement(currentControl);
                 currentControl > -1 && currentControl < this.DataEntryControls.Controls.Count;
                 currentControl = incrementOrDecrement(currentControl))
            {
                DataEntryControl control = this.DataEntryControls.Controls[currentControl];
                if (control.ContentReadOnly == false && control.IsContentControlEnabled == true && this.IsControlIncludedInTabOrder(control))
                {
                    this.lastControlWithFocus = control.Focus(this);
                    // There is a bug with Avalon: when the data control pane is floating the focus does not go to it via the above call
                    // (although it does when its docked).
                    // Setting the focus to the actual content control seems to fix it.
                    control.GetContentControl.Focus();
                    return;
                }
            }

            // if we've gone thorugh all the controls and couldn't set the focus, then we must be at the beginning or at the end.
            if (this.CopyPreviousValuesButton.IsEnabled)
            {
                // So set the focus to the Copy PreviousValuesButton, unless it is disabled.
                this.CopyPreviousValuesButton.Focus();
                this.lastControlWithFocus = this.CopyPreviousValuesButton;
                this.CopyPreviousValuesSetEnableStatePreviewsAndGlowsAsNeeded();
            }
            else
            {
                // Skip the CopyPreviousValuesButton, as it is disabled.
                DataEntryControl candidateControl = moveToPreviousControl ? this.DataEntryControls.Controls.Last() : this.DataEntryControls.Controls.First();
                if (moveToPreviousControl)
                {
                    // Find the LAST control
                    foreach (DataEntryControl control in this.DataEntryControls.Controls)
                    {
                        if (control.ContentReadOnly == false)
                        {
                            candidateControl = control;
                        }
                    }
                }
                else
                {
                    // Find the FIRST control
                    foreach (DataEntryControl control in this.DataEntryControls.Controls)
                    {
                        if (control.ContentReadOnly == false)
                        {
                            candidateControl = control;
                            break;
                        }
                    }
                }
                if (candidateControl != null)
                {
                    this.lastControlWithFocus = candidateControl.Focus(this);
                }
            }
        }