예제 #1
0
 public void AddEvent(Journal.EventsRow er)
 {
     flm.Reset();
     System.Drawing.Bitmap b  = null;
     Journal.UserPicsRow   ur = null;
     if (!er.IsPictureKeywordNull())
     {
         ur = j.UserPics.FindByPicKeyword(er.PictureKeyword);
     }
     if (ur != null)
     {
         b = new Bitmap(SimpleCache.Cache.GetStream(ur.PicURL));
     }
     else if (!j.Options[0].IsDefaultPicURLNull() && er.Poster == j.Options[0].UserName)
     {
         b = new Bitmap(SimpleCache.Cache.GetStream(j.Options[0].DefaultPicURL));
     }
     if (b != null)
     {
         MemoryStream ms = new MemoryStream();
         b.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
         flm.AddBlock(new RepObj[] { new RepImageMM(ms, Double.NaN, Double.NaN) });
     }
     flm.AddBlock(fp_Header, "Poster: " + er.Poster);
     flm.AddBlock(fp_Header, "Date: " + er.Date.ToString());
     flm.NewLine(fp_Header.rLineFeed);
     foreach (string s in er.Body.Replace("\r", "").Split('\n'))
     {
         flm.AddBlock(Format(s));;
     }
 }
예제 #2
0
        /// <summary>
        /// Output a transformed entry to the HTML stream.
        /// </summary>
        private void WriteEvent(TextWriter tw, Journal.EventsRow er, Journal.UserPicsDataTable updt,
                                Journal.MoodsDataTable mdt)
        {
            ArrayList idstack = new ArrayList();

            foreach (string block in _rblock.Split(entry))
            {
                if (block.StartsWith("<%"))
                {
                    string id = block.Substring(2, block.Length - 4).Trim().ToLower();
                    // check the id stack for additions
                    if (id.StartsWith("!"))
                    {
                        string idToBlock = id.Substring(1);
                        switch (idToBlock)
                        {
                        case "userpicurl":
                            if ((!er.IsPosterNull() && er.Poster != options.UserName) ||
                                ((er.IsPictureKeywordNull() || updt.FindByPicKeyword(er.PictureKeyword) == null) &&
                                 (options.IsDefaultPicURLNull())))
                            {
                                idstack.Add(idToBlock);
                            }
                            break;

                        case "currentmood":
                            if (er.IsCurrentMoodNull() && (er.IsCurrentMoodIDNull() ||
                                                           mdt.FindByID(er.CurrentMoodID) == null))
                            {
                                idstack.Add(idToBlock);
                            }
                            break;

                        case "securityiconpath":
                            if (er.IsSecurityNull() || (er.Security != "usemask" && er.Security != "private"))
                            {
                                idstack.Add(idToBlock);
                            }
                            break;

                        default:
                            if (!er.Table.Columns.Contains(idToBlock) || er.IsNull(idToBlock))
                            {
                                idstack.Add(idToBlock);
                            }
                            break;
                        }
                        continue;
                    }
                    // check the id stack for removals
                    else if (id.StartsWith("/!"))
                    {
                        idstack.Remove(id.Substring(2));
                        continue;
                    }
                    else
                    {
                        // we don't output anything until the stack is empty
                        if (idstack.Count > 0)
                        {
                            continue;
                        }
                        switch (id)
                        {
                        case "userpicurl":
                            if (er.IsPosterNull() || er.Poster == options.UserName)
                            {
                                Journal.UserPicsRow ur = null;
                                if (!er.IsPictureKeywordNull())
                                {
                                    ur = updt.FindByPicKeyword(er.PictureKeyword);
                                }
                                if (ur != null)
                                {
                                    tw.Write(ur.PicURL);
                                }
                                else if (!options.IsDefaultPicURLNull())
                                {
                                    tw.Write(options.DefaultPicURL);
                                }
                            }
                            break;

                        case "currentmood":
                            if (!er.IsCurrentMoodNull())
                            {
                                WritePreparedText(tw, er.CurrentMood, entrySearchString);
                            }
                            else if (!er.IsCurrentMoodIDNull() && mdt.FindByID(er.CurrentMoodID) != null)
                            {
                                WritePreparedText(tw, mdt.FindByID(er.CurrentMoodID).Name, entrySearchString);
                            }
                            break;

                        case "securityiconpath":
                            if (!er.IsSecurityNull() && er.Security == "usemask")
                            {
                                tw.Write(hjws.ProtectedIconPath);
                            }
                            else if (!er.IsSecurityNull() && er.Security == "private")
                            {
                                tw.Write(hjws.PrivateIconPath);
                            }
                            break;

                        case "posterusername":
                            if (!options.IsUseJournalNull() && !er.IsPosterNull())
                            {
                                tw.Write(er.Poster);
                            }
                            else
                            {
                                tw.Write(options.UserName);
                            }
                            break;

                        default:
                            if (id == "subject" || id == "currentmusic" || id == "body")
                            {
                                WritePreparedText(tw, er[id].ToString(), entrySearchString);
                            }
                            else if (er.Table.Columns.Contains(id))
                            {
                                tw.Write(er[id]);
                            }
                            break;
                        }
                    }
                }
                else
                {
                    if (idstack.Count == 0)
                    {
                        tw.Write(block);
                    }
                }
            }
        }