Exemple #1
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         dragging      = true;
         dragStart     = e.Location;
         sizeStart     = Size;
         locationStart = Location;
         CurGrip       = CheckGrip(e.Location);
     }
 }
Exemple #2
0
        public DragGrip GetItem(string name, string text, TranslateTransform translateTransform,
                                double width, Brush backgound, Thickness margin, string contextMenuName)
        {
            var newItem = new DragGrip
            {
                Name            = name,
                RenderTransform = translateTransform,
                IsDragable      = false,
                IsToolBarItem   = true,
                IsSelected      = false,
                ContextMenuName = contextMenuName
            };

            var binding = new Binding
            {
                RelativeSource = new RelativeSource
                {
                    Mode         = RelativeSourceMode.FindAncestor,
                    AncestorType = typeof(DragGrip)
                },
                Path                = new PropertyPath("IsSelected"),
                Converter           = new BoolToIntConverter(),
                ConverterParameter  = "2.5",
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Mode                = BindingMode.TwoWay
            };
            var border = new Border
            {
                Background  = backgound,
                Width       = width,
                Height      = 22,
                BorderBrush = Brushes.DeepSkyBlue,
                Child       =
                    new TextBlock
                {
                    Text                = text,
                    FontSize            = 16,
                    Foreground          = Brushes.White,
                    VerticalAlignment   = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    Margin              = margin
                }
            };

            border.SetBinding(Border.BorderThicknessProperty, binding);
            newItem.Child       = border;
            newItem.ContextMenu = MainCanvas.FindResource(contextMenuName) as ContextMenu;

            return(newItem);
        }
Exemple #3
0
 private void AddInLists(List <DragGrip> list, DragGrip item)
 {
     list.Add(item);
     MainCanvas.Children.Add(item);
 }
Exemple #4
0
 protected override void OnMouseUp(MouseEventArgs e)
 {
     dragging = false;
     CurGrip  = DragGrip.NoGrip;
     Cursor   = Cursors.Default;
 }