예제 #1
0
        private void Cmd_DeleteCircuit(object sender, ExecutedRoutedEventArgs e)
        {
            CircuitIconElement arriver  = (CircuitIconElement)e.OriginalSource;
            LineGeometry       geometry = (LineGeometry)arriver.Icon;
            Thickness          start    = GetThickness(geometry.StartPoint, NoneList);
            Thickness          end      = GetThickness(geometry.EndPoint, NoneList);

            if (start.Left < end.Left)
            {
                if (start.Top < end.Top)
                {
                    var vpl = NoneListCirc.Where(a => (a.Left >= start.Left) && (a.Left <= end.Left) &&
                                                 (a.Top >= start.Top) && (a.Top <= end.Top));
                    YesList.AddRange(vpl);
                    NoneListCirc.RemoveAll(x => vpl.Contains(x));
                }
                else
                {
                    var vpl = NoneListCirc.Where(a => (a.Left >= start.Left) && (a.Left <= end.Left) &&
                                                 (a.Top <= start.Top) && (a.Top >= end.Top));
                    YesList.AddRange(vpl);
                    NoneListCirc.RemoveAll(x => vpl.Contains(x));
                }
            }
            else
            {
                if (start.Top < end.Top)
                {
                    var vpl = NoneListCirc.Where(a => (a.Left <= start.Left) && (a.Left >= end.Left) &&
                                                 (a.Top >= start.Top) && (a.Top <= end.Top));
                    YesList.AddRange(vpl);
                    NoneListCirc.RemoveAll(x => vpl.Contains(x));
                }
                else
                {
                    var vpl = NoneListCirc.Where(a => (a.Left <= start.Left) && (a.Left >= end.Left) &&
                                                 (a.Top <= start.Top) && (a.Top >= end.Top));
                    YesList.AddRange(vpl);
                    NoneListCirc.RemoveAll(x => vpl.Contains(x));
                }
            }
            Canvas.Children.Remove(arriver);
            ContextMenuClosed = true;
        }
예제 #2
0
        private void Cmd_ConnectStation(object sender, ExecutedRoutedEventArgs e)
        {
            CircuitIconElement circuitIconElement = new CircuitIconElement();

            line = new LineGeometry();
            circuitIconElement.Icon = line;
            StationIconElement arriver  = (StationIconElement)e.OriginalSource;
            EllipseGeometry    geometry = (EllipseGeometry)arriver.Icon;
            Point     pos  = geometry.Center;
            Thickness ness = GetThickness(pos, NoneList);

            line.StartPoint          = new Point(ness.Left + Step / 2 - 0.25, ness.Top + Step / 2 - 0.25);
            circuitIconElement.Style = (Style)Application.Current.FindResource("CircuitStyle");
            Canvas.Children.Add(circuitIconElement);
            Canvas.SetZIndex(circuitIconElement, 1);
            Canvas.MouseMove           -= Canvas_MouseMove;
            Canvas.MouseMove           += Canvas_MoveLine;
            Canvas.MouseLeftButtonDown += Canvas_LeftButtonCircuit;
            path.Opacity = 0.0;
        }