Пример #1
0
    /// <summary>
    /// generates a tab that can be clicked in order to show model info
    /// </summary>
    /// <param name="index"></param>
    /// <param name="total"></param>
    /// <param name="color"></param>
    /// <param name="model_id"></param>
    /// <returns></returns>
    private HtmlGenericControl GenerateTab(int index, int total, string color, int model_id)
    {
        HtmlGenericControl tab = new HtmlGenericControl("div");

        tab.ID = "file-tab-" + index;
        tab.Attributes["class"] = "asset-file-tab";
        float width   = 15;
        float leftPos = 0;

        if (total > 1)
        {
            leftPos = 85 * index / (total - 1);
        }
        if (leftPos > 15 * index)
        {
            leftPos = 15 * index;
        }
        tab.Attributes["style"]   = "left:" + leftPos + "%; width:" + width + "%; background-color:" + color;
        tab.Attributes["onclick"] = "putInfront(" + index + ");";

        HtmlGenericControl tabTxt = new HtmlGenericControl("p");

        tabTxt.InnerHtml           = ws.GetModelName(model_id);
        tabTxt.Attributes["class"] = "tab-txt Report1942Font";
        tab.Controls.Add(tabTxt);
        return(tab);
    }
Пример #2
0
    /// <summary>
    /// gets asset id and generates description control from it
    /// </summary>
    /// <param name="model_id"></param>
    /// <returns></returns>
    private HtmlGenericControl GenerateDescriptionControl(int model_id)
    {
        HtmlGenericControl description = new HtmlGenericControl("div");

        description.Attributes["class"] = "description";

        HtmlGenericControl assetname = new HtmlGenericControl("p");

        assetname.Attributes["class"] = "AssetName";
        assetname.InnerHtml           = ws.GetModelName(model_id);
        HtmlGenericControl createdBy = new HtmlGenericControl("p");

        createdBy.Attributes["class"] = "CreatedBy";
        createdBy.InnerHtml           = "by " + GetUserName(model_id);

        description.Controls.Add(assetname);
        description.Controls.Add(createdBy);
        description.Controls.Add(GenerateExpandButton(model_id));

        return(description);
    }
Пример #3
0
    /// <summary>
    /// gets model information from data base by model id in the url
    /// clear TempModels file
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        DirectoryInfo temp = new DirectoryInfo(Server.MapPath("/Resources/TempModels/"));

        foreach (FileInfo f in temp.GetFiles())
        {
            f.Delete();
        }

        string url = Request.Url.AbsoluteUri;// /Pages/AssetPage.aspx?item_id=200134

        try
        {
            model_id = int.Parse(url.Substring(url.IndexOf('?') + 1));

            ws = new maker_service.WebService();

            CreatorsName.Text     = GetUserName(model_id);
            CreatorsName.ToolTip  = CreatorsName.Text;
            AssetName.Text        = ws.GetModelName(model_id);
            AssetName.ToolTip     = AssetName.Text;
            AssetDescription.Text = ws.GetModelDescription(model_id);
            Rating.Text           = (Math.Floor(ws.GetRate(model_id) * 100) / 100).ToString();
            int      userRate = ws.GetModelUserRate(model_id, (int)Session["user-id"]);
            string[] info     = ws.GetModelInfo(model_id);

            camPos.Text    = info[0];
            camLookAt.Text = info[1];

            positions.Text = info[2];
            colors.Text    = info[3];
            normals.Text   = info[4];


            selectedImg0.CssClass = "shownImg";
            selectedImg1.CssClass = "shownImg";
            selectedImg2.CssClass = "shownImg";
            selectedImg3.CssClass = "shownImg";
            selectedImg4.CssClass = "shownImg";

            if (userRate < 5)
            {
                selectedImg4.CssClass = "hiddenImg";
            }
            if (userRate < 4)
            {
                selectedImg3.CssClass = "hiddenImg";
            }
            if (userRate < 3)
            {
                selectedImg2.CssClass = "hiddenImg";
            }
            if (userRate < 2)
            {
                selectedImg1.CssClass = "hiddenImg";
            }
            if (userRate < 1)
            {
                selectedImg0.CssClass = "hiddenImg";
            }

            ws.CloseConnection();
        }
        catch//if anything failed print Error 404
        {
            HtmlGenericControl errorCover = new HtmlGenericControl("div");
            errorCover.Attributes["style"] = "position:absolute; left:0%; top:0%; width:100%; height:100%; background-color:rgba(0,0,0,0.75);";
            HtmlGenericControl errorDiv = new HtmlGenericControl("div");
            errorDiv.Attributes["class"] = "errorPos panelColor";
            HtmlGenericControl errorMessage = new HtmlGenericControl("p");
            errorMessage.InnerHtml = "Error 404: it seems like this asset does not exist anymore!";
            errorDiv.Controls.Add(errorMessage);
            ErrorMessage.Controls.Add(errorCover);
            ErrorMessage.Controls.Add(errorDiv);
            ErrorMessage.CssClass = "ErrorMessage";
        }
    }