コード例 #1
0
ファイル: PanedBox.cs プロジェクト: sharpend/Sharpend
        private Widget removeItem(Widget widget, bool x)
        {
            Widget w = container1.Children[0];

            if (w == widget)
            {
                container1.Remove(w);
                //w.Reparent(null); //TODO needed ?
                w.Parent = null;
                if (ParentBox != null)
                {
                    PanedBox temp = ChildBox;
                    if (temp != null)
                    {
                        ParentBox.removeChildbox();
                        temp.Reparent(this);
                        ParentBox.Append(temp);
                        //temp.Reparent(this);
                    }
                }
                else
                {
                    PanedBox temp = ChildBox;
                    if (temp != null)
                    {
                        Widget chld = temp.Widget1;
                        if (chld != null)
                        {
                            container1.PackStart(chld, true, true, 0);
                            chld.Reparent(container1);
                            container1.Visible = true;
                            chld.Visible       = true;
                            PanedBox temp2 = temp.ChildBox;
                            removeChildbox();
                            if (temp2 != null)
                            {
                                temp2.Reparent(this);
                                Append(temp2);
                            }
                        }
                    }
                }
                //Console.WriteLine(this.Name);
                return(w);
            }
            return(null);
        }
コード例 #2
0
ファイル: ViewNewsHlp.cs プロジェクト: undyings/Basketball
        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
                       ));
        }