Ejemplo n.º 1
0
 /// <summary>
 /// Icon collection for the theme
 /// </summary>
 public ThemeIconCollection()
 {
     About             = new ThemeImage();
     ActualSize        = new ThemeImage();
     AdjustWindowSize  = new ThemeImage();
     Checkerboard      = new ThemeImage();
     Convert           = new ThemeImage();
     FullScreen        = new ThemeImage();
     GoToImage         = new ThemeImage();
     LockRatio         = new ThemeImage();
     Menu              = new ThemeImage();
     OpenFile          = new ThemeImage();
     Plugins           = new ThemeImage();
     Print             = new ThemeImage();
     Refresh           = new ThemeImage();
     RotateLeft        = new ThemeImage();
     RotateRight       = new ThemeImage();
     Detele            = new ThemeImage();
     ScaleToHeight     = new ThemeImage();
     ScaleToWidth      = new ThemeImage();
     Settings          = new ThemeImage();
     Sharing           = new ThemeImage();
     Slideshow         = new ThemeImage();
     ThumbnailBar      = new ThemeImage();
     ViewNextImage     = new ThemeImage();
     ViewPreviousImage = new ThemeImage();
     ZoomIn            = new ThemeImage();
     ZoomOut           = new ThemeImage();
     ScaleToFit        = new ThemeImage();
     AutoZoom          = new ThemeImage();
 }
Ejemplo n.º 2
0
        public ActionResult AddTheme(ThemeImage ThemeImage)
        {
            if (Session["Username"] != null)
            {
                if (ThemeImage.Theme == null)
                {
                    ViewBag.ex = "Bạn chưa nhập chủ đề";
                    return(View());
                }
                else
                {
                    var theme1 = db_Trainee.ThemeImages.FirstOrDefault(x => x.Theme == ThemeImage.Theme);
                    if (theme1 == null)
                    {
                        db_Trainee.ThemeImages.Add(ThemeImage);
                        db_Trainee.SaveChanges();

                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ViewBag.ex = "Đã có chủ đề này !";
                        return(View());
                    }
                }
            }
            else
            {
                return(RedirectToAction("Index", "Error"));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Processes the item.
        /// </summary>
        /// <param name="e">The <see cref="RepeaterItemEventArgs" /> instance containing the event data.</param>
        /// <returns>Returns the Item as string</returns>
        private string ProcessItem(RepeaterItemEventArgs e)
        {
            var currentRow = (DataRowView)e.Item.DataItem;

            var currentItem = this.itemTemplate;

            var messageUrl =
                this.ResolveUrl(
                    "~/Default.aspx?tabid={1}&g=posts&m={0}#post{0}".FormatWith(
                        currentRow["LastMessageID"],
                        this.yafTabId));

            // make message url...
            if (Classes.Config.EnableURLRewriting)
            {
                messageUrl =
                    Globals.ResolveUrl(
                        "~/tabid/{0}/g/posts/m/{1}/{2}.aspx#post{1}".FormatWith(
                            this.yafTabId,
                            currentRow["LastMessageID"],
                            UrlRewriteHelper.CleanStringForURL(YafContext.Current.Get <IBadWordReplace>().Replace(currentRow["Topic"].ToString()))));
            }

            // Render [LASTPOSTICON]
            var lastPostedImage = new ThemeImage
            {
                LocalizedTitlePage = "DEFAULT",
                LocalizedTitleTag  = "GO_LAST_POST",
                LocalizedTitle     =
                    Localization.GetString("LastPost.Text", this.LocalResourceFile),
                ThemeTag = "TOPIC_NEW",
                Style    = "width:16px;height:16px"
            };

            currentItem = currentItem.Replace("[LASTPOSTICON]", lastPostedImage.RenderToString());

            // Render [TOPICLINK]
            var textMessageLink = new HyperLink
            {
                Text =
                    YafContext.Current.Get <IBadWordReplace>()
                    .Replace(currentRow["Topic"].ToString()),
                NavigateUrl = messageUrl
            };

            currentItem = currentItem.Replace("[TOPICLINK]", textMessageLink.RenderToString());

            // Render [FORUMLINK]
            var forumLink = new HyperLink
            {
                Text        = currentRow["Forum"].ToString(),
                NavigateUrl =
                    Classes.Config.EnableURLRewriting
                                            ? Globals.ResolveUrl(
                        "~/tabid/{0}/g/topics/f/{1}/{2}.aspx".FormatWith(
                            this.yafTabId,
                            currentRow["ForumID"],
                            currentRow["Forum"]))
                                            : this.ResolveUrl(
                        "~/Default.aspx?tabid={1}&g=topics&f={0}".FormatWith(
                            currentRow["ForumID"],
                            this.yafTabId))
            };

            currentItem = currentItem.Replace("[FORUMLINK]", forumLink.RenderToString());

            // Render [BYTEXT]
            currentItem = currentItem.Replace(
                "[BYTEXT]",
                YafContext.Current.Get <IHaveLocalization>().GetText("SEARCH", "BY"));

            // Render [LASTUSERLINK]
            // Just in case...
            if (currentRow["LastUserID"] != DBNull.Value)
            {
                var userName = YafContext.Current.Get <YafBoardSettings>().EnableDisplayName
                                   ? currentRow["LastUserDisplayName"].ToString()
                                   : currentRow["LastUserName"].ToString();

                userName = this.HtmlEncode(userName);

                var lastUserLink = new HyperLink
                {
                    Text        = userName,
                    ToolTip     = userName,
                    NavigateUrl =
                        Classes.Config.EnableURLRewriting
                                                   ? Globals.ResolveUrl(
                            "~/tabid/{0}/g/profile/u/{1}/{2}.aspx".FormatWith(
                                this.yafTabId,
                                currentRow["LastUserID"],
                                userName))
                                                   : this.ResolveUrl(
                            "~/Default.aspx?tabid={1}&g=profile&u={0}".FormatWith(
                                currentRow["LastUserID"],
                                this.yafTabId))
                };

                currentItem = currentItem.Replace("[LASTUSERLINK]", lastUserLink.RenderToString());
            }

            // Render [LASTMESSAGE]
            var lastMessage =
                BBCodeHelper.StripBBCode(
                    HtmlHelper.StripHtml(HtmlHelper.CleanHtmlString(currentRow["LastMessage"].ToType <string>())))
                .RemoveMultipleWhitespace();

            try
            {
                var match = Regex.Match(currentItem, @"\[LASTMESSAGE\:(?<count>[0-9]*)\]", RegexOptions.Compiled);

                if (match.Success)
                {
                    var messageLimit = match.Groups["count"].Value.ToType <int>();

                    currentItem = currentItem.Replace(
                        "[LASTMESSAGE:{0}]".FormatWith(match.Groups["count"].Value),
                        lastMessage.Truncate(messageLimit));
                }
                else
                {
                    currentItem = currentItem.Replace("[LASTMESSAGE]", lastMessage);
                }
            }
            catch (Exception)
            {
                currentItem = currentItem.Replace("[LASTMESSAGE]", lastMessage);
            }

            // Render [LASTPOSTEDDATETIME]
            var displayDateTime = new DisplayDateTime {
                DateTime = currentRow["LastPosted"].ToType <DateTime>()
            };

            currentItem = currentItem.Replace("[LASTPOSTEDDATETIME]", displayDateTime.RenderToString());

            return(currentItem);
        }
Ejemplo n.º 4
0
        protected override Theme Read(ContentReader input, Theme existingInstance)
        {
            if (existingInstance == null)
            {
                existingInstance = new Theme();
            }
            else
            {
                foreach (var cursor in existingInstance.Cursors)
                {
                    PlatformHelper.DestroyCursor(cursor.Cursor);
                }

                existingInstance.Cursors.Clear();
                existingInstance.Fonts.Clear();
                existingInstance.Styles.Clear();
                existingInstance.Textures.Clear();
            }

            existingInstance.Content = input.ContentManager;

            // Read cursors.
            int numberOfCursors = input.ReadInt32();

            for (int i = 0; i < numberOfCursors; i++)
            {
                var cursor = new ThemeCursor();
                cursor.Name      = input.ReadString();
                cursor.IsDefault = input.ReadBoolean();
                cursor.Cursor    = LoadCursor(input);
                existingInstance.Cursors.Add(cursor);
            }

            // Read fonts.
            int numberOfFonts = input.ReadInt32();

            for (int i = 0; i < numberOfFonts; i++)
            {
                var font = new ThemeFont();
                font.Name      = input.ReadString();
                font.IsDefault = input.ReadBoolean();
                font.Font      = input.ReadExternalReference <SpriteFont>();
                existingInstance.Fonts.Add(font);
            }

            // Read textures.
            int numberOfTextures = input.ReadInt32();

            for (int i = 0; i < numberOfTextures; i++)
            {
                var texture = new ThemeTexture();
                texture.Name      = input.ReadString();
                texture.IsDefault = input.ReadBoolean();
                texture.Texture   = input.ReadExternalReference <Texture2D>();
                existingInstance.Textures.Add(texture);
            }

            // Read styles.
            int numberOfStyles   = input.ReadInt32();
            var inheritanceTable = new Dictionary <ThemeStyle, string>();

            for (int i = 0; i < numberOfStyles; i++)
            {
                var style = new ThemeStyle();
                style.Name = input.ReadString();
                inheritanceTable.Add(style, input.ReadString());

                // Read attributes
                int numberOfAttributes = input.ReadInt32();
                for (int j = 0; j < numberOfAttributes; j++)
                {
                    var attribute = new ThemeAttribute();
                    attribute.Name  = input.ReadString();
                    attribute.Value = input.ReadString();
                    style.Attributes.Add(attribute);
                }

                // Read states.
                int numberOfStates = input.ReadInt32();
                for (int j = 0; j < numberOfStates; j++)
                {
                    var state = new ThemeState();
                    state.Name        = input.ReadString();
                    state.IsInherited = input.ReadBoolean();

                    // Read images.
                    int numberOfImages = input.ReadInt32();
                    for (int k = 0; k < numberOfImages; k++)
                    {
                        var image = new ThemeImage();
                        image.Name = input.ReadString();

                        string textureName = input.ReadString();
                        if (!string.IsNullOrEmpty(textureName))
                        {
                            ThemeTexture texture;
                            if (existingInstance.Textures.TryGet(textureName, out texture))
                            {
                                image.Texture = texture;
                            }
                        }

                        image.SourceRectangle     = input.ReadRawObject <Rectangle>();
                        image.Margin              = input.ReadRawObject <Vector4F>();
                        image.HorizontalAlignment = (HorizontalAlignment)input.ReadInt32();
                        image.VerticalAlignment   = (VerticalAlignment)input.ReadInt32();
                        image.TileMode            = (TileMode)input.ReadInt32();
                        image.Border              = input.ReadRawObject <Vector4F>();
                        image.IsOverlay           = input.ReadBoolean();
                        image.Color = input.ReadColor();
                        state.Images.Add(image);
                    }

                    bool hasBackground = input.ReadBoolean();
                    if (hasBackground)
                    {
                        state.Background = input.ReadColor();
                    }

                    bool hasForeground = input.ReadBoolean();
                    if (hasForeground)
                    {
                        state.Foreground = input.ReadColor();
                    }

                    bool hasOpacity = input.ReadBoolean();
                    if (hasOpacity)
                    {
                        state.Opacity = input.ReadSingle();
                    }

                    style.States.Add(state);
                }

                existingInstance.Styles.Add(style);
            }

            // Resolve style inheritance.
            foreach (var entry in inheritanceTable)
            {
                var    style      = entry.Key;
                string parentName = entry.Value;
                if (string.IsNullOrEmpty(parentName))
                {
                    continue;
                }

                ThemeStyle parent;
                if (existingInstance.Styles.TryGet(parentName, out parent))
                {
                    style.Inherits = parent;
                }
            }

            return(existingInstance);
        }