示例#1
0
        static IHtmlControl GetDialogBlock(IDataLayer forumConnection, UserStorage userStorage,
                                           LightObject user, RowLink dialog, int messageIndex)
        {
            LightObject collocutor = userStorage.FindUser(dialog.Get(DialogueType.CollocutorId));

            if (collocutor == null)
            {
                return(null);
            }

            bool        read      = dialog.Get(DialogueType.Unread);
            bool        inbox     = dialog.Get(DialogueType.Inbox);
            LightObject author    = inbox ? collocutor : user;
            DateTime    localTime = dialog.Get(DialogueType.ModifyTime).ToLocalTime();

            HBefore before = null;

            if (!inbox)
            {
                before = std.BeforeAwesome(@"\f112", 8);
            }

            IHtmlControl messageBlock = new HPanel("", new IHtmlControl[] {
                new HPanel(
                    ViewUserHlp.AvatarBlock(collocutor)
                    ).PositionAbsolute().Left(0).Top(0).Padding(7, 5, 10, 5),
                new HPanel(
                    new HPanel(
                        new HLabel(collocutor.Get(UserType.Login)).FontBold(),
                        new HLabel(collocutor.Get(UserType.FirstName)).MarginLeft(5),
                        new HLabel(localTime.ToString("dd.MM.yyyy HH:mm")).PositionAbsolute().Right(5)
                        .FontSize("90%").Color(Decor.minorColor)
                        ).PositionRelative().MarginBottom(6),
                    new HLabel(
                        //BasketballHlp.PreViewComment(dialog.Get(DialogueType.Content)),
                        dialog.Get(DialogueType.Content),
                        before
                        ).Block().PaddingBottom(15).BorderBottom("1px solid silver").MarginBottom(5)
                    .FontBold(read).Color(read ? Decor.textColor : Decor.minorColor)
                    .Width("100%").NoWrap().Overflow("hidden").CssAttribute("text-overflow", "ellipsis")
                    ).BoxSizing().Width("100%").BorderLeft(Decor.columnBorder).Padding(7, 5, 5, 5)
            },
                                                   new HHover().Background(Decor.pageBackground)
                                                   ).PositionRelative().PaddingLeft(64).BorderTop("2px solid #fff").Color(Decor.textColor);

            //if (messageIndex % 2 != 0)
            //  messageBlock.Background(Decor.evenBackground);

            return(new HLink(string.Format("{0}", UrlHlp.ShopUrl("dialog", collocutor.Id)),
                             messageBlock,
                             new HHover().Background(Decor.pageBackground)
                             ).TextDecoration("none"));
        }
示例#2
0
        public FormSalary()
        {
            InitializeComponent();

            Text = Config.PROJECT_NAME + " - Зарплата";

            HListView.Normillize(listView1);
            HPanel.ActivateToggle(panel1);

            SetColumns();
            FillListView();
        }
示例#3
0
        static IHtmlControl GetWhomBlock(SiteState state, UserStorage userStorage,
                                         TopicStorage topic, Dictionary <int, string> htmlRepresentByMessageId, RowLink comment)
        {
            int commentId = comment.Get(MessageType.Id);

            int?whomId = comment.Get(MessageType.WhomId);

            if (whomId == null)
            {
                return(null);
            }

            RowLink whom = topic.MessageLink.FindRow(MessageType.MessageById, whomId.Value);

            if (whom == null)
            {
                return(null);
            }

            LightObject whomUser = userStorage.FindUser(whom.Get(MessageType.UserId));
            DateTime    whomTime = whom.Get(MessageType.CreateTime).ToLocalTime();

            string whomHint = string.Format("whom_{0}", commentId);

            IHtmlControl whomTextBlock = null;

            if (state.BlockHint == whomHint)
            {
                //string whomDisplay = BasketballHlp.PreViewComment(whom.Get(MessageType.Content));
                string whomDisplay = DictionaryHlp.GetValueOrDefault(htmlRepresentByMessageId, whomId.Value);
                whomTextBlock = new HPanel(
                    new HTextView(whomDisplay).FontSize(12)
                    ).Padding(5);
            }

            return(new HPanel(
                       new HPanel(
                           new HButton(
                               whomUser?.Get(UserType.Login),
                               new HHover().TextDecoration("none")
                               ).Color(Decor.linkColor).TextDecoration("underline").MarginRight(5)
                           .Event("whom_display", "", delegate
            {
                state.SetBlockHint(whomHint);
            },
                                  commentId
                                  ),
                           new HLabel(string.Format("({0})", whomTime.ToString(Decor.timeFormat)))
                           ),
                       whomTextBlock
                       ).Color(Decor.minorColor).FontSize("90%"));
        }
        public LButton(
            System.Windows.Forms.Control parentpal,
            int lineint,
            string text,
            System.Drawing.Font font,
            System.Drawing.Size size,
            System.Drawing.Point point,
            System.Drawing.Color linecolor,
            System.Drawing.Color linelight,
            System.Drawing.Color backcolor,
            System.Drawing.Color backlight,
            System.Drawing.Color forecolor,
            System.Drawing.Color forelight,
            System.Windows.Forms.AnchorStyles anchorstyle
            )
        {
            Linecolor = linecolor;
            Linelight = linelight;
            Backcolor = backcolor;
            Backlight = backlight;
            Forecolor = forecolor;
            Forelight = forelight;

            var panelSec = new HPanel
                {
                    Size = size,
                    Location = point,
                    Anchor = anchorstyle,
                    BackColor = linecolor,
                };

            Text = text;
            Font = font;
            TextAlign = Helper.Align;
            Size = new System.Drawing.Size(panelSec.Size.Width - 2*lineint, panelSec.Size.Height - 2*lineint);
            Location = new System.Drawing.Point(lineint, lineint);
            ForeColor = Forecolor;
            BackColor = Backcolor;
            Anchor = Helper.AnchorFill;
            Cursor = Helper.HCursors;

            panelSec.Controls.Add(this);
            parentpal.Controls.Add(panelSec);

            MouseUp += LButton_MouseUp;
            MouseDown += LButton_MouseDown;
            MouseHover += LButton_MouseHover;
            MouseLeave += LButton_MouseLeave;
            AllowDrop = true;
            DragEnter += LButton_DragEnter;
        }
示例#5
0
        static IHtmlControl GetDialogItem(SiteState state, LightObject currentUser, string kind)
        {
            if (currentUser == null)
            {
                return(null);
            }

            RowLink unreadRow = context.UnreadDialogLink.FindRow(DialogReadType.UnreadByUserId, currentUser.Id);
            HAfter  after     = null;

            if (unreadRow != null)
            {
                after = new HAfter().Content(unreadRow.Get(DialogReadType.Count).ToString())
                        .Align(null).MarginLeft(8).FontBold().TextDecoration("none")
                        .InlineBlock().BoxSizing().Size(20, 20).LineHeight(18)
                        .BorderRadius("50%").Background(Decor.redColor);
            }

            HPanel labelPanel = new HPanel(
                new HLabel("Личные сообщения", after, new HHover().TextDecoration("none"))
                .Padding(7, 17, 8, 17).LineHeight(20).TextDecoration("underline")
                .Media(600, new HStyle().Display("none")),
                new HLabel("", std.BeforeAwesome(@"\f086", 0).FontSize(20).VAlign(-2), after)
                .Padding(7, 17, 8, 17).LineHeight(20)
                .Display("none").Media(600, new HStyle().InlineBlock())
                ).InlineBlock();

            if (kind != "dialog")
            {
                labelPanel.Color(Decor.menuColor);
            }
            else
            {
                labelPanel.Color(Decor.menuSelectedColor).FontBold().Background(Decor.menuSelectedBackground);
            }

            return(new HPanel(
                       new HLink(UrlHlp.ShopUrl("dialog", null),
                                 labelPanel
                                 )
                       ).InlineBlock().PositionAbsolute().Right(2).Top(3));
        }
 public MetroForFly(
     System.Windows.Forms.Control fatherControl, // 父容器
     int flyWidth,
     int flyHeight,
     System.Drawing.Point locationPoint,    // 整体位置
     System.Windows.Forms.AnchorStyles anchorstyle
     )
 {
     // 包裹外层
     var panelSec = new HPanel
     {
         Size = new System.Drawing.Size(flyWidth, flyHeight),
         Location = locationPoint,
         Anchor = anchorstyle,
         BackColor = System.Drawing.Color.Transparent,
     };
     // 列表包裹层
     var panelfly = new HPanel
         {
             Dock = System.Windows.Forms.DockStyle.Fill,
         };
     // 加载包裹层
     panelSec.Controls.Add(panelfly);
     Size = new System.Drawing.Size(flyWidth + 3 + 12, flyHeight + 3);
     Location = new System.Drawing.Point(-3, -3);
     BackColor = System.Drawing.Color.Transparent;
     Anchor = System.Windows.Forms.AnchorStyles.Top |
                                                              System.Windows.Forms.AnchorStyles.Left |
                                                              System.Windows.Forms.AnchorStyles.Right |
                                                              System.Windows.Forms.AnchorStyles.Bottom; ;
     AllowDrop = true;
     AutoScroll = true;
     MouseDown += MetroForFly_MouseDown;
     DragEnter += MetroForFly_DragEnter;
     Scroll += MetroForFly_Scroll;
     // 加载实体层
     panelfly.Controls.Add(this);
     // 加载包裹外层
     fatherControl.Controls.Add(panelSec);
 }
示例#7
0
        static IHtmlControl JumpElement(string urlWithoutPageIndex, int pageIndex, bool isSelected, bool isFirst)
        {
            IHtmlControl jumpItem = null;

            if (!isSelected)
            {
                jumpItem = new HLink(JumpPageUrl(urlWithoutPageIndex, pageIndex), (pageIndex + 1).ToString());
            }
            else
            {
                jumpItem = new HLabel(pageIndex + 1).FontBold();
            }

            HPanel jumpElement = new HPanel(
                !isFirst ? new HLabel(" | ").MarginLeft(5).MarginRight(5) : null,
                jumpItem
                ).InlineBlock();

            //if (!isFirst)
            //  jumpElement.BorderLeft("1px solid #000");

            return(jumpElement);
        }
示例#8
0
        public LPanel
            (
            System.Windows.Forms.Control parentpal,
            int lineint,
            System.Drawing.Size size,
            System.Drawing.Point point,
            System.Drawing.Color linecolor,
            System.Drawing.Color backcolor,
            System.Windows.Forms.AnchorStyles anchorstyle
            )
        {
            var panelSec = new HPanel
                {
                    Size = size,
                    Location = point,
                    Anchor = anchorstyle,
                    BackColor = linecolor,
                };
            Size = new System.Drawing.Size(panelSec.Size.Width - 2*lineint, panelSec.Size.Height - 2*lineint);
            Location = new System.Drawing.Point(lineint, lineint);
            BackColor = backcolor;
            Anchor = Helper.AnchorFill;

            panelSec.Controls.Add(this);
            parentpal.Controls.Add(panelSec);
        }
示例#9
0
        static IHtmlControl GetTopicRedoPanel(SiteState state,
                                              LightObject currentUser, LightSection forumSection, TopicStorage topic)
        {
            string blockHint = string.Format("topic_edit_{0}", topic.TopicId);

            IHtmlControl redoPanel = null;

            if (state.BlockHint == blockHint)
            {
                redoPanel = new HPanel(
                    new HPanel(
                        Decor.Button("Удалить тему").Event("delete_topic", "", delegate
                {
                    int messageCount = topic.MessageLink.AllRows.Length;
                    if (!state.Operation.Validate(messageCount > 1, "Тема с комментариями не может быть удалена"))
                    {
                        return;
                    }

                    MessageHlp.DeleteTopicMessages(context.ForumConnection, topic.Topic.Id);
                    BasketballHlp.DeleteTopic(context.FabricConnection, topic.TopicId);

                    topic.UpdateTopic();
                    topic.UpdateMessages();
                    context.UpdateLastComments(true);
                    context.Forum.ForSection(forumSection.Id).Update();

                    state.RedirectUrl = "/";
                }
                                                           )
                        ).Align(false),
                    Decor.PropertyEdit("editTopicTitle", "Заголовок темы", topic.Topic.Get(TopicType.Title)),
                    Decor.Button("Переименовать тему")
                    .Event("save_topic_edit", "editTopicData",
                           delegate(JsonData json)
                {
                    string title = json.GetText("editTopicTitle");

                    WebOperation operation = state.Operation;

                    if (!operation.Validate(title, "Не задан заголовок"))
                    {
                        return;
                    }

                    LightObject editTopic = DataBox.LoadObject(context.FabricConnection, TopicType.Topic, topic.TopicId);
                    editTopic.SetWithoutCheck(TopicType.Title, title);

                    editTopic.Box.Update();

                    context.Forum.ForSection(forumSection.Id).Update();
                    topic.UpdateTopic();

                    state.BlockHint = "";
                },
                           topic.TopicId
                           )
                    ).EditContainer("editTopicData")
                            .Padding(5, 10).MarginTop(5).Background(Decor.pageBackground);
            }

            return(new HPanel(
                       Decor.Button("Редактировать")
                       .Event("topic_edit", "", delegate
            {
                state.SetBlockHint(blockHint);
            }
                              ),
                       redoPanel
                       ).MarginTop(5).MarginBottom(10));
        }
示例#10
0
        static IHtmlControl GetTopicAddPanel(SiteState state, LightObject currentUser, LightSection section)
        {
            string blockHint = "topic_add";

            IHtmlControl addPanel = null;

            if (state.BlockHint == blockHint)
            {
                addPanel = new HPanel(
                    Decor.PropertyEdit("addTopicTitle", "Заголовок темы"),
                    new HTextArea("addTopicText")
                    .Width("100%").Height("6em").MarginBottom(5),
                    Decor.Button("Сохранить").MarginTop(10)
                    .Event("save_topic_add", "addTopicData", delegate(JsonData json)
                {
                    string title = json.GetText("addTopicTitle");
                    string text  = json.GetText("addTopicText");

                    WebOperation operation = state.Operation;

                    if (!operation.Validate(title, "Не задан заголовок"))
                    {
                        return;
                    }
                    if (!operation.Validate(text, "Не задан текст"))
                    {
                        return;
                    }

                    KinBox editBox = new KinBox(context.FabricConnection, "1=0");

                    int addTopicId    = editBox.CreateObject(TopicType.Topic, TopicType.Title.CreateXmlIds(title), DateTime.UtcNow);
                    LightKin addTopic = new LightKin(editBox, addTopicId);

                    addTopic.SetParentId(ForumSectionType.TopicLinks, section.Id);

                    addTopic.Set(ObjectType.ActTill, DateTime.UtcNow);
                    addTopic.Set(TopicType.PublisherId, currentUser.Id);

                    editBox.Update();

                    MessageHlp.InsertMessage(context.ForumConnection, addTopic.Id, currentUser.Id, null, text);

                    context.UpdateLastComments(true);
                    context.Forum.ForSection(section.Id).Update();

                    state.BlockHint = "";

                    //context.Forum.TopicsStorages.ForTopic(addTopic.Id);
                }
                           )
                    ).EditContainer("addTopicData").MarginTop(5);
            }

            return(new HPanel(
                       Decor.Button("Создать тему")
                       .Event("topic_add", "", delegate
            {
                state.SetBlockHint(blockHint);
            }
                              ),
                       addPanel
                       ).MarginTop(5).MarginBottom(10));
        }
示例#11
0
        static IHtmlControl GetNewsEditPanel(SiteState state, TopicStorage topic)
        {
            LightObject news = topic.Topic;

            string blockHint = string.Format("news_edit_{0}", news.Id);

            IHtmlControl redoPanel = null;

            if (state.BlockHint == blockHint)
            {
                IHtmlControl deletePanel = null;
                if (state.ModeratorMode)
                {
                    deletePanel = DeleteTopicPanel(state, topic);
                }

                if (state.Tag == null)
                {
                    state.Tag = ViewTagHlp.GetTopicDisplayTags(context.Tags.TagBox, topic.Topic);
                }

                redoPanel = new HPanel(
                    deletePanel,
                    Decor.PropertyEdit("newsTitle", "Заголовок новости", news.Get(NewsType.Title)),
                    new HPanel(
                        HtmlHlp.CKEditorCreate("newsText", news.Get(NewsType.Text), "300px", true)
                        ),
                    ViewTagHlp.GetEditTagsPanel(state, context.Tags.TagBox, state.Tag as List <string>, false),
                    Decor.PropertyEdit("newsOriginName", "Источник", news.Get(NewsType.OriginName)),
                    Decor.PropertyEdit("newsOriginUrl", "Ссылка", news.Get(NewsType.OriginUrl)),
                    Decor.Button("Изменить новость").CKEditorOnUpdateAll().MarginTop(10)
                    .Event("save_news_edit", "editNewsData",
                           delegate(JsonData json)
                {
                    string title      = json.GetText("newsTitle");
                    string text       = json.GetText("newsText");
                    string originName = json.GetText("newsOriginName");
                    string originUrl  = json.GetText("newsOriginUrl");

                    WebOperation operation = state.Operation;

                    if (!operation.Validate(title, "Не задан заголовок"))
                    {
                        return;
                    }
                    if (!operation.Validate(text, "Не задан текст"))
                    {
                        return;
                    }

                    LightKin editNews = DataBox.LoadKin(context.FabricConnection, NewsType.News, news.Id);

                    editNews.SetWithoutCheck(NewsType.Title, title);

                    editNews.Set(NewsType.Text, text);
                    editNews.Set(NewsType.OriginName, originName);
                    editNews.Set(NewsType.OriginUrl, originUrl);

                    editNews.Set(ObjectType.ActTill, DateTime.UtcNow);

                    ViewTagHlp.SaveTags(context, state, editNews);

                    editNews.Box.Update();

                    context.UpdateNews();
                    context.NewsStorages.ForTopic(news.Id).UpdateTopic();

                    state.BlockHint = "";
                },
                           news.Id
                           )
                    ).EditContainer("editNewsData")
                            .Padding(5, 10).MarginTop(10).Background(Decor.pageBackground);
            }

            return(new HPanel(
                       Decor.Button("Редактировать")
                       .Event("news_edit", "", delegate
            {
                state.SetBlockHint(blockHint);
            }
                              ),
                       redoPanel
                       ).MarginTop(10));
        }
示例#12
0
        public static IHtmlControl GetActualNewsBlock(SiteState state, LightObject currentUser)
        {
            IHtmlControl[] items = ViewNewsHlp.GetNewsItems(state, context.ActualNews);

            HPanel editBlock = null;
            string editHint  = "news_add";

            if (state.BlockHint == editHint)
            {
                if (state.Tag == null)
                {
                    state.Tag = new List <string>();
                }

                string unsaveText = BasketballHlp.AddCommentFromCookie();

                editBlock = new HPanel(
                    Decor.PropertyEdit("newsTitle", "Заголовок новости"),
                    new HPanel(
                        HtmlHlp.CKEditorCreate("newsText", unsaveText, "300px", true)
                        ),
                    ViewTagHlp.GetEditTagsPanel(state, context.Tags.TagBox, state.Tag as List <string>, true),
                    Decor.PropertyEdit("newsOriginName", "Источник"),
                    Decor.PropertyEdit("newsOriginUrl", "Ссылка"),
                    Decor.Button("Добавить новость").MarginTop(10) //.CKEditorOnUpdateAll()
                    .OnClick(string.Format("CK_updateAll(); {0}", BasketballHlp.AddCommentToCookieScript("newsText")))
                    .Event("save_news_add", "addNewsData",
                           delegate(JsonData json)
                {
                    string title      = json.GetText("newsTitle");
                    string text       = json.GetText("newsText");
                    string originName = json.GetText("newsOriginName");
                    string originUrl  = json.GetText("newsOriginUrl");

                    WebOperation operation = state.Operation;

                    if (!operation.Validate(title, "Не задан заголовок"))
                    {
                        return;
                    }

                    if (!operation.Validate(text, "Не задан текст"))
                    {
                        return;
                    }

                    ParentBox editBox = new ParentBox(context.FabricConnection, "1=0");

                    int addNewsId        = editBox.CreateObject(NewsType.News, NewsType.Title.CreateXmlIds(title), DateTime.UtcNow);
                    LightParent editNews = new LightParent(editBox, addNewsId);

                    editNews.Set(NewsType.PublisherId, currentUser.Id);
                    editNews.Set(NewsType.Text, text);
                    editNews.Set(NewsType.OriginName, originName);
                    editNews.Set(NewsType.OriginUrl, originUrl);

                    ViewTagHlp.SaveTags(context, state, editNews);

                    editBox.Update();

                    context.UpdateNews();

                    state.BlockHint = "";
                    state.Tag       = null;

                    BasketballHlp.ResetAddComment();
                }
                           )
                    ).EditContainer("addNewsData").Padding(5, 10).MarginTop(10).Background(Decor.pageBackground);
            }

            IHtmlControl addButton = null;

            if (currentUser != null && !BasketballHlp.NoRedactor(currentUser))
            {
                addButton = Decor.Button("Добавить").MarginLeft(10)
                            .Event("news_add", "", delegate
                {
                    state.Tag = null;
                    state.SetBlockHint(editHint);
                }
                                   );
            }

            return(new HPanel(
                       Decor.Subtitle("Новости"),
                       new HPanel(
                           items.ToArray()
                           ),
                       new HPanel(
                           new HLink("/novosti",
                                     "Все новости",
                                     new HBefore().ContentIcon(5, 12).BackgroundImage(UrlHlp.ImageUrl("pointer.gif")).MarginRight(5).VAlign(-2)
                                     ).FontBold(),
                           addButton
                           ).MarginTop(15),
                       editBlock
                       ));
        }
示例#13
0
        static IHtmlControl GetMessageBlock(IDataLayer forumConnection, SiteState state,
                                            LightObject user, LightObject collocutor, RowLink message, int messageIndex)
        {
            int         messageId = message.Get(CorrespondenceType.Id);
            LightObject author    = message.Get(CorrespondenceType.Inbox) ? collocutor : user;
            DateTime    localTime = message.Get(CorrespondenceType.CreateTime).ToLocalTime();

            IHtmlControl deleteElement = null;

            if (state.BlockHint == "correspondence_moderation")
            {
                deleteElement = new HButton("",
                                            std.BeforeAwesome(@"\f00d", 0)
                                            ).MarginLeft(5).Color(Decor.redColor).Title("удалить комментарий")
                                .Event("delete_message", "", delegate
                {
                    forumConnection.GetScalar("", "Delete From correspondence Where id = @messageId",
                                              new DbParameter("messageId", messageId)
                                              );
                },
                                       messageId
                                       );
            }

            IHtmlControl messageBlock = new HPanel("", new IHtmlControl[] {
                new HPanel(
                    ViewUserHlp.AvatarBlock(author)
                    ).PositionAbsolute().Left(0).Top(0).Padding(7, 5, 10, 5),
                new HPanel(
                    new HPanel(
                        //new HLabel(author.Get(UserType.Login)).FontBold(),
                        new HLink(UrlHlp.ShopUrl("user", author.Id),
                                  author.Get(UserType.FirstName)
                                  ).FontBold(),
                        //new HLabel(author.Get(UserType.FirstName)).MarginLeft(5),
                        new HPanel(
                            new HLabel(localTime.ToString("dd.MM.yyyy HH:mm")).FontSize("90%").Color(Decor.minorColor),
                            deleteElement
                            ).InlineBlock().PositionAbsolute().Right(5)
                        ).PositionRelative().MarginBottom(6),
                    new HTextView(
                        BasketballHlp.PreViewComment(message.Get(CorrespondenceType.Content))
                        ).Block().PaddingBottom(15).BorderBottom("1px solid silver").MarginBottom(5)
                    ).BoxSizing().Width("100%").BorderLeft(Decor.columnBorder).Padding(7, 5, 5, 5)
            }
                                                   ).PositionRelative().PaddingLeft(64).BorderTop("2px solid #fff").Color(Decor.textColor);

            //IHtmlControl messageBlock = new HXPanel(
            //  new HPanel(
            //    new HLink(UrlHlp.ShopUrl("user", author.Id),
            //      author.Get(UserType.Login)
            //    ).FontBold(),
            //    new HLabel(author.Get(UserType.FirstName)).Block()
            //      .MediaTablet(new HStyle().InlineBlock().MarginLeft(5)),
            //    new HPanel(
            //      ViewUserHlp.AvatarBlock(author)
            //    ).MarginTop(5)
            //      .MediaTablet(new HStyle().Display("none"))
            //  ).BoxSizing().WidthLimit("100px", "").Padding(7, 5, 10, 5)
            //    .MediaTablet(new HStyle().Block().PaddingBottom(0).PaddingRight(110)),
            //  new HPanel(
            //    new HPanel(
            //      new HLabel(localTime.ToString("dd.MM.yyyy HH:mm")).MarginRight(5)
            //        .MediaTablet(new HStyle().MarginBottom(5)),
            //      deleteElement
            //    ).Align(false).FontSize("90%").Color(Decor.minorColor),
            //    new HTextView(
            //      BasketballHlp.PreViewComment(message.Get(CorrespondenceType.Content))
            //    ).PaddingBottom(15).MarginBottom(5).BorderBottom("1px solid silver")
            //  ).BoxSizing().Width("100%").BorderLeft(Decor.columnBorder).Padding(7, 5, 5, 5)
            //    .MediaTablet(new HStyle().Block().MarginTop(-19))
            //).BorderTop("2px solid #fff");

            if (messageIndex % 2 != 0)
            {
                messageBlock.Background(Decor.evenBackground);
            }

            return(messageBlock);
        }
示例#14
0
        public static IHtmlControl GetAddPanel(BasketballContext context, SiteState state,
                                               LightObject user, LightObject collocutor, bool sendFromUserView)
        {
            if (user == null)
            {
                return(null);
            }

            if (user.Id == collocutor.Id)
            {
                return(null);
            }

            IHtmlControl editPanel = null;

            if (state.BlockHint == "messageAdd")
            {
                string commentValue = BasketballHlp.AddCommentFromCookie();

                editPanel = new HPanel(
                    new HTextArea("messageContent", commentValue).BoxSizing().Width("100%")
                    .Height("10em").MarginTop(5).MarginBottom(5),
                    Decor.Button("отправить")
                    .OnClick(BasketballHlp.AddCommentToCookieScript("messageContent"))
                    .Event("message_add_save", "messageData",
                           delegate(JsonData json)
                {
                    string content = json.GetText("messageContent");
                    if (StringHlp.IsEmpty(content))
                    {
                        return;
                    }

                    DialogueHlp.SendMessage(context, user.Id, collocutor.Id, content);

                    state.BlockHint = "";

                    BasketballHlp.ResetAddComment();

                    if (sendFromUserView)
                    {
                        state.Operation.Message = "Сообщение успешно отправлено";
                    }
                }
                           ),
                    new HElementControl(
                        h.Script(h.type("text/javascript"), "$('.messageContent').focus();"),
                        ""
                        )
                    ).EditContainer("messageData");
            }

            HButton moderatorButton = null;
            HPanel  moderatorPanel  = null;

            if (!sendFromUserView)
            {
                moderatorButton = new HButton("",
                                              std.BeforeAwesome(@"\f1e2", 0)
                                              ).PositionAbsolute().Right(5).Top(0)
                                  .Title("Модерирование личных сообщений").FontSize(14)
                                  .Color(state.BlockHint == correspondenceModeration ? Decor.redColor : Decor.disabledColor)
                                  .Event("correspondence_moderation_set", "", delegate
                {
                    state.SetBlockHint(correspondenceModeration);
                });

                if (state.BlockHint == correspondenceModeration)
                {
                    bool lockedCollocutor = user.Get(BasketballUserType.LockedUserIds, collocutor.Id);
                    moderatorPanel = new HPanel(
                        Decor.ButtonMidi(!lockedCollocutor ? "Заблокировать собеседника" : "Разблокировать собеседника")
                        .Event("collocutor_locked", "", delegate
                    {
                        LightObject editUser = DataBox.LoadObject(context.UserConnection, UserType.User, user.Id);
                        editUser.Set(BasketballUserType.LockedUserIds, collocutor.Id, !lockedCollocutor);
                        editUser.Box.Update();
                        context.UserStorage.Update();
                    }),
                        new HSpoiler(Decor.ButtonMidi("Удаление переписки").Block().FontBold(false),
                                     new HPanel(
                                         Decor.ButtonMidi("Удалить? (без подтверждения)")
                                         .MarginTop(5).MarginLeft(10)
                                         .Event("correspondence_delete", "", delegate
                    {
                        context.ForumConnection.GetScalar("",
                                                          "Delete From correspondence Where user_id = @userId and collocutor_id = @collocutorId",
                                                          new DbParameter("userId", user.Id), new DbParameter("collocutorId", collocutor.Id)
                                                          );

                        context.ForumConnection.GetScalar("",
                                                          "Delete From dialogue Where user_id = @userId and collocutor_id = @collocutorId",
                                                          new DbParameter("userId", user.Id), new DbParameter("collocutorId", collocutor.Id)
                                                          );

                        context.UpdateUnreadDialogs();
                    })
                                         )
                                     ).MarginTop(10)
                        ).MarginTop(10);
                }
            }

            bool locked = user.Get(BasketballUserType.LockedUserIds, collocutor.Id) ||
                          collocutor.Get(BasketballUserType.LockedUserIds, user.Id);

            return(new HPanel(
                       new HPanel(
                           Decor.ButtonMidi("Написать сообщение")
                           .Hide(locked)
                           .Event("message_add", "", delegate
            {
                state.SetBlockHint("messageAdd");
            }
                                  ),
                           new HLabel("Вы не можете отправить сообщение этому пользователю").Hide(!locked)
                           .MarginLeft(10).Color(Decor.subtitleColor),
                           moderatorButton
                           ).PositionRelative(),
                       editPanel,
                       moderatorPanel
                       ).MarginTop(10).MarginBottom(10));
        }
示例#15
0
        static IHtmlControl GetArticleEditPanel(SiteState state, TopicStorage topic)
        {
            LightObject article = topic.Topic;

            string blockHint = string.Format("article_edit_{0}", article.Id);

            IHtmlControl redoPanel = null;

            if (state.BlockHint == blockHint)
            {
                IHtmlControl deletePanel = null;
                if (state.ModeratorMode)
                {
                    deletePanel = ViewNewsHlp.DeleteTopicPanel(state, topic);
                }

                redoPanel = new HPanel(
                    deletePanel,
                    new HPanel(
                        Decor.PropertyEdit("editArticleTitle", "Заголовок статьи", article.Get(NewsType.Title)),
                        new HPanel(
                            new HLabel("Аннотация").FontBold(),
                            new HTextArea("editArticleAnnotation", article.Get(NewsType.Annotation))
                            .Width("100%").Height("4em").MarginBottom(5)
                            ),
                        new HPanel(
                            new HInputCheck(
                                "editArticleWideContent", article.Get(ArticleType.WideContent),
                                new HAfter().Content("Таблицы шире колонки статьи").MarginLeft(18).MarginBottom(1)
                                ).NoWrap()
                            ).MarginBottom(5),
                        HtmlHlp.CKEditorCreate("editArticleText", article.Get(NewsType.Text), "300px", true),
                        Decor.PropertyEdit("editArticleAuthor", "Автор", article.Get(ArticleType.Author)),
                        Decor.PropertyEdit("editArticleOriginName", "Источник (без префикса http://)", article.Get(NewsType.OriginName)),
                        Decor.PropertyEdit("editArticleOriginUrl", "Ссылка (с префиксом http://)", article.Get(NewsType.OriginUrl)),
                        Decor.Button("Сохранить статью").CKEditorOnUpdateAll().MarginTop(10).MarginBottom(10)
                        .Event("save_article_edit", "editArticleData",
                               delegate(JsonData json)
                {
                    string title      = json.GetText("editArticleTitle");
                    string annotation = json.GetText("editArticleAnnotation");
                    bool wideContent  = json.GetBool("editArticleWideContent");
                    string text       = json.GetText("editArticleText");
                    string author     = json.GetText("editArticleAuthor");
                    string originName = json.GetText("editArticleOriginName");
                    string originUrl  = json.GetText("editArticleOriginUrl");

                    WebOperation operation = state.Operation;

                    if (!operation.Validate(title, "Не задан заголовок"))
                    {
                        return;
                    }

                    if (!operation.Validate(text, "Не задан текст"))
                    {
                        return;
                    }

                    LightObject editNews = DataBox.LoadObject(context.FabricConnection, ArticleType.Article, article.Id);

                    editNews.SetWithoutCheck(NewsType.Title, title);

                    editNews.Set(ArticleType.WideContent, wideContent);
                    editNews.Set(NewsType.Annotation, annotation);
                    editNews.Set(NewsType.Text, text);
                    editNews.Set(ArticleType.Author, author);
                    editNews.Set(NewsType.OriginName, originName);
                    editNews.Set(NewsType.OriginUrl, originUrl);

                    editNews.Set(ObjectType.ActTill, DateTime.UtcNow);

                    editNews.Box.Update();

                    context.UpdateArticles();
                    context.ArticleStorages.ForTopic(article.Id).UpdateTopic();

                    state.BlockHint = "";
                },
                               article.Id
                               )
                        ).EditContainer("editArticleData"),
                    new HPanel(
                        EditElementHlp.GetImageThumb(article.Id)
                        ),
                    new HPanel(
                        EditElementHlp.GetDescriptionImagesPanel(state.Option, article.Id)
                        )
                    ).Padding(5, 10).MarginTop(10).Background(Decor.pageBackground);
            }

            return(new HPanel(
                       Decor.Button("Редактировать")
                       .Event("article_edit", "", delegate
            {
                state.SetBlockHint(blockHint);
            }
                              ),
                       redoPanel
                       ).MarginTop(5));
        }
示例#16
0
        public static IHtmlControl GetActualArticleBlock(SiteState state, LightObject currentUser)
        {
            IHtmlControl[] items = ViewArticleHlp.GetArticleItems(state, context.ActualArticles);

            HPanel editBlock = null;

            if (state.BlockHint == "articleAdd")
            {
                editBlock = new HPanel(
                    Decor.PropertyEdit("addArticleTitle", "Заголовок статьи"),
                    Decor.Button("Добавить статью").MarginTop(10)
                    .Event("article_add_save", "addArticleData",
                           delegate(JsonData json)
                {
                    string title = json.GetText("addArticleTitle");

                    WebOperation operation = state.Operation;

                    if (!operation.Validate(title, "Не задан заголовок"))
                    {
                        return;
                    }

                    ObjectBox editBox = new ObjectBox(context.FabricConnection, "1=0");

                    int addArticleId = editBox.CreateObject(
                        ArticleType.Article, ArticleType.Title.CreateXmlIds(title), DateTime.UtcNow
                        );
                    LightObject editArticle = new LightObject(editBox, addArticleId);

                    editArticle.Set(ArticleType.PublisherId, currentUser.Id);

                    editBox.Update();
                    context.UpdateArticles();

                    state.BlockHint = "";

                    state.RedirectUrl = UrlHlp.ShopUrl("article", addArticleId);
                }
                           )
                    ).EditContainer("addArticleData")
                            .Padding(5, 10).MarginTop(10).Background(Decor.pageBackground);
            }

            HButton addButton = null;

            if (currentUser != null && !BasketballHlp.NoRedactor(currentUser))
            {
                addButton = Decor.Button("Добавить").Hide(currentUser == null).MarginLeft(10)
                            .Event("article_add", "", delegate
                {
                    state.SetBlockHint("articleAdd");
                }
                                   );
            }

            return(new HPanel(
                       Decor.Subtitle("Статьи").MarginBottom(12),
                       new HPanel(
                           items.ToArray()
                           ),
                       new HPanel(
                           new HLink("/stati",
                                     "Все статьи",
                                     new HBefore().ContentIcon(5, 12).BackgroundImage(UrlHlp.ImageUrl("pointer.gif")).MarginRight(5).VAlign(-2)
                                     ).FontBold(),
                           addButton
                           ).MarginTop(15),
                       editBlock
                       ).MarginTop(10));
        }
示例#17
0
        public static IHtmlControl GetCommentsPanel(IDataLayer commentConnection,
                                                    SiteState state, LightObject currentUser, TopicStorage topic, RowLink[] pageMessages)
        {
            HPanel addPanel = null;

            if (currentUser != null)
            {
                HPanel editPanel = null;
                if (state.BlockHint == "commentAdd")
                {
                    string commentValue = BasketballHlp.AddCommentFromCookie();

                    editPanel = new HPanel(
                        new HTextArea("commentContent", commentValue).Width("100%").Height("10em").MarginTop(5).MarginBottom(5),
                        Decor.Button("отправить")
                        .OnClick(BasketballHlp.AddCommentToCookieScript("commentContent"))
                        .Event("comment_add_save", "commentData",
                               delegate(JsonData json)
                    {
                        lock (lockObj)
                        {
                            string content = json.GetText("commentContent");
                            if (StringHlp.IsEmpty(content))
                            {
                                return;
                            }

                            if (BasketballHlp.IsDuplicate(topic, currentUser.Id, content))
                            {
                                return;
                            }

                            InsertMessageAndUpdate(commentConnection, topic, currentUser, null, content);

                            state.BlockHint = "";

                            BasketballHlp.ResetAddComment();
                        }
                    }
                               ),
                        new HElementControl(
                            h.Script(h.type("text/javascript"), "$('.commentContent').focus();"),
                            ""
                            )
                        ).EditContainer("commentData");
                }

                addPanel = new HPanel(
                    Decor.ButtonMini("оставить комментарий").FontBold().FontSize(12).Padding(2, 7).
                    Event("comment_add", "", delegate
                {
                    state.SetBlockHint("commentAdd");
                }
                          ),
                    new HButton("",
                                new HBefore().ContentIcon(11, 11).BackgroundImage(UrlHlp.ImageUrl("refresh.png"))
                                ).Color("#9c9c9c").MarginLeft(10).Title("Загрузить новые комментарии")
                    .Event("comments_refresh", "", delegate { }),
                    editPanel
                    );
            }

            Dictionary <int, string> htmlRepresentByMessageId = topic.HtmlRepresentByMessageId;

            //RowLink[] allMessages = topic.MessageLink.AllRows;
            RowLink bottomMessage = null;

            if (pageMessages.Length > 0)
            {
                bottomMessage = pageMessages[Math.Max(0, pageMessages.Length - 2)];
            }

            return(new HPanel(
                       new HAnchor("comments"),
                       new HLabel("Комментарии:").MarginTop(30).MarginBottom(20).FontSize("160%")
                       .Hide(commentConnection == context.ForumConnection),
                       new HPanel(
                           new HLabel("Автор").PositionAbsolute().Top(0).Left(0)
                           .BoxSizing().Width(100).Padding(7, 5, 5, 5),
                           new HLabel("Сообщение").Block().Padding(7, 5, 5, 5).BorderLeft(Decor.columnBorder)
                           ).PositionRelative().Align(null).PaddingLeft(100).Background("#dddddd").FontBold(),
                       new HGrid <RowLink>(pageMessages, delegate(RowLink comment)
            {
                IHtmlControl commentBlock = ViewCommentHlp.GetCommentBlock(
                    commentConnection, state, currentUser, topic, htmlRepresentByMessageId, comment
                    );

                if (bottomMessage == comment)
                {
                    return new HPanel(new HAnchor("bottom"), commentBlock);
                }
                return commentBlock;
            },
                                           new HRowStyle().Even(new HTone().Background(Decor.evenBackground))
                                           ).BorderBottom(Decor.bottomBorder).MarginBottom(10),
                       //new HAnchor("bottom"),
                       addPanel
                       ));
        }
示例#18
0
        public static IHtmlControl GetCommentBlock(IDataLayer commentConnection, SiteState state,
                                                   LightObject currentUser, TopicStorage topic, Dictionary <int, string> htmlRepresentByMessageId, RowLink comment)
        {
            LightObject user      = context.UserStorage.FindUser(comment.Get(MessageType.UserId));
            DateTime    localTime = comment.Get(MessageType.CreateTime).ToLocalTime();

            IHtmlControl whomBlock = GetWhomBlock(state, context.UserStorage, topic, htmlRepresentByMessageId, comment);

            int          commentId   = comment.Get(MessageType.Id);
            string       answerHint  = string.Format("answer_{0}", commentId);
            IHtmlControl answerBlock = null;

            if (currentUser != null && state.BlockHint == answerHint)
            {
                string commentValue = BasketballHlp.AddCommentFromCookie();

                answerBlock = new HPanel(
                    new HTextArea("answerContent", commentValue).Width("100%").Height("10em").MarginTop(5).MarginBottom(5),
                    Decor.Button("отправить")
                    .OnClick(BasketballHlp.AddCommentToCookieScript("answerContent"))
                    .Event("save_answer", "answerContainer",
                           delegate(JsonData json)
                {
                    lock (lockObj)
                    {
                        string content = json.GetText("answerContent");
                        if (StringHlp.IsEmpty(content))
                        {
                            return;
                        }

                        if (BasketballHlp.IsDuplicate(topic, currentUser.Id, content))
                        {
                            return;
                        }

                        InsertMessageAndUpdate(commentConnection, topic, currentUser, commentId, content);

                        state.BlockHint = "";

                        BasketballHlp.ResetAddComment();
                    }
                },
                           commentId
                           ),
                    new HElementControl(
                        h.Script(h.type("text/javascript"), "$('.answerContent').focus();"),
                        ""
                        )
                    ).EditContainer("answerContainer");
            }

            IHtmlControl editBlock = null;

            if (currentUser != null && currentUser.Id == user?.Id)
            {
                editBlock = new HPanel(
                    );
            }

            string  redoHint   = string.Format("redo_{0}", commentId);
            HButton redoButton = null;

            if (currentUser != null && currentUser.Id == user?.Id)
            {
                redoButton = Decor.ButtonMini("редактировать").Event("comment_redo", "",
                                                                     delegate(JsonData json)
                {
                    state.SetBlockHint(redoHint);
                },
                                                                     commentId
                                                                     );
            }

            IHtmlControl redoBlock = null;

            if (currentUser != null && state.BlockHint == redoHint)
            {
                redoBlock = new HPanel(
                    new HTextArea("redoContent", comment.Get(MessageType.Content))
                    .Width("100%").Height("10em").MarginTop(5).MarginBottom(5),
                    Decor.Button("изменить").Event("save_redo", "redoContainer",
                                                   delegate(JsonData json)
                {
                    string content = json.GetText("redoContent");
                    if (StringHlp.IsEmpty(content))
                    {
                        return;
                    }

                    //content = BasketballHlp.PreSaveComment(content);

                    commentConnection.GetScalar("",
                                                "Update message Set content=@content, modify_time=@time Where id=@id",
                                                new DbParameter("content", content),
                                                new DbParameter("time", DateTime.UtcNow),
                                                new DbParameter("id", commentId)
                                                );
                    topic.UpdateMessages();

                    state.BlockHint = "";
                },
                                                   commentId
                                                   ),
                    new HElementControl(
                        h.Script(h.type("text/javascript"), "$('.redoContent').focus();"),
                        ""
                        )
                    ).EditContainer("redoContainer");
            }

            IHtmlControl deleteElement = null;

            if (state.ModeratorMode)
            {
                deleteElement = new HButton("",
                                            std.BeforeAwesome(@"\f00d", 0)
                                            ).MarginLeft(5).Color(Decor.redColor).Title("удалить комментарий")
                                .Event("delete_comment", "", delegate
                {
                    MessageHlp.DeleteMessage(commentConnection, commentId);
                    topic.UpdateMessages();
                    context.UpdateLastComments(commentConnection == context.ForumConnection);
                },
                                       commentId
                                       );
            }

            string topicType = topic.Topic.Get(ObjectType.TypeId) == NewsType.News ? "news" : "article";

            string anchor = string.Format("reply{0}", commentId);

            return(new HXPanel(
                       new HAnchor(anchor),
                       new HPanel(
                           new HLink(UrlHlp.ShopUrl("user", user?.Id),
                                     user?.Get(UserType.Login)
                                     ).FontBold(),
                           new HLabel(user?.Get(UserType.FirstName)).Block()
                           .MediaTablet(new HStyle().InlineBlock().MarginLeft(5)),
                           new HPanel(
                               ViewUserHlp.AvatarBlock(user)
                               ).MarginTop(5)
                           .MediaTablet(new HStyle().Display("none"))
                           ).BoxSizing().WidthLimit("100px", "").Padding(7, 5, 10, 5)
                       .MediaTablet(new HStyle().Block().PaddingBottom(0).PaddingRight(110)),
                       new HPanel(
                           new HPanel(
                               new HLabel(localTime.ToString("dd.MM.yyyy HH:mm")).MarginRight(5)
                               .MediaTablet(new HStyle().MarginBottom(5)),
                               new HLink(string.Format("/{0}/{1}#{2}", topicType, topic.TopicId, anchor), "#").TextDecoration("none")
                               .Hide(commentConnection == context.ForumConnection),
                               deleteElement
                               ).Align(false).FontSize("90%").Color(Decor.minorColor),
                           whomBlock,
                           new HTextView(
                               DictionaryHlp.GetValueOrDefault(htmlRepresentByMessageId, commentId)
                               ).PaddingBottom(15).MarginBottom(5).BorderBottom("1px solid silver"),
                           new HPanel(
                               Decor.ButtonMini("ответить").Event("comment_answer", "",
                                                                  delegate
            {
                state.SetBlockHint(answerHint);
            },
                                                                  commentId
                                                                  ),
                               redoButton
                               ).Hide(currentUser == null),
                           answerBlock,
                           redoBlock
                           ).BoxSizing().Width("100%").BorderLeft(Decor.columnBorder).Padding(7, 5, 5, 5)
                       .MediaTablet(new HStyle().Block().MarginTop(-19))
                       ).BorderTop("2px solid #fff"));
        }