internal MillingItemPropertiesDialog(MillingWorkspaceItem item, MillingWorkspacePanel workspace)
        {
            _item      = item;
            _workspace = workspace;

            InitializeComponent();
            KeyUp += (s, e) =>
            {
                if (e.Key == Key.Escape)
                {
                    this.Close();
                }
            };

            refreshWindow();

            ShapeTop.TextChanged       += ShapeTop_TextChanged;
            ShapeLeft.TextChanged      += ShapeLeft_TextChanged;
            ShapeWidth.TextChanged     += ShapeWidth_TextChanged;
            ShapeHeight.TextChanged    += ShapeHeight_TextChanged;
            MillingDepth.TextChanged   += MillingDepth_TextChanged;
            AngleNum.TextChanged       += AngleNum_TextChanged;
            ShapeRotation.ValueChanged += ShapeRotation_ValueChanged;
            ShowDialog();
        }
Beispiel #2
0
 internal IEnumerable <MillingJoin> GetIncomingJoins(MillingWorkspaceItem item)
 {
     foreach (var join in _itemJoins)
     {
         if (join.Item2 == item)
         {
             yield return(join);
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// Handler for moving mouse (calculates delta for drag and drop)
        /// </summary>
        private void _mouseMove(object sender, MouseEventArgs e)
        {
            if (_changesDisabled)
            {
                _draggedItem = null;
            }

            var position   = e.GetPosition(this);
            var mouseDelta = position - _lastMousePosition;

            _lastMousePosition = position;

            if (_draggedItem != null)
            {
                _draggedItem.PositionX += mouseDelta.X / ActualWidth * RangeX;
                _draggedItem.PositionY += mouseDelta.Y / ActualHeight * RangeY;
            }

            _positionInfo.PositionX = position.X / ActualWidth * RangeX;
            _positionInfo.PositionY = position.Y / ActualHeight * RangeY;
            _positionInfo.UpdateInfo();
        }
Beispiel #4
0
        /// <inheritdoc/>
        protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved)
        {
            if (visualRemoved != null)
            {
                //TODO cleanup handlers
                foreach (var join in _itemJoins.ToArray())
                {
                    if (join.Item1 == visualRemoved || join.Item2 == visualRemoved)
                    {
                        _itemJoins.Remove(join);
                    }
                }
            }

            if (visualAdded != null)
            {
                var millingItem = visualAdded as MillingWorkspaceItem;
                if (millingItem != null)
                {
                    //enable drag
                    millingItem.PreviewMouseLeftButtonDown += (s, e) => _draggedItem = millingItem;
                    //enable properties dialog
                    millingItem.MouseRightButtonUp += (s, e) => new MillingItemPropertiesDialog(millingItem, this);
                }

                //setup change listener to work items
                var workItem = visualAdded as MillingWorkspaceItem;
                if (workItem != null)
                {
                    workItem.OnSettingsChanged += fireOnSettingsChanged;
                    workItem.MouseUp           += (s, e) => fireOnWorkitemClicked(workItem);
                }
            }
            base.OnVisualChildrenChanged(visualAdded, visualRemoved);

            fireOnWorkItemListChanged();
            fireOnSettingsChanged();
        }
Beispiel #5
0
        private double projectToY(Size finalSize, MillingWorkspaceItem child)
        {
            var positionX = finalSize.Height * child.PositionY / RangeY;

            return(positionX);
        }
Beispiel #6
0
        private double projectToX(Size finalSize, MillingWorkspaceItem child)
        {
            var positionX = finalSize.Width * child.PositionX / RangeX;

            return(positionX);
        }
Beispiel #7
0
 private void fireOnWorkitemClicked(MillingWorkspaceItem item)
 {
     OnWorkItemClicked?.Invoke(item);
 }
Beispiel #8
0
 /// <summary>
 /// Handler for releasing dragged objects.
 /// </summary>
 private void _mouseUp(object sender, MouseButtonEventArgs e)
 {
     _draggedItem = null;
 }