private void UserControl_MouseMove(object sender, MouseEventArgs e) { if (!_isMoving) { return; } var mousePoint = Mouse.GetPosition(Container); var offsetX = (_currentTT == null ? _buttonPosition.Value.X : _buttonPosition.Value.X - _currentTT.X) + deltaX - mousePoint.X; var offsetY = (_currentTT == null ? _buttonPosition.Value.Y : _buttonPosition.Value.Y - _currentTT.Y) + deltaY - mousePoint.Y; this.RenderTransform = new TranslateTransform(-offsetX, -offsetY); Point CahePoint = new Point(); CahePoint.Y = this.TransformToAncestor(Container).Transform(new System.Windows.Point(0, 0)).Y + 25; CahePoint.X = this.TransformToAncestor(Container).Transform(new System.Windows.Point(0, 0)).X + 25; if (!TreeViewGlobal.LocationCollection.ContainsKey(this.id.ToString())) { TreeViewGlobal.LocationCollection.Add(this.id.ToString(), CahePoint); } else { TreeViewGlobal.LocationCollection[this.id.ToString()] = CahePoint; } try { if (TreeViewGlobal.LocationCollection.ContainsKey(this.ParentID.ToString())) { TreeViewGlobal.Update(this.ParentID, this.id, TreeViewGlobal.LocationCollection[this.ParentID.ToString()], CahePoint); } if (TreeViewGlobal.LocationCollection.ContainsKey(this.id.ToString())) { if (TreeViewGlobal.ParentChildPair.ContainsKey(this.id.ToString())) { foreach (var i in TreeViewGlobal.ParentChildPair[this.id.ToString()]) { if (TreeViewGlobal.LocationCollection.ContainsKey(i)) { TreeViewGlobal.Update(this.id, int.Parse(i), CahePoint, TreeViewGlobal.LocationCollection[i]); } } } } } catch { } // MoveEvent?.Invoke(); }
private void TreeViewNodeControl_Loaded(object sender, RoutedEventArgs e) { this.RenderTransform = new TranslateTransform(); if (_buttonPosition == null) { _buttonPosition = this.TransformToAncestor(Container).Transform(new System.Windows.Point(0, 0)); } Point CahePoint = new Point(); CahePoint.Y = this.TransformToAncestor(Container).Transform(new System.Windows.Point(0, 0)).Y + 25; CahePoint.X = this.TransformToAncestor(Container).Transform(new System.Windows.Point(0, 0)).X + 25; if (!TreeViewGlobal.LocationCollection.ContainsKey(this.id.ToString())) { TreeViewGlobal.LocationCollection.Add(this.id.ToString(), CahePoint); } else { TreeViewGlobal.LocationCollection[this.id.ToString()] = CahePoint; } try { if (TreeViewGlobal.LocationCollection.ContainsKey(this.ParentID.ToString())) { TreeViewGlobal.Update(this.ParentID, this.id, TreeViewGlobal.LocationCollection[this.ParentID.ToString()], CahePoint); } if (TreeViewGlobal.LocationCollection.ContainsKey(this.id.ToString())) { foreach (var i in TreeViewGlobal.ParentChildPair[this.id.ToString()]) { TreeViewGlobal.Update(this.id, int.Parse(i), CahePoint, TreeViewGlobal.LocationCollection[i]); } } } catch { } }