Exemplo n.º 1
0
        public static List<Employee> GetEmployeesFilter(int start, int limit, DataSorter sort, out int count)
        {
            NorthwindDataContext db = new NorthwindDataContext();
            IQueryable<Employee> result = db.Employees.Select(e => e);

            if (sort != null)
            {
                ParameterExpression param = Expression.Parameter(typeof(Employee), "e");

                if (sort.Property == "BirthDate" || sort.Property == "HireDate")
                {
                    Expression<Func<Employee, DateTime?>> sortExpression = Expression.Lambda<Func<Employee, DateTime?>>(Expression.Property(param, sort.Property), param);
                    if (sort.Direction == SortDirection.DESC)
                    {
                        result = result.OrderByDescending(sortExpression);
                    }
                    else
                    {
                        result = result.OrderBy(sortExpression);
                    }
                }
                else
                {
                    Expression<Func<Employee, object>> sortExpression = Expression.Lambda<Func<Employee, object>>(Expression.Property(param, sort.Property), param);
                    if (sort.Direction == SortDirection.DESC)
                    {
                        result = result.OrderByDescending(sortExpression);
                    }
                    else
                    {
                        result = result.OrderBy(sortExpression);
                    }
                }
            }

            if (start >= 0 && limit > 0)
            {
                result = result.Skip(start).Take(limit);
            }

            count = db.Employees.Count();

            return result.ToList();
        }
Exemplo n.º 2
0
    private void Awake()
    {
        var obj = FindObjectsOfType <SourceLoader>();

        if (obj.Length == 1)
        {
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }
        instance = this;

        datasorter = this.GetComponent <DataSorter>();
        loadSetEnd = true;
        datasorter.sourceLoadEnd = true;
        DownSource             = true;
        jsonSort               = true;
        loadSource             = true;
        downEnd                = true;
        index_downObject       = 0;
        OnLoadingCountChanged += loader_OnLoadingCountChanged;
    }
        public ActionResult ReadData(StoreRequestParameters parameters)
        {
            List <object> data = GridFiltersModel.Data;

            FilterConditions fc = parameters.GridFilters;

            //-- start filtering ------------------------------------------------------------
            if (fc != null)
            {
                foreach (FilterCondition condition in fc.Conditions)
                {
                    Comparison comparison = condition.Comparison;
                    string     field      = condition.Field;
                    FilterType type       = condition.Type;

                    object value;
                    switch (condition.Type)
                    {
                    case FilterType.Boolean:
                        value = condition.Value <bool>();
                        break;

                    case FilterType.Date:
                        value = condition.Value <DateTime>();
                        break;

                    case FilterType.List:
                        value = condition.List;
                        break;

                    case FilterType.Numeric:
                        if (data.Count > 0 && data[0].GetType().GetProperty(field).PropertyType == typeof(int))
                        {
                            value = condition.Value <int>();
                        }
                        else
                        {
                            value = condition.Value <double>();
                        }

                        break;

                    case FilterType.String:
                        value = condition.Value <string>();
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    data.RemoveAll(
                        item =>
                    {
                        object oValue     = item.GetType().GetProperty(field).GetValue(item, null);
                        IComparable cItem = oValue as IComparable;

                        switch (comparison)
                        {
                        case Comparison.Eq:

                            switch (type)
                            {
                            case FilterType.List:
                                return(!(value as List <string>).Contains(oValue.ToString()));

                            case FilterType.String:
                                return(!oValue.ToString().StartsWith(value.ToString()));

                            default:
                                return(!cItem.Equals(value));
                            }

                        case Comparison.Gt:
                            return(cItem.CompareTo(value) < 1);

                        case Comparison.Lt:
                            return(cItem.CompareTo(value) > -1);

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                    }
                        );
                }
            }
            //-- end filtering ------------------------------------------------------------


            //-- start sorting ------------------------------------------------------------
            if (parameters.Sort.Length > 0)
            {
                DataSorter sorter = parameters.Sort[0];
                data.Sort(delegate(object x, object y)
                {
                    object a;
                    object b;

                    int direction = sorter.Direction == Ext.Net.SortDirection.DESC ? -1 : 1;

                    a = x.GetType().GetProperty(sorter.Property).GetValue(x, null);
                    b = y.GetType().GetProperty(sorter.Property).GetValue(y, null);
                    return(CaseInsensitiveComparer.Default.Compare(a, b) * direction);
                });
            }
            //-- end sorting ------------------------------------------------------------


            //-- start paging ------------------------------------------------------------
            int limit = parameters.Limit;

            if ((parameters.Start + parameters.Limit) > data.Count)
            {
                limit = data.Count - parameters.Start;
            }

            List <object> rangeData = (parameters.Start < 0 || limit < 0) ? data : data.GetRange(parameters.Start, limit);

            //-- end paging ------------------------------------------------------------

            return(this.Store(rangeData, data.Count));
        }
Exemplo n.º 4
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            //TODO potential rendering loop.
            if (FilteredData.Count < 1)
            {
                FilteredData = DataFilter.Filter(DataSorter.Sort(Data));
                base.OnRender(drawingContext);
                return;
            }
            visualContext = new NestedArcChartVisualContext();

            PART_segments.Children.Clear();
            PART_inactivesegments.Children.Clear();
            PART_categorylabels.Children.Clear();

            var context = new ProviderContext(FilteredData.Count);

            MaterialProvider.Reset(context);

            var fullArcDiameter      = PART_main.RenderSize.Height - TopRingPadding;
            var fullArcWidth         = fullArcDiameter - BottomRingPadding;
            var subArcAvailableWidth = fullArcWidth / FilteredData.Count;
            var subArcActualWidth    = subArcAvailableWidth * SegmentWidthPercentage;
            var subRingOffset        = (subArcAvailableWidth - subArcActualWidth) / 2;

            var fullRadius  = PART_main.RenderSize.Width / 2;
            var centerPoint = new Point(0, fullRadius);

            if (FilteredData.Count < 1)
            {
                base.OnRender(drawingContext);
                return;
            }

            var max   = FilteredData.MaxValue();
            var trace = 0;

            foreach (var d in FilteredData)
            {
                var categoryVisualContext = new NestedArcCategoryVisualContext();
                var materialSet           = MaterialProvider.ProvideNext(context);

                categoryVisualContext.CategoryDataPoint = d;
                var arcDiameter = BottomRingPadding + (subArcAvailableWidth * trace) + subRingOffset;

                var inactiveArcPath = CalculatePath(centerPoint, arcDiameter, subArcActualWidth);
                inactiveArcPath.Fill = SegmentSpaceBackground.GetMaterial(materialSet);
                //BindingOperations.SetBinding(inactiveArcPath, Shape.FillProperty, new Binding("SegmentSpaceBackground") { Source = this });

                categoryVisualContext.InactiveArcVisual = inactiveArcPath;
                PART_inactivesegments.Children.Add(inactiveArcPath);

                var activeArcAngle = d.Value.Map(0, max, 0, MaxArcAngle);

                var activeArcPath = CalculateActiveArcPath(centerPoint, arcDiameter, subArcActualWidth, activeArcAngle);


                categoryVisualContext.CategoryMaterialSet = materialSet;

                activeArcPath.Fill                  = SegmentForeground.GetMaterial(materialSet);
                activeArcPath.MouseOverFill         = materialSet.GetMaterial(Luminosity.P700);
                activeArcPath.RenderTransformOrigin = new Point(.5, 1);
                activeArcPath.RenderTransform       = new RotateTransform((IsLoaded ? 0 : 180), .5, .5);
                d.RenderedVisual = activeArcPath;

                categoryVisualContext.ActiveArcVisual = activeArcPath;
                PART_segments.Children.Add(activeArcPath);

                visualContext.CategoryVisuals.Add(categoryVisualContext);
                trace++;
            }
            var ltrace = 0;

            for (var x = FilteredData.Count - 1; x >= 0; x--)
            {
                var d = FilteredData[x];
                var currentCategoryVisualContext = visualContext.CategoryVisuals[x];
                var shape              = (Shape)d.RenderedVisual;     //.ShouldBeCastable<Shape>();
                var renderedFill       = (SolidColorBrush)shape.Fill; //.ShouldBeType<SolidColorBrush>();
                var arcLabelMarginLeft = fullRadius + LeftArcLabelSpacing;
                var categoryLabel      = new Label
                {
                    Width                      = ValueLabelHorizontalSpacing,
                    VerticalAlignment          = VerticalAlignment.Top,
                    HorizontalAlignment        = HorizontalAlignment.Left,
                    VerticalContentAlignment   = VerticalAlignment.Center,
                    HorizontalContentAlignment = HorizontalAlignment.Left,
                    Margin                     = new Thickness(arcLabelMarginLeft, (ltrace * subArcAvailableWidth) + subRingOffset + 6, 0, 0),
                    //Foreground = renderedFill.Lighten(.2),
                    Foreground  = ValueForeground.GetMaterial(currentCategoryVisualContext.CategoryMaterialSet),
                    Content     = d.CategoryName.ToUpper(),
                    Height      = subArcAvailableWidth,
                    Padding     = new Thickness(0),
                    Opacity     = IsLoaded ? 1 : 0,                 // TODO isloaded
                    DataContext = this
                };
                currentCategoryVisualContext.CategoryLabel = categoryLabel;
                //BindingOperations.SetBinding(categoryLabel, FontFamilyProperty, new Binding("ValueFontFamily") { Source = this });
                //BindingOperations.SetBinding(categoryLabel, FontStyleProperty, new Binding("ValueFontStyle") { Source = this });
                //BindingOperations.SetBinding(categoryLabel, FontWeightProperty, new Binding("ValueFontWeight") { Source = this });
                //BindingOperations.SetBinding(categoryLabel, FontSizeProperty, new Binding("ValueFontSize") { Source = this });
                categoryLabel.BindTextualPrimitive <ValuePrimitive>(this);
                var valuePercentLabel = new Label
                {
                    Width                      = ValueLabelHorizontalSpacing,
                    VerticalAlignment          = VerticalAlignment.Top,
                    HorizontalAlignment        = HorizontalAlignment.Left,
                    VerticalContentAlignment   = VerticalAlignment.Center,
                    HorizontalContentAlignment = HorizontalAlignment.Right,
                    Margin                     = new Thickness(arcLabelMarginLeft, (ltrace * subArcAvailableWidth) + subRingOffset + 6, 0, 0),
                    //Foreground = renderedFill.Lighten(.2),
                    Foreground  = ValueForeground.GetMaterial(currentCategoryVisualContext.CategoryMaterialSet),
                    Content     = d.Value + " Minutes",
                    Height      = subArcAvailableWidth,
                    Padding     = new Thickness(0),
                    Opacity     = IsLoaded ? 1 : 0,
                    DataContext = this
                };
                currentCategoryVisualContext.ValuePercentLabel = valuePercentLabel;
                valuePercentLabel.BindTextualPrimitive <ValuePrimitive>(this);
                var valueLabelLeftSpace = arcLabelMarginLeft + ValueLabelHorizontalSpacing;
                var valueLabelWidth     = PART_main.RenderSize.Width - valueLabelLeftSpace;
                if (valueLabelWidth < 0)
                {
                    valueLabelWidth = 0;
                }
                var valueLabel = new Label()
                {
                    Width                      = valueLabelWidth,
                    VerticalAlignment          = VerticalAlignment.Top,
                    HorizontalAlignment        = HorizontalAlignment.Left,
                    VerticalContentAlignment   = VerticalAlignment.Center,
                    HorizontalContentAlignment = HorizontalAlignment.Left,
                    Foreground                 = SecondaryValueForeground.GetMaterial(currentCategoryVisualContext.CategoryMaterialSet),
                    Margin                     = new Thickness(arcLabelMarginLeft + ValueLabelHorizontalSpacing, (ltrace * subArcAvailableWidth) + subRingOffset + 6, 0, 0),
                    Content                    = $" = {Math.Round(d.Value / 60, 2)} Hours", //{Math.Round(d.Value * 48):n0}
                    Height                     = subArcAvailableWidth,
                    Opacity                    = IsLoaded ? 1 : 0,                          // TODO isloaded
                    Padding                    = new Thickness(0),
                };
                currentCategoryVisualContext.ValueLabel = valueLabel;
                valueLabel.BindTextualPrimitive <SecondaryValuePrimitive>(this);

                PART_categorylabels.Children.Add(categoryLabel);
                PART_categorylabels.Children.Add(valuePercentLabel);
                PART_categorylabels.Children.Add(valueLabel);

                ltrace++;
            }
            base.OnRender(drawingContext);
        }
Exemplo n.º 5
0
        public static List <FormCagriRes> GetFilterCagri(int start, int limit, DataSorter sort, out int count, string arax)
        {
            count = 0;
            if (HttpContext.Current.Session["secilenCrmFormIslemleri"] == null)
            {
                return(new List <FormCagriRes>());                                                               // otomatik her seferinde geliyor, diğer methodlara da ekle sunucuyu meşgul etmesin.
            }
            var mId   = HttpContext.Current.Session["secilenCrmFormIslemleri"] == null ? "0" : HttpContext.Current.Session["secilenCrmFormIslemleri"].ToString();
            var liste = Helper.GetWebService().CrmFormFirsatCagriListesi(mId.ToInt());

            var id = 0;

            count = liste.Value.cagrilist.Length;
            var ret = new List <FormCagriRes>();

            foreach (var cagri in liste.Value.cagrilist)
            {
                ret.Add(new FormCagriRes()
                {
                    id           = (id++),
                    _count       = count,
                    cari_kod     = cagri.cari_kod,
                    aciklama1    = cagri.aciklama1,
                    belge_tarih  = cagri.belge_tarih,
                    cagri_konusu = cagri.cagri_konusu
                });
            }

            var orderBy = String.IsNullOrEmpty(sort.Property) ? "cari_kod" : sort.Property;

            // filtreleme
            if (!string.IsNullOrEmpty(orderBy) && arax.Trim() != "")
            {
                switch (orderBy)
                {
                case "cari_kod":
                    ret   = ret.Where(x => x.cari_kod.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;

                case "aciklama1":
                    ret   = ret.Where(x => x.aciklama1.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;

                case "belge_tarih":
                    ret   = ret.Where(x => x.belge_tarih.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;

                case "cagri_konusu":
                    ret   = ret.Where(x => x.cagri_konusu.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;
                }
            }

            var dynamicPropFromStr = typeof(FormCagriRes).GetProperty(orderBy);

            if (sort.Direction == SortDirection.ASC)
            {
                ret = ret.OrderBy(x => dynamicPropFromStr.GetValue(x, null)).ToList();
            }
            else
            {
                ret = ret.OrderByDescending(x => dynamicPropFromStr.GetValue(x, null)).ToList();
            }

            return(ret);
        }
Exemplo n.º 6
0
        public static List <CrmFormRes> GetFilter(int start, int limit, DataSorter sort, out int count, string arax, DateTime bas, DateTime bit)
        {
            // saçmalıyır...
            var liste = Helper.GetWebService().CrmFormListesi(bas, bit, 0, 10000);// start, limit);

            //var liste = Helper.GetWebService().CrmFormListesi(DateTime.Now.AddYears(-10) , DateTime.Now.AddYears(10), 0, 10000);// start, limit);

            if (!string.IsNullOrEmpty(liste.Message))
            {
                throw new Exception(liste.Message);
            }

            var id = 0;

            count = liste.Value.FormListesi.Length;
            var tmpCount = liste.Value.FormListesi.Length;
            var ret      = new List <CrmFormRes>(tmpCount);

            ret.AddRange(liste.Value.FormListesi.Select(l => new CrmFormRes()
            {
                id             = (id++),
                _count         = tmpCount,
                form_ad        = l.form_ad,
                tip            = l.tip,
                yetkili_kisi   = l.yetkili_kisi,
                firma_tel      = l.firma_tel,
                firma_email    = l.firma_email,
                aciklama       = l.aciklama,
                firma_web      = l.firma_web,
                cari_kod       = l.cari_kod,
                cari_ad        = l.cari_ad,
                geldigi_kanal  = l.geldigi_kanal,
                kapali         = l.kapali != false ? "Kapali" : "Acik",
                master_no      = l.master_no,
                faaliyet_yili  = l.faaliyet_yili,
                faaliyet_yili2 = l.faaliyet_yili.JaponDate(),
                create_date    = l.create_date.ToString("dd.MM.yyyy") + " " + (l.create_time.Length == 4 ? (l.create_time.Substring(0, 2) + ":" + l.create_time.Substring(2)) : l.create_time),
                create_date2   = l.create_date.ToString("yyyy-MM-dd")
            }));//.Where(x=> !string.IsNullOrEmpty(x.form_ad) && !string.IsNullOrEmpty(x.tip)));

            var orderBy = String.IsNullOrEmpty(sort.Property) ? "geldigi_kanal" : sort.Property;

            // filtreleme
            if (!string.IsNullOrEmpty(orderBy) && arax.Trim() != "")
            {
                switch (orderBy)
                {
                case "create_date":
                    ret   = ret.Where(x => x.create_date2.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;

                case "faaliyet_yili":
                    ret   = ret.Where(x => x.faaliyet_yili2.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;

                case "kapali":
                    ret   = ret.Where(x => x.kapali.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;

                case "form_ad":
                    ret   = ret.Where(x => x.form_ad.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;

                case "tip":
                    ret   = ret.Where(x => x.tip.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;

                case "yetkili_kisi":
                    ret   = ret.Where(x => x.yetkili_kisi.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;

                case "firma_tel":
                    ret   = ret.Where(x => x.firma_tel.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;

                case "firma_email":
                    ret   = ret.Where(x => x.firma_email.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;

                case "aciklama":
                    ret   = ret.Where(x => x.aciklama.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;

                case "firma_web":
                    ret   = ret.Where(x => x.firma_web.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;

                case "cari_kod":
                    ret   = ret.Where(x => x.cari_kod.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;

                case "cari_ad":
                    ret   = ret.Where(x => x.cari_ad.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;

                case "geldigi_kanal":
                    ret   = ret.Where(x => x.geldigi_kanal.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;
                }
            }

            var dynamicPropFromStr = typeof(CrmFormRes).GetProperty(orderBy);

            if (sort.Direction == SortDirection.ASC)
            {
                ret = ret.OrderBy(x => dynamicPropFromStr.GetValue(x, null)).ToList();
            }
            else
            {
                ret = ret.OrderByDescending(x => dynamicPropFromStr.GetValue(x, null)).ToList();
            }

            return(ret);
        }
Exemplo n.º 7
0
        public static List <HedefKitleMRes> GetFilter(int start, int limit, DataSorter sort, out int count, string arax)
        {
            //var liste = Helper.GetWebService().HedefKitleMasterListe(arax,start,limit); // arama çalışmıyor.
            var liste = Helper.GetWebService().HedefKitleMasterListe("", start, limit);

            if (!string.IsNullOrEmpty(liste.Message))
            {
                throw new Exception(liste.Message);
            }

            count = liste.Value.Length;
            var tmpCount = liste.Value.Length;
            var ret      = new List <HedefKitleMRes>(tmpCount);

            ret.AddRange(liste.Value.Select(l => new HedefKitleMRes()
            {
                master_no      = l.master_no,
                _count         = tmpCount,
                hedef_liste_ad = l.hedef_liste_ad,
                hedef_liste_id = l.hedef_liste_id,
                aciklama       = l.aciklama,
                telefon_mail   = l.telefon_mail
            }));

            var orderBy = String.IsNullOrEmpty(sort.Property) ? "hedef_liste_id" : sort.Property;

            // filtreleme
            if (!string.IsNullOrEmpty(orderBy) && arax.Trim() != "")
            {
                switch (orderBy)
                {
                case "hedef_liste_ad":
                    ret   = ret.Where(x => x.hedef_liste_ad.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;

                case "hedef_liste_id":
                    ret   = ret.Where(x => x.hedef_liste_id.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;

                case "aciklama":
                    ret   = ret.Where(x => x.aciklama.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;

                case "telefon_mail":
                    ret   = ret.Where(x => x.telefon_mail.ToLower().Contains(arax.ToLower())).ToList();
                    count = ret.Count;
                    break;
                }
            }

            var dynamicPropFromStr = typeof(HedefKitleMRes).GetProperty(orderBy);

            if (sort.Direction == SortDirection.ASC)
            {
                ret = ret.OrderBy(x => dynamicPropFromStr.GetValue(x, null)).ToList();
            }
            else
            {
                ret = ret.OrderByDescending(x => dynamicPropFromStr.GetValue(x, null)).ToList();
            }

            return(ret);
        }
Exemplo n.º 8
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            //TODO potential rendering loop.
            if (FilteredData.Count < 1)
            {
                FilteredData = DataFilter.Filter(DataSorter.Sort(Data));
                base.OnRender(drawingContext);
                return;
            }
            visualContext = new ParetoChartVisualContext();

            PART_bars.Children.Clear();
            PART_barlabels.Children.Clear();
            PART_line.Children.Clear();
            PART_xaxis.Children.Clear();
            //_highlightGrid.Children.Clear();

            var max = FilteredData.MaxValue();

            var context           = new ProviderContext(FilteredData.Count);
            var barAvailableWidth = (PART_bars.RenderSize.Width) / FilteredData.Count;
            var barActiveWidth    = barAvailableWidth * SegmentWidthPercentage;
            var barLeftSpacing    = (barAvailableWidth - barActiveWidth) / 2;
            var barLabelSize      = RenderingExtensions.EstimateLabelRenderSize(BarTotalFontFamily, BarTotalFontSize);

            MaterialProvider.Reset(context);

            #region X-Axis Label Generation

            var xtrace = 0;
            foreach (var d in FilteredData)
            {
                var material = MaterialProvider.ProvideNext(context);
                var categoryVisualContext = new ParetoChartCategoryVisualContext();
                var axisLabel             = new Label
                {
                    Content                    = d.CategoryName,
                    IsHitTestVisible           = false,
                    HorizontalContentAlignment = HorizontalAlignment.Center,
                    VerticalContentAlignment   = VerticalAlignment.Center,
                    HorizontalAlignment        = HorizontalAlignment.Left,
                    VerticalAlignment          = VerticalAlignment.Bottom,
                    Width       = barAvailableWidth,
                    Margin      = new Thickness(barAvailableWidth * xtrace, 0, 0, 0),
                    DataContext = this,
                    Foreground  = XAxisForeground.GetMaterial(material)
                };
                axisLabel.BindTextualPrimitive <XAxisPrimitive>(this);
                categoryVisualContext.AxisLabel = axisLabel;
                PART_xaxis.Children.Add(axisLabel);
                visualContext.CategoryVisuals.Add(categoryVisualContext);
                xtrace++;
            }

            #endregion

            MaterialProvider.Reset(context);
            var horizontalTrace = 0d;
            var xAxisHeight     = barLabelSize.Height;         //_xAxisGrid.ActualHeight;
            var backHeight      = PART_bars.RenderSize.Height - xAxisHeight;
            var trace           = 0;
            foreach (var d in FilteredData)
            {
                var currentCategoryVisualContext = visualContext.CategoryVisuals[trace];
                currentCategoryVisualContext.CategoryDataPoint = d;
                //if (barActiveWidth <= 0 || backHeight <= 0) return; //TODO fix
                var material = MaterialProvider.ProvideNext(context);
                currentCategoryVisualContext.CategoryMaterialSet = material;

                var backRectangle = new Rectangle
                {
                    Width               = barActiveWidth,
                    Height              = Math.Abs(backHeight),
                    VerticalAlignment   = VerticalAlignment.Bottom,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Fill   = SegmentSpaceBackground.GetMaterial(material),
                    Margin = new Thickness(horizontalTrace + barLeftSpacing, 0, 0, xAxisHeight)
                };


                currentCategoryVisualContext.InactiveBarVisual = backRectangle;
                PART_bars.Children.Add(backRectangle);

                var height    = d.Value.Map(0, max, 0, PART_bars.RenderSize.Height - xAxisHeight - barLabelSize.Height);
                var rectangle = new Rectangle
                {
                    Width                 = barActiveWidth,
                    Height                = Math.Abs(height),
                    Fill                  = SegmentForeground.GetMaterial(material),
                    VerticalAlignment     = VerticalAlignment.Bottom,
                    HorizontalAlignment   = HorizontalAlignment.Left,
                    Margin                = new Thickness(horizontalTrace + barLeftSpacing, 0, 0, xAxisHeight),
                    RenderTransform       = new ScaleTransform(1, 0, .5, 1),
                    RenderTransformOrigin = new Point(.5, 1)
                };


                currentCategoryVisualContext.ActiveBarRenderTransformScaleYAnimationAspect =
                    new AnimationAspect <double, Transform, DoubleAnimation>(rectangle.RenderTransform,
                                                                             ScaleTransform.ScaleYProperty, 0, 1, animationState)
                {
                    AccelerationRatio = AnimationParameters.AccelerationRatio,
                    DecelerationRatio = AnimationParameters.DecelerationRatio,
                    Duration          = TimeSpan.FromMilliseconds(800)
                };

                //TODO replace .RenderedVisual pairing method completely
                d.RenderedVisual = rectangle;
                PART_bars.Children.Add(rectangle);

                #region Bar Value Label Generation

                var beginBarLabelMargin  = new Thickness(horizontalTrace, 0, 0, xAxisHeight);
                var actualBarLabelMargin = new Thickness(horizontalTrace, 0, 0, xAxisHeight + height);

                var barLabel = new Label
                {
                    Content                    = d.Value,
                    IsHitTestVisible           = false,
                    HorizontalContentAlignment = HorizontalAlignment.Center,
                    VerticalContentAlignment   = VerticalAlignment.Center,
                    HorizontalAlignment        = HorizontalAlignment.Left,
                    VerticalAlignment          = VerticalAlignment.Bottom,
                    Width      = barAvailableWidth,
                    Foreground = BarTotalForeground.GetMaterial(material)
                };
                barLabel.BindTextualPrimitive <BarTotalPrimitive>(this);

                currentCategoryVisualContext.BarLabelMarginAnimationAspect = new AnimationAspect
                                                                             <Thickness, Label, ThicknessAnimation>(
                    barLabel, MarginProperty, beginBarLabelMargin, actualBarLabelMargin, animationState)
                {
                    AccelerationRatio = AnimationParameters.AccelerationRatio,
                    DecelerationRatio = AnimationParameters.DecelerationRatio,
                    Duration          = TimeSpan.FromMilliseconds(800)
                };

                #endregion

                PART_barlabels.Children.Add(barLabel);
                horizontalTrace += barAvailableWidth;
                trace++;
            }
            var total = FilteredData.SumValue();
            var availableLineGraphSize = new Size(PART_bars.ActualWidth - (DotRadius * 2),
                                                  PART_bars.ActualHeight - (DotRadius * 2) - xAxisHeight);
            var startX = (barAvailableWidth / 2) - DotRadius;

            var verticalpttrace = 0d;
            var pttrace         = 0;

            var pathSegments = new PathSegmentCollection();
            var pathFigure   = new PathFigure
            {
                Segments = pathSegments
            };
            MaterialProvider.Reset(context);

            var isFirstPoint = true;
            foreach (var d in FilteredData)
            {
                var material = MaterialProvider.ProvideNext(context);
                var currentCategoryVisualContext = visualContext.CategoryVisuals[pttrace];
                var nextPoint          = new Point(startX + (barAvailableWidth * pttrace), verticalpttrace + xAxisHeight);
                var baseAnimationPoint = new Point(nextPoint.X, 0).LocalizeInCartesianSpace(PART_line);
                var actualNextPoint    = nextPoint.LocalizeInCartesianSpace(PART_line);

                // TODO get rid of this
                var plottedPoint = IsLoaded ? actualNextPoint : baseAnimationPoint;

                if (isFirstPoint)
                {
                    visualContext.PolyLineStartPointAnimationAspect = new AnimationAspect <Point, PathFigure, PointAnimation>(
                        pathFigure, PathFigure.StartPointProperty, baseAnimationPoint, actualNextPoint, animationState)
                    {
                        AccelerationRatio = AnimationParameters.AccelerationRatio,
                        DecelerationRatio = AnimationParameters.DecelerationRatio,
                        Duration          = TimeSpan.FromMilliseconds(800),
                    };
                    isFirstPoint = false;
                }
                else
                {
                    var lineSegment = new LineSegment(plottedPoint, true)
                    {
                        IsSmoothJoin = true
                    };
                    pathSegments.Add(lineSegment);

                    visualContext.LineSegmentVisuals.Add(new ParetoChartLineSegmentVisualContext
                    {
                        PointAnimationAspect =
                            new AnimationAspect <Point, LineSegment, PointAnimation>(lineSegment, LineSegment.PointProperty,
                                                                                     baseAnimationPoint, actualNextPoint, animationState)
                        {
                            AccelerationRatio = AnimationParameters.AccelerationRatio,
                            DecelerationRatio = AnimationParameters.DecelerationRatio,
                            Duration          = TimeSpan.FromMilliseconds(800)
                        }
                    });
                }

                var beginDotMargin  = new Thickness(nextPoint.X, 0, 0, xAxisHeight);
                var actualDotMargin = new Thickness(nextPoint.X, 0, 0, nextPoint.Y);

                var dot = new Ellipse
                {
                    Width               = (DotRadius * 2),
                    Height              = (DotRadius * 2),
                    VerticalAlignment   = VerticalAlignment.Bottom,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Fill   = DotFill.GetMaterial(material),
                    Stroke = DotStroke.GetMaterial(material),
                };
                BindingOperations.SetBinding(dot, Shape.StrokeThicknessProperty, new Binding("DotStrokeThickness")
                {
                    Source = this
                });

                currentCategoryVisualContext.DotMarginAnimationAspect =
                    new AnimationAspect <Thickness, Ellipse, ThicknessAnimation>(dot, MarginProperty,
                                                                                 beginDotMargin, actualDotMargin, animationState)
                {
                    AccelerationRatio = AnimationParameters.AccelerationRatio,
                    DecelerationRatio = AnimationParameters.DecelerationRatio,
                    Duration          = TimeSpan.FromMilliseconds(800)
                };

                PART_line.Children.Add(dot);
                Panel.SetZIndex(dot, 50);
                verticalpttrace += d.Value.Map(0, total, 0, availableLineGraphSize.Height);
                pttrace++;
            }

            var path = new Path
            {
                VerticalAlignment   = VerticalAlignment.Bottom,
                HorizontalAlignment = HorizontalAlignment.Left,
                Data = new PathGeometry
                {
                    Figures = new PathFigureCollection
                    {
                        pathFigure
                    }
                },
                Margin = new Thickness(DotRadius, 0, 0, xAxisHeight + DotRadius),
                Stroke = LineStroke.GetMaterial(FallbackMaterialSet),
            };
            BindingOperations.SetBinding(path, Shape.StrokeThicknessProperty, new Binding("LineStrokeThickness")
            {
                Source = this
            });

            PART_line.Children.Add(path);
            base.OnRender(drawingContext);
        }
Exemplo n.º 9
0
 protected override void OnInitialized()
 {
     base.OnInitialized();
     DataSorter?.Add(this);
 }
Exemplo n.º 10
0
        private void SortValues()
        {
            DataSorter dataSorter = new DataSorter(fileNamesWithValueCollection);

            resultOfSort = dataSorter.Sort();
        }