Esempio n. 1
0
    public void CreateHeatmapGeo(int x, int y, int index, int type, float meshYPosition)
    {
        updateIndices.Add(index);
        heatmapItems[index] = new HeatMapItem();

        heatmapItems [index].x     = x;
        heatmapItems [index].y     = y;
        heatmapItems [index].z     = meshYPosition;
        heatmapItems [index].type  = type;
        heatmapItems [index].score = -2f;

        heatmapItems[index].geo      = GameObject.CreatePrimitive(PrimitiveType.Quad);    //make cell cube
        heatmapItems[index].geo.name = (currentHeatmapParent.name + " Type: " + type);

        heatmapItems[index].geo.transform.localPosition = new Vector3(x * cellSize, meshYPosition + yOffset, y * cellSize);
        Quaternion _tmpRot = heatmapParent.transform.localRotation;

        _tmpRot.eulerAngles = new Vector3(90, 0, 0.0f);
        heatmapItems[index].geo.transform.localRotation = _tmpRot;

        vertices.Add(new Vector2(heatmapItems [index].geo.transform.localPosition.x, heatmapItems [index].geo.transform.localPosition.z));

        heatmapItems[index].geo.transform.localScale = new Vector3(cellSize * cellShrink, cellSize * cellShrink, cellSize * cellShrink);
        heatmapItems[index].geo.transform.GetComponent <Renderer>().receiveShadows    = false;
        heatmapItems[index].geo.transform.GetComponent <Renderer>().shadowCastingMode =
            UnityEngine.Rendering.ShadowCastingMode.Off;
        heatmapItems[index].geo.transform.parent = currentHeatmapParent.transform;         //put into parent object for later control
    }
Esempio n. 2
0
        //Raised When Mouse is entered inside HeatMapItem
        private void heatMapItem_MouseEnter(object sender, MouseEventArgs e)
        {
            hitTestList.Clear();
            Point pt = e.GetPosition(sender as IInputElement);

            VisualTreeHelper.HitTest(
                sender as Visual,
                null,
                CollectAllVisuals_Callback,
                new PointHitTestParameters(pt));
            hitTestList.Reverse();

            HeatMapItem item = null;

            foreach (DependencyObject element in hitTestList)
            {
                if (element.GetType().Name.Equals("Border"))
                {
                    item = ((Border)element).TemplatedParent as HeatMapItem;
                    if (item != null)
                    {
                        RegionalSales rr = item.Header as RegionalSales;
                        this.txtName.Text    = rr.Name;
                        this.txtCountry.Text = rr.Country;
                        this.txtSales.Text   = string.Format("${0}", rr.Sales);
                        this.txtExpense.Text = string.Format("${0}", rr.Expense);
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// To save the updated heat map items
        /// </summary>
        /// <param name="heatMapBusinessModels"></param>
        /// <returns></returns>
        public bool SaveHeatMapItems(List <HeatMapBusinessModel> heatMapBusinessModels)
        {
            try
            {
                List <HeatMapItem> existingHeatMapItems = (from h in _m3PactContext.HeatMapItem
                                                           where h.RecordStatus == DomainConstants.RecordStatusActive &&
                                                           h.StartTime <= DateTime.Now && h.EndTime > DateTime.Now
                                                           select h).ToList();
                List <HeatMapItem> updatedHeatMapItems = new List <HeatMapItem>();
                heatMapBusinessModels.ForEach(uhm =>
                {
                    HeatMapItem heatMapItem = _m3PactContext.HeatMapItem.Where(h => h.Kpiid == uhm.KpiId && h.RecordStatus == DomainConstants.RecordStatusActive && h.StartTime <= DateTime.Now && h.EndTime > DateTime.Now).FirstOrDefault();
                    if (heatMapItem != null)
                    {
                        updatedHeatMapItems.Add(heatMapItem);
                    }
                });
                List <HeatMapItem> unchangedHeatMapItems = updatedHeatMapItems.Intersect(existingHeatMapItems).ToList();
                List <int>         unchangedKPIIds       = unchangedHeatMapItems.Select(u => u.Kpiid).ToList();
                List <HeatMapItem> heatMapstoInactive    = existingHeatMapItems.Except(unchangedHeatMapItems).ToList();
                List <int>         kpistoInsert          = heatMapBusinessModels.Where(i => !unchangedKPIIds.Contains(i.KpiId)).Select(i => i.KpiId).ToList();

                if (heatMapstoInactive?.Count > 0 || kpistoInsert?.Count > 0)
                {
                    heatMapstoInactive.ForEach(hm =>
                    {
                        hm.EndTime      = DateTime.Now;
                        hm.ModifiedDate = DateTime.Now;
                        hm.ModifiedBy   = userContext.UserId;
                    });
                    _m3PactContext.HeatMapItem.UpdateRange(heatMapstoInactive);

                    List <HeatMapItem> heatMapstoInsert = new List <HeatMapItem>();

                    kpistoInsert.ForEach(kpi =>
                    {
                        HeatMapItem heatMapItem  = new HeatMapItem();
                        heatMapItem.Kpiid        = kpi;
                        heatMapItem.CreatedBy    = userContext.UserId;
                        heatMapItem.CreatedDate  = DateTime.Now;
                        heatMapItem.ModifiedBy   = userContext.UserId;
                        heatMapItem.ModifiedDate = DateTime.Now;
                        heatMapItem.RecordStatus = DomainConstants.RecordStatusActive;
                        heatMapItem.StartTime    = DateTime.Now;
                        heatMapItem.EndTime      = DateTime.MaxValue.Date;
                        heatMapstoInsert.Add(heatMapItem);
                    });

                    _m3PactContext.HeatMapItem.AddRange(heatMapstoInsert);
                    _m3PactContext.SaveChanges();
                    RecalculateRiskScores();
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
        public void HeatMapItemIncrementTest()
        {
            HeatMapItem heatMapItem = new HeatMapItem("A", "B");

            heatMapItem.Increment();
            heatMapItem.Increment();

            Assert.AreEqual(2, heatMapItem.Count);
        }
Esempio n. 5
0
        /// <summary>
        /// Event that finds selected item
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void heatMapItem_MouseDown(object sender, MouseButtonEventArgs e)
        {
            HeatMapItem item = new HeatMapItem();
            Type        type = e.OriginalSource.GetType();

            if (type.Name.Equals("Border"))
            {
                item = ((Border)e.OriginalSource).TemplatedParent as HeatMapItem;
            }
            else if (type.Name.Equals("TextBlock"))
            {
                item = ((ContentPresenter)((TextBlock)e.OriginalSource).TemplatedParent).TemplatedParent as HeatMapItem;
            }
            if (type.Name.Equals("Border") || type.Name.Equals("TextBlock"))
            {
                if (item.Header.GetType().Name.Equals("RegionSale"))
                {
                    MessageBox.Show(string.Format("You have clicked \"{0}\" item...", (item.Header as RegionSale).Name), "Hierarchical List", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
        }