Ejemplo n.º 1
0
        private void Mycanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (IsRuning)
            {
                return;
            }
            if (suspensionWindow.IsNowShown)
            {
                suspensionWindow.ReleaseChooses();
            }
            var      targetElement = e.Source as IInputElement;
            IntPoint point         = ToGrid(new IntPoint(e.GetPosition(Mycanvas)));

            if (targetElement != null)
            {
                targetElement.CaptureMouse();

                /*
                 * 点下的时候判断有没有选中某一个电子元件
                 * 如果选中了,记录状态,记录初始位置和初始光标位置
                 * Move的时候一直跟着动,但是位置不是鼠标的位置,而是贴合位置
                 * 这和第一次放上去元件是一样的,只能放在格点上
                 */
                /*if (elecCompSet.FoundPressedElecComp(point))
                 * {
                 *  //MessageBox.Show("Found!");
                 *  textBox.Text = "Found";
                 *  PushDownPoint = point;
                 *  HasMoved = new IntPoint(0, 0);
                 * }*/
                //更新为根据所选的Shape决定谁被选中
                if (elecCompSet.FoundPressedElecComp(targetElement))
                {
                    //MessageBox.Show("Found!");
                    //textBox.Text = "Found";
                    PushDownPoint = point;
                    HasMoved      = new IntPoint(0, 0);
                }
            }
        }
Ejemplo n.º 2
0
        private void Mycanvas_MouseDown(object sender, MouseButtonEventArgs e)
        {
            var      targetElement = e.Source as IInputElement;
            IntPoint point         = ToGrid(new IntPoint(e.GetPosition(Mycanvas)));

            if (targetElement != null)
            {
                targetElement.CaptureMouse();

                /*
                 * 点下的时候判断有没有选中某一个电子元件
                 * 如果选中了,记录状态,记录初始位置和初始光标位置
                 * Move的时候一直跟着动,但是位置不是鼠标的位置,而是贴合位置
                 * 这和第一次放上去元件是一样的,只能放在格点上
                 */
                if (elecCompSet.FoundPressedElecComp(point))
                {
                    //MessageBox.Show("Found!");
                    textBox.Text  = "Found";
                    PushDownPoint = point;
                    HasMoved      = new IntPoint(0, 0);
                }
            }
        }