Exemple #1
0
        internal static void Load(DockControl dockControl, DockLayout layout, Func <object, DockItem> loadDockItemCallback)
        {
            Debug.Assert(dockControl.DockItems.Count == 0);

            dockControl.DockTreeZOrder       = layout.DockTreeZOrder;
            dockControl.LeftDockTreeWidth    = layout.LeftDockTreeWidth;
            dockControl.RightDockTreeWidth   = layout.RightDockTreeWidth;
            dockControl.TopDockTreeHeight    = layout.TopDockTreeHeight;
            dockControl.BottomDockTreeHeight = layout.BottomDockTreeHeight;
            DockItemCollection items = dockControl.DockItems;

            foreach (DockItemReference itemRef in layout.DockItems)
            {
                DockItem item = loadDockItemCallback == null ? (DockItem)itemRef.Target : loadDockItemCallback(itemRef.Target);
                item.AutoHideSize = itemRef.AutoHideSize;
                items.AddInternal(item);
            }

            foreach (ShowAction action in layout.ShowActions)
            {
                action.Run(dockControl);
            }
        }
        public override void Loaded(DockItem item)
        {
            base.Loaded(item);

            item.Title = "Component List";

            foreach (ComponentFactoryInformation cfi in ComponentManager.ComponentFinder.ComponentInfos)
            {
                List <object> row = new List <object>();
                row.Add(cfi);
                row.Add(0);
                row.Add(cfi.ComponentType.ToString());
                row.Add(cfi.Comment);
                listStore.AppendValues(row.ToArray());
            }

            Persistence p = (Persistence)ComponentManager.LoadObject("ComponentList", typeof(Persistence), item); // TODO early prototype - abolish, implement IPersistable instead!

            if (p != null)
            {
                p.LoadColumnWidth(treeview1.Columns);
            }
        }
Exemple #3
0
        public static DockPaneNodeStruct FromDockPaneNode(DockPaneNode paneNode)
        {
            DockControl dockControl = paneNode.DockControl;

            Debug.Assert(dockControl != null);

            int          ancestorSplitLevel = 0;
            DockPaneNode node;

            for (node = paneNode; node is DockPaneSplit; node = (node as DockPaneSplit).Child1)
            {
                ancestorSplitLevel++;
            }
            DockPane pane = node as DockPane;

            Debug.Assert(pane != null);

            DockItem item       = pane.Items[0];
            int      itemIndex  = dockControl.DockItems.IndexOf(item);
            bool     isFloating = paneNode.IsFloating;

            return(new DockPaneNodeStruct(itemIndex, isFloating, ancestorSplitLevel));
        }
Exemple #4
0
        private void UpdateActivatedPanes()
        {
            int      lastActivePaneIndex = _activatedPanes.Count - 1;
            DockPane lastActivePane      = lastActivePaneIndex >= 0 ? _activatedPanes[lastActivePaneIndex] : null;

            if (lastActivePane != null)
            {
                DockItem selectedItem = lastActivePane.SelectedItem;
                if (selectedItem == null || !selectedItem.IsSelected)
                {
                    _activatedPanes.Remove(lastActivePane);
                }
            }

            for (int i = lastActivePaneIndex - 1; i >= 0; i--)
            {
                DockPane pane = _activatedPanes[i];
                if (pane.SelectedItem == null || pane.IsAutoHide)
                {
                    _activatedPanes.Remove(pane);
                }
            }
        }
Exemple #5
0
        public InterTabTransfer(object item, DockItem originatorContainer, Point dragStartItemOffset,
                                IList <FloatingItemSnapShot> floatingItemSnapShots)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (originatorContainer == null)
            {
                throw new ArgumentNullException(nameof(originatorContainer));
            }
            if (floatingItemSnapShots == null)
            {
                throw new ArgumentNullException(nameof(floatingItemSnapShots));
            }

            _transferReason = InterTabTransferReason.Reentry;

            _item = item;
            _originatorContainer   = originatorContainer;
            _dragStartItemOffset   = dragStartItemOffset;
            _floatingItemSnapShots = floatingItemSnapShots;
        }
Exemple #6
0
        internal void ShowComponentInfoPad(BasicNodeControl component)
        {
            DockItem infoDockItem = m_mainWindowDockFrame.GetItem(component.ExperimentNode.ID);

            if (infoDockItem == null)
            {
                infoDockItem         = m_mainWindowDockFrame.AddItem(component.ExperimentNode.ID);
                infoDockItem.Content = CreateInfoWidget(component);
            }

            infoDockItem.Label         = component.ExperimentNode.Data.Metadata.Label;
            infoDockItem.DefaultHeight = 150;
            infoDockItem.DefaultWidth  = 200;

            infoDockItem.DefaultLocation = GetLocation();

            m_mainWindowDockFrame.SetVisible(infoDockItem, true);

            infoPads.AddLast(infoDockItem);

            //TODO: floating info panels
            //there is still problem with below solution - if user resizes the window it frequently crashes (not always though)
            //however it crashes only when running from MONO Develop with attached debugger

            //            //this line allows setting window as floating automatically, to consider in future
            //            m_dockFrame.SetStatus(infoDockItem, DockItemStatus.Floating);
            //            Gdk.Rectangle floatRectangle = infoDockItem.FloatingPosition;
            //            floatRectangle.Width = 350;
            //            floatRectangle.Height = 180;
            //
            //            // TODO set location of info box next to the component node
            //            // to do this probably some translation will be needed of componentControl.DisplayBox on experiment canvas
            //            // to absolute x and y in relation to window
            //            floatRectangle.X = 600;
            //            floatRectangle.Y = 600;
            //            infoDockItem.SetFloatMode(floatRectangle);
        }
        void OnWorkspacesChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.NewItems != null && e.NewItems.Count != 0)
            {
                foreach (WorkspaceViewModel workspace in e.NewItems)
                {
                    DockItem dockItem = new DockItem();
                    dockItem.HideOnPerformClose       = false;
                    dockItem.Content                  = workspace;
                    dockItem.AllowedDockTreePositions = AllowedDockTreePositions.Document;
                    dockItem.TabText                  = workspace.DisplayName;
                    dockItem.Show(this, DockPosition.Document);
                    _dockItems.Add(workspace, dockItem);
                }
            }

            if (e.OldItems != null && e.OldItems.Count != 0)
            {
                foreach (WorkspaceViewModel workspace in e.OldItems)
                {
                    _dockItems.Remove(workspace);
                }
            }
        }
Exemple #8
0
        internal DockPane AddItem(DockItem item, DockPaneNode targetPaneNode, bool isAutoHide, Dock side, SplitterDistance size, bool isSizeForTarget)
        {
            Debug.Assert(targetPaneNode.DockTree == this);

            DockPane pane = DockControl.PaneManager.CreatePane(item, isAutoHide);

            AddDirtyNode(pane);
            AddDirtyNode(targetPaneNode);

            DockPaneSplit parent            = targetPaneNode.Parent;
            DockPaneNode  child1            = side == Dock.Left || side == Dock.Top ? pane : targetPaneNode;
            DockPaneNode  child2            = side == Dock.Left || side == Dock.Top ? targetPaneNode : pane;
            Orientation   orientation       = side == Dock.Left || side == Dock.Right ? Orientation.Horizontal : Orientation.Vertical;
            bool          isSplitterTopLeft = isSizeForTarget ? child1 == targetPaneNode : child2 == targetPaneNode;

            targetPaneNode.ClearParent();
            DockPaneSplit newSplit;

            newSplit = new DockPaneSplit(child1, child2, orientation, isSplitterTopLeft, size);
            AddDirtyNode(newSplit);
            if (parent != null)
            {
                AddDirtyNode(parent);
                parent.SetSibling(parent.GetSibling(targetPaneNode), newSplit);
            }
            else
            {
                SetRootNode(newSplit, false);
            }
            AddPaneToCollection(pane);
            Debug.Assert(newSplit.Child1 != null);
            Debug.Assert(newSplit.Child1.Parent == newSplit);
            Debug.Assert(newSplit.Child2 != null);
            Debug.Assert(newSplit.Child2.Parent == newSplit);
            return(pane);
        }
Exemple #9
0
        /// <exclude />
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonDown(e);
            if (e.Handled)
            {
                return;
            }

            if (e.ClickCount == 1)
            {
                DockItem dockItem = DockItem;
                if (dockItem != null)
                {
                    dockItem.Activate();
                    UpdateLayout(); // Fix in 2.0.4846: this can avoid unnecessary mouse move event caused by layout change
                }
                DockManager.BeginDrag(this, this, e);
                e.Handled = true;
            }
            else if (e.ClickCount == 2)
            {
                e.Handled = DockCommands.Execute(this, DoubleClickCommand);
            }
        }
Exemple #10
0
        /// <summary>
        /// Initialize the window pad in the given dock frame.
        /// </summary>
        /// <param name='dockFrame'>
        /// Dock frame.
        /// </param>
        public void Initialize(DockFrame dockFrame)
        {
            m_dockFrame = dockFrame;
            DockItem outputDockingWindow = m_dockFrame.AddItem("Output");

            outputDockingWindow.Label           = Catalog.GetString("Output");
            outputDockingWindow.DefaultHeight   = 100;
            outputDockingWindow.DefaultLocation = "ExperimentPad/Bottom"; //or experiment
            outputDockingWindow.Behavior       |= DockItemBehavior.CantClose;

            DockItemToolbar toolbar = outputDockingWindow.GetToolbar(PositionType.Top);

            m_buttonClear          = new Button(new Gtk.Image("gtk-clear", IconSize.Menu));
            m_buttonClear.Clicked += new EventHandler(OnButtonClearClick);
            toolbar.Add(m_buttonClear);

            toolbar.ShowAll();

            outputDockingWindow.Content = CreateOutputView();

            LoadIcons();

            m_initialized = true;
        }
        public DockItemViewModel(DockItem model)
        {
            if (model != null)
            {
                Model = model;

                model.PropertyChanged += (s, e) =>
                {
                    if (e.PropertyName == "Image")
                    {
                        IconImage = ImageToBitmapSource(model.Image);
                    }
                };

                Model       = model;
                IconImage   = ImageToBitmapSource(model.Image);
                Name        = model.Name;
                Width       = 60;
                Height      = 60;
                ContextMenu = model.MenuItems.Select(m => new ContextMenuItemViewModel(m)).ToList();

                LeftClickCommand = new RelayCommand(() => Model.OnLeftClick());
            }
        }
Exemple #12
0
 private void Select()
 {
     DockItem.Show(DockItemShowMethod.Select);
     IsMouseOverTab = true;
 }
 internal sealed override void Run(DockItem dockItem, DockPane targetPane)
 {
     dockItem.Show(targetPane, Index, ShowMethod);
 }
 public ToggleAutoHideEventArgs(DockItem dockItem, bool isAutoHide, DockItemShowMethod showMethod)
     : base(dockItem)
 {
     _isAutoHide = isAutoHide;
     _showMethod = showMethod;
 }
Exemple #15
0
 public FloatRequestedEventArgs(RoutedEvent routedEvent, IInteractive source, DockItem dockItem)
     : base(routedEvent, source, dockItem)
 {
     _dockItem = dockItem;
 }
Exemple #16
0
 internal static Target Tab(DockItem targetItem)
 {
     Debug.Assert(targetItem != null);
     return(new Target(targetItem));
 }
Exemple #17
0
 /// <exclude />
 protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
 {
     base.OnMouseLeftButtonDown(e);
     MouseHoverTimer = null;
     DockItem.Activate();
 }
 private void Initialize(DockItem dockItem, SplitterDistance oldValue, SplitterDistance newValue)
 {
     _dockItemIndex = dockItem.DockControl.DockItems.IndexOf(dockItem);
     _oldValue      = oldValue;
     _newValue      = newValue;
 }
 public UpdateAutoHideSizeCommand(DockItem dockItem, SplitterDistance oldValue, SplitterDistance newValue)
 {
     Initialize(dockItem, oldValue, newValue);
 }
Exemple #20
0
 public static bool IsHidden(this DockItem item)
 {
     return(item.DockState == DockItemState.Hidden);
 }
Exemple #21
0
 private string GetString(DockItem item)
 {
     return(item == null ? "null" : item.TabText);
 }
Exemple #22
0
 public static bool IsSimple(this DockItem item)
 {
     return(item is DockItemGroup == false);
 }
Exemple #23
0
 private Target(DockItem targetItem)
 {
     Debug.Assert(targetItem != null);
     _targetItem     = targetItem;
     _targetPosition = DropPosition.Tab;
 }
 public HideEventArgs(DockItem dockItem)
     : base(dockItem)
 {
 }
Exemple #25
0
 internal static Target FillPane(DockItem targetItem)
 {
     Debug.Assert(targetItem != null);
     Debug.Assert(targetItem.FirstPane != null);
     return(new Target(targetItem.FirstPane, DockPanePreviewPlacement.Fill));
 }
Exemple #26
0
 // currently nothing do to, but special cases can be considered
 void ILocalizableComponent.LocalizationChanged(DockItem item)
 {
 }
Exemple #27
0
 public FloatRequestedEventArgs(RoutedEvent routedEvent, DockItem dockItem)
     : base(routedEvent, dockItem)
 {
 }
Exemple #28
0
 bool IDragSource.CanDrop(DockItem targetItem)
 {
     return(DockManager.CanDrop(DockPane, targetItem));
 }
Exemple #29
0
        /// <summary>
        /// Shows the component info pad.
        /// </summary>
        /// <param name="component">Component.</param>
        /// <param name="defaultLocationX">Default location x for the floating window</param>
        /// <param name="defaultLocationY">Default location y for the floating window</param>
        /// <param name="onVisibleChanged">The action that is executed when visibility of window changes.</param>
        internal void ShowComponentInfoPad(BasicNodeControl component,
                                           int defaultLocationX, int defaultLocationY, System.Action <Boolean> onVisibleChanged)
        {
            DockItem infoDockItem = m_mainWindowDockFrame.GetItem(component.ExperimentNode.ID);

            if (infoDockItem == null)
            {
                infoDockItem         = m_mainWindowDockFrame.AddItem(component.ExperimentNode.ID);
                infoDockItem.Content = CreateInfoWidget(component);

                if (component is DecisionNodeControl)
                {
                    //    string m = component.ExperimentNode.ID;
                    //  if (m. ID.Equals (DecisionMetadataDefinition.GotoDecisionGuid)) {
                    if (component.ExperimentNode.Data.Metadata.Label.Equals("Goto Decision"))
                    {
                        infoDockItem.Label = GOTO_INFO_PANEL_TITLE_LABEL;
                    }
                    else
                    {
                        infoDockItem.Label = DECISION_INFO_PANEL_TITLE_LABEL;
                    }
                }
                else if (component is LoopNodeControl)
                {
                    infoDockItem.Label = LOOP_INFO_PANEL_TITLE_LABEL;
                }
                else
                {
                    infoDockItem.Label = component.ExperimentNode.Data.Metadata.Label;
                }

                infoDockItem.DefaultHeight = 150;
                //infoDockItem.DefaultWidth = 200;
                // HERZUM SPRINT 4.2: TLAB-226
                infoDockItem.DefaultHeight = 100;
                if (component is ScopeNodeControl || component is CommentNodeControl)
                {
                    infoDockItem.DefaultHeight = 50;
                }
                // END HERZUM SPRINT 4.2: TLAB-226

                infoDockItem.DefaultLocation = GetLocation();

                infoDockItem.Visible = true;

                //attach action on visible changed, so that if window is closed then it toggles off the info icon
                infoDockItem.VisibleChanged += (object sender, EventArgs e) =>
                {
                    bool isVisible = ((DockItem)sender).Visible;
                    onVisibleChanged(isVisible);
                };

                AttachMouseOverHighlightHandlers(component, infoDockItem);

                infoPads.AddLast(infoDockItem);

                //Float window
                //this line allows setting window as floating automatically, to consider in future
                m_mainWindowDockFrame.SetStatus(infoDockItem, DockItemStatus.Floating);
                Gdk.Rectangle floatRectangle = infoDockItem.FloatingPosition;
                floatRectangle.Width = 350;
                //floatRectangle.Height = 180;
                // HERZUM SPRINT 4.2: TLAB-225
                floatRectangle.Height = 100;
                if (component is ScopeNodeControl || component is CommentNodeControl)
                {
                    floatRectangle.Height = 50;
                }
                // END HERZUM SPRINT 4.2: TLAB-225

                //location of info box next to the component node just sligthly below cursor click
                floatRectangle.X = defaultLocationX;
                floatRectangle.Y = defaultLocationY + 20;
                infoDockItem.SetFloatMode(floatRectangle);
            }
            else
            {
                //if already exists just set it visible
                infoDockItem.Visible = true;
            }
        }
Exemple #30
0
 void IDragSource.Drop(DockItem targetItem)
 {
     DockManager.Drop(DockPane, targetItem);
 }