예제 #1
0
    public void drawpictures(Graphics g, pagelayout pl, sessionpictures sps)
    {
        grapher = g;
        sessionpicture sp;

        // look at all the pictures in the page layout. check the name property against all pictures in the sessionpictures object
        for (int i = 0; i < pl.pictures.Count; i++)
        {
            sp = sps.picture(pl.pictures[i].name);
            if (sp != null)
            {
                drawpicture(pl.pictures[i], sp);
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        picturetinkerer   pt;
        sessionpagelayout spl;
        pagelayout        pl = null;

        // picture data now in session so retrieve from there
        sessionpictures sps = (sessionpictures)Session["sessionpictures"];

        if (sps == null)
        {
            sps = new sessionpictures();
        }
        spl = (sessionpagelayout)Session["sessionpagelayout"];
        if (spl != null)
        {
            pl = ceddio.loadpagelayout(spl.pagelayoutfilename);
        }
        if (pl == null)
        {
            Response.Redirect("~/default.aspx", true);
        }

        if ((pl == null) || (sps == null))
        {
            Response.Redirect("~/default.aspx", true);
        }
        foreach (picturelayout p in pl.pictures)
        {
            pt            = (picturetinkerer)LoadControl("~/picturetinkerer.ascx");
            pt.picinfo    = sps.picture(p.name);
            pt.layoutinfo = p;
            pt.layout     = pl;
            ptinkerers.Controls.Add(pt);
            if (pt.picinfo != null)
            {
                ladddhtml.Text += pt.getparentjavascript() + "\n";
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Single xscale, yscale;

        // get the article index to choose from the query string
        try
        {
            fpictureindex = Convert.ToInt16(Request.QueryString["picture"]);
        }
        catch
        {
            fpictureindex = 0;
        }

        // get layout and picture info from the seesion, redirect to home page if we don't have all that we need
        try
        {
            spl = (sessionpagelayout)Session["sessionpagelayout"];
            if (spl != null)
            {
                pl = ceddio.loadpagelayout(spl.pagelayoutfilename);
            }
            layoutinfo = pl.pictures[pictureindex];
            // get the total number of articles
            fpicturestotal = pl.pictures.Count;

            // get the prompt for the current article
            fpicturename   = pl.pictures[pictureindex].name;
            fpictureprompt = pl.pictures[pictureindex].prompt;
            sps            = (sessionpictures)Session["sessionpictures"];
            if (sps == null)
            {
                sps = new sessionpictures();
                Session["sessionpictures"] = sps;
            }
        }
        catch
        {
            Response.Redirect("default.aspx", true);
        }

        // if this is the first load of this page then save an image containing just the text of the articles. This will be overlaid on the uploaded pictures so that the user can line up the picture and the headline nicely.
        if ((Request.UrlReferrer == null) || (Request.Url.AbsolutePath != Request.UrlReferrer.AbsolutePath))
        {
            Session["articleoverlayfilename"] = "";
            // get an image containing just the text overlay
            Bitmap barticles = articlesdrawer.drawarticles(pl, (sessionarticles)Session["sessionarticles"], (sessioncustomisations)Session["sessioncustomisation"], sps, true);
            string articleoverlayfilename = Guid.NewGuid().ToString() + ".png";
            barticles.Save(Server.MapPath("~/articleoverlays/") + articleoverlayfilename, ImageFormat.Png);
            Session["articleoverlayfilename"] = articleoverlayfilename;
        }

        // work out the scaling for this picture so that all pictures take up the same space on screen when positioning. This is so that small pictures are easily visible and so large pictures are not unmanageably large
        xscale    = (400f / (Single)layoutinfo.width);
        yscale    = (300f / (Single)layoutinfo.height);
        pagescale = Math.Min(xscale, yscale);

        // get the session info for this picture, if there is any
        try { picinfo = sps.picture(fpicturename); }
        catch { picinfo = null; }

        if (Page.IsPostBack == true)
        {
            return;
        }

        // show hide the controls for an optional picture
        poptional.Visible = layoutinfo.optional;

        // hide the javascript if there is no picture to work with
        if ((picinfo == null) || (System.IO.File.Exists(HostingEnvironment.ApplicationPhysicalPath + "\\uploadedpictures\\" + picinfo.filename)) == false)
        {
            pimgscript.Visible = false;
            //pcrop.Visible = false;
        }
        else
        {
            //
        }

        DataBind();
    }