Пример #1
0
        private void LegendHandleRectangleElement_RectangleTapped(object sender, object e, object datum)
        {
            if (secondColumnViewModel == null)
            {
                return;
            }

            TappedRoutedEventArgs       args          = e as TappedRoutedEventArgs;
            BarChartDatum               barChartDatum = datum as BarChartDatum;
            IEnumerable <BarChartDatum> barChartData  = ChartData.Where(cd => cd.Key == barChartDatum.Key);

            if (SelectionChanged != null)
            {
                Logger.Instance.Log($"selection,groupedbarchart,touch");
                if (barChartDatum.Rows == null || barChartData.SelectMany(cd => cd.Rows).Count() < barChartData.SelectMany(cd => cd.EnvelopeRows).Count())
                {
                    SelectionChanged(this, barChartData.SelectMany(cd => cd.EnvelopeRows), SelectionChangedType.Add);//, ReflectReason2.SelectionChanged);
                }
                else
                {
                    SelectionChanged(this, barChartData.SelectMany(cd => cd.Rows), SelectionChangedType.Remove);//, ReflectReason2.SelectionChanged);
                }
            }

            args.Handled = true;
        }
Пример #2
0
        void RectangleElement_RectangleTapped(object sender, object e, object datum)
        {
            TappedRoutedEventArgs args = e as TappedRoutedEventArgs;
            //if (args.PointerDeviceType == PointerDeviceType.Pen) return;
            BarChartDatum barChartDatum = datum as BarChartDatum;

            if (SelectionChanged != null)
            {
                Logger.Instance.Log($"selection,barchart,touch");
                if (barChartDatum.Rows == null || barChartDatum.Rows.Count() < barChartDatum.EnvelopeRows.Count())
                {
                    SelectionChanged(this, barChartDatum.EnvelopeRows, SelectionChangedType.Add);//, ReflectReason2.SelectionChanged);
                }
                else
                {
                    SelectionChanged(this, barChartDatum.Rows, SelectionChangedType.Remove);//, ReflectReason2.SelectionChanged);
                }
            }

            args.Handled = true;
        }
Пример #3
0
        public override bool Equals(object obj)
        {
            if (!(obj is BarChartDatum))
            {
                return(false);
            }
            if (Parent == null)
            {
                return(Key == ((BarChartDatum)obj).Key);
            }
            else
            {
                BarChartDatum o = (BarChartDatum)obj;
                if (o.Parent == null)
                {
                    return(false);
                }

                return(Key == o.Key && Parent.Key == o.Parent.Key);
            }
        }
Пример #4
0
        private void Drawable_StrokeAdded(InkManager inkManager)
        {
            if (inkManager.GetStrokes().Count > 0)
            {
                List <Point> points       = inkManager.GetStrokes()[0].GetInkPoints().Select(ip => ip.Position).ToList();
                Rect         boundingRect = inkManager.GetStrokes()[0].BoundingRect;

                Int32      index = 0;
                List <Row> intersectedRows = new List <Row>();
                Boolean    horizontalAxisStroke = false, legendStroke = false;

                index = 0;
                foreach (D3Rectangle rect in HandleRectangleElement.ChildRectangles)
                {
                    Rect r = new Rect(rect.X, rect.Y, rect.Width, rect.Height);

                    if (Const.IsIntersected(r, boundingRect))
                    {
                        GroupedBarChartDatum datum = ChartData[index].Parent;
                        intersectedRows = intersectedRows.Concat(datum.EnvelopeRows).ToList();
                    }
                    index++;
                }


                index = 0;
                foreach (D3Rectangle rect in LegendHandleRectangleElement.ChildRectangles)
                {
                    Rect r = new Rect(rect.X + ChartAreaEndX, rect.Y, rect.Width, rect.Height);

                    if (Const.IsIntersected(r, boundingRect))
                    {
                        if (secondColumnViewModel != null)
                        {
                            BarChartDatum     datum = LegendData[index];
                            IEnumerable <Row> rows  = ChartData.Where(cd => cd.Key == datum.Key).SelectMany(cd => cd.EnvelopeRows);
                            intersectedRows = intersectedRows.Concat(rows).ToList();
                            legendStroke    = true;
                        }
                        else
                        {
                            RemoveColumnViewModel(this, LegendData[index].Key.ToString());
                            drawable.RemoveAllStrokes();
                            return;
                        }
                    }
                    index++;
                }

                index = 0;
                foreach (TextBlock label in HorizontalAxis.TickLabels)
                {
                    Rect r = new Rect(Canvas.GetLeft(label), Canvas.GetTop(label) + ChartAreaEndY, label.ActualWidth, label.ActualHeight);

                    if (Const.IsIntersected(r, boundingRect))
                    {
                        GroupedBarChartDatum datum = Data[index];
                        intersectedRows      = intersectedRows.Concat(datum.EnvelopeRows).ToList();
                        horizontalAxisStroke = true;
                    }
                    index++;
                }

                if (Const.IsStrikeThrough(boundingRect)) // strikethrough 및 무조건 필터아웃
                {
                    if (FilterOut != null && intersectedRows.Count > 0)
                    {
                        Logger.Instance.Log($"filter out,groupedbarchart,pen");
                        if (horizontalAxisStroke && !legendStroke)
                        {
                            IEnumerable <Category> categories = intersectedRows
                                                                .Select(row => row.Cells[firstColumnViewModel.Index].Content as Category)
                                                                .Distinct()
                                                                .OrderBy(cate => cate.Order);

                            FilterOut(this, categories);
                        }
                        else if (legendStroke && !horizontalAxisStroke)
                        {
                            IEnumerable <Category> categories = intersectedRows
                                                                .Select(row => row.Cells[secondColumnViewModel.Index].Content as Category)
                                                                .Distinct()
                                                                .OrderBy(cate => cate.Order);

                            FilterOut(this, categories);
                        }
                        else
                        {
                            //throw new Exception("ojioij");
                            //FilterOut(this, String.Format(FlexTable.Const.Loader.GetString("FilterOutMessage"), intersectedRows.Count()), intersectedRows);
                        }
                    }
                }
                else // 하나라도 선택 안된게 있으면 선택
                {
                    if (SelectionChanged != null)
                    {
                        Logger.Instance.Log($"selection,groupedbarchart,pen");
                        SelectionChanged(this, intersectedRows, SelectionChangedType.Add);//, ReflectReason2.SelectionChanged);
                    }
                }
            }

            drawable.RemoveAllStrokes();
        }
Пример #5
0
        private void Drawable_StrokeAdded(InkManager inkManager)
        {
            if (inkManager.GetStrokes().Count > 0)
            {
                List <Point> points       = inkManager.GetStrokes()[0].GetInkPoints().Select(ip => ip.Position).ToList();
                Rect         boundingRect = inkManager.GetStrokes()[0].BoundingRect;

                // 먼저 boundingRect와 겹친 row들을 모두 찾는다.
                List <Row> intersectedRows = new List <Row>();
                Int32      index           = 0;

                index = 0;
                foreach (D3Rectangle rect in HandleRectangleElement.ChildRectangles)
                {
                    Rect r = new Rect(rect.X, rect.Y, rect.Width, rect.Height);

                    if (Const.IsIntersected(r, boundingRect))
                    {
                        BarChartDatum datum = Data[index];
                        intersectedRows = intersectedRows.Concat(datum.EnvelopeRows).ToList();
                    }
                    index++;
                }

                index = 0;
                foreach (D3Rectangle rect in LegendHandleRectangleElement.ChildRectangles)
                {
                    Rect r = new Rect(rect.X + ChartAreaEndX, rect.Y, rect.Width, rect.Height);

                    if (Const.IsIntersected(r, boundingRect))
                    {
                        BarChartDatum datum = Data[index];
                        intersectedRows = intersectedRows.Concat(datum.EnvelopeRows).ToList();
                    }
                    index++;
                }

                index = 0;
                foreach (TextBlock label in HorizontalAxis.TickLabels)
                {
                    Rect r = new Rect(Canvas.GetLeft(label), Canvas.GetTop(label) + ChartAreaEndY, label.ActualWidth, label.ActualHeight);

                    if (Const.IsIntersected(r, boundingRect))
                    {
                        BarChartDatum datum = Data[index];
                        intersectedRows = intersectedRows.Concat(datum.EnvelopeRows).ToList();
                    }
                    index++;
                }

                intersectedRows = intersectedRows.Distinct().ToList();

                if (Const.IsStrikeThrough(boundingRect)) // strikethrough 및 무조건 필터아웃
                {
                    Logger.Instance.Log($"filter out,barchart,pen");
                    if (FilterOut != null && intersectedRows.Count > 0)
                    {
                        ColumnViewModel columnViewModel = Data[0].ColumnViewModel;
                        if (columnViewModel.Type == ColumnType.Categorical)
                        {
                            IEnumerable <Category> categories = intersectedRows.Select(row => row.Cells[columnViewModel.Index].Content as Category)
                                                                .OrderBy(cate => cate.Order)
                                                                .Distinct();

                            FilterOut(this, categories);
                        }
                    }
                }
                else // 아니면 무조건 셀렉션
                {
                    Logger.Instance.Log($"selection,barchart,pen");
                    if (SelectionChanged != null)
                    {
                        SelectionChanged(this, intersectedRows, SelectionChangedType.Add);//, ReflectReason2.SelectionChanged);
                    }
                }
            }

            drawable.RemoveAllStrokes();
        }