Ejemplo n.º 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);
     }
 }
Ejemplo n.º 2
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;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        // Paste the data values from the previous copyable controls to the currently displayed controls
        private bool TryCopyPreviousValuesPasteValues()
        {
            int previousRow = this.DataHandler.ImageCache.CurrentRow - 1;

            // This is an unneeded test as the CopyPreviousButton should be disabled if these conditions are met
            if (this.IsDisplayingSingleImage() == false || previousRow < 0)
            {
                return(false);
            }

            this.FilePlayer_Stop(); // In case the FilePlayer is going
            foreach (KeyValuePair <string, DataEntryControl> pair in this.DataEntryControls.ControlsByDataLabel)
            {
                DataEntryControl control = pair.Value;
                if (control.Copyable)
                {
                    control.SetContentAndTooltip(this.DataHandler.FileDatabase.FileTable[previousRow].GetValueDisplayString(control.DataLabel));
                }
            }
            return(true);
        }