Ejemplo n.º 1
0
 public IEnumerable <RowInfo> GetStoreSalesWhere_SubLocation_Brand_Category(string store, SubLocation subLocation, string brand, string category)
 {
     return(this.RowData.Where(x => x.Store == store && x.SubLocation == subLocation && x.Brand == brand && x.Category == category));
 }
Ejemplo n.º 2
0
        private CartesianDataPoint CaculateSalesAmountByProduct(string product, IEnumerable <RowInfo> subLocationSales, SubLocation subLocation)
        {
            var sales = subLocationSales.Where(x => x.Product == product).Select(x => x.SalesAmount);

            return(new CartesianDataPoint()
            {
                Category = product,
                Value = this.Sum(sales),
                SubLocation = subLocation,
            });
        }
Ejemplo n.º 3
0
 public IEnumerable <RowInfo> GetStoreSalesAtAssignedSubLocation(string store, SubLocation subLocation)
 {
     return(this.RowData.Where(x => x.Store == store && x.SubLocation == subLocation));
 }
Ejemplo n.º 4
0
 public IEnumerable <RowInfo> GetSalesWhere_SubLocation_Brand(SubLocation subLocation, string brand)
 {
     return(this.RowData.Where(x => x.SubLocation == subLocation && x.Brand == brand));
 }
Ejemplo n.º 5
0
 public IEnumerable <RowInfo> GetYearSalesAtAssignedSubLocation(SubLocation subLocation, int year)
 {
     return(this.RowData.Where(x => x.SubLocation == subLocation && x.Year == year));
 }
Ejemplo n.º 6
0
 public IEnumerable <RowInfo> GetSubLocationSales(SubLocation subLocation)
 {
     return(this.RowData.Where(x => x.SubLocation == subLocation));
 }
Ejemplo n.º 7
0
        public IEnumerable <RowInfo> GetStoreSalesWhere_SubLocation_Brand_Category(string store, SubLocation subLocation, string brand, string category)
        {
            var currentSeason = this.GetCurrentSeason(DateTime.Now.Month);

            return(this.RowData.Where(x => x.Store == store && x.SubLocation == subLocation && x.Brand == brand && x.Category == category &&
                                      (x.Month == currentSeason[0] || x.Month == currentSeason[1] || x.Month == currentSeason[2])));
        }
Ejemplo n.º 8
0
 public CommandGotoLocation(SubLocation location)
 {
     Location = location;
 }
Ejemplo n.º 9
0
        private bool LoadSubLocation(int index)
        {
            if (DemoApp.Navigation == null)
            {
                return(false);
            }

            if (location == null || index < 0 || index >= location.SubLocations.Count)
            {
                return(false);
            }

            SubLocation subLoc = (SubLocation)location.SubLocations[index];

            Log.Debug(TAG, $"Loading sublocation {subLoc.Name} ({subLoc.Width} x {subLoc.Height})");

            if (subLoc.Width < 1.0f || subLoc.Height < 1.0f)
            {
                Log.Debug(TAG, $"Loading sublocation failed: invalid size: {subLoc.Width} x {subLoc.Height}");
                return(false);
            }

            if (!locationView.LoadSubLocation(subLoc))
            {
                Log.Debug(TAG, "Loading sublocation failed: invalid image");
                return(false);
            }

            float viewWidth     = locationView.Width;
            float viewHeight    = locationView.Height;
            float minZoomFactor = Math.Min(viewWidth / subLoc.Width, viewHeight / subLoc.Height);
            float maxZoomFactor = LocationView.ZoomFactorMax;

            locationView.SetZoomRange(minZoomFactor, maxZoomFactor);
            locationView.ZoomFactor = minZoomFactor;

            adjustTime = 0;

            currentSubLocationIndex = index;
            currentFloorLabel.Text  = $"{currentSubLocationIndex}";

            if (currentSubLocationIndex > 0)
            {
                prevFloorButton.Enabled = true;
                prevFloorView.SetBackgroundColor(Color.ParseColor("#90aaaaaa"));
            }
            else
            {
                prevFloorButton.Enabled = false;
                prevFloorView.SetBackgroundColor(Color.ParseColor("#90dddddd"));
            }

            if (currentSubLocationIndex + 1 < location.SubLocations.Count)
            {
                nextFloorButton.Enabled = true;
                nextFloorView.SetBackgroundColor(Color.ParseColor("#90aaaaaa"));
            }
            else
            {
                nextFloorButton.Enabled = false;
                nextFloorView.SetBackgroundColor(Color.ParseColor("#90dddddd"));
            }

            CancelVenue();

            Refresh();
            return(true);
        }
Ejemplo n.º 10
0
        public IEnumerable <RowInfo> GetStoreSalesAtAssignedSubLocation(string store, SubLocation subLocation)
        {
            var currentSeason = this.GetCurrentSeason(DateTime.Now.Month);

            return(this.RowData.Where(x => x.Store == store && x.SubLocation == subLocation &&
                                      (x.Month == currentSeason[0] || x.Month == currentSeason[1] || x.Month == currentSeason[2])));
        }
Ejemplo n.º 11
0
        private void DrawDevice(Canvas canvas)
        {
            // Check if location is loaded
            if (deviceInfo == null || location == null || currentSubLocationIndex < 0)
            {
                return;
            }

            // Check if navigation is available
            if (deviceInfo.ErrorCode != 0)
            {
                return;
            }

            // Check if device belongs to the location loaded
            if (deviceInfo.Location != location.Id)
            {
                return;
            }

            // Get current sublocation displayed
            SubLocation subLoc = (SubLocation)location.SubLocations[currentSubLocationIndex];

            if (subLoc == null)
            {
                return;
            }

            Color solidColor  = Color.Argb(255, 64, 163, 205);  // Light-blue color
            Color circleColor = Color.Argb(127, 64, 163, 205);  // Semi-transparent light-blue color
            Color arrowColor  = Color.Argb(255, 255, 255, 255); // White color
            float dp          = DemoApp.DisplayDensity;

            // Preparing paints
            Paint paint = new Paint(PaintFlags.AntiAlias);

            paint.SetStyle(Paint.Style.FillAndStroke);
            paint.StrokeCap = Paint.Cap.Round;

            /// Drawing device path (if it exists)
            if (deviceInfo.Paths != null && deviceInfo.Paths.Count > 0)
            {
                RoutePath path = (RoutePath)deviceInfo.Paths[0];
                if (path.Points.Count >= 2)
                {
                    paint.Color = solidColor;

                    for (int j = 1; j < path.Points.Count; ++j)
                    {
                        LocationPoint p = (LocationPoint)path.Points[j - 1];
                        LocationPoint q = (LocationPoint)path.Points[j];
                        if (p.SubLocation == subLoc.Id && q.SubLocation == subLoc.Id)
                        {
                            paint.StrokeWidth = 3 * dp;
                            PointF P1 = locationView.GetScreenCoordinates(p);
                            PointF Q1 = locationView.GetScreenCoordinates(q);
                            canvas.DrawLine(P1.X, P1.Y, Q1.X, Q1.Y, paint);
                        }
                    }
                }
            }

            paint.StrokeCap = Paint.Cap.Butt;

            // Check if device belongs to the current sublocation
            if (deviceInfo.SubLocation != subLoc.Id)
            {
                return;
            }

            float x       = deviceInfo.X;
            float y       = deviceInfo.Y;
            float r       = deviceInfo.R;
            float angle   = deviceInfo.Azimuth;
            float sinA    = (float)System.Math.Sin(angle);
            float cosA    = (float)System.Math.Cos(angle);
            float radius  = locationView.GetScreenLengthX(r); // External radius: navigation-determined, transparent
            float radius1 = 25 * dp;                          // Internal radius: fixed, solid

            PointF O = locationView.GetScreenCoordinates(x, y);
            PointF P = new PointF(O.X - radius1 * sinA * 0.22f, O.Y + radius1 * cosA * 0.22f);
            PointF Q = new PointF(O.X + radius1 * sinA * 0.55f, O.Y - radius1 * cosA * 0.55f);
            PointF R = new PointF(O.X + radius1 * cosA * 0.44f - radius1 * sinA * 0.55f, O.Y + radius1 * sinA * 0.44f + radius1 * cosA * 0.55f);
            PointF S = new PointF(O.X - radius1 * cosA * 0.44f - radius1 * sinA * 0.55f, O.Y - radius1 * sinA * 0.44f + radius1 * cosA * 0.55f);

            // Drawing transparent circle
            paint.StrokeWidth = 0;
            paint.Color       = circleColor;
            canvas.DrawCircle(O.X, O.Y, radius, paint);

            // Drawing solid circle
            paint.Color = solidColor;
            canvas.DrawCircle(O.X, O.Y, radius1, paint);

            if (OrientationEnabled)
            {
                // Drawing arrow
                paint.Color = arrowColor;
                Path path = new Path();
                path.MoveTo(Q.X, Q.Y);
                path.LineTo(R.X, R.Y);
                path.LineTo(P.X, P.Y);
                path.LineTo(S.X, S.Y);
                path.LineTo(Q.X, Q.Y);
                canvas.DrawPath(path, paint);
            }
        }
Ejemplo n.º 12
0
        private void DrawPoints(Canvas canvas)
        {
            // Check if location is loaded
            if (location == null || currentSubLocationIndex < 0)
            {
                return;
            }

            // Get current sublocation displayed
            SubLocation subLoc = (SubLocation)location.SubLocations[currentSubLocationIndex];

            if (subLoc == null)
            {
                return;
            }

            Color solidColor  = Color.Argb(255, 64, 163, 205);  // Light-blue color
            int   circleColor = Color.Argb(127, 64, 163, 205);  // Semi-transparent light-blue color
            int   arrowColor  = Color.Argb(255, 255, 255, 255); // White color
            float dp          = DemoApp.DisplayDensity;
            float textSize    = 16 * dp;

            // Preparing paints
            Paint paint = new Paint(PaintFlags.AntiAlias);

            paint.SetStyle(Paint.Style.FillAndStroke);
            paint.TextSize = textSize;
            paint.SetTypeface(Typeface.Create(Typeface.Default, TypefaceStyle.Bold));

            // Drawing pin point (if it exists and belongs to the current sublocation)
            if (pinPoint != null && pinPoint.SubLocation == subLoc.Id)
            {
                PointF T       = locationView.GetScreenCoordinates(pinPoint);
                float  tRadius = 10 * dp;

                paint.SetARGB(255, 0, 0, 0);
                paint.StrokeWidth = 4 * dp;
                canvas.DrawLine(T.X, T.Y, T.X, T.Y - 3 * tRadius, paint);

                paint.Color       = solidColor;
                paint.StrokeWidth = 0;
                canvas.DrawCircle(T.X, T.Y - 3 * tRadius, tRadius, paint);

                string text      = "Make route";
                float  textWidth = paint.MeasureText(text);
                float  h         = 50 * dp;
                float  w         = System.Math.Max(120 * dp, textWidth + h / 2);
                float  x0        = T.X;
                float  y0        = T.Y - 75 * dp;

                pinPointRect.Set(x0 - w / 2, y0 - h / 2, x0 + w / 2, y0 + h / 2);

                paint.Color = solidColor;
                canvas.DrawRoundRect(pinPointRect, h / 2, h / 2, paint);

                paint.SetARGB(255, 255, 255, 255);
                canvas.DrawText(text, x0 - textWidth / 2, y0 + textSize / 4, paint);
            }

            // Drawing target point (if it exists and belongs to the current sublocation)
            if (targetPoint != null && targetPoint.SubLocation == subLoc.Id)
            {
                PointF T       = locationView.GetScreenCoordinates(targetPoint);
                float  tRadius = 10 * dp;

                paint.SetARGB(255, 0, 0, 0);
                paint.StrokeWidth = 4 * dp;
                canvas.DrawLine(T.X, T.Y, T.X, T.Y - 3 * tRadius, paint);

                paint.Color = solidColor;
                canvas.DrawCircle(T.X, T.Y - 3 * tRadius, tRadius, paint);
            }
        }
Ejemplo n.º 13
0
        private void HandleClick(float x, float y)
        {
            Log.Debug(TAG, $"Click at ({x}, {y})");

            if (location == null || currentSubLocationIndex < 0)
            {
                return;
            }

            SubLocation subLoc = (SubLocation)location.SubLocations[currentSubLocationIndex];

            if (subLoc == null)
            {
                return;
            }

            if (pinPoint != null)
            {
                if (pinPointRect != null && pinPointRect.Contains(x, y))
                {
                    targetPoint  = pinPoint;
                    targetVenue  = null;
                    pinPoint     = null;
                    pinPointRect = null;
                    DemoApp.Navigation.SetTarget(targetPoint);
                    backView.Visibility = ViewStates.Visible;
                    return;
                }

                CancelPin();
                return;
            }

            if (selectedVenue != null)
            {
                if (selectedVenueRect != null && selectedVenueRect.Contains(x, y))
                {
                    targetVenue = selectedVenue;
                    targetPoint = null;
                    DemoApp.Navigation.SetTarget(new LocationPoint(location.Id, subLoc.Id, targetVenue.X, targetVenue.Y));
                    backView.Visibility = ViewStates.Visible;
                }

                CancelVenue();
                return;
            }

            // Check if we touched venue
            selectedVenue     = GetVenueAt(x, y);
            selectedVenueRect = new RectF();

            // Check if we touched zone
            if (selectedVenue == null)
            {
                Zone Z = getZoneAt(x, y);
                if (Z != null)
                {
                    selectedZone = (selectedZone == Z) ? null : Z;
                }
            }

            Refresh();
        }
Ejemplo n.º 14
0
        public void RedrawMap()
        {
            if (DemoApp.Navigation == null)
            {
                Log.Debug(TAG, "Sorry, navigation is not supported on your device!");
                return;
            }

            long timeNow = NavigineSDK.CurrentTimeMillis();

            if (errorMessageTime > 0 && timeNow > errorMessageTime + ErrorMessageTimeout)
            {
                errorMessageTime             = 0;
                errorMessageLabel.Visibility = ViewStates.Gone;
            }

            // Check if location is loaded
            if (location == null || currentSubLocationIndex < 0)
            {
                return;
            }

            // Get current sublocation displayed
            SubLocation subLoc = (SubLocation)location.SubLocations[currentSubLocationIndex];

            // Start navigation if necessary
            if (DemoApp.Navigation.Mode == NavigationThread.ModeIdle)
            {
                DemoApp.Navigation.Mode = NavigationThread.ModeNormal;
            }

            // Get device info from NavigationThread
            deviceInfo = DemoApp.Navigation.DeviceInfo;

            if (deviceInfo.ErrorCode == 0)
            {
                errorMessageTime             = 0;
                errorMessageLabel.Visibility = ViewStates.Gone;

                if (adjustMode)
                {
                    AdjustDevice();
                }

                if (targetPoint != null || targetVenue != null)
                {
                    backView.Visibility = ViewStates.Visible;
                }
                else
                {
                    backView.Visibility = ViewStates.Gone;
                }
            }
            else
            {
                switch (deviceInfo.ErrorCode)
                {
                case 4:
                    SetErrorMessage("You are out of navigation zone! Please, check that your bluetooth is enabled!");
                    break;

                case 8:
                case 30:
                    SetErrorMessage("Not enough beacons on the location! Please, add more beacons!");
                    break;

                default:
                    SetErrorMessage(
                        $"Something is wrong with location {location.Name} (error code {deviceInfo.ErrorCode})! Please, contact technical support!");
                    break;
                }

                backView.Visibility = ViewStates.Gone;
            }

            // Secondly, adjust device to the center of the screen
            PointF center = locationView.ScreenCenter;
            float  deltaX = locationView.Width / 2 - center.X;
            float  deltaY = locationView.Height / 2 - center.Y;

            adjustTime = timeNow;
            locationView.ScrollBy(deltaX, deltaY);

            // This causes map redrawing
            locationView.Redraw();
        }
Ejemplo n.º 15
0
        private void InitializeLocations()
        {
            DesignSubLocation = new SubLocation
            {
                Name = "Grease Trap",
                Notes = "Here are some notes",
                Latitude = (decimal?) 40.454821,
                Longitude = (decimal?) -86.935696,
                Number = 1,
                CreatedDate = DateTime.UtcNow,
                LastModified = DateTime.UtcNow
            };

            DesignSubLocationTwo = new SubLocation
            {
                Name = "Laundy",
                Notes = "Many notes!",
                Latitude = (decimal?)38.888934,
                Longitude = (decimal?)-77.386901,
                Number = 2,
                CreatedDate = DateTime.UtcNow,
                LastModified = DateTime.UtcNow
            };

            DesignSubLocationThree = new SubLocation
            {
                Name = "Parking",
                Notes = "Small amount of notes",
                Latitude = (decimal?)38.979607,
                Longitude = (decimal?)-77.326368,
                Number = 3,
                CreatedDate = DateTime.UtcNow,
                LastModified = DateTime.UtcNow
            };
            DesignSubLocationFour = new SubLocation
            {
                Name = "Room",
                Notes = "More notes",
                Latitude = (decimal?)37.979607,
                Longitude = (decimal?)-75.326368,
                Number = 4,
                CreatedDate = DateTime.UtcNow,
                LastModified = DateTime.UtcNow
            };
            DesignSubLocationFive = new SubLocation
            {
                Name = "Another Room",
                Notes = "Important notes",
                Latitude = (decimal?)38.879607,
                Longitude = (decimal?)-77.226368,
                Number = 5,
                CreatedDate = DateTime.UtcNow,
                LastModified = DateTime.UtcNow
            };
            DesignSubLocationSix = new SubLocation
            {
                Name = "Hidden Place",
                Notes = "Unimportant notes",
                Latitude = (decimal?)39.979607,
                Longitude = (decimal?)-78.326368,
                Number = 6,
                CreatedDate = DateTime.UtcNow,
                LastModified = DateTime.UtcNow
            };
            DesignSubLocationSeven = new SubLocation
            {
                Name = "Go Here",
                Notes = "No notes here",
                Latitude = (decimal?)38.679607,
                Longitude = (decimal?)-77.626368,
                Number = 7,
                CreatedDate = DateTime.UtcNow,
                LastModified = DateTime.UtcNow
            };
            DesignSubLocationEight = new SubLocation
            {
                Name = "Don't Go Here",
                Notes = "Lots of notes",
                Latitude = (decimal?)38.379607,
                Longitude = (decimal?)-77.526368,
                Number = 8,
                CreatedDate = DateTime.UtcNow,
                LastModified = DateTime.UtcNow
            };
            DesignSubLocationNine = new SubLocation
            {
                Name = "Name",
                Notes = "Notes Notes",
                Latitude = (decimal?)37.979607,
                Longitude = (decimal?)-78.126368,
                Number = 9,
                CreatedDate = DateTime.UtcNow,
                LastModified = DateTime.UtcNow
            };

            DesignSubLocations = new List<SubLocation> { DesignSubLocation, DesignSubLocationTwo, DesignSubLocationThree, DesignSubLocationFour, DesignSubLocationFive, 
                DesignSubLocationSix, DesignSubLocationSeven, DesignSubLocationEight, DesignSubLocationNine};
        }