コード例 #1
0
        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;
        }
コード例 #2
0
        // 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 { };
        }