Example #1
0
        private void CreateControlTargets(TabbedGroups host, TabGroupLeaf leaf)
        {
            // Get the total size of the tabbed groups control itself in screen coordinates
            Rectangle totalSize = host.RectangleToScreen(host.ClientRectangle);

            int horzThird = totalSize.Width / 3;
            int vertThird = totalSize.Height / 3;

            // Create the four display rectangles
            Rectangle leftDisplay   = new Rectangle(totalSize.X, totalSize.Y, horzThird, totalSize.Height);
            Rectangle rightDisplay  = new Rectangle(totalSize.Right - horzThird, totalSize.Y, horzThird, totalSize.Height);
            Rectangle topDisplay    = new Rectangle(totalSize.X, totalSize.Y, totalSize.Width, vertThird);
            Rectangle bottomDisplay = new Rectangle(totalSize.X, totalSize.Bottom - vertThird, totalSize.Width, vertThird);

            // Create the four hot rectangles
            Rectangle leftHot   = new Rectangle(totalSize.X, totalSize.Y, _hotVector, totalSize.Height);
            Rectangle rightHot  = new Rectangle(totalSize.Right - _hotVector, totalSize.Y, _hotVector, totalSize.Height);
            Rectangle topHot    = new Rectangle(totalSize.X, totalSize.Y, totalSize.Width, _hotVector);
            Rectangle bottomHot = new Rectangle(totalSize.X, totalSize.Bottom - _hotVector, totalSize.Width, _hotVector);

            // Create the four default targets which represent each control edge
            _targets.Add(new Target(leftHot, leftDisplay, leaf, Target.TargetActions.ControlLeft));
            _targets.Add(new Target(rightHot, rightDisplay, leaf, Target.TargetActions.ControlRight));
            _targets.Add(new Target(topHot, topDisplay, leaf, Target.TargetActions.ControlTop));
            _targets.Add(new Target(bottomHot, bottomDisplay, leaf, Target.TargetActions.ControlBottom));
        }
Example #2
0
        /// <summary>
        /// Initialize a new instance of the TargetArea class.
        /// </summary>
        /// <param name="squares">Showing as squares or diamonds.</param>
        /// <param name="host">Hosting tabbed groups instance.</param>
        /// <param name="leaf">Leaf that is being dragged.</param>
        public TargetAreaSides(bool squares, TabbedGroups host, TabGroupLeaf leaf)
        {
            // Remember host for later
            _squares = squares;

            // Get the total size of the tabbed groups control itself in screen coordinates
            _screenRect = host.RectangleToScreen(host.ClientRectangle);

            int horzThird = _screenRect.Width / 3;
            int vertThird = _screenRect.Height / 3;

            // Create the four display rectangles
            Rectangle leftDisplay   = new Rectangle(_screenRect.X, _screenRect.Y, horzThird, _screenRect.Height);
            Rectangle rightDisplay  = new Rectangle(_screenRect.Right - horzThird, _screenRect.Y, horzThird, _screenRect.Height);
            Rectangle topDisplay    = new Rectangle(_screenRect.X, _screenRect.Y, _screenRect.Width, vertThird);
            Rectangle bottomDisplay = new Rectangle(_screenRect.X, _screenRect.Bottom - vertThird, _screenRect.Width, vertThird);

            // Create the four default targets which represent each control edge
            _left   = new Target(leftDisplay, leftDisplay, leaf, Target.TargetActions.ControlLeft);
            _right  = new Target(rightDisplay, rightDisplay, leaf, Target.TargetActions.ControlRight);
            _top    = new Target(topDisplay, topDisplay, leaf, Target.TargetActions.ControlTop);
            _bottom = new Target(bottomDisplay, bottomDisplay, leaf, Target.TargetActions.ControlBottom);

            // Not currently inside the hot area
            _hotInside = false;
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the TargetManagerZones class.
 /// </summary>
 /// <param name="squares">Show as squares or diamonds.</param>
 /// <param name="host">Control that is requesting target management.</param>
 /// <param name="leaf">Source leaf causing drag operation.</param>
 /// <param name="source">Source TabControl of drag operation.</param>
 public TargetManagerZones(bool squares,
                           TabbedGroups host,
                           TabGroupLeaf leaf,
                           Controls.TabControl source)
     : base(squares, host, leaf, source)
 {
 }
Example #4
0
        private void tabbedGroups_PageCloseRequest(TabbedGroups tg, TGCloseRequestEventArgs e)
        {
            e.Cancel = true;
            Editor editor = (Editor)e.TabPage.Controls[0];

            editor.Close(false);
        }
Example #5
0
 private void OnControlPageChanged(TabbedGroups tg, Crownwood.DotNetMagic.Controls.TabPage selectedPage)
 {
     if (_component.StackStyle == StackStyle.ShowMultiple)
     {
         if (selectedPage != null)
         {
             ChangeComponentPageFromLeaf(tg.LeafForPage(selectedPage));
         }
     }
 }
Example #6
0
        private void TabbedGroupPageClosePressedEventHandler(TabbedGroups groups, TGCloseRequestEventArgs e)
        {
            var wv = (WorkspaceView)e.TabPage.Tag;

            // We cancel so that DotNetMagic doesn't remove the tab; we want
            // to do that programatically
            e.Cancel = true;

            // raise close requested event
            wv.RaiseCloseRequested();
        }
Example #7
0
        protected void InternalConstruct(TabbedGroups tabbedGroups, TabGroupBase parent)
        {
            // Assign initial values
            _tabbedGroups = tabbedGroups;
            _parent       = parent;
            _unique       = _count++;

            // Defaults
            _tag     = null;
            _space   = 100m;
            _minSize = new Size(_tabbedGroups.DefaultGroupMinimumWidth,
                                _tabbedGroups.DefaultGroupMinimumHeight);
        }
Example #8
0
        /// <summary>
        /// Initializes a new instance of the TargetManager class.
        /// </summary>
        /// <param name="squares">Show as squares or diamonds.</param>
        /// <param name="host">Control that is requesting target management.</param>
        /// <param name="leaf">Source leaf causing drag operation.</param>
        /// <param name="source">Source TabControl of drag operation.</param>
        public TargetManager(bool squares,
                             TabbedGroups host,
                             TabGroupLeaf leaf,
                             Controls.TabControl source)
        {
            // Define state
            _squares    = squares;
            _host       = host;
            _leaf       = leaf;
            _source     = source;
            _lastTarget = null;

            // Setup targets
            Initialize();
        }
Example #9
0
        /// <summary>
        /// Begins tracking toolset activities and raising associated events.
        /// </summary>
        /// <exception cref="InvalidOperationException">Start() has already been called on this instance.</exception>
        public void Start()
        {
            if (IsRunning)
            {
                return;
            }

            isRunning = true;

            /*
             * Track when a module is opened, when resources are added to or removed from
             * the module, when blueprints are added to or removed from the module, and
             * when objects are added to or removed from an area.
             */

            WatchModule(NWN2ToolsetMainForm.App.Module);

            NWN2ToolsetMainForm.ModuleChanged += delegate(object oSender, ModuleChangedEventArgs e)
            {
                OnModuleChanged(oSender, e);
                WatchModule(NWN2ToolsetMainForm.App.Module);
            };

            FieldInfo[] fields = typeof(NWN2ToolsetMainForm).GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
            foreach (FieldInfo field in fields)
            {
                /*
                 * Track when resource viewers are opening or closing.
                 */
                if (field.FieldType == typeof(TabbedGroups))
                {
                    TabbedGroups     tg     = (TabbedGroups)field.GetValue(NWN2ToolsetMainForm.App);
                    CollectionChange opened = new CollectionChange(ViewerOpened);
                    CollectionChange closed = new CollectionChange(ViewerClosed);

                    tg.ActiveLeaf.TabPages.Inserted += opened;
                    tg.ActiveLeaf.TabPages.Removed  += closed;

                    // ActiveLeaf is disposed whenever all viewers are closed, so attach handlers again:
                    tg.ActiveLeafChanged += delegate
                    {
                        tg.ActiveLeaf.TabPages.Inserted += opened;
                        tg.ActiveLeaf.TabPages.Removed  += closed;
                    };
                }
            }
        }
Example #10
0
        public TabGroupLeaf(TabbedGroups tabbedGroups, TabGroupBase parent)
            : base(tabbedGroups, parent)
        {
            // Create our managed tab control instance
            _tabControl = new Controls.TabControl();

            // We need page drag to begin when mouse dragged a small distance
            _tabControl.DragFromControl = false;

            // We need to monitor attempts to drag into the tab control
            _dragEntered           = false;
            _tabControl.AllowDrop  = true;
            _tabControl.DragDrop  += new DragEventHandler(OnControlDragDrop);
            _tabControl.DragEnter += new DragEventHandler(OnControlDragEnter);
            _tabControl.DragLeave += new EventHandler(OnControlDragLeave);

            // Need notification when page drag begins
            _tabControl.PageDragStart += new MouseEventHandler(OnPageDragStart);
            _tabControl.PageDragMove  += new MouseEventHandler(OnPageDragMove);
            _tabControl.PageDragEnd   += new MouseEventHandler(OnPageDragEnd);
            _tabControl.PageDragQuit  += new MouseEventHandler(OnPageDragQuit);

            // Hook into tab page collection events
            _tabControl.TabPages.Cleared  += new CollectionClear(OnTabPagesCleared);
            _tabControl.TabPages.Inserted += new CollectionChange(OnTabPagesInserted);
            _tabControl.TabPages.Removed  += new CollectionChange(OnTabPagesRemoved);

            // Hook into page level events
            _tabControl.GotFocus     += new EventHandler(OnGainedFocus);
            _tabControl.PageGotFocus += new EventHandler(OnGainedFocus);
            _tabControl.ClosePressed += new EventHandler(OnClose);

            // Manager only created at start of drag operation
            _targetManager = null;

            DefinePopupMenuForControl(_tabControl);

            // Setup the correct 'HideTabsMode' for the control
            Notify(TabGroupBase.NotifyCode.DisplayTabMode);

            // Define the default setup of TabControl and allow developer to customize
            _tabbedGroups.OnTabControlCreated(_tabControl);
        }
Example #11
0
        private void TabbedGroupPageChangedEventHandler(TabbedGroups tg, Crownwood.DotNetMagic.Controls.TabPage tp)
        {
            // de-activate the previous workspace before activating the new one
            var lastActive = _workspaceActivationOrder.LastElement;

            if (lastActive != null)
            {
                lastActive.SetActiveStatus(false);
            }

            // important to check tp != null to account for the case where the last workspace closes
            var nowActive = (tp != null) ? (WorkspaceView)tp.Tag : null;

            if (nowActive != null)
            {
                nowActive.SetVisibleStatus(true);   // the very first time the page is selected, need to change its visible status
                nowActive.SetActiveStatus(true);
                _workspaceActivationOrder.Add(nowActive);
            }
        }
Example #12
0
        public TargetManager(TabbedGroups host, TabGroupLeaf leaf, Controls.TabControl source)
        {
            // Define state
            _host       = host;
            _leaf       = leaf;
            _source     = source;
            _lastTarget = null;

            // Create collection to hold generated targets
            _targets = new TargetCollection();

            // Process each potential leaf in turn
            TabGroupLeaf tgl = host.FirstLeaf();

            while (tgl != null)
            {
                // Create all possible targets for this leaf
                CreateTargets(tgl);

                // Enumerate all leafs
                tgl = host.NextLeaf(tgl);
            }
        }
Example #13
0
        /// <summary>
        /// Makes changes to the standard Neverwinter Nights 2
        /// toolset user interface. Should only be called
        /// when the toolset is first loaded.
        /// </summary>
        public void ModifyUI()
        {
            FieldInfo[] fields = typeof(NWN2ToolsetMainForm).GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
            foreach (FieldInfo field in fields)
            {
                /*
                 * Track when resource viewers are opening or closing.
                 */
                if (field.FieldType == typeof(TabbedGroups))
                {
                    TabbedGroups     tg     = (TabbedGroups)field.GetValue(NWN2ToolsetMainForm.App);
                    CollectionChange opened = new CollectionChange(ViewerOpened);
                    tg.ActiveLeaf.TabPages.Inserted += opened;

                    // ActiveLeaf is disposed whenever all viewers are closed, so attach handlers again:
                    tg.ActiveLeafChanged += delegate
                    {
                        tg.ActiveLeaf.TabPages.Inserted += opened;
                    };
                }
            }

            WatchForPropertyGridChanges();
        }
		private void OnControlPageChanged(TabbedGroups tg, Crownwood.DotNetMagic.Controls.TabPage selectedPage)
		{
			if (_component.StackStyle == StackStyle.ShowMultiple)
			{
				if (selectedPage != null)
					ChangeComponentPageFromLeaf(tg.LeafForPage(selectedPage));
			}
		}
 private void tabbedGroupsWebSites_PageCloseRequest(TabbedGroups tg, TGCloseRequestEventArgs e)
 {
     try
     {
         e.TabPage.Dispose();
     }
     catch
     {
     }
 }
Example #16
0
 private void OnTabbedGroupsTabControlCreated(TabbedGroups tabbedGroups, Crownwood.DotNetMagic.Controls.TabControl tabControl)
 {
     InitializeTabControl(tabControl);
 }
Example #17
0
        private void TabbedGroupPageClosePressedEventHandler(TabbedGroups groups, TGCloseRequestEventArgs e)
        {
            var wv = (WorkspaceView)e.TabPage.Tag;

            // We cancel so that DotNetMagic doesn't remove the tab; we want
            // to do that programatically
            e.Cancel = true;

            // raise close requested event
            wv.RaiseCloseRequested();
        }
Example #18
0
        private void TabbedGroupPageChangedEventHandler(TabbedGroups tg, Crownwood.DotNetMagic.Controls.TabPage tp)
        {
            // de-activate the previous workspace before activating the new one
            var lastActive = _workspaceActivationOrder.LastElement;
            if (lastActive != null)
            {
                lastActive.SetActiveStatus(false);
            }

            // important to check tp != null to account for the case where the last workspace closes
            var nowActive = (tp != null) ? (WorkspaceView)tp.Tag : null;
            if (nowActive != null)
            {
                nowActive.SetVisibleStatus(true);   // the very first time the page is selected, need to change its visible status
                nowActive.SetActiveStatus(true);
                _workspaceActivationOrder.Add(nowActive);
            }
        }
Example #19
0
 public TabGroupSequence(TabbedGroups tabbedGroups, TabGroupBase parent)
     : base(tabbedGroups, parent)
 {
     InternalConstruct(null, Common.Direction.Horizontal);
 }
Example #20
0
 public TabGroupSequence(TabbedGroups tabbedGroups, TabGroupBase parent, River.Orqa.Controls.Common.Direction direction)
     : base(tabbedGroups, parent)
 {
     InternalConstruct(null, direction);
 }
Example #21
0
 public TabGroupSequence(TabbedGroups tabbedGroups)
     : base(tabbedGroups)
 {
     // Root instance always defaults to being horizontal
     InternalConstruct(tabbedGroups, Common.Direction.Horizontal);
 }
Example #22
0
 private void OnTabbedGroupsTabControlCreated(TabbedGroups tabbedGroups, Crownwood.DotNetMagic.Controls.TabControl tabControl)
 {
     InitializeTabControl(tabControl);
 }
Example #23
0
 public TabGroupBase(TabbedGroups tabbedGroups)
 {
     InternalConstruct(tabbedGroups, null);
 }
Example #24
0
 public TabGroupSequence(TabbedGroups tabbedGroups, TabGroupBase parent, Direction direction)
     : base(tabbedGroups, parent)
 {
     InternalConstruct(null, direction);
 }
Example #25
0
 public TabGroupBase(TabbedGroups tabbedGroups, TabGroupBase parent)
 {
     InternalConstruct(tabbedGroups, parent);
 }