Example #1
0
 public static void GetMeta(FileInfo f, ref ph p)
 {
     using (FileStream fs = new FileStream(f.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
     {
         BitmapSource   img = BitmapFrame.Create(fs);
         BitmapMetadata md  = (BitmapMetadata)img.Metadata;
         p.time_stamp  = md.DateTaken == null ? f.CreationTime : DateTime.Parse(md.DateTaken);
         p.description = md.Subject;
     }
 }
Example #2
0
File: Data.cs Project: Vek007/av
 internal static void AddPhAsDup(ph p)
 {
     if (alDb.phs.Where(p1 => p1.path.Trim() == p.path.Trim()).Count() <= 0)
     {
         p.is_dup = true;
         Data.alDb.phs.Add(p);
         Data.alDb.SaveChanges();
         RefreshDatabase(p);
     }
 }
Example #3
0
        private void UpdateStatusBar(string infoTags)
        {
            if (selectedNode != null && selectedNode.Tag != null)
            {
                ph     phh  = (ph)selectedNode.Tag;
                string info = phh.infoTags ?? string.Empty;
                this.sbLabel.Text = phh.id + " (" + info.Trim() + ")";
            }

            this.sbPictSizeMode.Text = pictImage.SizeMode.ToString();
            this.Text = this.sbLabel.Text + " - " + this.sbPictSizeMode.Text;
        }
Example #4
0
        public static void IterateAndSave(string rootPath, Main parent)
        {
            string[] allFiles = Directory.EnumerateFiles(rootPath, "*.JPG", SearchOption.AllDirectories).ToArray();

            if (parent != null)
            {
                parent.Invoke((MethodInvoker)(() =>
                {
                    parent.ShowProgressBar(true);
                }));
            }

            foreach (string filename in allFiles)
            {
                List <string> als = GetFoldersNames(Path.GetDirectoryName(filename));

                ph p = new ph();
                p.id   = Path.GetFileNameWithoutExtension(filename);
                p.path = filename;
                p.name = p.id;

                FileInfo fi = new FileInfo(filename);
                p.time_stamp = fi.LastWriteTime;

                GetMeta(fi, ref p);

                if (!Data.ExistsAsRecord(p))
                {
                    Data.AddPh(p);
                }
                else
                {
                    Data.AddPhAsDup(p);
                }
            }

            if (parent != null)
            {
                parent.Invoke((MethodInvoker)(() =>
                {
                    parent.ShowProgressBar(false);
                }));

                if (MessageBox.Show("Do you want to refresh the Album tree?", "Refresh", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    parent.Invoke((MethodInvoker)(() =>
                    {
                        parent.RefreshTree();
                    }));
                }
            }
        }
Example #5
0
        public static void UpdatePh(this ph phh)
        {
            string strSql = "update ph set infoTags = '" + phh.infoTags + "' where id = '" + phh.id + "'";

            try
            {
                DBExecutor.ExecuteCommand(strSql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #6
0
File: Data.cs Project: Vek007/av
        /// <summary>
        /// Add Ph to Al
        /// </summary>
        /// <param name="albumId">Id of Album to add Ph to</param>
        /// <param name="p">Ph to add</param>
        public static void AddPh(ph p)
        {
            if (!Data.ExistsAsRecord(p))
            {
                Data.alDb.phs.Add(p);
                Data.alDb.SaveChanges();
                RefreshDatabase(p);
            }
            else
            {
                Debug.WriteLine("Duplicate:" + p.id + " - " + p.path);
            }

            //string sqlInsert = "Insert into ph (id, name, description,path,time_stamp) values ('"+ p.Id + "','" +p.Name + "','" + p.Description + "','" + p.FilePath + "','" + p.CreationDate+"')";

            //DBExecutor.ExecuteCommand(sqlInsert);
        }
Example #7
0
        public void SaveTags()
        {
            var allNodes = treeAlbums.Nodes
                           .Cast <TreeNode>()
                           .SelectMany(GetNodeBranch);

            foreach (TreeNode itm in allNodes)
            {
                if (itm.Tag != null)
                {
                    ph img = (ph)itm.Tag;

                    if (img.infoTags != null)
                    {
                        img.UpdatePh();
                        Data.RefreshDatabase(img);
                    }
                }
            }
        }
Example #8
0
File: Data.cs Project: Vek007/av
        public static bool ExistsAsRecord(ph p)
        {
            Debug.WriteLine(p.id + p.time_stamp.ToString());
            List <ph> pDbs = alDb.phs.Where(p1 => p1.id.Trim() == p.id.Trim()).ToList();

            foreach (ph pd in pDbs)
            {
                {
                    if (pd.time_stamp.Value.Date.Day == p.time_stamp.Value.Date.Day &&
                        pd.time_stamp.Value.Date.Month == p.time_stamp.Value.Date.Month &&
                        pd.time_stamp.Value.Date.Year == p.time_stamp.Value.Date.Year &&
                        pd.time_stamp.Value.Date.Hour == p.time_stamp.Value.Date.Hour &&
                        pd.time_stamp.Value.Date.Minute == p.time_stamp.Value.Date.Minute)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Example #9
0
 public static Photo GetPhoto(this ph p)
 {
     return(new Photo(p.id, p.name, p.description, p.path, p.infoTags));
 }
Example #10
0
        protected override bool ProcessKeyPreview(ref Message m)
        {
            Debug.WriteLine(m.ToString());

            //if (m.Msg == WM_KEYUP)
            {
                int j = 0;
            }

            if (m.Msg == 257)
            {
                if ((int)m.WParam == (int)Keys.Left)
                {
                    //Debug.WriteLine("Sending left key to tree album.");
                    //KeyEventArgs e = new KeyEventArgs(Keys.Left);
                    //treeAlbums_KeyDown(null, e);
                }
                else if ((int)m.WParam == (int)Keys.Right)
                {
                    //Debug.WriteLine("Sending right key to tree album.");
                    //KeyEventArgs e = new KeyEventArgs(Keys.Right);
                    //treeAlbums_KeyDown(null, e);
                }
                else if ((int)m.WParam == (int)Keys.Add)
                {
                }
                else if ((int)m.WParam == (int)Keys.Subtract)
                {
                }
                else if ((int)m.WParam == (int)Keys.F2)
                {
                    this.WindowState     = FormWindowState.Maximized;
                    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                    treeAlbums.Visible   = false;
                    stBar.Visible        = false;
                    stpgFiles.Visible    = false;
                    tbMain.Width        += treeAlbums.Width;
                    tbMain.Left          = 0;
                }
                else if ((int)m.WParam == (int)Keys.F8)
                {
                    if (pictImage.SizeMode == PictureBoxSizeMode.Zoom)
                    {
                        pictImage.SizeMode = 0;
                    }
                    pictImage.SizeMode = pictImage.SizeMode + 1;

                    sbPictSizeMode.Text = pictImage.SizeMode.ToString();
                }
                else if ((int)m.WParam == (int)Keys.F1)
                {
                    sbSlideShow_Click(null, null);
                }
                else if ((int)m.WParam == (int)Keys.F3)
                {
                    stpgFiles.Visible    = bFileAdd;
                    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
                    stBar.Visible        = true;
                    treeAlbums.Visible   = true;
                    treeAlbums.Refresh();
                    tbMain.Width -= treeAlbums.Width;
                    tbMain.Left   = treeAlbums.Width + 5;
                }
                else if ((int)m.WParam == (int)Keys.F12)
                {
                    sbSlideShow_Click(null, null);
                }
                else if ((int)m.WParam == (int)Keys.F4)
                {
                    DatePicker dp = new DatePicker();
                    if (dp.ShowDialog() == DialogResult.OK)
                    {
                        DateTime stDt = dp.StartDate;
                        DateTime enDt = dp.EndDate;

                        if (!dp.ResetDate)
                        {
                            LoadAls(stDt, enDt);
                        }
                        else
                        {
                            LoadAls();
                        }
                    }
                }
                else if ((int)m.WParam == (int)Keys.F5)
                {
                    showIcons = !showIcons;
                    pictImage.Invalidate();
                }
                else if (char.IsLetter((char)m.WParam) || char.IsDigit((char)m.WParam))
                {
                    Debug.WriteLine(m.WParam.ToString());

                    ph curPhh = treeAlbums.SelectedNode.Tag as ph;//Data.alDb.phs.Where(a => a.path == curImg.path).FirstOrDefault();

                    curPhh = pictImage.Tag as ph;

                    if (curPhh != null)
                    {
                        curPhh.infoTags = curPhh.infoTags ?? "";

                        if (curPhh != null && !curPhh.infoTags.ToLower().Contains((char)m.WParam))
                        {
                            curPhh.infoTags += (char)m.WParam;
                        }

                        UpdateStatusBar(curPhh.infoTags);

                        curPhh.UpdatePh();
                        Data.RefreshDatabase(curPhh);
                        pictImage.Tag = curPhh;
                        pictImage.Invalidate();
                    }
                }
                else if ((int)m.WParam == (int)Keys.Back)
                {
                    ph curPhh = treeAlbums.SelectedNode.Tag as ph;//Data.alDb.phs.Where(a => a.path == curImg.path).FirstOrDefault();

                    curPhh = pictImage.Tag as ph;

                    curPhh.infoTags = curPhh.infoTags ?? "";

                    if (curPhh != null && curPhh.infoTags.Trim().Length > 0)
                    {
                        curPhh.infoTags = curPhh.infoTags.Trim().Substring(0, curPhh.infoTags.Length - 1);
                    }

                    UpdateStatusBar(curPhh.infoTags);

                    curPhh.UpdatePh();
                    Data.RefreshDatabase(curPhh);
                    pictImage.Tag = curPhh;
                    pictImage.Invalidate();
                }
            }
            return(base.ProcessKeyPreview(ref m));
        }