public DlgPopulateFieldWithMetadata(DBData db_data, string file_name, string folder_path)
 {
     this.fileName = file_name;
     this.folderPath = folder_path;
     this.dbData = db_data;
     InitializeComponent();
 }
        public DlgDateTimeChangeCorrection(DBData db_data)
        {
            InitializeComponent();
            bool result;
            this.dbData = db_data;

            // Get the original date and display it
            this.dbData.GetIdOfCurrentRow();
            this.lblOriginalDate.Content = dbData.IDGetDate(out result) + " " + dbData.IDGetTime(out result);

            // Get the image filename and display it
            this.lblImageName.Content = dbData.IDGetFile(out result);

            // Display the image. While we should be on a valid image (our assumption), we can still show a missing or corrupted image if needed
            string path = System.IO.Path.Combine(dbData.FolderPath, dbData.IDGetFile(out result));
            BitmapFrame bmap;
            try
            {
                bmap = BitmapFrame.Create(new Uri(path), BitmapCreateOptions.None, BitmapCacheOption.None);
            }
            catch
            {
                if (! File.Exists  (path))
                    bmap = BitmapFrame.Create(new Uri("pack://application:,,/Resources/missing.jpg"));
                else
                    bmap = BitmapFrame.Create(new Uri("pack://application:,,/Resources/corrupted.jpg"));
            }
            this.imgDateImage.Source = bmap;
        }
        int originalDarkPixelThreshold = 0; // Default value

        #endregion Fields

        #region Constructors

        public DlgOptionsDarkImagesThreshold(DBData db_data, int dark_pixel_threshold, double dark_pixel_ratio)
        {
            InitializeComponent();

            this.dbData = db_data;
            this.originalDarkPixelThreshold = dark_pixel_threshold;
            this.originalDarkPixelRatio = dark_pixel_ratio;

            this.darkPixelThreshold = dark_pixel_threshold;
            this.darkPixelRatio = dark_pixel_ratio;
        }
        /// <summary>
        /// Export all the database data associated with the filtered view to the CSV file indicated in the file path so that spreadsheet applications (like Excel) can display it.
        /// </summary>
        /// <param name="db"></param>
        /// <param name="filepath"></param>
        public static void ExportDataAsCSV(DBData db, string filepath)
        {
            TextWriter tw = new StreamWriter(filepath, false);
            try
            {
                // Write the header as defined by the data labels in the template file
                // If the data label is an empty string, we use the label instead.
                string header = "";
                string label;
                string datalabel;
                List<string> datalabels = new List<string>();
                for (int i = 0; i < db.templateTable.Rows.Count; i++)
                {
                    label = (string)db.templateTable.Rows[i][Constants.LABEL];
                    datalabel = (string)db.templateTable.Rows[i][Constants.DATALABEL];
                    header += addColumn(getLabel(label, datalabel));

                    // get a list of datalabels so we can add columns in the order that matches the current template table order
                    if (Constants.ID != datalabel) datalabels.Add(datalabel);
                }
                tw.WriteLine(header);
                // For each row in the data table, write out the columns in the same order as the
                // data labels in the template file
                for (int i = 0; i < db.dataTable.Rows.Count; i++)
                {
                    string row = "";
                    foreach (string dataLabel in datalabels)
                    {
                        row += addColumn((string)db.dataTable.Rows[i][dataLabel]);
                    }
                    tw.WriteLine(row);
                }
            }
            catch
            {
                // Can't write the spreadsheet file
                DlgMessageBox dlgMB = new DlgMessageBox();
                dlgMB.IconType = MessageBoxImage.Error;
                dlgMB.ButtonType = MessageBoxButton.OK;

                dlgMB.MessageTitle = "Can't write the spreadsheet file.";
                dlgMB.MessageProblem = "The following file can't be written: " + filepath + ".";
                dlgMB.MessageReason = "You may already have it open in Excel or another  application.";
                dlgMB.MessageSolution = "If the file is open in another application, close it and try again.";
                dlgMB.ShowDialog();
            }
            tw.Close();
        }
        /// <summary>
        /// Create a CustomFilter, where we build a list of potential search term expressions based on the controls found in the sorted template table
        /// The search term will be used only if its 'UseForSearching' field is true
        /// </summary>
        /// <param name="db_data"></param>
        public CustomFilter(DBData db_data)
        {
            dbData = db_data;
            LogicalOperator = LogicalOperators.Or; // We default the search operation to this logical operation
            SearchTermList = new Dictionary<int, SearchTerm>();

            DataTable sortedTemplateTable = dbData.TemplateGetSortedByControls();

            // Initialize the filter to reflect the desired controls in the template (in sorted order)
            int row_count = 1; // We start at 1 as there is already a header row
            for (int i = 0; i < sortedTemplateTable.Rows.Count; i++)
            {
                // Get the values for each control
                DataRow row = sortedTemplateTable.Rows[i];
                string type = row[Constants.TYPE].ToString();

                // We only handle certain types, e.g., we don't give the user the opportunity to search over file names / folders / date / time
                if (type == Constants.NOTE || type == Constants.COUNTER || type == Constants.FIXEDCHOICE || type == Constants.IMAGEQUALITY || type == Constants.FLAG)
                {
                    // Create a new search expression for each row, where each row specifies a particular control and how it can be searched
                    string default_value = "";
                    string expression = CH_EQUALS;
                    bool is_use_for_searching = false;
                    if (type == Constants.COUNTER)
                    {
                        default_value = "0";
                        expression = CH_GREATER_THAN;  // Makes more sense that people will test for > as the default rather than counters
                    }
                    else if (type == Constants.FLAG)
                    {
                        default_value = "false";
                    }

                    // Create a new search term and add it to the list
                    SearchTerm st = new SearchTerm();
                    st.UseForSearching = is_use_for_searching;
                    st.Type = type;
                    st.Label = (string) row[Constants.LABEL];
                    st.DataLabel = (string) row[Constants.DATALABEL];
                    st.Expression = expression;
                    st.Value = default_value;
                    st.List = (string)row[Constants.LIST];
                    this.SearchTermList.Add(row_count, st);
                    row_count++;
                }
            }
        }
        private bool isCorrupted; // whether that image was corrupted or not

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Ask the user if he/she wants to delete the given image indicated by the index.
        /// Other parameters indicate various specifics of that image that we will use to display and delete it
        /// </summary>
        /// <param name="currentImageIndex"></param>
        /// <param name="imageFilename"></param>
        /// <param name="imageFolderPath"></param>
        /// <param name="isCorrupted"></param>
        public DlgDeleteImage(DBData db_data, string imageFilename, string imageFolderPath, bool isCorrupted, bool delete_data)
        {
            InitializeComponent();

            // Set the local variables to the passed in parameters
            this.imageFilename = imageFilename;
            this.imageFolderPath = imageFolderPath;
            this.deleteData = delete_data;
            this.dbData = db_data;

            if (this.deleteData == true)
            {
                this.textMain.Text = "Delete the current image file and its data: " + this.imageFilename; // put the file name in the title
                this.TBDeleteImageAndData1.Visibility = Visibility.Visible;
                this.TBDeleteImageOnly1.Visibility = Visibility.Collapsed;
                this.TBDeleteImageOnly2.Visibility = Visibility.Collapsed;
                this.TBDeleteImageOnly3.Visibility = Visibility.Collapsed;
                this.LblImageOnly.Visibility = Visibility.Hidden;
                this.deletedImage.Visibility = Visibility.Hidden;
                this.chkboxConfirm.Visibility = Visibility.Visible;
                this.OkButton.IsEnabled = false;            }
            else
            {
               this.textMain.Text = "Delete the current image file: " + this.imageFilename; // put the file name in the title
               this.TBDeleteImageAndData1.Visibility = Visibility.Collapsed;
               this.TBDeleteImageOnly1.Visibility = Visibility.Visible;
               this.TBDeleteImageOnly2.Visibility = Visibility.Visible;
               this.TBDeleteImageOnly3.Visibility = Visibility.Visible;
               this.LblImageOnly.Visibility = Visibility.Visible;
               this.deletedImage.Visibility = Visibility.Visible;

               this.chkboxConfirm.Visibility = Visibility.Hidden;
               this.OkButton.IsEnabled = true;
            }
            this.isCorrupted = isCorrupted;
            this.deleteData = delete_data;
            this.showOriginalImage();
            this.showDeletedImage();
        }
        // Create the interface
        public DlgDateCorrection(DBData db_data)
        {
            InitializeComponent();
            this.dbData = db_data;
            bool result;
            // Get the original date and display it
            this.lblOriginalDate.Content = dbData.IDGetDate(out result) + " " + dbData.IDGetTime(out result);

            // Get the image filename and display it
            this.lblImageName.Content = dbData.IDGetFile(out result);

            // Display the image. While we should be on a valid image (our assumption), we can still show a missing or corrupted image if needed
            string path = System.IO.Path.Combine(dbData.FolderPath, dbData.IDGetFile(out result));
            BitmapFrame bmap;
            try
            {
                bmap = BitmapFrame.Create(new Uri(path), BitmapCreateOptions.None, BitmapCacheOption.None);
            }
            catch
            {
                if (! File.Exists  (path))
                    bmap = BitmapFrame.Create(new Uri("pack://application:,,/Resources/missing.jpg"));
                else
                    bmap = BitmapFrame.Create(new Uri("pack://application:,,/Resources/corrupted.jpg"));
            }
            this.imgDateImage.Source = bmap;

            // Try to put the original date / time into the corrected date field. If we can't, leave it as it is (i.e., as dd-mmm-yyyy hh:mm am).
            string format = "dd-MMM-yyyy hh:mm tt";
            CultureInfo provider = CultureInfo.InvariantCulture;
            string sDate = this.lblOriginalDate.Content.ToString();
            try
            {
                DateTime.ParseExact(sDate, format, provider);
                this.tbNewDate.Text = this.lblOriginalDate.Content.ToString();
            }
            catch { };
        }
Exemple #8
0
 public Propagate(DBData dbData)
 {
     this.dbData = dbData;  // We need a reference to the database if we are going to update it.
 }
 /// <summary>Constructor </summary>
 /// <param name="db"></param>
 public DlgDataView(DBData dbData)
 {
     InitializeComponent();
     this.dbData = dbData;
     RefreshDataTable ();
 }
        public void GenerateControls(DBData dbData)
        {
            const string EXAMPLE_DATE = "28-Dec-2014";
            const string EXAMPLE_TIME = "04:00 PM";

            string key = ""; // Construct a key

            Propagate = new Propagate(dbData);
            //this.ControlGrid.Inlines.Clear();
            //this.WP.Children.Clear();

            DataTable sortedTemplateTable = dbData.TemplateGetSortedByControls();
            for (int i = 0; i < sortedTemplateTable.Rows.Count; i++)
            {
                // Get the values for each control
                DataRow row = sortedTemplateTable.Rows[i];
                string type = row[Constants.TYPE].ToString();
                string defaultValue = row[Constants.DEFAULT].ToString();
                string label = row[Constants.LABEL].ToString();
                string tooltip = row[Constants.TOOLTIP].ToString();
                string width = row[Constants.TXTBOXWIDTH].ToString();
                int    iwidth = (width == "") ? 0 : Convert.ToInt32(width);
                string visiblity = row[Constants.VISIBLE].ToString();
                bool   bvisiblity = ("true" == visiblity.ToLower ()) ? true : false;
                string copyable = row[Constants.COPYABLE].ToString();
                bool   bcopyable = ("true" == copyable.ToLower ()) ? true : false;
                string list = row[Constants.LIST].ToString();
                int id = Convert.ToInt32 (row[Constants.ID].ToString ()); // TODO Need to use this ID to pass between controls and data

                // Get the key
                key = (string) row[Constants.DATALABEL];
                if (type == Constants.DATE && defaultValue == "")
                {
                    defaultValue = EXAMPLE_DATE;
                }
                else if (type == Constants.TIME && defaultValue == "")
                {
                    defaultValue = EXAMPLE_TIME;
                }

                if (type == Constants.FILE || type == Constants.FOLDER || type == Constants.DATE || type == Constants.TIME || type == Constants.NOTE)
                {
                    bool createContextMenu = (type == Constants.FILE) ? false : true;
                    MyNote myNote = new MyNote(this, createContextMenu);
                    myNote.Key = key;
                    myNote.Label = label;
                    myNote.DataLabel = key; // TODO we probably don't need a datalabel and a key any more as its redundant. Should just keep the DataLabel as its the key
                    myNote.Tooltip = tooltip;
                    myNote.Width = iwidth;
                    myNote.Visible = bvisiblity;
                    myNote.Content = defaultValue;
                    myNote.ReadOnly = (type == Constants.FOLDER || type == Constants.FILE) ? true : false; // File and Folder Notes are read only i.e., non-editable by the user
                    myNote.Copyable = bcopyable;
                    this.ControlGrid.Inlines.Add(myNote.Container);
                    //this.WP.Children.Add(myNote.Container);
                    this.ControlFromDataLabel.Add(key, myNote);
                }
                else if (type == Constants.FLAG || type == Constants.DELETEFLAG)
                {
                    MyFlag myFlag = new MyFlag(this, true);
                    myFlag.Key = key;
                    myFlag.Label = label;
                    myFlag.DataLabel = key; // TODO we probably don't need a datalabel and a key any more as its redundant. Should just keep the DataLabel as its the key
                    myFlag.Tooltip = tooltip;
                    myFlag.Width = iwidth;
                    myFlag.Visible = bvisiblity;
                    myFlag.Content = defaultValue;
                    myFlag.ReadOnly = false; // Flags are editable by the user
                    myFlag.Copyable = bcopyable;
                    //this.WP.Children.Add(myFlag.Container);
                    this.ControlGrid.Inlines.Add(myFlag.Container);
                    this.ControlFromDataLabel.Add(key, myFlag);
                }
                else if (type == Constants.COUNTER)
                {
                    MyCounter myCounter = new MyCounter(this, true);
                    myCounter.Key = key;
                    myCounter.Label = label;
                    myCounter.DataLabel = key; // TODO we probably don't need a datalabel and a key any more as its redundant. Should just keep the DataLabel as its the key
                    myCounter.Tooltip = tooltip;
                    myCounter.Width = iwidth;
                    myCounter.Visible = bvisiblity;
                    myCounter.Content = defaultValue;
                    myCounter.ReadOnly = false; // Couonters are editable by the user
                    myCounter.Copyable = bcopyable;
                    this.ControlGrid.Inlines.Add(myCounter.Container);
                    //this.WP.Children.Add(myCounter.Container);
                    this.ControlFromDataLabel.Add(key, myCounter);
                }
                else if (type == Constants.FIXEDCHOICE || type == Constants.IMAGEQUALITY)
                {
                    MyFixedChoice myFixedChoice = new MyFixedChoice(this, true, list);
                    myFixedChoice.Key = key;
                    myFixedChoice.Label = label;
                    myFixedChoice.DataLabel = key; // TODO we probably don't need a datalabel and a key any more as its redundant. Should just keep the DataLabel as its the key
                    myFixedChoice.Tooltip = tooltip;
                    myFixedChoice.Width = iwidth;
                    myFixedChoice.Visible = bvisiblity;
                    myFixedChoice.Content = defaultValue;
                    myFixedChoice.ReadOnly = false; // Fixed choices are editable (by selecting a menu) by the user
                    myFixedChoice.Copyable = bcopyable;
                    this.ControlGrid.Inlines.Add(myFixedChoice.Container);
                    //this.WP.Children.Add(myFixedChoice.Container);
                    this.ControlFromDataLabel.Add(key, myFixedChoice);
                }
            }
            //var panel = this.ButtonLocation.Parent as Panel;
            //panel.Children.Remove(this.ButtonLocation);
            //this.ControlGrid.Inlines.Add(this.ButtonLocation);
        }
        public List<MyCounter> MyCountersList = new List<MyCounter>(); // list of all our counter controls

        #endregion Fields

        #region Constructors

        public Controls(DBData dbData)
        {
            InitializeComponent();
            WP = new WrapPanel ();
        }
        private string imageFolderPath; // the full folder path where that image is located

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Ask the user if he/she wants to delete the given image indicated by the index.
        /// Other parameters indicate various specifics of that image that we will use to display and delete it
        /// </summary>
        /// <param name="currentImageIndex"></param>
        /// <param name="imageFilename"></param>
        /// <param name="imageFolderPath"></param>
        /// <param name="isCorrupted"></param>
        public DlgDeleteImages(DBData db_data, DataTable deletedTable, string imageFolderPath, bool delete_data)
        {
            InitializeComponent();
            Mouse.OverrideCursor = Cursors.Wait;
            this.deletedTable = deletedTable;
            this.imageFolderPath = imageFolderPath;
            this.deleteData = delete_data;
            this.dbData = db_data;

            string fname= "";
            string path="";
            BitmapImage image;
            System.Windows.Controls.Image imagectl;
            Label label;

            if (this.deleteData)
            {
                this.sp_DeleteAll.Visibility = Visibility.Visible;
                this.sp_DeleteImages.Visibility = Visibility.Collapsed;
                this.OkButton.IsEnabled = false;
                this.chkboxConfirm.Visibility= Visibility.Visible;
            }
            else
            {
                this.sp_DeleteAll.Visibility = Visibility.Collapsed;
                this.sp_DeleteImages.Visibility = Visibility.Visible;
                this.OkButton.IsEnabled = true;
                this.chkboxConfirm.Visibility = Visibility.Collapsed;
            }
            this.GridGallery.RowDefinitions.Clear();

            // Set the local variables to the passed in parameters
            int col = 0;
            int row = 0;

            GridLength gridlength200 = new GridLength(1, GridUnitType.Auto);
            GridLength gridlength20 = new GridLength(1, GridUnitType.Auto);
            for (int i = 0; i < deletedTable.Rows.Count; i++ )
            {
                fname = (string) deletedTable.Rows[i][Constants.FILE];

                label = new Label();
                label.Content = fname;
                label.Height = 25;
                label.VerticalAlignment = VerticalAlignment.Top;

                path = System.IO.Path.Combine(this.imageFolderPath, fname);

                if (Constants.IMAGEQUALITY_CORRUPTED == (string)deletedTable.Rows[i][Constants.IMAGEQUALITY])
                    image = this.getImage(path, "corrupted");
                else if (File.Exists(path))
                    image = this.getImage(path, "ok");
                else
                    image = this.getImage(path, "missing");

                imagectl = new System.Windows.Controls.Image() ;
                imagectl.Source = image;

                if (col == 0)
                {
                    this.GridGallery.RowDefinitions.Add(new RowDefinition() { Height = gridlength20 });
                    this.GridGallery.RowDefinitions.Add(new RowDefinition() { Height = gridlength200 });
                }
                Grid.SetRow(label, row);
                Grid.SetRow(imagectl, row+1);
                Grid.SetColumn(label, col);
                Grid.SetColumn(imagectl, col);
                this.GridGallery.Children.Add(label);
                this.GridGallery.Children.Add(imagectl);
                col++;
                if (col == 5) // A new row is started every 5th time
                {
                    col = 0;
                    row += 2;
                }
            }
            this.scroller.CanContentScroll = true;
            Mouse.OverrideCursor = null;
        }
 public DlgDateRereadDatesFromImages(DBData dbData)
 {
     InitializeComponent();
     this.dbData = dbData;
 }
        // Read all the data into the imageData structure from the XML file in the filepath.
        // Note that we need to know the code controls,as we have to associate any points read in with a particular counter control
        public static void Read(string filePath, DataTable template, DBData dbData)
        {
            // XML Preparation
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(filePath);

            // Import the old log (if any)
            XmlNodeList nodeLog = xmlDoc.SelectNodes(IMAGES + SLASH + LOG);
            if (nodeLog.Count > 0)
            {
                XmlNode nlog = nodeLog[0];
                dbData.Log = nlog.InnerText;
            }

            XmlNodeList nodelist = xmlDoc.SelectNodes(IMAGES + SLASH + IMAGE);
            XmlNodeList innerNodeList;

            string filename = "";
            string date;
            string time;

            List<string> counts = new List<string>();
            ColumnTupleList countercoords = new ColumnTupleList();
            Dictionary<String, Object> dataline;
            Dictionary<Dictionary<String, Object>, String> control_values_to_update = new Dictionary<Dictionary<String, Object>, String>();
            List<ColumnTupleListWhere> marker_value_to_update = new List<ColumnTupleListWhere>();

            int id = 0;
            List<string> notenames = new List<string>();
            List<string> counternames = new List<string>();
            List<string> choicenames = new List<string>();

            // Create three lists, each one representing the datalabels (in order found in the template) of notes, counters and choices
            // We will use these to find the matching ones in the xml data table.
            for (int i = 0; i < template.Rows.Count; i++ )
            {
                if (template.Rows[i][Constants.TYPE].Equals (Constants.NOTE) )
                {
                    notenames.Add((string) template.Rows[i][Constants.DATALABEL]);
                }
                else if  (template.Rows[i][Constants.TYPE].Equals (Constants.COUNTER) )
                {
                    counternames.Add((string) template.Rows[i][Constants.DATALABEL]);
                }
                else if (template.Rows[i][Constants.TYPE].Equals(Constants.FIXEDCHOICE))
                {
                    choicenames.Add((string)template.Rows[i][Constants.DATALABEL]);
                }
            }

            foreach (XmlNode n in nodelist)
            {
                int idx;

                id++;
                dataline = new Dictionary<String, Object>(); // Populate the data

                // File Field - We use the file name as a key into a particular database row. We don't change the database field as it is our key.
                filename = n[FILE].InnerText;

                // If the Folder Path differs from where we had previously loaded it,
                // warn the user that the new path will be substituted in its place

                // Folder - We are going to leave this field unchanged, so ignore it
                //string folder = n[FOLDER].InnerText);

                // Date - We use the original date, as the analyst may have adjusted them
                date = n[DATE].InnerText;
                dataline.Add(Constants.DATE, date);

                // Date - We use the original time, although its almost certainly identical
                time = n[TIME].InnerText;
                dataline.Add(Constants.TIME, time);

                // We don't use the imagequality, as the new system may have altered how quality is determined (e.g., deleted files)
                // imagequality = n[IMAGEQUALITY].InnerText;
                // dataline.Add(Constants.IMAGEQUALITY, imagequality);
                // System.Diagnostics.Debug.Print("----" + filename + " " + date + " " + time + " " + imagequality);

                // Notes: Iterate through
                idx = 0;
                innerNodeList = n.SelectNodes(NOTE);
                foreach (XmlNode node in innerNodeList)
                {
                    dataline.Add(notenames[idx++], node.InnerText);
                }

                // Choices: Iterate through
                idx = 0;
                innerNodeList = n.SelectNodes(FIXEDCHOICE);
                foreach (XmlNode node in innerNodeList)
                {
                    dataline.Add(choicenames[idx++], node.InnerText);
                }

                // Counters: Iterate through
                idx = 0;
                innerNodeList = n.SelectNodes(COUNTER);

                // For each counter control
                string where = "";
                foreach (XmlNode node in innerNodeList)
                {
                    // Add the value of each counter to the dataline
                    XmlNodeList dataNode = node.SelectNodes(DATA);
                    dataline.Add(counternames[idx], dataNode[0].InnerText);

                    // For each counter, find the points associated with it and compose them together as x1,y1|x2,y2|...|xn,yn
                    XmlNodeList pointNodeList = node.SelectNodes(POINT);
                    string countercoord = "";
                    foreach (XmlNode pnode in pointNodeList)
                    {
                        String x = pnode.SelectSingleNode(X).InnerText;
                        if (x.Length > 5) x = x.Substring(0, 5);
                        String y = pnode.SelectSingleNode(Y).InnerText;
                        if (y.Length > 5) y = y.Substring(0, 5);
                        countercoord += x + "," + y + "|";
                    }

                    // Remove the last "|" from the point list
                    if (!countercoord.Equals(""))  countercoord = countercoord.Remove(countercoord.Length - 1); // Remove the last "|"

                    // Countercoords will have a list of points (possibly empty) with each list entry representing a control
                    countercoords.Add(new ColumnTuple (counternames[idx], countercoord));
                    idx++;
                }
                // Add this update to the list of all updates for the Datatable, and then update it
                control_values_to_update.Add(dataline, Constants.FILE + "='" + filename + "'");

                where = Constants.ID + "='" + id.ToString() + "'";
                marker_value_to_update.Add(new ColumnTupleListWhere (countercoords, where));
                //dbData.UpdateMarkersInRow (id, counternames, countercoords); // Update the marker table

                // Create a list of all updates for the MarkerTable, and then update it

                countercoords = new ColumnTupleList ();
            }
            // Update the various tables in one fell swoop
            dbData.RowsUpdateRowsFromFilenames(control_values_to_update);
            dbData.RowsUpdateMarkerRows(marker_value_to_update);
            dbData.UpdateMarkersInRows(marker_value_to_update);
        }
 public DlgCustomViewFilter(DBData db_data, CustomFilter custom_filter)
 {
     this.dbData = db_data;
     this.customFilter = custom_filter;
     InitializeComponent();
 }
        /// <summary>
        /// Check to see if we can swap the day and month in all date fields. It checks to see if this is possible.
        /// If it isn't, it returns false, else true
        /// Assumes that we are showing all images (i.e., it checks the current datatable)
        /// TODO: Change it to use a temp table?
        /// </summary>
        /// <param name="main"></param>
        /// 
        public static int SwapDayMonthIsPossible(DBData dbData)
        {
            DateTime date; //Month/Day order
            DateTime reversedDate;
            bool succeeded = true;
            string sdate ;

            // First, do a pass to see if swapping the date/time order is even possible
            for (int i = 0; i < dbData.dataTable.Rows.Count; i++)
            {
               // Skip over corrupted images for now, as we know those dates are likley wrong
               if (dbData.RowIsImageCorrupted(i)) continue;

               // Parse the date, which should always work at this point. But just in case, put out a debug message
               sdate = (string) dbData.dataTable.Rows[i][Constants.DATE] + " " + (string) dbData.dataTable.Rows[i][Constants.TIME];
               succeeded = DateTime.TryParse(sdate, out date);
               if (!succeeded) Debug.Print("In SwapDayMonth - something went wrong trying to parse a date!");

               // Now check to see if the reversed date is legit. If it throws an exception, we know its a problem so get out of here.
               try
               {
                   reversedDate = new DateTime(date.Year, date.Day, date.Month); // we have swapped the day with the month
                   succeeded = true;
               }
               catch
               {
                   return (i); // Return the first image where we couldn't swap the date
               }
               if (!succeeded) break;
               }

            return -1; //-1 means we can reverse the dates
        }