Exemplo n.º 1
0
        internal override void RenderLabelView(WebGridHtmlWriter writer, RowCell cell)
        {
            string uniqueID = cell.CellClientId;

            if (ChartType == ChartType.HorizontalBar)
            {
                if (m_Image == null) // Draw using table
                {
                    StringBuilder bg = new StringBuilder(string.Empty);
                    if (BackgroundImage != null)
                    {
                        bg.AppendFormat(" background=\"{0}\"", BackgroundImage);
                    }
                    StringBuilder s = new StringBuilder(string.Empty);
                    s.AppendFormat("<table height=\"{0}\">", HeightEditableColumn);
                    if (m_StartImage != null)
                    {
                        s.AppendFormat(
                            "<td><img alt=\"{2}\" border=\"0\" src=\"{0}\"  height={1}/></td>", m_StartImage,
                            HeightEditableColumn, Title);
                    }
                    s.AppendFormat("<td width=\"{0}\" {1}></td>", BarWidth, bg);
                    if (m_EndImage != null)
                    {
                        s.AppendFormat(
                            "<td><img alt=\"{2}\" border=\"0\" src=\"{0}\"  height={1}/></td>", m_EndImage,
                            HeightEditableColumn, Title);
                    }
                    s.Append("</table>");
                    LabelHtml(s.ToString(), writer, cell);
                    return;
                }
                else // Draw using image
                {
                    StringBuilder s = new StringBuilder(string.Empty);
                    if (m_StartImage != null)
                    {
                        s.AppendFormat("<img alt=\"{2}\" border=\"0\" src=\"{0}\"  height={1}/>",
                                       m_StartImage, HeightEditableColumn, Title);
                    }
                    s.AppendFormat("<img alt=\"{3}\" border=\"0\" src=\"{0}\"  height={1} width={2}/>",
                                   m_Image, HeightEditableColumn, BarWidth, Title);
                    if (m_EndImage != null)
                    {
                        s.AppendFormat("<img alt=\"{2}\" border=\"0\" src=\"{0}\"  height={1}/>", m_EndImage,
                                       HeightEditableColumn, Title);
                    }

                    LabelHtml(s.ToString(), writer, cell);
                    return;
                }
            }
            if (ChartType == ChartType.HorizontalBar)
            {
                // 2005.01.09 - jorn, string optimization
                StringBuilder namesBuilder = new StringBuilder();
                string        values       = string.Empty;
                Table         t            = Grid.MasterTable;
                for (int i = 0; i < t.Rows.Count; i++)
                {
                    if (namesBuilder.Length != 0)
                    {
                        namesBuilder.Append(",");
                    }
                    if (values.Length != 0)
                    {
                        values += ",";
                    }
                    namesBuilder.Append(HttpUtility.UrlEncode(t.Rows[i][TitleColumn].Value.ToString(), Encoding.Default));
                    try
                    {
                        values +=
                            HttpUtility.UrlEncode(t.Rows[i][ValueColumn].Value.ToString().Replace(",", "."),
                                                  Encoding.Default);
                    }
                    catch
                    {
                        values += "0";
                    }
                }

                string width = "150";
                if (WidthEditableColumn.IsEmpty == false)
                {
                    width = WidthEditableColumn.Value.ToString();
                }
                string s =
                    string.Format(
                        "<img alt=\"{4}\" border=\"0\" src=\"?wgpiechart={0}&values={1}&names={2}&width={3}\"/>",
                        uniqueID, values, namesBuilder, width, Title);
                LabelHtml(s, writer, cell);
                return;
            }
            else
            {
                ArrayList values = new ArrayList();

                Table t = Grid.MasterTable;
                for (int i = 0; i < t.Rows.Count; i++)
                {
                    double val  = double.Parse(t.Rows[i][ValueColumn].Value.ToString());
                    string name = string.Empty;
                    if (t.Rows[i][TitleColumn].Value != null)
                    {
                        name = t.Rows[i][TitleColumn].Value.ToString();
                    }

                    ChartValue cv = new ChartValue(name, val);
                    values.Add(cv);

                    /*					if(names != string.Empty) names += ",";
                     *                  if(values != string.Empty) values += ",";
                     *                  names += HttpUtility.UrlEncode( t.Rows[i][ TitleColumn ].Value );
                     *                  try
                     *                  {
                     *                      values += HttpUtility.UrlEncode( t.Rows[i][ ValueColumn ].Value.Replace(",",".") );
                     *                  }
                     *                  catch
                     *                  {
                     *                      values += "0";
                     *                  }*/
                }

                int width = (int)WidthEditableColumn.Value;
                if (width < 16)
                {
                    width = 150;
                }
                int height = (int)HeightEditableColumn.Value;
                if (height < 16)
                {
                    height = 200;
                }

                //try
                //{
                Util.Chart c = new Util.Chart(ChartType, width, height);
                if (BackgroundImage != null && Grid.GotHttpContext)
                {
                    if (BackgroundImage.ToUpperInvariant().StartsWith("HTTP://") == false)
                    {
                        BackgroundImage = HttpContext.Current.Server.MapPath(BackgroundImage);
                    }
                    c.ChartBackground = new ChartBackground(BackgroundImage);
                }
                c.ShowPieValues          = false;
                c.ChartHeadline.Headline = Title;
                c.AddDataArray(values);
                c.RenderLabelBoard = TitleBoardOnChart;
                if (Grid.GotHttpContext)
                {
                    HttpContext.Current.Session[string.Format("{0}_{1}_img", Grid.ClientID, uniqueID)] = c.Render();
                }

                string s; //src=\"?wgchart=" + this.Grid.ColumnId + "_" + this.FormElementName + "_img\"
                if (Grid.GotHttpContext &&
                    HttpContext.Current.Request.Browser.Type.ToUpperInvariant().StartsWith("IE"))
                {
                    s =
                        string.Format(
                            "<img height=\"{0}\" width=\"{1}\"  src=\"{2}\" style=\"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='?wgchart={3}_{4}_img', sizingMethod='scale');\" alt=\"{5}\" border=\"0\" />",
                            Unit.Pixel(height), Unit.Pixel(width), Grid.Page.ClientScript.GetWebResourceUrl(Grid.GetType(), "WebGrid.Resources.images.transparent.gif"), Grid.ClientID, uniqueID, Title);
                }
                else
                {
                    s =
                        string.Format("<img alt=\"{2}\" border=\"0\" src=\"?wgchart={0}_{1}_img\"/>",
                                      Grid.ClientID, uniqueID, Title);
                }
                LabelHtml(s, writer, cell);
                return;
            }

            /*
             * else		// impossible!!!
             * {
             *  return null;
             * }*/
        }
Exemplo n.º 2
0
        // 2005.01.09 - jorn, string optimize, String.Compare
        internal override void RenderEditView(WebGridHtmlWriter writer, RowCell cell)
        {
            if (AllowEdit == false || (Grid.DisplayView == DisplayView.Grid && AllowEditInGrid == false))
            {
                RenderLabelView(writer, cell);
                return;
            }

            base.RenderEditView(writer, cell);

            if (DisplayCalendar && Grid.GotHttpContext)
            {
                Grid.AddClientScript(writer, string.Format(calendarsetup, cell.CellClientId,
                                                           CalendarFormat, AddCalendarClientAttributes,
                                                           Grid.Page.ClientScript.GetWebResourceUrl(Grid.GetType(),
                                                                                                    "WebGrid.Resources.images.calendar.gif")));
            }
        }
Exemplo n.º 3
0
        private string CreateSlider()
        {
            int startrecord;
            int endrecord = 0;



            string range;
            string slidertemplate;
            int    recordcount;

            if (PagerType == PagerType.RangedSlider)
            {
                range          = "true";
                startrecord    = m_PagerGrid.PageIndex * m_PagerGrid.PageSize;
                recordcount    = m_PagerGrid.RecordCount;
                slidertemplate = gridsliderrange;
                endrecord      = (m_PagerGrid.PageIndex * m_PagerGrid.PageSize) + m_PagerGrid.PageSize;
            }
            else
            {
                startrecord    = m_PagerGrid.PageIndex;
                range          = "false";
                recordcount    = m_Pages;
                slidertemplate = gridslider;
            }

            int[] values = GetSliderValues;
            if (values != null)
            {
                switch (values.Length)
                {
                //Ranged slider
                case 2:
                    startrecord = values[0];
                    endrecord   = values[1];
                    break;

                //Page slider
                case 1:
                    startrecord = values[0];
                    break;
                }
            }
            if (Anthem.Manager.IsCallBack)
            {
                Anthem.Manager.AddScriptForClientSideEval(string.Format(slidertemplate, startrecord, endrecord,

                                                                        recordcount,
                                                                        m_PagerGrid.ID, SliderStep,
                                                                        range,
                                                                        m_PagerGrid.ClientObjectId ?? m_PagerGrid.ID, SliderOperation.ToString().ToLower()));
            }
            else
            {
                m_PagerGrid.Page.ClientScript.RegisterClientScriptBlock(m_PagerGrid.GetType(),
                                                                        m_PagerGrid.ID,
                                                                        string.Format(slidertemplate, startrecord,
                                                                                      endrecord,

                                                                                      recordcount,
                                                                                      m_PagerGrid.ID,
                                                                                      SliderStep,
                                                                                      range,
                                                                                      m_PagerGrid.ClientObjectId ??
                                                                                      m_PagerGrid.ID, SliderOperation.ToString().ToLower()), true);
            }

            switch (SliderOperation)
            {
            case Orientation.Horizontal:
                if (Grid.GotHttpContext)
                {
                    return
                        (string.Format(
                             "<input class=\"wgslidervalue\"  type=\"hidden\" name=\"{0}slidervalue\" id=\"{0}slidervalue\"  /><div class=\"wgslider\" style=\"width:{2}\" id=\"{0}slider\" title=\"{1}\" />",
                             m_PagerGrid.ID,
                             HttpContext.Current.Server.HtmlEncode(GetPagerStatus), SliderWidth));
                }
                return
                    (string.Format(
                         "<input class=\"wgslidervalue\" type=\"hidden\" name=\"{0}slidervalue\" id=\"{0}slidervalue\"  /><div class=\"wgslider\" style=\"width:{2}\" id=\"{0}slider\" title=\"{1}\" />",
                         m_PagerGrid.ID, GetPagerStatus, SliderWidth));

            case Orientation.Vertical:
                if (Grid.GotHttpContext)
                {
                    return
                        (string.Format(
                             "<input class=\"wgslidervalue\"  type=\"hidden\" name=\"{0}slidervalue\" id=\"{0}slidervalue\"  /><div class=\"wgslider\" style=\"height:{2}\" id=\"{0}slider\" title=\"{1}\" />",
                             m_PagerGrid.ID,
                             HttpContext.Current.Server.HtmlEncode(GetPagerStatus), SliderHeight));
                }
                return
                    (string.Format(
                         "<input class=\"wgslidervalue\" type=\"hidden\" name=\"{0}slidervalue\" id=\"{0}slidervalue\"  /><div class=\"wgslider\" style=\"height:{2}\" id=\"{0}slider\" title=\"{1}\" />",
                         m_PagerGrid.ID, GetPagerStatus, SliderHeight));
            }
            return(null);
        }