Beispiel #1
0
                } // end UISettingPanel

                public void DoBeforeEntering() {
                    stuffArray = new UICell[4];
                    cellArray = new UICell[ConstConfig.GRID_COUNT];
                    blueprintPack = SceneManager.mainCharacter.pack.GetItemPack(ConstConfig.PRINT);
                    gameObject = ObjectTool.InstantiateGo("ForgePanelUI", ResourcesTool.LoadPrefabUI(id), SceneManager.mainCanvas.rectTransform);
                    rectTransform = gameObject.GetComponent<RectTransform>();
                    rectTransform.sizeDelta = SceneManager.mainCanvas.sizeDelta;
                    buleprint = rectTransform.Find("Blueprint/Print").gameObject.AddComponent<UICell>();
                    for (int i = 0; i < cellArray.Length; i++) {
                        cellArray[i] = rectTransform.Find("GridPanel/Grids/Grid_" + i).gameObject.AddComponent<UICell>();
                        string itemID = blueprintPack.GetItemIDForGrid(i);
                        IItemInfo info = Configs.itemConfig.GetItemInfo(itemID);
                        if (null == info) {
                            cellArray[i].HideItem();
                            continue;
                        } // end 
                        int id = i;
                        cellArray[i].AddAction(delegate () { OnSelectedGrid(id); });
                        cellArray[i].SetUIItem(ResourcesTool.LoadSprite(info.spritepath), 0);
                    } // end for
                    for (int i = 0; i < stuffArray.Length; i++) {
                        stuffArray[i] = rectTransform.Find("Blueprint/Stuff_" + i).gameObject.AddComponent<UICell>();
                        stuffArray[i].gameObject.SetActive(false);
                    } // end for
                    rectTransform.Find("ForgeBtn").gameObject.AddComponent<UIButtonNormal>().AddListener(delegate () { OnClickForgeBtn(); });
                    rectTransform.Find("CloseBtn").gameObject.AddComponent<UIButtonNormal>().AddListener(delegate () { OnClickCloseBtn(); }, "ui_close");
                } // end DoBeforeEntering
Beispiel #2
0
        void Sliders(Design_Item parent, List <Design_Item> baners, UISection U)
        {
            if (baners.Count > 0)
            {
                WebMeta config = UMC.Data.JSON.Deserialize <WebMeta>(parent.Data) ?? new UMC.Web.WebMeta();


                UICell slider2  = UISlider.Create(Sliders(parent.Id.Value, baners));
                int[]  paddings = UIStyle.Padding(config);
                if (paddings.Length > 0)
                {
                    slider2.Style.Padding(paddings);
                }
                U.Add(slider2);
            }
            else if (_editer)
            {
                UIDesc desc = new UIDesc("\ue907");
                desc.Click(new UIClick(parent.Id.ToString())
                           .Send("Design", "Item"));
                desc.Desc("{desc}\r\n配置横幅栏");
                desc.Style.AlignCenter().Name("desc", new UIStyle().Font("wdk").Size(38));
                U.Add(desc);
            }
        }
Beispiel #3
0
    void AddDoors()
    {
        // add up
        UICell cellU = InstantiateCell(5, m_RoomConfig.GetUp(), UIItem.eType.Door);
        UIItem doorU = Instantiate <UIItem>(m_RoomConfig.GetDoor(RoomConfig.eDir.UP), cellU.transform);

        cellU.AddItem(doorU);

        // add left
        UICell cellL = InstantiateCell(m_RoomConfig.GetLeft(), 5, UIItem.eType.Door);
        UIItem doorL = Instantiate <UIItem>(m_RoomConfig.GetDoor(RoomConfig.eDir.LEFT), cellL.transform);

        cellL.AddItem(doorL);

        // add bottom
        UICell cellB = InstantiateCell(5, m_RoomConfig.GetDown(), UIItem.eType.Door);
        UIItem doorB = Instantiate <UIItem>(m_RoomConfig.GetDoor(RoomConfig.eDir.DOWN), cellB.transform);

        cellB.AddItem(doorB);

        // add right
        UICell cellR = InstantiateCell(m_RoomConfig.GetRight(), 5, UIItem.eType.Door);
        UIItem doorR = Instantiate <UIItem>(m_RoomConfig.GetDoor(RoomConfig.eDir.RIGHT), cellR.transform);

        cellR.AddItem(doorR);
    }
 public static void   ResetActiveCell(UICell cell)
 {
     if (m_ActiveCell == cell)
     {
         m_ActiveCell = null;
     }
 }
Beispiel #5
0
 void Append()
 {
     if (data.Count > 0 || dataText.Length > 0)
     {
         if (dataText.Length > 0)
         {
             data.Put("m" + data.Count.ToString(), dataText.ToString());
         }
         dataText = new StringBuilder();
         var sb = new StringBuilder();
         for (int i = 0; i < data.Count; i++)
         {
             sb.Append("{m");
             sb.Append(i);
             sb.Append("}");
         }
         var cell = UICell.Create(data["type"] ?? "CMSText", data);
         data.Remove("type");
         cell.Format.Put("text", sb.ToString());
         cell.Style.Copy(style);
         cells.Add(cell);
         data  = new WebMeta();
         style = new UIStyle();
     }
 }
Beispiel #6
0
        WebMeta Text()
        {
            var webr = UMC.Data.WebResource.Instance();
            var data = new UMC.Web.WebMeta().Put("text", "插入文字");
            var cell = UICell.Create("CMSText", data);

            return(new UMC.Web.WebMeta().Cell(cell));
        }
Beispiel #7
0
 /// <summary>
 /// 由cell派发消息
 /// </summary>
 /// <param name="buttonId"></param>
 /// <param name="cell"></param>
 public void NotifyEvent(string eventName, UICell cell, bool flag = true)
 {
     if (eventName.Equals(UICell.ClickCellEvent))
     {
         _curSelectIndex = cell.index;
     }
     gameObject.BroadcastMessage("OnBroadcastSelectIndex", _curSelectIndex, SendMessageOptions.DontRequireReceiver);
     onCellEvent.Invoke(eventName, cell, flag);
 }
    public override void SetCellContent(UICell cell, int row)
    {
        ResourceCell resourceCell = cell.GetComponent <ResourceCell>();

        if (resourceCell != null)
        {
            resourceCell.SetContent(resources[row]);
        }
    }
Beispiel #9
0
    public override void SetCellContent(UICell cell, int row)
    {
        PlantCell plantCell = cell.GetComponent <PlantCell>();

        if (plantCell != null)
        {
            plantCell.rowNumber = row;
            plantCell.SetContent(puts[row]);
        }
    }
Beispiel #10
0
 bool isCellValid(UICell cell)
 {
     return(
         GameManager.CanAddItems() &&
         m_Item.CanBuy() &&
         cell &&
         cell.canHover() &&
         cell.GetEType() == UIItem.eType.None &&
         (!cell.isDamaged())
         );
 }
Beispiel #11
0
    public TableViewCell GetCellForRowInTableView(TableView tableView, int row)
    {
        UICell cell = tableView.GetReusableCell(m_cellPrefab.reuseIdentifier) as UICell;

        if (cell == null)
        {
            cell      = (UICell)GameObject.Instantiate(m_cellPrefab);
            cell.name = "RessourceCellInstance_" + (++m_numInstancesCreated).ToString();
        }
        SetCellContent(cell, row);
        return(cell);
    }
    public static void Do(eACTION actionType, UICell cell, UIItem item = null)
    {
        m_HistoryRedo.Clear();

        Action action = new Action();

        action.m_Action = actionType;
        action.m_Cell   = cell;
        action.m_Item   = item;

        m_History.Push(action);
    }
Beispiel #13
0
    public void RefreshAllCells()
    {
        int count = content.childCount;

        for (int i = 0; i < count; i++)
        {
            Transform tf   = content.GetChild(i);
            UICell    cell = tf.GetComponent <UICell>();
            if (cell != null)
            {
                cell.Refresh();
            }
        }
    }
Beispiel #14
0
    /// <summary>
    /// Called from LevelController by each hex, instantiates an object at corresponding position
    /// </summary>
    /// <param name="cell"></param>
    public void addCellToUIMap(UICell cell)
    {
        //Create a new GameObject to represent a location in the world
        GameObject newHologramCell = (GameObject)Instantiate(uiGridPrefab, cell.centerPos, transform.rotation);

        cell.setGameObject(newHologramCell);
        newHologramCell.GetComponent <UICellObj>().parent = cell;
        newHologramCell.GetComponent <UICellObj>().q      = cell.q;
        newHologramCell.GetComponent <UICellObj>().r      = cell.r;
        newHologramCell.GetComponent <UICellObj>().h      = cell.h;
        //Put the cell into the UIGrid
        uiGrid[cell.q, cell.r, cell.h] = cell;
        //Set the game object's parent transform for scaling/rotation purposes.
        newHologramCell.transform.SetParent(gameObject.transform);
    }
Beispiel #15
0
    public Vector2Int PosInJigsaw(UICell cell)
    {
        Vector2Int cellPos = new Vector2Int();

        cellPos.x = (int)((cell.transform.position.x - originPos.position.x) / sideSizeUI);
        cellPos.y = (int)((cell.transform.position.y - originPos.position.y) / sideSizeUI);
        if (cellPos.x >= 0 && cellPos.x < WorldGrid.Instance.horizontalCells &&
            cellPos.y >= 0 && cellPos.y < WorldGrid.Instance.verticalCells)
        {
            return(cellPos);
        }
        else
        {
            return(new Vector2Int(-1, -1)); //表示不在范围内,cell在等候区
        }
    }
Beispiel #16
0
    UICell InstantiateCell(int x, int y, UIItem.eType type)
    {
        Transform parent = m_CellBase.transform.parent;
        Vector3   refPos = getRefGridPos();

        UICell cell = Instantiate <UICell>(m_CellBase, parent);

        cell.transform.localPosition = refPos + getPos(m_RoomConfig.getPos(x, y));
        cell.name = "cell_" + x + "_" + y + (type != UIItem.eType.None ? "_" + type.ToString() : "");
        cell.gameObject.SetActive(true);
        cell.SetCoord(x, y);

        m_Cells.Add(cell);

        return(cell);
    }
Beispiel #17
0
            public UICell Paster(String text, string type)
            {
                switch ((type ?? "").ToLower().Trim())
                {
                case "text":
                case "shell":
                    dataText.Append(text);
                    break;

                case "html":
                case "xml":
                    CheckXml(text);

                    break;

                default:
                    Check(text);
                    Append();
                    break;
                }
                if (dataText.Length > 0)
                {
                    data.Put("h" + data.Count.ToString(), dataText.ToString());
                }
                dataText = new StringBuilder();
                var sb = new StringBuilder();

                for (int i = 0; i < data.Count; i++)
                {
                    sb.Append("{h");
                    sb.Append(i);
                    sb.Append("}");
                }
                var cell = UICell.Create("CMSCode", data);

                if (String.IsNullOrEmpty(type) == false)
                {
                    data.Put("type", type);
                }
                cell.Format.Put("text", sb.ToString());
                cell.Style.Copy(style);

                return(cell);
            }
Beispiel #18
0
    private void OnMouseUp()
    {
        m_Dragging = false;

        if (GameManager.CanAddItems())
        {
            UICell activeCell = GameManager.GetActiveCell();

            if (activeCell && isCellValid(activeCell))
            {
                UIItem item = Instantiate <UIItem>(m_Item, activeCell.transform);
                activeCell.AddItem(item);
                m_DragOffset = Vector3.zero;

                m_Item.Buy();
            }
        }
        m_SnapToPos = false;
    }
Beispiel #19
0
    /// <summary>
    /// callback by LoopScrollRect
    /// </summary>
    /// <param name="index"></param>
    /// <param name="tf"></param>
    private void OnRefreshCell(int index, Transform tf)
    {
        if (_data == null || _data.Count < 0)
        {
            //Debug.LogError("loopScrollView data is empty");
            return;
        }
        if (index < 0 || index > _data.Count - 1)
        {
            Debug.LogError("cell index is overflow " + index);
            return;
        }
        UICell cel = tf.GetComponent <UICell>();

        if (cel)
        {
            cel.Init(this);
            cel.SetData(index, _data[index], _curSelectIndex == index);
        }
    }
Beispiel #20
0
        void Header(string text)
        {
            int i = 0;

            while (i < text.Length && text[i] == '#')
            {
                i++;
                if (i == 6)
                {
                    break;
                }
            }
            int size = 26 - (i - 1) * 2;

            var cell = UICell.Create("CMSText", new WebMeta().Put("text", text.Substring(i).Trim()).Put("Key", i));

            cell.Format.Put("text", "{text}");
            cell.Style.Bold().Size(size);
            cells.Add(cell);
        }
Beispiel #21
0
    private void OnMouseDrag()
    {
        if (!GameManager.CanAddItems())
        {
            return;
        }
        m_Dragging = true;

        m_DragOffset = Camera.main.ScreenToWorldPoint(Input.mousePosition) - m_InitDrag;
        UICell activeCell = GameManager.GetActiveCell();

        if (activeCell && isCellValid(activeCell))
        {
            m_SnapToPos = true;
            m_SnapPos   = activeCell.transform.position - transform.position;
        }
        else
        {
            m_SnapToPos = false;
        }
    }
    /// <summary>
    /// AddCell is what the individual cell objects use to dynamically generate the level at runtime
    /// Cell objects detect their location in the world and pass that data to the LevelController via this method.
    /// This method generates corresponding entries in all relevant areas of the game state.
    /// </summary>
    /// <param name="q">column</param>
    /// <param name="r">row</param>
    /// <param name="h">height</param>
    /// <param name="cellObj">Hex cell object</param>
    public void AddCell(int q, int r, int h, GameObject cellObj)
    {
        //Create a hex data object to go into the level grid
        HexCellData newCell = new HexCellData(q, r, h, cellObj);

        levelGrid[q, r, h] = newCell;

        //Create an pathing hex object to go into the pathing grid
        PathCell pathCell = new PathCell(q, r, h);

        aiController[q, r, h] = pathCell;

        //Create a UI cell object to go into the UI grid
        UICell uiCell = new UICell(q, r, h);

        uiController.addCellToUIMap(uiCell);
        //Set the scale of the object to equal the world hex it represents
        uiController[q, r, h].setModelScale(cellObj.GetComponent <HexCellObj>().modelScale);

        cellsReady++;
    }
Beispiel #23
0
    private void createBrainUI()
    {
        int s = cells[0].brain.layer_size.Length;

        uicells = new UICell[s][];

        for (int i = 0; i < s; i++)
        {
            uicells[i] = new UICell[cells[0].brain.layer_size[i]];
        }

        for (int i = 0; i < s; i++)
        {
            for (int j = 0; j < uicells[i].Length; j++)
            {
                // Instantiate the UI
                int        x  = nX + (2 * i + 1) * ncw;
                int        y  = nY + (2 * j + 1) * nch;
                GameObject go = Instantiate(uiCellPrefab, new Vector3(x, y, 0), Quaternion.identity);
                uicells[i][j] = go.GetComponent <UICell>();
            }
        }
    }
Beispiel #24
0
            public UICell Transform(String text)
            {
                Check(text);
                Append();
                if (dataText.Length > 0)
                {
                    data.Put("h" + data.Count.ToString(), dataText.ToString());
                }
                dataText = new StringBuilder();
                var sb = new StringBuilder();

                for (int i = 0; i < data.Count; i++)
                {
                    sb.Append("{h");
                    sb.Append(i);
                    sb.Append("}");
                }
                var cell = UICell.Create("CMSCode", data);

                cell.Format.Put("text", sb.ToString());
                cell.Style.Copy(style);

                return(cell);
            }
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var user = UMC.Security.Identity.Current;


            var header = new UIHeader();
            var title  = UITitle.Create();

            title.Title = "设置";
            var ui = UISection.Create(title);

            if (user.IsAuthenticated)
            {
                ui.NewSection().AddCell("我的账户", new Web.UIClick()
                {
                    Model = "Account", Command = "Self"
                });
            }
            else
            {
                ui.NewSection().AddCell("未登录", "请登录", new Web.UIClick()
                {
                    Model = "Account", Command = "Login"
                });
            }
            ui.NewSection()
            .AddCell("清空缓存", "", new Web.UIClick()
            {
                Key = "ClearCache"
            })
            .AddCell("检查更新", "", new Web.UIClick("Version")
            {
                Model = "UI", Command = "App"
            })
            .AddCell("应用测试", "", new Web.UIClick()
            {
                Model = "UI", Command = "Demo"
            })
            .AddCell("关于作者", "", Web.UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "365lu/help/AboutUs"), true));



            if (user.IsAuthenticated)
            {
                var cell = UICell.Create("UI", new UMC.Web.WebMeta().Put("text", "退出登录").Put("Icon", '\uf011').Put("click", new UIClick()
                {
                    Model   = "Account",
                    Command = "Close"
                }));
                cell.Style.Name("text", new UIStyle().Color(0xf00));
                ui.NewSection().NewSection()
                .Add(cell);
                //}
                //else
                //{
                //    var cell = UICell.Create("UI", new UMC.Web.WebMeta().Put("text", "登录").Put("Icon", '\uf007').Put("click", new UIClick()
                //    {
                //        Model = "Account",
                //        Command = "Login"
                //    }));
                //    cell.Style.Name("text", new UIStyle().Color(0xf00));
                //    ui.NewSection().NewSection()
                //        .Add(cell);
            }
            response.Redirect(ui);
        }
Beispiel #26
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            Guid designId = UMC.Data.Utility.Guid(this.AsyncDialog("Id", g => this.DialogValue(Guid.Empty.ToString()))).Value;//this.DialogValue(response.Ticket[AttributeNames.TICKET_STORE_ID])), true).Value;


            if (_isEditer)
            {
                WebMeta form = request.SendValues ?? request.Arguments;

                this.AsyncDialog("Model", anycId =>
                {
                    if (form.ContainsKey("limit") == false)
                    {
                        this.Context.Send(new UISectionBuilder(request.Model, request.Command, new WebMeta().Put("Id", designId))
                                          .RefreshEvent("Design", "image")
                                          .Builder(), true);
                    }
                    var entity = Database.Instance().ObjectEntity <Design_Item>();
                    entity.Where.And().Equal(new Design_Item {
                        design_id = Guid.Empty, for_id = Guid.Empty
                    });
                    entity.Order.Asc(new Design_Item {
                        Seq = 0
                    });
                    //IObjectEntity<Design_Item> entity = Database.instance().objectEntity(Design_Item.class);
                    //    entity.where().and().equal(new Design_Item().Design_id(Utility.uuidEmpty).For_id(Utility.uuidEmpty));
                    //    entity.order().asc(new Design_Item().Seq(0));
                    Design_Item[] headers = entity.Query();

                    UISection section = UISection.Create(new UITitle("UMC"));

                    int limit = UMC.Data.Utility.Parse(form.Get("limit"), 10);
                    int start = UMC.Data.Utility.Parse(form.Get("start"), 0);

                    switch (headers.Length)
                    {
                    case 0:
                        break;

                    case 1:
                        section.Title.Title = (headers[0].ItemName);
                        //     section.title().right('\ue907', new UIClick("Id", headers[0].Id.toString(), "Model", "none").model(request.model(), request.cmd()));
                        break;

                    default:
                        if (start == 0)
                        {
                            List <WebMeta> items = new List <WebMeta>();
                            foreach (Design_Item item in headers)
                            {
                                items.Add(new UMC.Web.WebMeta().Put("text", item.ItemName).Put("search", new WebMeta().Put("Id", item.Id)));
                            }
                            section.Add(UICell.Create("TabFixed", new UMC.Web.WebMeta().Put("items", items)));
                        }
                        break;
                    }


                    if (designId == Guid.Empty)
                    {
                        switch (headers.Length)
                        {
                        case 0:
                            break;

                        default:
                            new UIDesigner(true).Section(section, headers[0].Id.Value);
                            break;
                        }
                    }
                    else
                    {
                        new UIDesigner(true).Section(section, designId);
                    }
                    if (section.Length == 0)
                    {
                        section.Add("Desc", new UMC.Web.WebMeta().Put("desc", "未有设计分类项,请添加").Put("icon", "\uEA05")
                                    , new UMC.Web.WebMeta().Put("desc", "{icon}\n{desc}"),
                                    new UIStyle().Align(1).Color(0xaaa).Padding(20, 20).BgColor(0xfff).Size(12).Name("icon", new UIStyle().Font("wdk").Size(60)));
                    }
                    UIFooter footer = new UIFooter();
                    footer.IsFixed  = true;// e);

                    switch (headers.Length)
                    {
                    case 0:

                        footer.AddText(new UIEventText("添加分类项").Click(new UIClick("Model", "News", "Type", "Append").Send(request.Model, request.Command)));
                        break;

                    default:
                        Guid did = designId;
                        if (designId == Guid.Empty)
                        {
                            did = headers[0].Id.Value;
                        }
                        footer.AddIcon(new UIEventText("分类项").Icon('\uf009').Click(new UIClick("Model", "News", "Id", did.ToString()).Send(request.Model, request.Command)));


                        footer.AddText(new UIEventText("增加UI组件").Click(new UIClick(did.ToString()).Send("Design", "Item")));
                        footer.AddText(new UIEventText("查看效果").Style(new UIStyle().BgColor(0xef4f4f))
                                       .Click(new UIClick("Model", "News", "Type", "View").Send(request.Model, request.Command)));


                        break;
                    }


                    section.UIFooter = (footer);
                    response.Redirect(section);
                    return(this.DialogValue("none"));
                });
                String type = this.AsyncDialog("Type", g =>
                {
                    UIRadioDialog di = new UIRadioDialog();
                    di.Title         = ("页面设计");
                    di.Options.Put("编辑分类项", "Edit");
                    di.Options.Put("增加分类项", "Append");
                    di.Options.Put("删除此分类", "Delete");
                    return(di);
                });
                switch (type)
                {
                case "Edit":
                    Design(request, designId);
                    break;

                case "Append":
                    Design(request, Guid.NewGuid());    //.randomUUID());
                    break;

                case "Delete":
                    Delete(designId);
                    break;

                case "View":
                    if (request.IsApp)
                    {
                        List <WebMeta> tabs = new List <WebMeta>();

                        Database.Instance().ObjectEntity <Design_Item>()
                        .Where.And().Equal(new Design_Item()
                        {
                            design_id = Guid.Empty, for_id = Guid.Empty
                        })                                                                                               //(Utility.uuidEmpty).For_id(Utility.uuidEmpty))

                        .Entities.Order.Asc(new Design_Item()
                        {
                            Seq = 0
                        })
                        .Entities.Query(dr =>
                        {
                            tabs.Add(new UMC.Web.WebMeta().Put("text", dr.ItemName).Put("search", new UMC.Web.WebMeta().Put("Id", dr.Id.ToString())).Put("cmd", "Home", "model", "Design"));
                        });
                        if (tabs.Count == 1)
                        {
                            UISectionBuilder builder = new UISectionBuilder("Design", "Home", new WebMeta().Put("Id", tabs[0].GetMeta("search").Get("Id")));
                            //                            builder.builder()
                            this.Context.Send(builder.Builder(), true);    //"Tab", new WebMeta().put("sections", tabs).put("text", "UMC界面设计"), true);
                        }
                        else
                        {
                            this.Context.Send("Tab", new WebMeta().Put("sections", tabs).Put("text", "UMC界面设计"), true);
                        }
                    }
                    else
                    {
                        this.AsyncDialog("From", k =>
                        {
                            UIFormDialog fm = new UMC.Web.UIFormDialog();
                            fm.Title        = ("移动效果体验");
                            fm.AddImage(new Uri(UMC.Data.Utility.QRUrl("https://oss.365lu.cn/Click/Deisgn/Home/")));


                            fm.AddPrompt("请用支持UMC协议的APP“扫一扫”。");

                            return(fm);
                        });
                        break;
                    }
                    break;
                }
            }
            else
            {
                if (designId == Guid.Empty)
                {
                    var entity = Database.Instance().ObjectEntity <Design_Item>();
                    entity.Where.And().Equal(new Design_Item {
                        design_id = Guid.Empty, for_id = Guid.Empty
                    });
                    entity.Order.Asc(new Design_Item {
                        Seq = 0
                    });

                    List <WebMeta> tabs = new List <WebMeta>();
                    entity.Query(dr =>
                    {
                        tabs.Add(new UMC.Web.WebMeta().Put("text", dr.ItemName).Put("search", new UMC.Web.WebMeta().Put("Id", dr.Id)).Put("cmd", "UI", "model", "Design"));
                    });

                    var     chash = new Hashtable();
                    UITitle title = new UITitle("UMC移动界面");
                    title.Left('\uea0e', UIClick.Search());

                    title.Right(new UIEventText().Icon('\uf2c0').Click(new UIClick().Send("Account", "Info")));


                    chash.Add("sections", tabs);
                    chash.Add("title", title);
                    response.Redirect(chash);
                }
                else
                {
                    UIDesigner designer = new UIDesigner(false);
                    response.Redirect(designer.Section("", designId));
                }
            }
        }
        public void Wildcard(WebRequest request, WebResponse response, string name)
        {
            var wddEntity = UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Wildcard>();
            var wdk       = wddEntity.Where.And().Equal(new Data.Entities.Wildcard {
                WildcardKey = name
            }).Entities.Single();

            var auths = new List <UMC.Security.Authorize>();

            if (wdk != null)
            {
                var data = new Data.Entity <Data.Entities.Wildcard, List <Security.Authorize> >(wdk, wdk.Authorizes);

                auths.AddRange(data.Config);
            }
            var Type = this.AsyncDialog("WType", gg =>
            {
                var form = request.SendValues ?? new UMC.Web.WebMeta();
                if (form.ContainsKey("limit") == false)
                {
                    this.Context.Send(new UISectionBuilder(request.Model, request.Command, new WebMeta(request.Arguments.GetDictionary()))
                                      .RefreshEvent("Wildcard")
                                      .Builder(), true);
                }
                var ui = UMC.Web.UISection.Create(new UITitle("权限设置"));
                ui.AddCell('\uf084', "标识", name);


                var ui3   = ui.NewSection().AddCell('\uf007', "许可用户", "", new Web.UIClick(new WebMeta(request.Arguments.GetDictionary()).Put(gg, "User")).Send(request.Model, request.Command));
                var users = auths.FindAll(g => g.Type == Security.AuthorizeType.UserAllow);
                var uids  = new List <String>();
                foreach (var u in users)
                {
                    uids.Add(u.Value);
                }

                var dusers = UMC.Security.Membership.Instance().Identity(uids.ToArray());


                foreach (var u in users)
                {
                    var text = u.Value;
                    var u1   = dusers.Find(d => d.Name == u.Value);
                    if (u1 != null)
                    {
                        text = u1.Alias;
                    }
                    var cell = UICell.Create("Cell", new WebMeta().Put("value", u.Value).Put("text", text));//.Put("Icon", '\uf007'));

                    ui3.Delete(cell, new UIEventText().Click(new Web.UIClick(new WebMeta(request.Arguments.GetDictionary()).Put(gg, u.Value)).Send(request.Model, request.Command)));
                }
                if (users.Count == 0)
                {
                    ui3.Add("Desc", new UMC.Web.WebMeta().Put("desc", "未设置许可用户").Put("icon", "\uEA05"), new UMC.Web.WebMeta().Put("desc", "{icon}\n{desc}"),
                            new UIStyle().Align(1).Color(0xaaa).Padding(20, 20).BgColor(0xfff).Size(12).Name("icon", new UIStyle().Font("wdk").Size(60)));//.Name
                }

                var ui2 = ui.NewSection().AddCell('\uf0c0', "许可角色", "", new Web.UIClick(new WebMeta(request.Arguments.GetDictionary()).Put(gg, "Role")).Send(request.Model, request.Command));

                var roles = auths.FindAll(g => g.Type == Security.AuthorizeType.RoleAllow);

                foreach (var u in roles)
                {
                    var cell = UICell.Create("Cell", new WebMeta().Put("text", u.Value));//.Put("Icon", '\uf0c0'));

                    ui2.Delete(cell, new UIEventText().Click(new Web.UIClick(new WebMeta(request.Arguments.GetDictionary()).Put(gg, u.Value)).Send(request.Model, request.Command)));
                }
                if (roles.Count == 0)
                {
                    ui2.Add("Desc", new UMC.Web.WebMeta().Put("desc", "未设置许可角色").Put("icon", "\uEA05"), new UMC.Web.WebMeta().Put("desc", "{icon}\n{desc}"), new UIStyle().Align(1).Color(0xaaa).Padding(20, 20).BgColor(0xfff).Size(12).Name("icon", new UIStyle().Font("wdk").Size(60)));//.Name
                }
                response.Redirect(ui);
                return(this.DialogValue("none"));
            });

            switch (Type)
            {
            case "Role":
                var role = this.AsyncDialog("SelectRole", request.Model, "SelectRole");
                auths.RemoveAll(k => String.Equals(k.Value, role));
                auths.Add(new Security.Authorize {
                    Type = UMC.Security.AuthorizeType.RoleAllow, Value = role
                });
                wddEntity.IFF(e => e.Update(new Data.Entities.Wildcard {
                    Authorizes = UMC.Data.JSON.Serialize(auths)
                }) == 0
                              , e => e.Insert(new Data.Entities.Wildcard {
                    WildcardKey = name, Authorizes = UMC.Data.JSON.Serialize(auths)
                }));
                this.Context.Send("Wildcard", true);
                break;

            case "User":

                var user = this.AsyncDialog("SelectUser", request.Model, "SelectUser");
                auths.RemoveAll(k => String.Equals(k.Value, user));
                auths.Add(new Security.Authorize {
                    Type = UMC.Security.AuthorizeType.UserAllow, Value = user
                });
                wddEntity.IFF(e => e.Update(new Data.Entities.Wildcard {
                    Authorizes = UMC.Data.JSON.Serialize(auths)
                }) == 0
                              , e => e.Insert(new Data.Entities.Wildcard {
                    WildcardKey = name, Authorizes = UMC.Data.JSON.Serialize(auths)
                }));
                this.Context.Send("Wildcard", true);
                break;

            default:
                var a = auths.Find(k => String.Equals(Type, k.Value));
                if (a != null)
                {
                    auths.Remove(a);
                    wddEntity.Update(new Data.Entities.Wildcard {
                        Authorizes = UMC.Data.JSON.Serialize(auths)
                    });
                    if (auths.Exists(k => k.Type == a.Type) == false)
                    {
                        this.Context.Send("Wildcard", true);
                    }
                }
                break;
            }
            //var acc =
        }
Beispiel #28
0
        void TitleDesc(Design_Item parent, List <Design_Item> items, UISection U)
        {
            UMC.Data.WebResource webr = UMC.Data.WebResource.Instance();


            //WebMeta config = Utility.isNull(UMC.Data.JSON.deserialize(parent.Data, WebMeta.class), new UMC.Web.WebMeta());
            WebMeta config = UMC.Data.JSON.Deserialize <WebMeta>(parent.Data) ?? new UMC.Web.WebMeta();

            int rows = UMC.Data.Utility.IntParse(config.Get("Total"), 1);

            if (rows <= 1)
            {
                int[] padding = UIStyle.Padding(config);
                foreach (Design_Item i in items)
                {
                    UICell tdesc = this.TitleDesc(config, i, "cms1", webr);
                    if (padding.Length > 0)
                    {
                        tdesc.Style.Padding(padding);
                    }
                    U.Add(tdesc);
                }
            }
            else
            {
                int    m    = 0;
                String hide = config.Get("Hide") ?? "";
                if (hide.Contains("HideTitle"))
                {
                    m |= 1;
                }
                if (hide.Contains("HideDesc"))
                {
                    m |= 2;
                }
                if (hide.Contains("HideLeft"))
                {
                    m |= 4;
                }
                if (hide.Contains("HideRight"))
                {
                    m |= 8;
                }

                int len = items.Count;

                for (int i = 0; (i + rows - 1) < len; i = i + rows)
                {
                    List <WebMeta> ls = new List <WebMeta>();//<>();
                    for (int c = 0; c < rows; c++)
                    {
                        UICell p = TitleDesc(config, items[i + c], "350", webr);
                        ls.Add(new UMC.Web.WebMeta().Put("value", p.Data).Put("format", p.Format).Put("style", p.Style));
                    }
                    UICell desc     = UICell.Create("ItemsTitleDesc", new UMC.Web.WebMeta().Put("items", ls.ToArray()).Put("total", rows).Put("show", m));
                    int[]  paddings = UIStyle.Padding(config);
                    if (paddings.Length > 0)
                    {
                        desc.Style.Padding(paddings);
                    }
                    U.Add(desc);
                }
                int total = len % rows;

                if (total > 0)
                {
                    List <WebMeta> ls = new List <WebMeta>();
                    for (int c = total; c > 0; c--)
                    {
                        UICell p = TitleDesc(config, items[len - c], "350", webr);
                        ls.Add(new UMC.Web.WebMeta().Put("value", p.Data).Put("format", p.Format).Put("style", p.Style));
                    }

                    UICell desc     = UICell.Create("ItemsTitleDesc", new UMC.Web.WebMeta().Put("items", ls.ToArray()).Put("total", rows).Put("show", m));
                    int[]  paddings = UIStyle.Padding(config);
                    if (paddings.Length > 0)
                    {
                        desc.Style.Padding(paddings);
                    }
                    U.Add(desc);
                }
            }
            if (items.Count == 0 && _editer)
            {
                UIDesc desc = new UIDesc("\ue907");
                desc.Desc("{desc}\r\n配置图文栏");

                desc.Style.AlignCenter().Name("desc", new UIStyle().Font("wdk").Size(38).Click(new UIClick(parent.Id.ToString())
                                                                                               .Send("Design", "Item")));
                U.Add(desc);
            }
        }
 public static void   SetActiveCell(UICell cell)
 {
     m_ActiveCell = cell;
 }
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var ProjectId = Utility.Guid(this.AsyncDialog("Id", g =>
            {
                this.Prompt("请输入项目");

                return(this.DialogValue("Project"));
            })) ?? Guid.Empty;

            UISection ui      = null;
            var       project = Utility.CMS.ObjectEntity <Project>().Where.And().Equal(new Data.Entities.Project {
                user_id = ProjectId
            }).Entities.Single();

            //var svs = request.SendValues ?? new UMC.Web.WebMeta();
            var form    = (request.SendValues ?? new UMC.Web.WebMeta()).GetDictionary();
            int start   = UMC.Data.Utility.IntParse(form["start"] as string, 0);
            var nextKey = this.AsyncDialog("NextKey", g => this.DialogValue("Header"));;

            if (start == 0 && String.Equals(nextKey, "Header"))
            {
                var logoUrl = UMC.Data.WebResource.Instance().ResolveUrl(String.Format("{0}{1}/1/0.jpg!200", UMC.Data.WebResource.ImageResource, project.Id));

                //    var mcode = "您未登录";

                var members = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>()
                              .Where.And().Equal(new Data.Entities.ProjectMember {
                    project_id = project.Id
                })
                              .Entities.Count() + 1;
                var subs = Utility.CMS.ObjectEntity <Subject>().Where.And().Equal(new Data.Entities.Subject {
                    project_id = project.Id
                }).Entities.Count();


                //Sections.Add(cmsText);

                String mcode = String.Format("成员 {0} 图文 {1}", members, subs);

                var Discount = new UIHeader.Profile(project.Caption, mcode, logoUrl);


                var color = 0x63b359;
                Discount.Gradient(color, color);
                var header = new UIHeader();
                var title  = UITitle.Create();

                title.Title = "项目介绍";
                header.AddProfile(Discount, "{number}", "{amount}");


                ui = UISection.Create(header, title);
                if (String.IsNullOrEmpty(project.Description) == false)
                {
                    var cmsText = UICell.Create("CMSText", new UMC.Web.WebMeta().Put("text", project.Description));
                    cmsText.Style.Size(14).Color(0x999);
                }
            }
            else
            {
                ui = UISection.Create();
            }
            var items = new List <WebMeta>();

            items.Add(new UMC.Web.WebMeta().Put("text", "文章", "search", "Subs"));
            items.Add(new UMC.Web.WebMeta().Put("text", "成员", "search", "Member"));
            items.Add(new UMC.Web.WebMeta().Put("text", "动态", "search", "Dynamic"));
            int limit       = UMC.Data.Utility.IntParse(form["limit"] as string, 25);
            var selectIndex = UMC.Data.Utility.IntParse(this.AsyncDialog("selectIndex", g => this.DialogValue("0")), 0);
            var webr        = UMC.Data.WebResource.Instance();

            switch (selectIndex)
            {
            case 0:
            {
                var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>();
                subEntity.Order.Desc(new Subject {
                        ReleaseDate = DateTime.Now
                    });
                subEntity.Where.And().Equal(new Data.Entities.Subject {
                        Status = 1, IsDraught = false, project_id = project.Id
                    });
                SubjectUIActivity.Search(ui, subEntity, start, limit);
                response.Redirect(ui);
            }
            break;

            case 1:
            {
                int mlimit    = limit * 4;
                int mstart    = start * 4;
                var ids       = new List <Guid>();
                var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectMember>();
                subEntity.Order.Desc(new ProjectMember {
                        CreationTime = DateTime.Now
                    });
                subEntity.Query(mstart, mlimit, dr => ids.Add(dr.user_id.Value));
                if (mstart == 0)
                {
                    ids.Add(project.user_id.Value);
                }
                if (ids.Count > 0)
                {
                    var users = new List <User>();
                    UMC.Data.Database.Instance().ObjectEntity <User>()
                    .Where.And().In(new User {
                            Id = ids[0]
                        }, ids.ToArray()).Entities.Query(dr => users.Add(dr));

                    var icons = new List <UIEventText>();
                    foreach (var v in users)
                    {
                        icons.Add(new UIEventText(v.Alias).Src(webr.ResolveUrl(v.Id.Value, "1", "4")));

                        if (icons.Count % 4 == 0)
                        {
                            ui.AddIcon(icons.ToArray());
                            icons.Clear();
                        }
                    }
                    if (icons.Count > 0)
                    {
                        ui.AddIcon(icons.ToArray());
                    }
                }
                var m     = subEntity.Count();
                int total = m / 4;
                if (m % 4 > 0)
                {
                    total++;
                }
                ui.Total = total;
                response.Redirect(ui);
            }
            break;

            case 2:
            {
                var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.ProjectDynamic>();
                subEntity.Where.And().Equal(new ProjectDynamic
                    {
                        project_id = project.Id
                    }).Entities.Order.Desc(new ProjectDynamic {
                        Time = DateTime.MinValue
                    });

                var subs = new List <ProjectDynamic>();
                var uids = new List <Guid>();
                subEntity.Query(start, limit, dr =>
                    {
                        subs.Add(dr);
                        uids.Add(dr.user_id ?? Guid.Empty);
                    });
                var cates = new List <User>();
                if (uids.Count > 0)
                {
                    UMC.Data.Database.Instance().ObjectEntity <User>().Where.And().In(new User {
                            Id = uids[0]
                        }, uids.ToArray())
                    .Entities.Query(dr => cates.Add(dr));
                }
                foreach (var sub in subs)
                {
                    var sType = "成员动态";
                    switch (sub.Type)
                    {
                    case DynamicType.Member:
                        break;

                    case DynamicType.Portfolio:
                        sType = "文集动态";
                        break;

                    case DynamicType.Project:
                        sType = "项目动态";
                        break;

                    case DynamicType.Subject:
                        sType = "文档动态";
                        break;

                    case DynamicType.ProjectItem:
                        sType = "栏位动态";
                        break;
                    }
                    //



                    var user2 = cates.Find(d => d.Id == sub.user_id) ?? new User();

                    var data = new WebMeta().Put("alias", user2.Alias, "type", sType, "desc", sub.Explain).Put("time", sub.Time)
                               .Put("title", sub.Title);
                    var cell = UIImageTitleBottom.Create(webr.ResolveUrl(sub.user_id ?? Guid.Empty, "1", 5), data);

                    cell.Format.Put("left", "{alias} {time} {desc}").Put("right", "{type}");
                    cell.Style.Name("image-radius", 30);
                    ui.Add(cell);
                    //data.Rows.Add(sub.user_id, sub.Title, sub.Explain, sub.Time, sType, webr.ResolveUrl(sub.user_id ?? Guid.Empty, "1", 5),
                    //user2.Alias);
                }
                ui.Total = subEntity.Count();
            }
            break;
            }



            //var appKey = UMC.Security.Principal.Current.AppKey ?? Guid.Empty;


            //var li = ui.NewSection();// UIClick.Pager("Member", "Order", new WebADNuke.Web.WebMeta().Put("type", "App", "selectIndex", "0"))
            //li.AddCell("我的订单", "查看全部", UIClick.Pager("Member", "Order", new UMC.Web.WebMeta().Put("type", "App", "selectIndex", "0")));
            //li.AddCell("我的佣金", "", new Web.UIClick() { Command = "Commission", Model = "Member" });
            //li.AddCell("我的收藏", new Web.UIClick() { Command = "Favs", Model = request.Model });
            //li.AddCell("我的优惠券", new Web.UIClick() { Command = "Coupons", Model = "Member" });
            //if (appKey == Guid.Empty)
            //{

            //    var cate = Utility.CMS.ObjectEntity<UMC.Data.Entities.Category>().Where.And().Equal(new Data.Entities.Category { user_id = user.Id })
            //          .Entities.Count();
            //    if (cate > 0)
            //    {
            //        li.NewSection().AddCell("我的版务", new Web.UIClick() { Command = "Apply", Model = "Subject" });

            //    }
            //    li.AddCell("我的图文", new Web.UIClick() { Command = "Self", Model = "Subject" });
            //    li.NewSection().AddCell("积分政策", UIClick.Pager("Subject", "UIData", new UMC.Web.WebMeta().Put("Id", "Subject.Points")));
            //}
            //else
            //{
            //li.AddCell("我的图文", new Web.UIClick() { Command = "Self", Model = "Subject" });
            //li.NewSection().AddCell("卡券分享", "被领取即可获的收益", UIClick.Pager("Corp", "Coupons"));
            ////}


            //if (request.IsApp)
            //{
            //    ui.NewSection().AddCell('\uf083', "扫一扫", "", new Web.UIClick() { Key = "Scanning" });
            //    //.AddCell('\uf0c5', "软文转码", "将检测粘贴板", new Web.UIClick() { Key = "CaseCMS" });
            //    ui.NewSection()
            //        //.AddCell('\uf19c', "切换企业", "", Web.UIClick.Pager("Platform", "Corp", true))
            //        .AddCell('\uf013', "设置", "", Web.UIClick.Pager("UI", "Setting", true, "Close"));


            //}
            //else
            //{
            //    ui.NewSection()
            //        .AddCell('\uf013', "设置", "", Web.UIClick.Pager("UI", "Setting", true, "Close"));

            //}

            response.Redirect(ui);


            //}
        }