示例#1
0
        public static int SaveEvent(int eventId, string eventName)
        {
            DBKOMPDataContext db = new DBKOMPDataContext();

            PhotoDirectory obj = new PhotoDirectory();

            if (eventId == 0)
            {
                obj.AlbumName  = eventName;
                obj.FolderName = eventName.Replace(" ", "");
                obj.Sequence   = (from w in db.PhotoDirectories where w.Type == "E" select w).Count() + 1;
                obj.Type       = "E";
                db.PhotoDirectories.InsertOnSubmit(obj);
                Directory.CreateDirectory(HttpContext.Current.Server.MapPath("images/" + eventName.Replace(" ", "")));
            }
            else
            {
                PhotoDirectory objUpdated = db.PhotoDirectories.Where(p => (p.Id == eventId)).First();
                objUpdated.AlbumName = eventName;
            }

            db.SubmitChanges();
            db.Dispose();
            return(obj.Id);
        }
示例#2
0
        /// <summary>
        /// Inserts a new PhotoDirectory in to the database.
        /// </summary>
        /// <param name="parent">The parent directory object, or null if at the root.</param>
        /// <param name="dir">The PhotoDirectory object to insert.</param>
        /// <returns>The ID of the newly inserted PhotoDirectory.</returns>
        internal int Insert(PhotoDirectory parent, PhotoDirectory photoDirectory)
        {
            IDbCommand cmd = GetCommand();

            if (parent == null)
            {
                //cmd.CommandText = "INSERT INTO tblDirectories (ParentID, Name, VirtualPath) VALUES (NULL, ?, ?)";
                cmd.CommandText = "INSERT INTO tblDirectories (ParentID, Name, VirtualPath) VALUES (NULL, '" + photoDirectory.Name + "', '" + photoDirectory.VirtualPath + "')";
            }
            else
            {
                //cmd.CommandText = "INSERT INTO tblDirectories (ParentID, Name, VirtualPath) VALUES (?, ?, ?)";
                //cmd.Parameters.Add(CreateIntParam("ParentID", parent.Id));
                cmd.CommandText = "INSERT INTO tblDirectories (ParentID, Name, VirtualPath) VALUES (" + parent.Id + ",  '" + photoDirectory.Name + "', '" + photoDirectory.VirtualPath + "')";
            }

            //         cmd.Parameters.Add(CreateStringParam("Name", photoDirectory.Name));
            //cmd.Parameters.Add(CreateStringParam("VirtualPath", photoDirectory.VirtualPath));

            cmd.ExecuteNonQuery();

            // Get the AutoNumber identity column values and update the input parameter object
            //return GetIdentityValue(photoDirectory);
            cmd.CommandText = "SELECT MAX(ID) from tblDirectories";
            int id = (int)cmd.ExecuteScalar();

            photoDirectory.SetId(id);
            return(id);
        }
示例#3
0
        /// <summary>
        /// Recursively adds a collection of directories to the treeview.
        /// </summary>
        /// <param name="directoryLookup">A cache of all the PhotoDirectory objects.</param>
        /// <param name="dirBrowser">A reference to a DirectoryBrowser object.</param>
        /// <param name="dirs">A collection of PhotoDirectory objects.</param>
        /// <param name="parentNode">A reference to the parent tree node object, or null if at the root of the tree view.</param>
        private void addDirectoryNodes(Hashtable directoryLookup, DirectoryBrowser dirBrowser,
                                       PhotoDirectories dirs, squishyWARE.WebComponents.squishyTREE.TreeNode parentNode)
        {
            IEnumerator enumerator = dirs.GetEnumerator();

            while (enumerator.MoveNext())
            {
                PhotoDirectory dir = (PhotoDirectory)enumerator.Current;

                squishyWARE.WebComponents.squishyTREE.TreeNode node;
                if (parentNode == null)
                {
                    node = tvwMain.AddNode(HttpUtility.HtmlEncode(dir.Name), dir.Id.ToString());
                }
                else
                {
                    node = parentNode.AddNode(HttpUtility.HtmlEncode(dir.Name), dir.Id.ToString());
                }

                addDirectoryNodes(directoryLookup, dirBrowser, dir.GetDirectories(), node);

                if (!directoryLookup.Contains(dir.Id))
                {
                    directoryLookup.Add(dir.Id, dir);
                }
            }
        }
示例#4
0
        /// <summary>
        /// Returns a TableCell object for each photo in the photo album.
        /// </summary>
        /// <param name="dir">The PhotoDirectory the photo belongs to.</param>
        /// <param name="photo">The photo that is to be displayed in the table cell.</param>
        /// <returns>A TableCell object.</returns>
        private TableCell createCell(PhotoDirectory dir, Photo photo)
        {
            TableCell cell = new TableCell();

            cell.CssClass        = "indexThumbCell";
            cell.HorizontalAlign = HorizontalAlign.Left;
            cell.Width           = new Unit("33%");

            HyperLink hl = new HyperLink();

            hl.NavigateUrl = Context.Request.Path + "?method=displayPhoto&photoID=" + photo.Id +
                             "&directoryID=" + dir.Id;

            System.Web.UI.WebControls.Image image = new System.Web.UI.WebControls.Image();
            image.CssClass    = "image";
            image.ImageUrl    = "photos" + photo.FullThumbnailVirtualPath.Replace(@"\", "/");
            image.BorderStyle = BorderStyle.None;

            /*Comments comments = photo.GetComments();
             *
             * if (comments.Count > 0)
             * {
             *
             *      string cs = String.Format("Comments:<BR>{0}",  CreateCommentsString(comments));
             *
             *      image.Attributes.Add("onmouseover", "doTooltip(event,'" + cs + "')");
             *      image.Attributes.Add("onmouseout", "hideTip()");
             * }*/

            hl.Controls.Add(image);

            LiteralControl text = new LiteralControl();

            text.Text = "<br><div class=\"thumbLabel\"><b>" + HttpUtility.HtmlEncode(photo.Name) + "</b></div>";

            hl.Controls.Add(text);
            cell.Controls.Add(hl);

            string dateText;

            if (photo.DateTaken == DateTime.MinValue)
            {
                dateText = photo.FileSizeText;
            }
            else
            {
                dateText = photo.DateTaken.ToString("dd MMM yyyy - hh:mm") + ", " + photo.FileSizeText;
            }

            LiteralControl date = new LiteralControl("<div class=\"thumbDetails\">" + dateText + "</div>");

            //string commentsCount = "(" + comments.Count + " comments)";

            //LiteralControl commentLit = new LiteralControl("<div class=\"thumbComment\">" + commentsCount + "</div><br>");

            cell.Controls.Add(date);
            //cell.Controls.Add(commentLit);

            return(cell);
        }
示例#5
0
        /// <summary>
        /// Retrieves a list of photos that belong to a particular directory.
        /// </summary>
        /// <param name="token">A reference to the current SessionToken object.</param>
        /// <param name="dir">A PhotoDirectory object representing the directory who's photos that are to be retrieved.</param>
        /// <returns></returns>
        public Photos GetPhotos(SessionToken token, PhotoDirectory dir)
        {
            IDbCommand cmd = GetCommand();

            cmd.CommandText = "SELECT ID, Name, VirtualPath, DateTaken, FileSize, ViewedCount FROM tblPhotos WHERE DirectoryID = " + dir.Id +
                              " AND IsDeleted <> 'Y' ORDER BY DateTaken, Name";
            //cmd.Parameters.Add(CreateIntParam("DirectoryID", dir.Id));

            Photos results = new Photos();

            using (IDataReader reader = cmd.ExecuteReader(CommandBehavior.Default))
            {
                while (reader.Read())
                {
                    Photo photo = new Photo(token,
                                            reader.GetInt32(0),
                                            reader.GetString(1),
                                            reader.GetString(2),
                                            reader.IsDBNull(3) ? DateTime.MinValue : reader.GetDateTime(3),
                                            reader.GetInt32(4),
                                            reader.GetInt32(5));
                    results.Add(photo);
                }
            }

            return(results);
        }
示例#6
0
        /// <summary>
        /// Retrieves a list of sub-directories stored in the PhotosServer databse.
        /// </summary>
        /// <param name="token">A reference to the current directory browser session token object.</param>
        /// <param name="virtualPath">The virtual path to the parent directory.</param>
        /// <returns>A collection of PhotoDirectory objects</returns>
        public PhotoDirectories GetDirectories(SessionToken token, string virtualPath)
        {
            IDbCommand cmd = GetCommand();

            //cmd.CommandText = "SELECT ID, Name from tblDirectories where VirtualPath = ? " +
            cmd.CommandText = "SELECT ID, Name from tblDirectories where VirtualPath = '" + virtualPath + "' AND IsDeleted <> 'Y' ORDER BY Name";
            //cmd.Parameters.Add(CreateStringParam("VirtualPath", virtualPath));

            PhotoDirectories results = new PhotoDirectories();

            using (IDataReader reader = cmd.ExecuteReader(CommandBehavior.Default))
            {
                while (reader.Read())
                {
                    PhotoDirectory photoDir = new PhotoDirectory(token,
                                                                 reader.GetInt32(0),
                                                                 reader.GetString(1),
                                                                 virtualPath);

                    results.Add(photoDir);
                }
            }

            return(results);
        }
示例#7
0
        /// <summary>
        /// Inserts a new photo into the database.
        /// </summary>
        /// <param name="dir">A PhotoDirectory object representing the photo's parent directory.</param>
        /// <param name="photo">The photo object to insert.</param>
        /// <returns>The primary key of the newly inserted photo.</returns>
        internal int Insert(PhotoDirectory dir, Photo photo)
        {
            DateTime dt;

            if (photo.DateTaken == DateTime.MinValue)
            {
                dt = DateTime.Today;
            }
            else
            {
                dt = photo.DateTaken;
            }

            IDbCommand cmd = GetCommand();

            //cmd.CommandText = "INSERT INTO tblPhotos (DirectoryID, Name, VirtualPath, DateTaken, FileSize, ViewedCount) VALUES (?, ?, ?, ?, ?, 0)";
            cmd.CommandText = "INSERT INTO tblPhotos (DirectoryID, Name, VirtualPath, DateTaken, FileSize, ViewedCount) VALUES (" + dir.Id + ", '" + photo.Name + "', '" + photo.VirtualPath + "', '" + dt + "', '" + photo.FileSize + "', 0)";

            //cmd.Parameters.Add(CreateIntParam("DirectoryID", dir.Id));
            //cmd.Parameters.Add(CreateStringParam("Name", photo.Name));
            //cmd.Parameters.Add(CreateStringParam("VirtualPath", photo.VirtualPath));
            //cmd.Parameters.Add(CreateDateTimeParam("DateTaken", photo.DateTaken));
            //cmd.Parameters.Add(CreateLongParam("FileSize", photo.FileSize));

            cmd.ExecuteNonQuery();

            //return GetIdentityValue(photo);
            cmd.CommandText = "SELECT MAX(ID) from tblPhotos";
            int id = (int)cmd.ExecuteScalar();

            photo.SetId(id);
            return(id);
        }
示例#8
0
文件: PhotoDB.cs 项目: riyuexing/rms
        public void DeleteDirectoryPhotos(PhotoDirectory dir)
        {
            IDbCommand command = base.GetCommand();

            command.CommandText = "DELETE FROM tblPhotos WHERE DirectoryID = ?";
            command.Parameters.Add(base.CreateIntParam("DirectoryID", dir.Id));
            command.ExecuteNonQuery();
        }
示例#9
0
        /// <summary>
        /// Deletes the database photo records belonging to a particular directory.
        /// </summary>
        /// <param name="dir">A PhotoDirectory object representing the directory who's photos that are to be deleted.</param>
        public void DeleteDirectoryPhotos(PhotoDirectory dir)
        {
            IDbCommand cmd = GetCommand();

            cmd.CommandText = "DELETE FROM tblPhotos WHERE DirectoryID = " + dir.Id;

            //cmd.Parameters.Add(CreateIntParam("DirectoryID", dir.Id));

            cmd.ExecuteNonQuery();
        }
示例#10
0
        internal override void Delete(PhotoObjectBase obj)
        {
            PhotoDirectory directory = (PhotoDirectory)obj;
            IDbCommand     command   = base.GetCommand();

            command.CommandText = "DELETE FROM tblDirectories WHERE ID = ?";
            command.Parameters.Add(base.CreateIntParam("ID", directory.Id));
            if (command.ExecuteNonQuery() != 1)
            {
                throw new Exception("Attempted to delete a PhotoDirectory record that did not exit");
            }
        }
示例#11
0
        public bool UpdateFolderOrder(string folders)
        {
            DBKOMPDataContext db = new DBKOMPDataContext();

            string[] folderArr = folders.Split('^');
            for (int k = 0; k < folderArr.Length; k++)
            {
                PhotoDirectory tbl = db.PhotoDirectories.Single(p => p.Id == Convert.ToInt32(folderArr[k]));
                tbl.Sequence = k + 1;
                db.SubmitChanges();
            }
            return(true);
        }
示例#12
0
文件: PhotoDB.cs 项目: riyuexing/rms
        internal int Insert(PhotoDirectory dir, Photo photo)
        {
            IDbCommand command = base.GetCommand();

            command.CommandText = "INSERT INTO tblPhotos (DirectoryID, Name, VirtualPath, DateTaken, FileSize, ViewedCount) VALUES (?, ?, ?, ?, ?, 0)";
            command.Parameters.Add(base.CreateIntParam("DirectoryID", dir.Id));
            command.Parameters.Add(base.CreateStringParam("Name", photo.Name));
            command.Parameters.Add(base.CreateStringParam("VirtualPath", photo.VirtualPath));
            command.Parameters.Add(base.CreateDateTimeParam("DateTaken", photo.DateTaken));
            command.Parameters.Add(base.CreateLongParam("FileSize", photo.FileSize));
            command.ExecuteNonQuery();
            return(base.GetIdentityValue(photo));
        }
示例#13
0
        /// <summary>
        /// Displays a photo album page choosen by the user.
        /// </summary>
        /// <param name="request">The current HttpRequest object.</param>
        private void GotoPage(HttpRequest request)
        {
            // Gets the neccessary IDs out of the request
            int pageNumber  = Int32.Parse(request.Params["pageNumber"]);
            int directoryID = Int32.Parse(request.Params["directoryID"]);

            // Obtain a reference to the PhotoDirectory object
            Hashtable      directoryLookup = (Hashtable)Session["DirectoryLookup"];
            PhotoDirectory dir             = (PhotoDirectory)directoryLookup[directoryID];

            // Display the album grid for the selected page
            GeneratePhotosTable(dir, pageNumber);
        }
示例#14
0
        private void InitPage(HttpRequest request)
        {
            DirectoryBrowser dirBrowser       = (DirectoryBrowser)Session["photo_DirectoryBrowser"];
            PhotoDirectory   CurrentDirectory = (PhotoDirectory)Session["photo_CurrentDirectory"];

            if (dirBrowser == null || request.Params["method"] == null)
            {
//                string photosPath = request.ApplicationPath + Path.DirectorySeparatorChar;
                string mappedPhotosDbPath = request.MapPath("") + "\\photos";
                if (Session["photo_rootpath"] == null)
                {
                    Response.Write("错误的参数,通知管理员此异常现象");
                    Response.End();
                }
                string path = (string)Session["photo_rootpath"];
                dirBrowser = new DirectoryBrowser(mappedPhotosDbPath, path);
            }
            Hashtable directoryLookup = (Hashtable)Session["photo_DirectoryLookup"];

            if (directoryLookup == null)
            {
                directoryLookup = new Hashtable();
            }

            DisplayTreeview(dirBrowser, directoryLookup);
            // expand out the current directory node
            int directoryID = -1;

            if (CurrentDirectory != null)
            {
                directoryID = CurrentDirectory.Id;
            }
            else if (request.Params["directoryID"] != null)
            {
                directoryID = Int32.Parse(request.Params["directoryID"]);
            }
            else
            {
                PhotoObjectBase pd1 = dirBrowser.rootDir.GetByIndex(0);
                directoryID = pd1.Id;
            }
            squishyWARE.WebComponents.squishyTREE.TreeNode node = tvwMain.FindTreeNode(directoryID.ToString());
            ExpandNode(node);

            Session.Add("photo_DirectoryBrowser", dirBrowser);
            Session.Add("photo_DirectoryLookup", directoryLookup);

            // Must be called after DisplayTreeview
            ProcessMethod(request, directoryLookup, directoryID);
        }
示例#15
0
        /// <summary>
        /// Removes a PhotoDirectory object from the collection, based on its full virtual path.
        /// </summary>
        /// <param name="fullVirtualPath">The PhotoDirectory object to remove.</param>
        public void Remove(string fullVirtualPath)
        {
            IEnumerator enumerator = GetEnumerator();

            while (enumerator.MoveNext())
            {
                PhotoDirectory dir = (PhotoDirectory)enumerator.Current;
                if (dir.FullVirtualPath.Equals(fullVirtualPath))
                {
                    Remove(dir);
                    break;
                }
            }
        }
示例#16
0
        public bool Contains(string fullVirtualPath)
        {
            IEnumerator enumerator = GetEnumerator();

            while (enumerator.MoveNext())
            {
                PhotoDirectory directory = (PhotoDirectory)enumerator.Current;
                if (directory.FullVirtualPath.Equals(fullVirtualPath))
                {
                    return(true);
                }
            }
            return(false);
        }
示例#17
0
        private void ShowByDirectoryID(int directoryID)
        {
            pnlComments.Visible = false;
            // Retrieve the relevant PhotoDirectory object from the lookup, keyed on the
            // unique ID
            Hashtable directoryLookup = (Hashtable)Context.Session["photo_DirectoryLookup"];

            if (directoryLookup != null)
            {
                PhotoDirectory dir = (PhotoDirectory)directoryLookup[directoryID];
                GeneratePhotosTable(dir, 1);
                Session.Add("photo_CurrentDirectory", dir);
                CurDir.Text = dir.FullVirtualPath;
            }
        }
示例#18
0
        private void tvwMain_SelectedNodeChanged(object sender, System.EventArgs e)
        {
            pnlComments.Visible = false;

            TreeViewNodeClickEventArgs args = (TreeViewNodeClickEventArgs)e;

            squishyWARE.WebComponents.squishyTREE.TreeNode node = args.Node;

            // Retrieve the relevant PhotoDirectory object from the lookup, keyed on the
            // unique ID
            Hashtable      directoryLookup = (Hashtable)Context.Session["DirectoryLookup"];
            PhotoDirectory dir             = (PhotoDirectory)directoryLookup[Int32.Parse(node.Key)];

            GeneratePhotosTable(dir, 1);

            Session.Add("CurrentDirectory", dir);
        }
示例#19
0
        /// <summary>
        /// Deletes a direectory from the database. Note that the associated photos will
        /// be deleted by the Jet engine.
        /// </summary>
        /// <param name="obj">A PhotoDirectory object representing the photo to be deleted.</param>
        internal override void Delete(PhotoObjectBase obj)
        {
            PhotoDirectory photoDirectory = (PhotoDirectory)obj;

            IDbCommand cmd = GetCommand();

            cmd.CommandText = "DELETE FROM tblDirectories WHERE ID = " + photoDirectory.Id;

            //cmd.Parameters.Add(CreateIntParam("ID", photoDirectory.Id));

            int rowsAffected = cmd.ExecuteNonQuery();

            if (rowsAffected != 1)
            {
                throw new Exception("Attempted to delete a PhotoDirectory record that did not exit");
            }
        }
示例#20
0
        public PhotoDirectories GetDirectories(SessionToken token, string virtualPath)
        {
            IDbCommand command = base.GetCommand();

            command.CommandText = "SELECT ID, Name from tblDirectories where VirtualPath = ? ORDER BY Name";
            command.Parameters.Add(base.CreateStringParam("VirtualPath", virtualPath));
            PhotoDirectories directories = new PhotoDirectories();

            using (IDataReader reader = command.ExecuteReader(CommandBehavior.Default))
            {
                while (reader.Read())
                {
                    PhotoDirectory photoDirectory = new PhotoDirectory(token, reader.GetInt32(0), reader.GetString(1), virtualPath);
                    directories.Add(photoDirectory);
                }
            }
            return(directories);
        }
示例#21
0
        internal int Insert(PhotoDirectory parent, PhotoDirectory photoDirectory)
        {
            IDbCommand command = base.GetCommand();

            if (parent == null)
            {
                command.CommandText = "INSERT INTO tblDirectories (ParentID, Name, VirtualPath) VALUES (NULL, ?, ?)";
            }
            else
            {
                command.CommandText = "INSERT INTO tblDirectories (ParentID, Name, VirtualPath) VALUES (?, ?, ?)";
                command.Parameters.Add(base.CreateIntParam("ParentID", parent.Id));
            }
            command.Parameters.Add(base.CreateStringParam("Name", photoDirectory.Name));
            command.Parameters.Add(base.CreateStringParam("VirtualPath", photoDirectory.VirtualPath));
            command.ExecuteNonQuery();
            return(base.GetIdentityValue(photoDirectory));
        }
示例#22
0
        /// <summary>
        /// Configures the images and URL used by the page nagivation arrows diaplayed at the top
        /// and bottom of the photos album grid.
        /// </summary>
        /// <param name="dir">The current photo album directory the user is viewing.</param>
        /// <param name="currentPage">The current page number.</param>
        /// <param name="totalPages">The total number of pages in the album.</param>
        public void ConfigurePageNavigationArrows(PhotoDirectory dir, int currentPage, int totalPages)
        {
            hylPreviousPage1.Visible = true;
            hylNextPage1.Visible     = true;
            hylPreviousPage2.Visible = true;
            hylNextPage2.Visible     = true;

            if (currentPage == 1)
            {
                hylPreviousPage1.ImageUrl = "PhotoBrowserRes/previous_disabled.gif";
                hylPreviousPage1.Enabled  = false;
            }
            else
            {
                hylPreviousPage1.NavigateUrl = Context.Request.Path + "?method=gotoPage&pageNumber=" + (currentPage - 1) +
                                               "&directoryID=" + dir.Id;
                hylPreviousPage1.ImageUrl = "PhotoBrowserRes/previous.gif";
                hylPreviousPage1.Enabled  = true;
            }

            if (currentPage == totalPages)
            {
                hylNextPage1.ImageUrl = "PhotoBrowserRes/next_disabled.gif";
                hylNextPage1.Enabled  = false;
            }
            else
            {
                hylNextPage1.NavigateUrl = Context.Request.Path + "?method=gotoPage&pageNumber=" + (currentPage + 1) +
                                           "&directoryID=" + dir.Id;
                hylNextPage1.ImageUrl = "PhotoBrowserRes/next.gif";
                hylNextPage1.Enabled  = true;
            }

            // These are the duplicate controls shown at the bottom of the page so we simply copy
            // the values accross from those at the top
            hylNextPage2.NavigateUrl = hylNextPage1.NavigateUrl;
            hylNextPage2.ImageUrl    = hylNextPage1.ImageUrl;
            hylNextPage2.Enabled     = hylNextPage1.Enabled;

            hylPreviousPage2.NavigateUrl = hylPreviousPage1.NavigateUrl;
            hylPreviousPage2.ImageUrl    = hylPreviousPage1.ImageUrl;
            hylPreviousPage2.Enabled     = hylPreviousPage1.Enabled;
        }
示例#23
0
        /// <summary>
        /// Configures the control to display the correct content, depending on the current
        /// URL.
        /// </summary>
        /// <param name="request">The current HttpRequest object.</param>
        /// <param name="directoryLookup">A cache of all of the PhotoDirectory objects.</param>
        private void ProcessMethod(HttpRequest request, Hashtable directoryLookup)
        {
            string method = request.Params["method"];

            switch (method)
            {
            case ("gotoPage"):
                GotoPage(request);
                break;

            case ("displayPhoto"):
                int photoID     = Int32.Parse(request.Params["photoID"]);
                int directoryID = Int32.Parse(request.Params["directoryID"]);

                PhotoDirectory dir = (PhotoDirectory)directoryLookup[directoryID];
                DisplayPhoto(dir, photoID);

                break;
            }
        }
示例#24
0
        /// <summary>
        /// Configures the page hyperlinks displayed at the top and bottom of the photo album grid.
        /// </summary>
        /// <param name="dir">The current photo album directory the user is viewing.</param>
        /// <param name="currentPage">The current page number.</param>
        /// <param name="totalPages">The total number of pages in the album.</param>
        public void ConfigurePageLinks(PhotoDirectory dir, int currentPage, int totalPages)
        {
            plhPageLinks1.Controls.Clear();
            plhPageLinks2.Controls.Clear();

            for (int i = 1; i <= totalPages; i++)
            {
                if (i != currentPage)
                {
                    HyperLink hl = new HyperLink();
                    hl.Text        = i.ToString();
                    hl.NavigateUrl = Context.Request.Path + "?method=gotoPage&pageNumber=" + i.ToString() +
                                     "&directoryID=" + dir.Id;
                    hl.CssClass = "pageNavCell";

                    HyperLink hl2 = new HyperLink();
                    hl2.Text        = hl.Text;
                    hl2.NavigateUrl = hl.NavigateUrl;
                    hl2.CssClass    = hl.CssClass;

                    plhPageLinks1.Controls.Add(hl);
                    plhPageLinks2.Controls.Add(hl2);
                }
                else
                {
                    Label label = new Label();
                    label.Text     = i.ToString();
                    label.CssClass = "pageNavCell";

                    Label label2 = new Label();
                    label2.Text     = label.Text;
                    label2.CssClass = label.CssClass;

                    plhPageLinks1.Controls.Add(label);
                    plhPageLinks2.Controls.Add(label2);
                }
                plhPageLinks1.Controls.Add(new LiteralControl(" "));
                plhPageLinks2.Controls.Add(new LiteralControl(" "));
            }
        }
示例#25
0
        /// <summary>
        /// Adds a PhotoDirectory object to the collection.
        /// </summary>
        /// <param name="photoDirectory">The PhotoDirectory object to add.</param>
        public void Add(PhotoDirectory photoDirectory)
        {
            KeyBase key = CreateKey(photoDirectory);

            Add(key, photoDirectory);
        }
示例#26
0
        /// <summary>
        /// Displays an individual photo as selected by the user.
        /// </summary>
        /// <param name="dir">The PhotoDirectory the selected photo belongs to.</param>
        /// <param name="id">The ID of the selected photo.</param>
        private void DisplayPhoto(PhotoDirectory dir, int id)
        {
            pnlPhotoContents.Visible     = true;
            pnlPhotoGridContents.Visible = false;

            Photos photos = dir.GetPhotos();
            Photo  photo  = (Photo)photos[id];

            photo.IncrementViewed();

            imgPhoto.ImageUrl = "photos" + photo.FullVirtualPath.Replace(@"\", "/");

            int index = photos.IndexOf(photo);

            if (index == 0)
            {
                hlkPreviousImagePhoto.Visible = false;

                hlkPreviousImage.ImageUrl = "PhotoBrowserRes/previous_disabled.gif";

                hlkPreviousImageName.Enabled = false;
                hlkPreviousImageName.Text    = "无";
            }
            else
            {
                Photo previousPhoto = (Photo)photos.GetByIndex(index - 1);

                hlkPreviousImagePhoto.Visible     = true;
                hlkPreviousImagePhoto.ImageUrl    = "photos" + previousPhoto.FullThumbnailVirtualPath.Replace(@"\", "/");
                hlkPreviousImagePhoto.NavigateUrl = Context.Request.Path + "?method=displayPhoto&photoID=" + previousPhoto.Id +
                                                    "&directoryID=" + dir.Id;

                hlkPreviousImage.ImageUrl    = "PhotoBrowserRes/previous.gif";
                hlkPreviousImage.NavigateUrl = hlkPreviousImagePhoto.NavigateUrl;

                hlkPreviousImageName.NavigateUrl = hlkPreviousImage.NavigateUrl;
                hlkPreviousImageName.Enabled     = true;
                hlkPreviousImageName.Text        = previousPhoto.Name;
            }

            if (index == photos.Count - 1)
            {
                hlkNextImagePhoto.Visible = false;

                hlkNextImage.ImageUrl = "PhotoBrowserRes/next_disabled.gif";

                hlkNextImageName.Enabled = false;
                hlkNextImageName.Text    = "无";
            }
            else
            {
                Photo nextPhoto = (Photo)photos.GetByIndex(index + 1);

                hlkNextImagePhoto.Visible     = true;
                hlkNextImagePhoto.ImageUrl    = "photos" + nextPhoto.FullThumbnailVirtualPath.Replace(@"\", "/");
                hlkNextImagePhoto.NavigateUrl = Context.Request.Path + "?method=displayPhoto&photoID=" + nextPhoto.Id +
                                                "&directoryID=" + dir.Id;

                hlkNextImage.ImageUrl    = "PhotoBrowserRes/next.gif";
                hlkNextImage.NavigateUrl = hlkNextImagePhoto.NavigateUrl;

                hlkNextImageName.NavigateUrl = hlkNextImage.NavigateUrl;
                hlkNextImageName.Enabled     = true;
                hlkNextImageName.Text        = nextPhoto.Name;
            }

            // Have to figure out which page the current photograph would appear on
            int page = (index / PhotosPerPage) + 1;

            hlkReturnToThumbnails1.NavigateUrl = Context.Request.Path + "?method=gotoPage&pageNumber=" + page +
                                                 "&directoryID=" + dir.Id;
            hlkReturnToThumbnails2.NavigateUrl = hlkReturnToThumbnails1.NavigateUrl;

            //DisplayComments(photo);

            lblViewedCount.Text = String.Format("Image has been viewed {0} times", photo.Viewed);

            Session["photo_CurrentPhoto"] = photo;
        }
示例#27
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            HttpRequest request = Context.Request;

            tvwMain.WindowsLafImageBase = @"PhotoBrowserRes\Treeview\";
            tvwMain.TreeOutputStyle     = TreeOutputStyle.WindowsLookAndFeel;
            tvwMain.NodeDisplayStyle    = NodeDisplayStyle.Standard;

            // We only get a post back if the user is navigating via the treeview control.
            // If we've not got a postback then we need to display correct state of the
            // control.
            if (!IsPostBack)
            {
                InitPage(request);
            }
            else
            {
                string curfullpath = "";
                if (Session["photo_CurrentDirectory"] != null)
                {
                    curfullpath = this.MapPath(null) + "\\photos" + ((PhotoDirectory)Session["photo_CurrentDirectory"]).FullVirtualPath;
                }
                if (request.Params["PhotoBrowser1:DirMaintainType"] == "AddChildDir")
                {
                    if (Session["photo_CurrentDirectory"] == null)
                    {
                    }
                    else
                    {
                        string newpath = curfullpath + "\\" + txtDirName.Value;
                        labReport.Text = newpath;
                        System.IO.Directory.CreateDirectory(newpath);
                        InitPage(request);
                    }
                }
                else if (request.Params["PhotoBrowser1:DirMaintainType"] == "DelPhoto")
                {
                    int photoID     = Int32.Parse(request.Params["photoID"]);
                    int directoryID = Int32.Parse(request.Params["directoryID"]);

                    PhotoDirectory dir    = (PhotoDirectory)((Hashtable)Session["photo_DirectoryLookup"])[directoryID];
                    Photos         photos = dir.GetPhotos();
                    Photo          photo  = (Photo)photos[photoID];
                    string         newurl = Context.Request.Path;

                    //Photo nextPhoto = (Photo)photos.GetByIndex(photos.IndexOf(photo) + 1);
                    DirectoryBrowser dirBrowser = (DirectoryBrowser)Session["photo_DirectoryBrowser"];
                    dirBrowser.DeletePhoto(photo, this.MapPath(null) + "\\photos");
                    Response.Redirect(newurl);
                }
                else if (request.Params["PhotoBrowser1:DirMaintainType"] == "DirRename")
                {
                }
                else if (request.Params["PhotoBrowser1:DirMaintainType"] == "DelDir")
                {
                }
                else if (FileUpload1.HasFile)
                {
                    UploadFile(curfullpath);
                    InitPage(request);
                    ShowByDirectoryID(((PhotoDirectory)Session["photo_CurrentDirectory"]).Id);
                }
                ClearCmd();
            }
            pnlImageNavigationBottom.Visible = DISPLAY_BOTTOM_IMAGE_NAVIGATION;
        }
示例#28
0
 /// <summary>
 /// Removes a PhotoDirectory object from the collection.
 /// </summary>
 /// <param name="photoDirectory">The PhotoDirectory object to remove.</param>
 public void Remove(PhotoDirectory photoDirectory)
 {
     Remove(CreateKey(photoDirectory));
 }
示例#29
0
        /// <summary>
        /// Populates the photo album with photos.
        /// </summary>
        /// <param name="dir">A reference to the PhotoDirectory representing the album to display.</param>
        /// <param name="pageNumber">The page number of the album to display.</param>
        private void GeneratePhotosTable(PhotoDirectory dir, int pageNumber)
        {
            tblPhotos.Rows.Clear();

            Photos photos = dir.GetPhotos();

            if (photos.Count > 0)
            {
                pnlPhotoGridContents.Visible = true;
                pnlPhotoContents.Visible     = false;

                int photosPerPage    = rowsPerPage * colsPerPage;
                int totalNoOfPages   = (int)Math.Floor((double)(photos.Count / photosPerPage));
                int photosOnLastPage = photos.Count % photosPerPage;
                if (photosOnLastPage > 0)
                {
                    totalNoOfPages++;
                }

                if (pageNumber > totalNoOfPages)
                {
                    throw new Exception("Illegal page number requested");
                }

                // figure out which photos we want to display
                int startIndex = (pageNumber == 1 ? 0 : (photosPerPage * (pageNumber - 1)));
                int endIndex   = (pageNumber == totalNoOfPages ? photos.Count - 1 : startIndex + photosPerPage - 1);

                System.Diagnostics.Debug.Assert(startIndex <= endIndex);

                Photo[] photosArray = new Photo[photos.Count];
                photos.CopyTo(photosArray, 0);

                // loop through the required photos and output the correct table cells
                int      rowCounter = 0;
                TableRow row        = null;
                for (int i = startIndex; i <= endIndex; i++)
                {
                    if (rowCounter == 0)
                    {
                        row       = new TableRow();
                        row.Width = Unit.Percentage(100);
                        tblPhotos.Rows.Add(row);
                        rowCounter++;
                    }

                    Photo photo = photosArray[i];

                    TableCell cell = createCell(dir, photo);
                    cell.Width = Unit.Percentage(100 / colsPerPage);
                    row.Cells.Add(cell);

                    if (row.Cells.Count == colsPerPage)
                    {
                        rowCounter = 0;
                    }
                }

                ConfigurePageNavigationArrows(dir, pageNumber, totalNoOfPages);
                ConfigurePageLinks(dir, pageNumber, totalNoOfPages);
            }
            else
            {
                pnlPhotoGridContents.Visible = false;
                pnlPhotoContents.Visible     = false;
            }

            Session.Add("photo_CurrentPageNumber", pageNumber);
            Session.Add("photo_CurrentPhotos", photos);
        }
示例#30
0
        /// <summary>
        /// Creates the collection key based on a PhotoDirectory object.
        /// </summary>
        /// <param name="obj">The PhotoDirectory object who's collection key we want.</param>
        /// <returns>A PhotoDirectoryKey object.</returns>
        protected override KeyBase CreateKey(PhotoObjectBase obj)
        {
            PhotoDirectory photoDirectory = (PhotoDirectory)obj;

            return(new PhotoDirectoryKey(photoDirectory.Id, photoDirectory.Name));
        }