コード例 #1
0
        private void Target_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point mousePos = e.GetPosition(target);

            if (Keyboard.Modifiers == ModifierKeys.Control) //bareshaft
            {
                BareshaftGraphic bareshaft = new BareshaftGraphic(mousePos);
                lBareshaft.Add(bareshaft);
            }
            else
            {
                FletchedGraphic fletched = new FletchedGraphic(mousePos);
                lFletched.Add(fletched);
            }

            UpdateTargetChildren();
        }
コード例 #2
0
        //Target graphics
        private void UpdateTargetChildren()
        {
            target.Children.Clear();
            AddTargetGraphic();

            if (lBareshaft.GetNumElements() > 0)
            {
                int head = lBareshaft.GetHead();
                lBareshaft.SetHead(0);
                for (int i = 0; i < lBareshaft.GetSize(); i++)
                {
                    BareshaftGraphic bareshaft = (BareshaftGraphic)lBareshaft[i];
                    if (bareshaft != null)
                    {
                        target.Children.Add(bareshaft);                             //ienumerator will go through the whole array even if elements are null
                    }
                    lBareshaft.MoveNext();
                }
                lBareshaft.SetHead(head);
            }

            if (lFletched.GetNumElements() > 0)
            {
                int head = lFletched.GetHead();
                lFletched.SetHead(0);
                for (int i = 0; i < lFletched.GetSize(); i++)
                {
                    FletchedGraphic fletched = (FletchedGraphic)lFletched[i];
                    if (fletched != null)
                    {
                        target.Children.Add(fletched);
                    }
                    lFletched.MoveNext();
                }
                lFletched.SetHead(head);
            }
        }