Пример #1
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.EnsureChildControls();

            this.SetImageAndSize();

            if (!this.Page.IsPostBack && this.data.Value != null)
            {
                // set the x and y textboxes
                ImagePoint value = new ImagePoint();
                ((uQuery.IGetProperty)value).LoadPropertyValue(this.data.Value.ToString());

                if (value.X.HasValue)
                {
                    this.xTextBox.Text = value.X.ToString();
                }

                if (value.Y.HasValue)
                {
                    this.yTextBox.Text = value.Y.ToString();
                }
            }

            this.RegisterEmbeddedClientResource("uComponents.DataTypes.ImagePoint.ImagePoint.css", ClientDependencyType.Css);
            this.RegisterEmbeddedClientResource("uComponents.DataTypes.ImagePoint.ImagePoint.js", ClientDependencyType.Javascript);

            string startupScript = @"
                <script language='javascript' type='text/javascript'>
                    $(document).ready(function () {
                        ImagePoint.init(jQuery('div#" + this.div.ClientID + @"'));
                    });
                </script>";

            ScriptManager.RegisterStartupScript(this, typeof(ImagePointDataEditor), this.ClientID + "_init", startupScript, false);
        }
        /// <summary>
        /// from a collection of document or media properties, create and add any required ghost images to the areaDiv
        /// </summary>
        /// <param name="properties"></param>
        private void CreateGhostImages(IEnumerable<Property> properties)
        {
            foreach(Property property in properties)
            {
                ImagePoint imagePoint = new ImagePoint();
                ((uQuery.IGetProperty)imagePoint).LoadPropertyValue(property.Value.ToString());

                if (imagePoint.HasCoordinate)
                {
                    Image ghostImage = new Image();

                    ghostImage.ImageUrl = this.Page.ClientScript.GetWebResourceUrl(this.GetType(), "uComponents.DataTypes.ImagePoint.ImagePointGhost.png");
                    ghostImage.CssClass = "ghost";

                    // using sql here, else would have to query document and media seperately
                    using(IRecordsReader iRecordsReader = uQuery.SqlHelper.ExecuteReader(@"
                                                                                            SELECT  A.contentNodeId AS 'Id',
                                                                                                    B.text AS 'Name',
                                                                                                    C.Name AS 'PropertyName'

                                                                                            FROM    cmsPropertyData A
                                                                                                    LEFT OUTER JOIN umbracoNode B ON A.ContentNodeId = B.Id
                                                                                                    LEFT OUTER JOIN cmsPropertyType C ON A.propertytypeid = C.id

                                                                                            WHERE   A.id = @propertyDataId",
                                                                                            uQuery.SqlHelper.CreateParameter("propertyDataId", property.Id)))
                    {
                        iRecordsReader.Read(); // there should only be a single row returned

                        // if the properties are on the same item, then label with property name, otherwise default to labeling with the node / media or member name
                        if (iRecordsReader.Get<int>("Id") == this.CurrentContentId)
                        {
                            ghostImage.ToolTip = iRecordsReader.Get<string>("PropertyName");
                        }
                        else
                        {
                            ghostImage.ToolTip = iRecordsReader.Get<string>("Name");
                        }
                    }

                    ghostImage.Style.Add(HtmlTextWriterStyle.Left, (imagePoint.X - 7).ToString() + "px");
                    ghostImage.Style.Add(HtmlTextWriterStyle.Top, (imagePoint.Y - 7).ToString() + "px");

                    areaDiv.Controls.Add(ghostImage);
                }
            }
        }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.EnsureChildControls();
            this.ConfigureControls();

            if (!this.Page.IsPostBack && this.data.Value != null)
            {
                // set the x and y textboxes
                ImagePoint value = new ImagePoint();
                ((uQuery.IGetProperty)value).LoadPropertyValue(this.data.Value.ToString());

                if (value.X.HasValue)
                {
                    this.xTextBox.Text = value.X.ToString();
                }

                if (value.Y.HasValue)
                {
                    this.yTextBox.Text = value.Y.ToString();
                }
            }

            this.RegisterEmbeddedClientResource("uComponents.DataTypes.ImagePoint.ImagePoint.css", ClientDependencyType.Css);
            this.RegisterEmbeddedClientResource("uComponents.DataTypes.ImagePoint.ImagePoint.js", ClientDependencyType.Javascript);

            string startupScript = @"
                <script language='javascript' type='text/javascript'>
                    $(document).ready(function () {
                        ImagePoint.init(jQuery('div#" + this.imagePointDiv.ClientID + @"'));
                    });
                </script>";

            ScriptManager.RegisterStartupScript(this, typeof(ImagePointDataEditor), this.ClientID + "_init", startupScript, false);
        }