예제 #1
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;
        }