private void DecodeProc(object param) { DecodeProcParams request = (DecodeProcParams)param; List <FrameData> frames = new List <FrameData>(); int width = 0; int height = 0; GifStream gifStream = new GifStream(request.filePath); int readFrame = 0; while (gifStream.HasMoreData) { if (readFrame >= request.frameToRead && request.frameToRead > 0) { break; } switch (gifStream.CurrentToken) { case GifStream.Token.Image: var image = gifStream.ReadImage(); width = gifStream.Header.width; height = gifStream.Header.height; Color32[] copiedColors = new Color32[image.colors.Length]; image.colors.CopyTo(copiedColors, 0); frames.Add(new FrameData() { colors = copiedColors, delay = image.DelaySeconds }); readFrame++; break; default: gifStream.SkipToken(); break; } } gifStream.Dispose(); request.runner.RunInMainThread(() => { Texture2D[] textures = new Texture2D[frames.Count]; int fps = 2; float totalTime = 0; for (int i = 0; i < frames.Count; i++) { textures[i] = new Texture2D(width, height, TextureFormat.ARGB32, false, false); textures[i].name = i.ToString(); textures[i].SetPixels32(frames[i].colors); textures[i].Apply(); totalTime += frames[i].delay; fps = Mathf.RoundToInt(frames.Count / totalTime); } animatedClip = new AnimatedClip(width, height, fps, textures); IsCompleted = true; request.runner.DestroySelf(); }); }
// Decode gif file to textures frame list private void DecodeGif(byte[] bytes) { var ms = new MemoryStream(bytes); frames = new List <Texture>(); frameDelays = new List <float>(); // To stop playing previous gif index = 0; using (var gifStream = new GifStream(ms)) { while (gifStream.HasMoreData) { switch (gifStream.CurrentToken) { case GifStream.Token.Image: // var image = gifStream.ReadImage(); // do something with image // This code is copy from Unitylist var image = gifStream.ReadImage(); var frame = new Texture2D( gifStream.Header.width, gifStream.Header.height, TextureFormat.ARGB32, false); frame.SetPixels32(image.colors); frame.Apply(); frames.Add(frame); frameDelays.Add(image.SafeDelaySeconds); // More about SafeDelay below break; case GifStream.Token.Comment: var comment = gifStream.ReadComment(); // log this comment break; default: gifStream.SkipToken(); // this token has no use for you, skip it break; } } } }
/* * add image data */ void addImage() { /* * LZW code size * set it to one more than the colour bits so we can have * transparent bit */ this.write8((byte)(this.numColourBits + 1)); GifStream gifStream = new GifStream(this.stream); int clearCode = 1 << (this.numColourBits + 1); int curPos = 0; int numPixels = this.width * this.height; int pixelPos = numPixels >> 3; int numTokens = 1 << this.numColourBits; gifStream.write(clearCode); while (curPos < numPixels) { if ((curPos % numTokens) == 0) { gifStream.write(clearCode); } if (this.isMask(curPos)) { gifStream.write(this.transparentColour); } else { gifStream.write(this.getPixel(curPos)); } curPos++; } gifStream.write(clearCode + 1); gifStream.flush(); this.write8(0); }
void LoadRegularPage() { //panel comicPanel = new Panel(); comicPanel.AutoSize = true; comicPanel.Width = REGULAR_COMIC_PANEL_WIDTH; comicPanel.MaximumSize = new Size(REGULAR_COMIC_PANEL_WIDTH, Int32.MaxValue); comicPanel.Location = new Point(mainPanel.Width / 2 - comicPanel.Width / 2, REGULAR_COMIC_PANEL_Y_OFFSET); comicPanel.BackColor = Color.FromArgb(REGULAR_COMIC_PANEL_COLOUR_R, REGULAR_COMIC_PANEL_COLOUR_G, REGULAR_COMIC_PANEL_COLOUR_B); mainPanel.Controls.Add(comicPanel); //title title = new GrowRich(); title.Width = REGULAR_PAGE_TITLE_WIDTH; title.SelectionAlignment = HorizontalAlignment.Center; title.Font = new System.Drawing.Font("Courier New", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); title.Text = page.meta.title; comicPanel.Controls.Add(title); title.Location = new Point(comicPanel.Width / 2 - title.Width / 2, REGULAR_TITLE_Y_OFFSET); //content int currentHeight = !Enum.IsDefined(typeof(Writer.FullScreenFlashes), page.number) ? title.Location.Y + title.Height + REGULAR_TITLE_Y_OFFSET : 0; if (Parser.IsOpenBound(page.number)) { flash = new WebBrowser(); comicPanel.Controls.Add(flash); InitOpenbound(); flash.Location = new Point(comicPanel.Width / 2 - flash.Width / 2, currentHeight); currentHeight += flash.Height; pageContainsFlash = true; } else { for (int i = 0; i < page.resources.Count(); i++) { if (i == page.resources.Count() - 1 && Parser.Is2x(page.number) && page.resources != page.resources2) { currentHeight -= REGULAR_COMIC_PANEL_BOTTOM_Y_OFFSET; continue; } if (page.resources[i].isInPesterLog) continue; if (!pageContainsFlash && ((page.number == 8848 || page.number == 8850) //special horizontal scroll || !Parser.IsGif(page.resources[i].originalFileName))) { if (Path.GetExtension(page.resources[i].originalFileName) == ".mp4") { FVideoPlayer = TryInitVLC(); if (FVideoPlayer == null) return; var loc = WriteTempResource(ref page.resources[i]); FVideoPlayer.Width = Width; FVideoPlayer.Height = Height; FVideoPlayer.SetMedia(new FileInfo(loc)); FVideoPlayer.Play(); Controls.Add(FVideoPlayer); currentHeight += 750; } else { flash = new WebBrowser(); comicPanel.Controls.Add(flash); InitFlashMovie(flash, page.resources[i]); flash.Location = new Point(comicPanel.Width / 2 - flash.Width / 2, currentHeight); currentHeight += flash.Height; pageContainsFlash = true; } } else if (Parser.IsGif(page.resources[i].originalFileName)) { var tempPB = new GifStream(); tempPB.loc = new System.IO.MemoryStream(page.resources[i].data); tempPB.gif = new PictureBox(); tempPB.gif.Image = Image.FromStream(tempPB.loc); tempPB.gif.Width = tempPB.gif.Image.Width; tempPB.gif.Height = tempPB.gif.Image.Height; tempPB.gif.Location = new Point(comicPanel.Width / 2 - tempPB.gif.Width / 2, currentHeight); comicPanel.Controls.Add(tempPB.gif); currentHeight += tempPB.gif.Height; if (i < page.resources.Count() - 1 || (page.resources[page.resources.Count() - 1].isInPesterLog && i == page.resources.Count() - 1)) currentHeight += REGULAR_COMIC_PANEL_BOTTOM_Y_OFFSET; gifs.Add(tempPB); } } } if (!Enum.IsDefined(typeof(Writer.FullScreenFlashes), page.number)) currentHeight += REGULAR_SPACE_BETWEEN_CONTENT_AND_TEXT; //words int leftSide; if (page.meta.narr != null) { narrative = new GrowRich(); narrative.Width = REGULAR_NARRATIVE_WIDTH; narrative.DetectUrls = true; narrative.SelectionAlignment = HorizontalAlignment.Center; narrative.Font = new System.Drawing.Font("Courier New", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); narrative.Text = page.meta.narr.text; narrative.ForeColor = System.Drawing.ColorTranslator.FromHtml(page.meta.narr.hexColour); var tmpl = narrative; if (page.meta.narr.subTexts.Count() != 0) for (int j = 0; j < page.meta.narr.subTexts.Count(); ++j) { if (!page.meta.narr.subTexts[j].isImg && !page.meta.narr.subTexts[j].isLink) { //font change tmpl.Select(page.meta.narr.subTexts[j].begin, page.meta.narr.subTexts[j].length); if (page.meta.narr.subTexts[j].underlined) tmpl.SelectionFont = new System.Drawing.Font("Courier New", 10.5F, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0))); tmpl.SelectionColor = System.Drawing.ColorTranslator.FromHtml(page.meta.narr.subTexts[j].colour); } else if (page.meta.narr.subTexts[j].isLink) { //so since rtf hyperlinks are broken to f**k we'll just improvise var link = new GrowLinkLabel(); tmpl.Select(page.meta.narr.subTexts[j].begin, page.meta.narr.subTexts[j].length); link.Text = tmpl.SelectedText; link.Font = narrative.Font; var inlineLink = page.meta.narr.subTexts[j].colour; //for lack of a better place to put this snippet/lazyness' if (page.number == (int)Writer.StoryBoundaries.EOHSB) link.Click += (o, i) => { WakeUpMr((int)Writer.StoryBoundaries.HOMESTUCK_PAGE_ONE); }; else link.Click += (o, i) => { System.Diagnostics.Process.Start(inlineLink); }; link.Width = narrative.Width; link.Height = narrative.Height; link.TextAlign = ContentAlignment.MiddleCenter; conversations.Add(new LineOrPB(link)); } else { //inline image //what needs to happen here is we need to advance the text so that the image can fit in which should just be " " times some factor of the width of the image //for now assume 1space = 10.5 pt = 14px Parser.Resource inlineImg = Array.Find(page.resources, x => x.isInPesterLog == true && x.originalFileName == page.meta.narr.subTexts[j].colour); var tmpPB = new GifStream(); tmpPB.loc = new MemoryStream(inlineImg.data); tmpPB.gif = new PictureBox(); tmpPB.gif.Image = Image.FromStream(tmpPB.loc); string spaces = ""; int needed = tmpPB.gif.Image.Width / 14; for (int k = 0; k < needed; ++k) spaces += " "; tmpl.Text = tmpl.Text.Substring(0, page.meta.narr.subTexts[j].begin) + spaces + tmpl.Text.Substring(page.meta.narr.subTexts[j].begin); //just dispose the picture while we are testing this tmpPB.gif.Dispose(); tmpPB.loc.Dispose(); } } leftSide = comicPanel.Width / 2 - narrative.Width / 2; narrative.Location = new Point(leftSide, currentHeight); currentHeight += narrative.Height; comicPanel.Controls.Add(narrative); foreach (var link in conversations) { comicPanel.Controls.Add(link.GetControl()); link.GetControl().Location = narrative.Location; link.GetControl().BringToFront(); } } else { pesterlog = new Panel(); pesterlog.AutoSize = true; pesterlog.Width = REGULAR_PESTERLOG_WIDTH; pesterlog.Height = REGULAR_PESTERLOG_HEIGHT; pesterlog.MinimumSize = new Size(REGULAR_PESTERLOG_WIDTH, REGULAR_PESTERLOG_HEIGHT); pesterlog.MaximumSize = new Size(REGULAR_PESTERLOG_WIDTH, Int32.MaxValue); pesterlog.BorderStyle = BorderStyle.FixedSingle; pesterlog.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; leftSide = comicPanel.Width / 2 - pesterlog.Width / 2; pesterlog.Location = new Point(leftSide, currentHeight); comicPanel.Controls.Add(pesterlog); pesterHideShow = new Button(); pesterHideShow.FlatStyle = FlatStyle.Flat; pesterHideShow.AutoSize = true; pesterHideShow.Font = new System.Drawing.Font("Arial", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); pesterHideShow.Text = "Show " + page.meta.promptType; pesterHideShow.Click += pesterHideShow_Click; pesterLogVisible = false; pesterlog.Controls.Add(pesterHideShow); pesterHideShow.Location = new Point(pesterlog.Width / 2 - pesterHideShow.Width / 2, 2); pLMaxHeight = currentHeight + REGULAR_SPACE_BETWEEN_CONTENT_AND_TEXT; //log lines for (int i = 0; i < page.meta.lines.Count(); ++i) { if (!page.meta.lines[i].isImg) { var tmpl = new GrowRich(); tmpl.Width = REGULAR_PESTERLOG_LINE_WIDTH; tmpl.DetectUrls = true; tmpl.MaximumSize = new Size(tmpl.Width, Int32.MaxValue); tmpl.Font = new System.Drawing.Font("Courier New", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); tmpl.BackColor = pesterlog.BackColor; //can't change forecolour otherwise tmpl.ForeColor = System.Drawing.ColorTranslator.FromHtml(page.meta.lines[i].hexColour); tmpl.Text = ""; tmpl.Text += page.meta.lines[i].text; if (page.meta.lines[i].subTexts.Count() != 0) for (int j = 0; j < page.meta.lines[i].subTexts.Count(); ++j) { if (!page.meta.lines[i].subTexts[j].isImg && !page.meta.lines[i].subTexts[j].isLink) { //font change tmpl.Select(page.meta.lines[i].subTexts[j].begin, page.meta.lines[i].subTexts[j].length); if (page.meta.lines[i].subTexts[j].underlined) tmpl.SelectionFont = new System.Drawing.Font("Courier New", 10.5F, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0))); tmpl.SelectionColor = System.Drawing.ColorTranslator.FromHtml(page.meta.lines[i].subTexts[j].colour); } else if (page.meta.lines[i].subTexts[j].isLink) { tmpl.Select(page.meta.lines[i].subTexts[j].begin, page.meta.lines[i].subTexts[j].length); tmpl.DetectUrls = true; tmpl.AppendText(page.meta.lines[i].subTexts[j].colour); Debugger.Break(); } else { //inline image //what needs to happen here is we need to advance the text so that the image can fit in which should just be " " times some factor of the width of the image //for now assume 1space = 10.5 pt = 14px Parser.Resource inlineImg = Array.Find(page.resources, x => x.isInPesterLog == true && x.originalFileName == page.meta.lines[i].subTexts[j].colour); var tmpPB = new GifStream(); tmpPB.loc = new MemoryStream(inlineImg.data); tmpPB.gif = new PictureBox(); tmpPB.gif.Image = Image.FromStream(tmpPB.loc); string spaces = ""; int needed = tmpPB.gif.Image.Width / 14; for (int k = 0; k < needed; ++k) spaces += " "; tmpl.Text = tmpl.Text.Substring(0, page.meta.lines[i].subTexts[j].begin) + spaces + tmpl.Text.Substring(page.meta.lines[i].subTexts[j].begin); //just dispose the picture while we are testing this tmpPB.gif.Dispose(); tmpPB.loc.Dispose(); } } tmpl.Location = new Point(pesterlog.ClientSize.Width / 2 - tmpl.Width / 2, pLMaxHeight - currentHeight); pLMaxHeight += tmpl.Height; conversations.Add(new LineOrPB(tmpl)); } else { //find the resource var tmpI = Array.Find(page.resources, x => x.isInPesterLog == true && x.originalFileName == page.meta.lines[i].text); //TODO: Handle image lines ("SHE HAS WHAT????") if (Parser.IsGif(tmpI.originalFileName)) { var tempPB = new GifStream(); tempPB.loc = new System.IO.MemoryStream(tmpI.data); tempPB.gif = new PictureBox(); tempPB.gif.Image = Image.FromStream(tempPB.loc); tempPB.gif.Width = tempPB.gif.Image.Width; tempPB.gif.Height = tempPB.gif.Image.Height; tempPB.gif.Location = new Point(pesterlog.ClientSize.Width / 2 - REGULAR_PESTERLOG_LINE_WIDTH / 2, pLMaxHeight - currentHeight); pLMaxHeight += tempPB.gif.Height; conversations.Add(new LineOrPB(tempPB)); } else { //there's problems Debugger.Break(); //then let us bounce } } } currentHeight += pesterlog.Height; pLMinHeight = currentHeight; pLMaxHeight += REGULAR_SPACE_BETWEEN_CONTENT_AND_TEXT; } if (!Enum.IsDefined(typeof(Writer.FullScreenFlashes), page.number)) currentHeight += REGULAR_SPACE_BETWEEN_CONTENT_AND_TEXT; //add 2x fake link if (Parser.Is2x(page.number) && page.resources != page.resources2) { var tempPB = new GifStream(); tempPB.loc = new System.IO.MemoryStream(page.resources[page.resources.Count() - 1].data); tempPB.gif = new PictureBox(); tempPB.gif.Image = Image.FromStream(tempPB.loc); tempPB.gif.Width = tempPB.gif.Image.Width; tempPB.gif.Height = tempPB.gif.Image.Height; tempPB.gif.Location = new Point(comicPanel.Width / 2 - tempPB.gif.Width / 2, currentHeight); comicPanel.Controls.Add(tempPB.gif); currentHeight += tempPB.gif.Height; gifs.Add(tempPB); } //next page if (page.number < db.lastPage && page.links != null) { for (int i = 0; i < page.links.Count(); i++) { var linkPrefixn = new Label(); linkPrefixn.AutoSize = true; linkPrefixn.Font = new System.Drawing.Font("Verdana", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); linkPrefixn.Text = REGULAR_LINK_PREFIX; linkPrefixn.Location = new Point(leftSide, currentHeight); comicPanel.Controls.Add(linkPrefixn); linkPrefix.Add(linkPrefixn); var nextn = new GrowLinkLabel(); nextn.Width = 600; nextn.Font = new System.Drawing.Font("Verdana", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); nextn.Text = " " + page.links[i].originalText; nextn.Location = new Point(leftSide, currentHeight); var tmpi = i; //I really don't know how these labmdas work sometimes if (Enum.IsDefined(typeof(Writer.PasswordPages), page.links[tmpi].pageNumber)) nextn.LinkClicked += HandleTereziPassword; else nextn.LinkClicked += (o, z) => { WakeUpMr(page.links[tmpi].pageNumber); }; comicPanel.Controls.Add(nextn); next.Add(nextn); linkPrefixn.BringToFront(); if (i < page.links.Count() - 1) currentHeight += nextn.Height; } } comicPanel.Height = currentHeight + REGULAR_COMIC_PANEL_BOTTOM_PADDING; mainPanel.Height = comicPanel.Height + REGULAR_COMIC_PANEL_Y_OFFSET + REGULAR_COMIC_PANEL_BOTTOM_Y_OFFSET; if (page.meta.promptType == "CalibornLog") FixNarrativePrompt(); RemoveControl(pageLoadingProgress);RemoveControl(progressLabel); }
void LoadOvershine() { //panel comicPanel = new Panel(); comicPanel.AutoSize = true; comicPanel.Width = REGULAR_COMIC_PANEL_WIDTH; comicPanel.MaximumSize = new Size(REGULAR_COMIC_PANEL_WIDTH, Int32.MaxValue); comicPanel.Location = new Point(mainPanel.Width / 2 - comicPanel.Width / 2, REGULAR_COMIC_PANEL_Y_OFFSET); comicPanel.BackColor = Color.FromArgb(REGULAR_COMIC_PANEL_COLOUR_R, REGULAR_COMIC_PANEL_COLOUR_G, REGULAR_COMIC_PANEL_COLOUR_B); var bright = new GifStream(); bright.loc = new MemoryStream(page.resources[0].data); bright.gif = new PictureBox(); var gif = bright.gif; gif.Image = Image.FromStream(bright.loc); gif.Width = gif.Image.Width; gif.Height = gif.Image.Height; comicPanel.Height = 743; mainPanel.Controls.Add(gif); gif.Location = new Point(0, 0); mainPanel.Controls.Add(comicPanel); //next page var currentHeight = gif.Height + REGULAR_SPACE_BETWEEN_CONTENT_AND_TEXT; var leftSide = comicPanel.Width / 2 - REGULAR_PESTERLOG_WIDTH / 2; if (page.number < db.lastPage && page.links != null) { for (int i = 0; i < page.links.Count(); i++) { var linkPrefixn = new Label(); linkPrefixn.AutoSize = true; linkPrefixn.Font = new System.Drawing.Font("Verdana", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); linkPrefixn.Text = REGULAR_LINK_PREFIX; linkPrefixn.Location = new Point(leftSide, currentHeight); comicPanel.Controls.Add(linkPrefixn); linkPrefix.Add(linkPrefixn); var nextn = new GrowLinkLabel(); nextn.Width = 600; nextn.Font = new System.Drawing.Font("Verdana", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); nextn.Text = " " + page.links[i].originalText; nextn.Location = new Point(leftSide, currentHeight); var tmpi = i; //I really don't know how these labmdas work sometimes nextn.LinkClicked += (o, z) => { WakeUpMr(page.links[tmpi].pageNumber); }; comicPanel.Controls.Add(nextn); next.Add(nextn); linkPrefixn.BringToFront(); if (i < page.links.Count() - 1) currentHeight += nextn.Height; } } comicPanel.Height = currentHeight + REGULAR_COMIC_PANEL_BOTTOM_PADDING; mainPanel.Height = comicPanel.Height + REGULAR_COMIC_PANEL_Y_OFFSET + REGULAR_COMIC_PANEL_BOTTOM_Y_OFFSET; RemoveControl(pageLoadingProgress); RemoveControl(progressLabel); }
void LoadCascade() { //cascade has no comic panel, use the mainPanel comicPanel = mainPanel; comicPanel.Location = new Point(comicPanel.Location.X, 0); //title is part of the flash title = null; //special header var tempPB = new GifStream(); tempPB.loc = new System.IO.MemoryStream(page.resources[6].data); tempPB.gif = new PictureBox(); tempPB.gif.Image = Image.FromStream(tempPB.loc); tempPB.gif.Width = tempPB.gif.Image.Width; tempPB.gif.Height = tempPB.gif.Image.Height; tempPB.gif.Location = new Point(comicPanel.Width / 2 - tempPB.gif.Width / 2, 0); comicPanel.Controls.Add(tempPB.gif); gifs.Add(tempPB); //* //first write the segments WriteTempResource(ref page.resources[1]); WriteTempResource(ref page.resources[2]); WriteTempResource(ref page.resources[3]); WriteTempResource(ref page.resources[4]); WriteTempResource(ref page.resources[5]); flash = new WebBrowser(); comicPanel.Controls.Add(flash); InitFlashMovie(flash, page.resources[0]); flash.Location = new Point(comicPanel.Width / 2 - flash.Width / 2, CASCADE_PANEL_Y_OFFSET + REGULAR_PANEL_Y_OFFSET + 40); // * */ pageContainsFlash = true; var linkPrefixn = new Label(); linkPrefixn.AutoSize = true; linkPrefixn.Font = new System.Drawing.Font("Verdana", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); linkPrefixn.Text = REGULAR_LINK_PREFIX; linkPrefixn.Location = new Point(REGULAR_PANEL_WIDTH / 2 - REGULAR_PESTERLOG_WIDTH/2, flash.Location.Y + flash.Height + 23); comicPanel.Controls.Add(linkPrefixn); linkPrefix.Add(linkPrefixn); var nextn = new GrowLinkLabel(); nextn.Width = 600; nextn.Font = new System.Drawing.Font("Verdana", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); nextn.Text = " " + page.links[0].originalText; nextn.Location = linkPrefixn.Location; //TODO: MAGIC NUMBERS!!! nextn.LinkClicked += (o, z) => { WakeUpMr(page.links[0].pageNumber); }; comicPanel.Controls.Add(nextn); next.Add(nextn); linkPrefixn.BringToFront(); mainPanel.Height = flash.Location.Y + flash.Height + CASCADE_BOTTOM_Y_OFFSET; headerPanel.BringToFront(); RemoveControl(pageLoadingProgress);RemoveControl(progressLabel); }
void CurtainsUp(Writer.Style s = Writer.Style.REGULAR) { previousStyle = s; CleanControls(); headerPanel = null; switch (s) { case Writer.Style.JAILBREAK: case Writer.Style.OVERSHINE: case Writer.Style.REGULAR: BackColor = Color.FromArgb(REGULAR_BACK_COLOUR_R, REGULAR_BACK_COLOUR_G, REGULAR_BACK_COLOUR_B); mainPanel = new Panel(); mainPanel.AutoSize = true; mainPanel.MaximumSize = new System.Drawing.Size(REGULAR_PANEL_WIDTH, Int32.MaxValue); mainPanel.Width = REGULAR_PANEL_WIDTH; mainPanel.Location = new Point(this.Width / 2 - mainPanel.Width / 2, REGULAR_PANEL_Y_OFFSET); mainPanel.BackColor = Color.FromArgb(REGULAR_PANEL_COLOUR_R, REGULAR_PANEL_COLOUR_G, REGULAR_PANEL_COLOUR_B); Controls.Add(mainPanel); SetupHeader(); break; case Writer.Style.X2: BackColor = Color.FromArgb(REGULAR_BACK_COLOUR_R, REGULAR_BACK_COLOUR_G, REGULAR_BACK_COLOUR_B); mainPanel = new Panel(); mainPanel.AutoSize = true; mainPanel.MaximumSize = new System.Drawing.Size(1660, Int32.MaxValue); mainPanel.Width = 1660; mainPanel.Location = new Point(this.Width / 2 - mainPanel.Width / 2, 66); mainPanel.BackColor = Color.FromArgb(REGULAR_PANEL_COLOUR_R, REGULAR_PANEL_COLOUR_G, REGULAR_PANEL_COLOUR_B); Controls.Add(mainPanel); SetupHeader(); headerPanel.Location = new Point(headerPanel.Location.X, headerPanel.Location.Y + 47); headerP = new GifStream(); headerP.loc = new MemoryStream(db.Getx2Header()); headerP.gif = new PictureBox(); headerP.gif.Image = Image.FromStream(headerP.loc); headerP.gif.Width = mainPanel.Width; headerP.gif.Height = 47; Controls.Add(headerP.gif); headerP.gif.Location = new Point(mainPanel.Location.X, 0); break; case Writer.Style.CASCADE: BackColor = Color.FromArgb(CASCADE_BACK_COLOUR_R, CASCADE_BACK_COLOUR_G, CASCADE_BACK_COLOUR_B); mainPanel = new Panel(); mainPanel.AutoSize = true; mainPanel.MaximumSize = new System.Drawing.Size(REGULAR_PANEL_WIDTH, Int32.MaxValue); mainPanel.Width = REGULAR_PANEL_WIDTH; mainPanel.Location = new Point(this.Width / 2 - mainPanel.Width / 2, 0); mainPanel.BackColor = Color.FromArgb(CASCADE_PANEL_COLOUR_R, CASCADE_PANEL_COLOUR_G, CASCADE_PANEL_COLOUR_B); Controls.Add(mainPanel); SetupHeader(); headerPanel.Location = new Point(headerPanel.Location.X, CASCADE_PANEL_Y_OFFSET); break; case Writer.Style.SMASH: BackColor = Color.FromArgb(REGULAR_BACK_COLOUR_R, REGULAR_BACK_COLOUR_G, REGULAR_BACK_COLOUR_B); mainPanel = new Panel(); mainPanel.AutoSize = true; mainPanel.MaximumSize = new System.Drawing.Size(REGULAR_PANEL_WIDTH, Int32.MaxValue); mainPanel.Width = REGULAR_PANEL_WIDTH; mainPanel.Location = new Point(this.Width / 2 - mainPanel.Width / 2, 0); mainPanel.BackColor = Color.FromArgb(CASCADE_PANEL_COLOUR_R, CASCADE_PANEL_COLOUR_G, CASCADE_PANEL_COLOUR_B); Controls.Add(mainPanel); break; case Writer.Style.SCRATCH: BackColor = Color.FromArgb(SCRATCH_BACK_COLOUR_R, SCRATCH_BACK_COLOUR_G, SCRATCH_BACK_COLOUR_B); mainPanel = new Panel(); mainPanel.AutoSize = true; mainPanel.MaximumSize = new System.Drawing.Size(REGULAR_PANEL_WIDTH, Int32.MaxValue); mainPanel.Width = REGULAR_PANEL_WIDTH; mainPanel.Location = new Point(this.Width / 2 - mainPanel.Width / 2, 0); mainPanel.BackColor = Color.FromArgb(SCRATCH_PANEL_COLOUR_R, SCRATCH_PANEL_COLOUR_G, SCRATCH_PANEL_COLOUR_B); Controls.Add(mainPanel); SetupHeader(); headerPanel.Location = new Point(headerPanel.Location.X,SCRATCH_HEADER_Y); //color header approprately headerPanel.BackColor = Color.Black; foreach (Control con in headerPanel.Controls) con.BackColor = Color.Black; headerPanel.BringToFront(); for (int i = 0; i < mspaHeaderLink.Count(); ++i) { mspaHeaderLink[i].ForeColor = Color.White; } SetCandy(Writer.IconTypes.CUEBALL); break; case Writer.Style.DOTA: BackColor = Color.Black; mainPanel = new Panel(); mainPanel.BackColor = Color.Black; mainPanel.MaximumSize = new System.Drawing.Size(REGULAR_PANEL_WIDTH, Int32.MaxValue); mainPanel.Width = REGULAR_PANEL_WIDTH; mainPanel.Location = new Point(this.Width / 2 - mainPanel.Width / 2, 0); Controls.Add(mainPanel); break; case Writer.Style.SHES8ACK: BackColor = Color.White; mainPanel = new Panel(); mainPanel.BackColor = Color.White; mainPanel.MaximumSize = new System.Drawing.Size(REGULAR_PANEL_WIDTH, Int32.MaxValue); mainPanel.Width = REGULAR_PANEL_WIDTH; mainPanel.Location = new Point(this.Width / 2 - mainPanel.Width / 2, 0); Controls.Add(mainPanel); break; case Writer.Style.HOMOSUCK: case Writer.Style.GAMEOVER: BackColor = Color.FromArgb(4, 35, 0); mainPanel = new Panel(); mainPanel.BackColor = Color.FromArgb(4, 35, 0); mainPanel.MaximumSize = new System.Drawing.Size(REGULAR_PANEL_WIDTH, Int32.MaxValue); mainPanel.Width = REGULAR_PANEL_WIDTH; mainPanel.Location = new Point(this.Width / 2 - mainPanel.Width / 2, 0); Controls.Add(mainPanel); if (s == Writer.Style.HOMOSUCK) StyleHomosuck(); break; case Writer.Style.TRICKSTER: BackColor = Color.White; mainPanel = new Panel(); mainPanel.BackColor = Color.White; mainPanel.MaximumSize = new System.Drawing.Size(REGULAR_PANEL_WIDTH, Int32.MaxValue); mainPanel.Width = REGULAR_PANEL_WIDTH; mainPanel.Location = new Point(this.Width / 2 - mainPanel.Width / 2, 24); Controls.Add(mainPanel); trick = new TricksterShit(this,db.GetTricksterShit()); break; case Writer.Style.SBAHJ: BackColor = Color.FromArgb(7,7,236); mainPanel = new Panel(); mainPanel.BackColor = Color.FromArgb(244, 0, 236); mainPanel.MaximumSize = new System.Drawing.Size(REGULAR_PANEL_WIDTH, Int32.MaxValue); mainPanel.Width = REGULAR_PANEL_WIDTH; mainPanel.Location = new Point(this.Width / 2 - mainPanel.Width / 2, 24); Controls.Add(mainPanel); SetupHeader(); headerPanel.BackColor = Color.Black; break; default: Debugger.Break(); break; } if (candyCorn[0].Image == null) SetCandy(Writer.IconTypes.CANDYCORN); }
void CleanControls() { CleanComic(); if (trick != null) { trick.Dispose(); trick = null; } RemoveControl(mainPanel); for (int i = 0; i < mspaHeaderLink.Count(); ++i) RemoveControl(mspaHeaderLink[i]); for (int i = 0; i < candyCorn.Count(); ++i) RemoveControl(candyCorn[i]); RemoveControl(headerPanel); RemoveControl(pageLoadingProgress); RemoveControl(progressLabel); if (currentIcon != null) { currentIcon.gif.Dispose(); currentIcon.loc.Dispose(); currentIcon = null; } if (headerP != null) { headerP.gif.Dispose(); headerP.loc.Dispose(); headerP = null; } }
public LineOrPB(GifStream g) { isImg = true; strm = g; }
void LoadScratchPage() { LoadRegularPage(); //special header var tempPB = new GifStream(); tempPB.loc = new System.IO.MemoryStream(page.resources[0].data); //always the first tempPB.gif = new PictureBox(); tempPB.gif.Image = Image.FromStream(tempPB.loc); tempPB.gif.SizeMode = PictureBoxSizeMode.CenterImage; tempPB.gif.Width = mainPanel.Width; tempPB.gif.Height = tempPB.gif.Image.Height; tempPB.gif.BackColor = Color.Black; //increase Y of all mainPanelItems and header by height foreach (Control i in mainPanel.Controls) i.Location = new Point(i.Location.X, i.Location.Y + SCRATCH_PANEL_Y_OFFSET); //mainPanel.Controls.Add(tempPB.gif); tempPB.gif.Location = new Point(mainPanel.Width / 2 - tempPB.gif.Width / 2, 0); mainPanel.Controls.Add(tempPB.gif); gifs.Add(tempPB); if (page.meta.altText != null) { var hoverText = new ToolTip(); hoverText.AutoPopDelay = 5000; hoverText.InitialDelay = 500; hoverText.ReshowDelay = 500; // Force the ToolTip text to be displayed whether or not the form is active. hoverText.ShowAlways = true; hoverText.SetToolTip(tempPB.gif, page.meta.altText); } //therefore also Remove the first var shiftHeight = gifs[0].gif.Height; gifs[0].gif.Dispose(); gifs[0].loc.Dispose(); gifs.RemoveAt(0); //decrease Y of all comicPanel Items and header by height except title foreach (Control con in comicPanel.Controls) if (con != title) con.Location = new Point(con.Location.X, con.Location.Y - shiftHeight); //recalculate bottoms comicPanel.Height -= shiftHeight; mainPanel.Height -= shiftHeight; pLMaxHeight -= shiftHeight; pLMinHeight -= shiftHeight; //set colours comicPanel.BackColor = Color.FromArgb(SCRATCH_COMIC_PANEL_COLOUR_R, SCRATCH_COMIC_PANEL_COLOUR_G, SCRATCH_COMIC_PANEL_COLOUR_B); title.BackColor = Color.FromArgb(SCRATCH_COMIC_PANEL_COLOUR_R, SCRATCH_COMIC_PANEL_COLOUR_G, SCRATCH_COMIC_PANEL_COLOUR_B); title.ForeColor = Color.White; if (page.meta.narr != null) { narrative.BackColor = Color.FromArgb(SCRATCH_COMIC_PANEL_COLOUR_R, SCRATCH_COMIC_PANEL_COLOUR_G, SCRATCH_COMIC_PANEL_COLOUR_B); } else { pesterlog.BackColor = Color.FromArgb(SCRATCH_COMIC_PANEL_COLOUR_R, SCRATCH_COMIC_PANEL_COLOUR_G, SCRATCH_COMIC_PANEL_COLOUR_B); foreach (var line in conversations) { line.GetControl().BackColor = Color.FromArgb(SCRATCH_COMIC_PANEL_COLOUR_R, SCRATCH_COMIC_PANEL_COLOUR_G, SCRATCH_COMIC_PANEL_COLOUR_B); } } //handle the top le text if in the range //TODO if (page.number >= 5976 && page.number <= 5981) { //kill off the second last gif var theLEText = gifs[gifs.Count - 2].gif.Height; comicPanel.Controls.Remove(gifs[gifs.Count - 2].gif); gifs[gifs.Count - 2].gif.BackColor = System.Drawing.Color.Transparent; gifs[gifs.Count - 2].gif.Visible = false; Controls.Add(gifs[gifs.Count - 2].gif); gifs[gifs.Count - 2].gif.BringToFront(); //move narrative/pesterlog and link up if (page.meta.narr != null) { narrative.Location = new Point(narrative.Location.X, narrative.Location.Y - theLEText); } else { foreach (var lin in conversations) { lin.GetControl().Location = new Point(lin.GetControl().Location.X, lin.GetControl().Location.Y - theLEText); } } foreach (var lp in linkPrefix) lp.Location = new Point(lp.Location.X, lp.Location.Y - theLEText); foreach (var lp in next) lp.Location = new Point(lp.Location.X, lp.Location.Y - theLEText); comicPanel.Height -= theLEText; mainPanel.Height -= theLEText; tempPB.gif.MouseMove += MoveLEText; tempPB.gif.MouseEnter += ShowLEText; tempPB.gif.MouseLeave += HideLEText; } foreach (var lp in linkPrefix) lp.ForeColor = Color.White; foreach (var lp in next) lp.LinkColor = Color.FromArgb(44, 255, 75); //TODO: }