protected void Page_Load(object sender, EventArgs e) { // get the existing customisations sc = (sessioncustomisations)Session["sessioncustomisation"]; if (sc == null) { Response.Redirect("~/default.aspx", true); } if (sc.getsessioncustomisation("", "Nickname") == null) { Response.Redirect("~/default.aspx", true); } if (sc.getsessioncustomisation("", "First Name") == null) { Response.Redirect("~/default.aspx", true); } if (sc.getsessioncustomisation("", "Surname") == null) { Response.Redirect("~/default.aspx", true); } // get the layout, if there is no layout specified then redirect back to the home page spl = (sessionpagelayout)Session["sessionpagelayout"]; if (spl != null) { pl = ceddio.loadpagelayout(spl.pagelayoutfilename); } if (pl == null) { Response.Redirect("~/default.aspx", true); } // get the article index to choose from the query string try { farticleindex = Convert.ToInt16(Request.QueryString["article"]); } catch { farticleindex = 0; } // get the total number of articles farticlestotal = pl.articles.Count; // get the prompt for the current article farticleprompt = pl.articles[articleindex].prompt; farticlename = pl.articles[articleindex].name; if (Page.IsPostBack == true) { return; } DataBind(); ceddutils.databindrepeater("spArticlesGetAll", rarticles, "htsp"); }
protected void Page_Load(object sender, EventArgs e) { // get the article index to choose from the query string try { farticleindex = Convert.ToInt16(Request.QueryString["article"]); } catch { farticleindex = 0; } // get the page layout spl = (sessionpagelayout)Session["sessionpagelayout"]; if (spl == null) { Response.Redirect("~/default.aspx", true); } pl = ceddio.loadpagelayout(spl.pagelayoutfilename); // if there is no layout specified the redirect back to the home page if (pl == null) { Response.Redirect("~/default.aspx", true); } // get the customisation scs = (sessioncustomisations)Session["sessioncustomisation"]; if (scs == null) { scs = new sessioncustomisations(); } // get all the articles and add all customisable items sas = (sessionarticles)Session["sessionarticles"]; if (sas == null) { Response.Redirect("~/default.aspx", true); } sa = sas.getarticle(pl.articles[articleindex].name); if (sa == null) { Response.Redirect("~/default.aspx", true); } if (Page.IsPostBack == false) { setuppage(); } else { savecustomisations(); } }
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) { sessionpagelayout spl; pagelayout pl = null; Graphics gbackground; //, gthumbnail; System.Drawing.Bitmap bbackground, bbackgroundimage, barticles; //, bthumbnail; //string thumbnailfilename; sessionpictures sps; Response.ClearContent(); Response.ContentType = "image/jpeg"; spl = (sessionpagelayout)Session["sessionpagelayout"]; if (spl != null) { pl = ceddio.loadpagelayout(spl.pagelayoutfilename); } // if there is no layout specified the redirect back to the home page if (pl == null) { Response.Redirect("~/default.aspx", true); } sps = (sessionpictures)Session["sessionpictures"]; // some pictures seem to have some funny information in them which messes up the dimensions and suchlike, Couldn't find a way to work out what was doing this or to reset it so we create our own bitmap which will have default settings which we can rely on bbackgroundimage = pl.backgroundimage; bbackground = new Bitmap(bbackgroundimage.Width, bbackgroundimage.Height); gbackground = Graphics.FromImage(bbackground); gbackground.PageUnit = GraphicsUnit.Pixel; gbackground.PageScale = 1; gbackground.ResetTransform(); gbackground.PixelOffsetMode = PixelOffsetMode.None; gbackground.DrawImage(bbackgroundimage, new Rectangle(0, 0, bbackgroundimage.Width, bbackgroundimage.Height)); // get an image containing just the text overlay barticles = articlesdrawer.drawarticles(pl, (sessionarticles)Session["sessionarticles"], (sessioncustomisations)Session["sessioncustomisation"], sps, false); // save thumbnails of the background and the text /* * bthumbnail = (System.Drawing.Bitmap) ceddutils.generatethumbnail((System.Drawing.Image) bbackground, (int)((float)bbackground.Width / ((float)bbackground.Height / 150.0)), 150); * gthumbnail = Graphics.FromImage(bthumbnail); * gthumbnail.DrawImage(barticles, 0, 0, bthumbnail.Width, bthumbnail.Height); * * thumbnailfilename = Guid.NewGuid().ToString() + ".jpg"; * bthumbnail.Save(Server.MapPath("~/frontpagethumbnails/") + thumbnailfilename, ImageFormat.Jpeg); * Session["frontpagethumbnail"] = thumbnailfilename; */ try { //serializer = new XmlSerializer(typeof(sessionpictures)); //StringReader sr = new StringReader(HttpUtility.UrlDecode(Request.Cookies["pictures"].Value)); //sps = (sessionpictures)serializer.Deserialize(sr); picturedrawer p = new picturedrawer(); p.drawpictures(gbackground, pl, sps); } catch { } // combine the background and the text and return it gbackground.DrawImage(barticles, new Rectangle(0, 0, bbackground.Width, bbackground.Height)); bbackground.Save(Response.OutputStream, ImageFormat.Jpeg); Response.End(); }
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(); }
protected void Page_Load(object sender, EventArgs e) { int i; HyperLink a; Literal l; try { spl = (sessionpagelayout)Session["sessionpagelayout"]; pl = ceddio.loadpagelayout(spl.pagelayoutfilename); } catch { Response.Redirect("default.aspx", true); } DataBind(); // add links to customise the various parts of the page // step 2 - choose articles // and step 3 - customise articles for (i = 0; i < pl.articles.Count; i++) { a = new HyperLink(); a.Text = "Change the " + pl.articles[i].prompt; a.NavigateUrl = "~/choose_articles.aspx?article=" + Convert.ToString(i) + "&return=true"; phchoosearticles.Controls.Add(a); if (i < pl.articles.Count - 1) { l = new Literal(); l.Text = "<br />"; phchoosearticles.Controls.Add(l); } a = new HyperLink(); a.Text = "Customise the " + pl.articles[i].prompt; a.NavigateUrl = "~/customise_articles.aspx?article=" + Convert.ToString(i) + "&return=true"; phcustomisearticles.Controls.Add(a); if (i < pl.articles.Count - 1) { l = new Literal(); l.Text = "<br />"; phcustomisearticles.Controls.Add(l); } } // and step 4 - choose pictures for (i = 0; i < pl.pictures.Count; i++) { a = new HyperLink(); a.Text = "Change the " + pl.pictures[i].prompt; a.NavigateUrl = "~/choose_pictures.aspx?picture=" + Convert.ToString(i) + "&return=true"; phchoosepictures.Controls.Add(a); if (i < pl.pictures.Count - 1) { l = new Literal(); l.Text = "<br />"; phchoosepictures.Controls.Add(l); } } /* * sessionpicture sp = new sessionpicture(); * sp.name = "main"; * sp.filename = "wahey.jpg"; * sp.thumbnailfilename = "wahey.jpg"; * sp.borderfilename = "border3.png"; * sp.imageheight = 536; * sp.imagewidth = 800; * sp.thumbnailheight = 800; * sp.thumbnailwidth = 800; * sp.offsetx = 270; * sp.offsety = 0; * sp.setzoom(1.2f); * //sp.setzoom(3f); * //sp.setzoom(1.5f); * sessionpictures sps = new sessionpictures(); * sps.Add(sp); * sps.setcookie(Response); * * sessionarticles sas = new sessionarticles(); * sas.addsessionarticle("main", "\\articles\\testarticle.xml"); * sas.setcookie(Response); * * sessionpagelayout spl = new sessionpagelayout(); * spl.pagelayoutfilename = "\\layouts\\testlayout3.xml"; * spl.setcookie(Response); * * Global.getcookiedata(Request, Session); * * articlestyles a = new articlestyles(); * //a.brush = new SolidBrush(Color.Black); * * textstyle ts = new textstyle(); * ts.style = textstyletype.headline; * ts.fontdef.family = "Arial"; * ts.fontdef.style = FontStyle.Regular; * ts.fontdef.size = 8; * a.text.Add(ts); * * paragraphstyle ps = new paragraphstyle(); * ps.style = paragraphstyletype.headline; * ps.justification = paragraphjustification.justified; * a.paragraph.Add(ps); * * // serialise the object * XmlSerializer serializer = new XmlSerializer(typeof(articlestyles)); * StringWriter tw = new StringWriter(); * serializer.Serialize(tw, a); * Literal1.Text = Server.HtmlEncode(tw.ToString()); * * // unserialise it, just to make sure that it works * StringReader sr = new StringReader(Server.HtmlDecode(Literal1.Text)); * a = (articlestyles)serializer.Deserialize(sr); * * // serialise it again so we can see the results * tw = new StringWriter(); * serializer.Serialize(tw, a); * Literal2.Text = Server.HtmlEncode(tw.ToString()); * * articlelayout al = new articlelayout(); * articlelayoutpart alp = new articlelayoutpart(); * al.layoutparts.Add(alp); * * alp.parttypes.Add(articleparttype.body); * * al.styles.text.Add(ts); * al.styles.paragraph.Add(ps); * * pagelayout pl = new pagelayout(); * pl.articles.Add(al); * pl.backgroundimagefilename = "frontpage.jpg"; * * // serialise the object * * serializer = new XmlSerializer(typeof(pagelayout)); * tw = new StringWriter(); * serializer.Serialize(tw, pl); * Literal3.Text = Server.HtmlEncode(tw.ToString()); * * // unserialise it, just to make sure that it works * sr = new StringReader(Server.HtmlDecode(Literal3.Text)); * pl = (pagelayout)serializer.Deserialize(sr); * * // serialise it again so we can see the results * tw = new StringWriter(); * serializer.Serialize(tw, pl); * Literal4.Text = Server.HtmlEncode(tw.ToString()); * * sometextstatic sts = new sometextstatic(); * sts.statictext = "Good morning "; * sts.style = textstyletype.intro; * * sometextreplace str = new sometextreplace(); * str.initialtext = "cedd"; * str.maxlength = 10; * str.prompt = "First name"; * str.style = textstyletype.intro; * * paragraph p = new paragraph(); * p.style = paragraphstyletype.intro; * p.textparts.Add(sts); * p.textparts.Add(str); * * article art = new article(); * articlepart artp = new articlepart(); * articlepart artp2 = new articlepart(); * artp2.parttype = articleparttype.subhead; * art.Add(artp); * art.Add(artp2); * * artp.paragraphs.Add(p); * artp.finetune.Add(p); * artp.finetune.Add(p); * * artp2.paragraphs.Add(p); * artp2.finetune.Add(p); * artp2.finetune.Add(p); * * // serialise the article * tw = new StringWriter(); * serializer = new XmlSerializer(typeof(article)); * serializer.Serialize(tw, art); * Literal5.Text = Server.HtmlEncode(tw.ToString()); * * // now deserialise it to make sure its the same! * sr = new StringReader(Server.HtmlDecode(Literal5.Text)); * art = (article)serializer.Deserialize(sr); * * // serialise it again so we can see the results * tw = new StringWriter(); * serializer.Serialize(tw, art); * Literal6.Text = Server.HtmlEncode(tw.ToString()); * * Bitmap bm = new Bitmap(40, 40); * * Graphics g = Graphics.FromImage(bm); * GraphicsPath ph = new GraphicsPath(); * Font f = new Font("Arial", 16); * ph.AddString("Cedditisj" , f.FontFamily, (int)f.Style, f.Size, new Point(0, 0), StringFormat.GenericTypographic); * ph.Flatten(new Matrix(), (float)0.01); * * for (int i = 0; i < ph.PathPoints.Length; i++) * { * Literal6.Text += "<BR>" + ph.PathPoints[i].X.ToString() + ", " + ph.PathPoints[i].Y.ToString() + ", " + ph.PathTypes[i].ToString(); * } * * GraphicsPathIterator gpi = new GraphicsPathIterator(ph); * * Literal6.Text += "<br>" + ph.GetBounds().ToString() + "<br>"; * Literal6.Text += g.MeasureString("C", f, 1000, StringFormat.GenericTypographic).ToString() + "<br>"; * Literal6.Text += gpi.SubpathCount + "<br>"; * * foreach (FontFamily ff in FontFamily.Families) * { * if (ff.IsStyleAvailable(FontStyle.Regular)) * { * Literal7.Text += ff.Name+"<br>"; * } * } */ }