Example #1
0
        /// <summary>
        /// Walks up the visual tree starting with the specified DependencyObject,
        /// looking for a UIElement which is a child of the Canvas.  If a suitable
        /// element is not found, null is returned.  If the 'depObj' object is a
        /// UIElement in the Canvas's Children collection, it will be returned.
        /// </summary>
        /// <param name="depObj">
        /// A DependencyObject from which the search begins.
        /// </param>
        public UIElement FindCanvasChild(DependencyObject depObj)
        {
            while (depObj != null)
            {
                // If the current object is a UIElement which is a child of the
                // Canvas, exit the loop and return it.
                UIElement elem = depObj as UIElement;
                if (elem != null && base.Children.Contains(elem))
                {
                    break;
                }

                if (!DragCanvas.GetCanBeDragged(elem))
                {
                    return(null);
                }


                // VisualTreeHelper works with objects of type Visual or Visual3D.
                // If the current object is not derived from Visual or Visual3D,
                // then use the LogicalTreeHelper to find the parent element.
                if (depObj is Visual || depObj is Visual3D)
                {
                    depObj = VisualTreeHelper.GetParent(depObj);
                }
                else
                {
                    depObj = LogicalTreeHelper.GetParent(depObj);
                }
            }
            return(depObj as UIElement);
        }
        public TabItem Add(string id, string header)
        {
            var ellipse = new Ellipse {Fill = Brushes.Green, Width = 30.0, Height = 30.0};
            var canvas = new DragCanvas {Name = "canvas_" + id};
            var ti = new TabItem { Name = "tab_"+id, Header = header, Content = canvas};
            var tci = new TabCanvasItem(ti, canvas);

            mw.tcDraw.Items.Add(ti);
            tabs.Add(id, tci);
            return ti;
        }
Example #3
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.btnAllowDragging = ((System.Windows.Controls.Primitives.ToggleButton)(target));
     return;
     case 2:
     this.btnAllowDragOutOfView = ((System.Windows.Controls.Primitives.ToggleButton)(target));
     return;
     case 3:
     this.btnOnlyShowOffsetIndicators = ((System.Windows.Controls.Primitives.ToggleButton)(target));
     return;
     case 4:
     this.dragCanvas = ((WPF.JoshSmith.Controls.DragCanvas)(target));
     return;
     case 5:
     
     #line 32 "..\..\Window1.xaml"
     ((System.Windows.Controls.ContextMenu)(target)).Opened += new System.Windows.RoutedEventHandler(this.OnContextMenuOpened);
     
     #line default
     #line hidden
     
     #line 32 "..\..\Window1.xaml"
     ((System.Windows.Controls.ContextMenu)(target)).AddHandler(System.Windows.Controls.MenuItem.ClickEvent, new System.Windows.RoutedEventHandler(this.OnMenuItemClick));
     
     #line default
     #line hidden
     return;
     case 6:
     this.menuItemBringToFront = ((System.Windows.Controls.MenuItem)(target));
     return;
     case 7:
     this.menuItemSendToBack = ((System.Windows.Controls.MenuItem)(target));
     return;
     case 8:
     this.menuItemCanBeDragged = ((System.Windows.Controls.MenuItem)(target));
     return;
     case 9:
     this.stackPanel = ((System.Windows.Controls.StackPanel)(target));
     return;
     case 10:
     
     #line 74 "..\..\Window1.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.OnButtonClick);
     
     #line default
     #line hidden
     return;
     }
     this._contentLoaded = true;
 }
Example #4
0
 public CanvasManager(DragCanvas canvas)
 {
     Canvas = canvas;
 }
 public TabCanvasItem(TabItem tabItem, DragCanvas canvas)
 {
     TabItem = tabItem;
     Canvas = canvas;
 }