Ejemplo n.º 1
0
 private void BloodSugarEntries_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
     {
         foreach (var item in e.NewItems)
         {
             if (item is BloodSugarEntry entry)
             {
                 entry.CalcStats(EntryUnits);
                 if (!Loading)
                 {
                     var firstOfMonth = new DateTime(entry.EntryDateTime.Year, entry.EntryDateTime.Month, 1);
                     if (firstOfMonth > StatsLastUpdated)
                     {
                         var days  = new TimeSpan(Constants.DaysToGetStatsFor, 0, 0, 0);
                         var stats = GetStats(firstOfMonth - days, firstOfMonth);
                         StatsLastUpdated = firstOfMonth;
                         if (stats.Item1 > 0 && stats.Item2 > 0)
                         {
                             var newStatsEntry = new BloodSugarStat();
                             newStatsEntry.StatDate          = firstOfMonth;
                             newStatsEntry.AverageBloodSugar = stats.Item1;
                             newStatsEntry.AverageDeviation  = stats.Item2;
                             newStatsEntry.EntryOwnerID      = EntryOwnerID;
                             newStatsEntry.Owner             = this;
                             newStatsEntry.AverageAIC        = ProjectMath.CalcA1C(this.EntryUnits, stats.Item1);
                             Stats.Add(newStatsEntry);
                         }
                     }
                     IsModified = true;
                 }
             }
         }
     }
 }
        // Event listeners
        public void OnCreationButtonClick()
        {
            string       name = nameField.text;
            VariableType type = ProjectMath.GetVariableType(typeText.text);

            Variables.CreateVariable(name, type);

            Manager.ContextManager.RenderVariablesMenu();
        }
Ejemplo n.º 3
0
        public void OnDrag()
        {
            Vector3 currentCursorPosition = ProjectMath.GetCursorPosition();

            transform.position += currentCursorPosition - beforeCursorPosition;

            RenderLines();

            beforeCursorPosition = currentCursorPosition;
        }
Ejemplo n.º 4
0
        protected void Start()
        {
            leftConnectors  = GetComponentsInChildren <LeftConnector>();
            rightConnectors = GetComponentsInChildren <RightConnector>();

            inputs = GetComponentsInChildren <InputPivot>();
            output = GetComponentInChildren <OutputPivot>();

            nodeName = GetComponentInChildren <Text>().text.TrimEnd();
            id       = ProjectMath.GetNodeId();
        }
Ejemplo n.º 5
0
        public void OnDrag(PointerEventData eventData)
        {
            Vector3 currentCursorPosition = ProjectMath.GetCursorPosition();
            Vector3 position = currentCursorPosition - beforeCursorPosition;

            nodes.transform.position += new Vector3(position.x * speed, position.y * speed);

            foreach (Node node in nodes.GetComponentsInChildren <Node>())
            {
                node.RenderLines();
            }

            beforeCursorPosition = currentCursorPosition;
        }
Ejemplo n.º 6
0
        public void OnAddedPathComplete(Path p)
        {
            addedPath = new List <List <Vector3> >();

            List <Vector3?> leftList    = new List <Vector3?>();
            List <Vector3?> leftOneList = new List <Vector3?>();
            List <Vector3?> leftTwoList = new List <Vector3?>();

            List <Vector3?> rightList    = new List <Vector3?>();
            List <Vector3?> rightOneList = new List <Vector3?>();
            List <Vector3?> rightTwoList = new List <Vector3?>();

            for (var i = 0; i < p.vectorPath.Count; i++)
            {
                var pointVectorPath = p.vectorPath[i];

                if (i + 1 < p.vectorPath.Count)
                {
                    var dir = (p.vectorPath[i + 1] - pointVectorPath).normalized;

                    var left    = new Vector2(-dir.y, dir.x);
                    var leftOne = ProjectMath.Vector2Rotate(left, -10);
                    var leftTwo = ProjectMath.Vector2Rotate(left, 10);

                    var right    = new Vector2(dir.y, -dir.x);
                    var rightOne = ProjectMath.Vector2Rotate(right, -10);
                    var rightTwo = ProjectMath.Vector2Rotate(right, 10);

                    leftList.Add(checkRayDistance(Physics2D.Raycast(pointVectorPath, left), pointVectorPath));
                    leftOneList.Add(checkRayDistance(Physics2D.Raycast(pointVectorPath, leftOne), pointVectorPath));
                    leftTwoList.Add(checkRayDistance(Physics2D.Raycast(pointVectorPath, leftTwo), pointVectorPath));

                    rightList.Add(checkRayDistance(Physics2D.Raycast(pointVectorPath, right), pointVectorPath));
                    rightOneList.Add(checkRayDistance(Physics2D.Raycast(pointVectorPath, rightOne), pointVectorPath));
                    rightTwoList.Add(checkRayDistance(Physics2D.Raycast(pointVectorPath, rightTwo), pointVectorPath));
                }
            }

            addedPath.Add(leftList.Where(e => e.HasValue).Select(e => e.Value).ToList());
            addedPath.Add(leftOneList.Where(e => e.HasValue).Select(e => e.Value).ToList());
            addedPath.Add(leftTwoList.Where(e => e.HasValue).Select(e => e.Value).ToList());

            addedPath.Add(rightList.Where(e => e.HasValue).Select(e => e.Value).ToList());
            addedPath.Add(rightOneList.Where(e => e.HasValue).Select(e => e.Value).ToList());
            addedPath.Add(rightTwoList.Where(e => e.HasValue).Select(e => e.Value).ToList());

            addedPath.ForEach(e => Debug.Log(e.Count));
        }
Ejemplo n.º 7
0
        private void Update()
        {
            if (isConnecting)
            {
                Vector3 cursorPosition = ProjectMath.GetCursorPosition();

                if (selectedConnector)
                {
                    selectedConnector.DrawLineToPosition(cursorPosition);
                }
                else if (selectedPivot)
                {
                    selectedPivot.DrawLineToPosition(cursorPosition);
                }
            }
        }
Ejemplo n.º 8
0
        private void CreateMenu(GameObject prefab, bool onMenuPosition = false)
        {
            Vector3 position;

            if (onMenuPosition)
            {
                position = menu.transform.position;
            }
            else
            {
                position = ProjectMath.GetCursorPosition() + new Vector3(0, 0, -1);
            }

            DestroyMenu();

            menu = Instantiate(prefab, position, Quaternion.identity, nodes.transform);
        }
Ejemplo n.º 9
0
 // Event listeners
 public void OnBeginDrag()
 {
     beforeCursorPosition = ProjectMath.GetCursorPosition();
 }
Ejemplo n.º 10
0
 public void OnBeginDrag(PointerEventData eventData)
 {
     beforeCursorPosition = ProjectMath.GetCursorPosition();
 }