コード例 #1
0
 internal void RecreateCanvasViewModel()
 {
     if (CurrentProject.Last == null)
     {
         return;
     }
     Dominoes.Clear();
     for (int i = 0; i < CurrentProject.Last.shapes.Count(); i++)
     {
         EditingDominoVM dic = new EditingDominoVM(i, CurrentProject.Last[i], CurrentProject.colors, DisplaySettingsTool.Expanded);
         Dominoes.Add(dic);
     }
 }
コード例 #2
0
        public EditingDominoVM FindDominoAtPosition(Avalonia.Point pos, int tolerance = 0)
        {
            double          min_dist = int.MaxValue;
            EditingDominoVM result   = null;

            foreach (var shape in Dominoes)
            {
                if (shape.domino.IsInside(new Core.Point(pos.X, pos.Y), expanded: DisplaySettingsTool.Expanded))
                {
                    return(shape);
                }
                var    rect = shape.domino.GetContainer();
                double dist = Math.Pow((rect.x + rect.width / 2) - pos.X, 2) + Math.Pow(rect.y + rect.height / 2 - pos.Y, 2);
                if (min_dist > dist && dist < tolerance)
                {
                    min_dist = dist;
                    result   = shape;
                }
            }
            return(result);
        }