Esempio n. 1
0
        /// <summary>
        /// Release unmanaged and optionally managed resources.
        /// </summary>
        /// <param name="disposing">Called from Dispose method.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
                _workspace = null;

            base.Dispose(disposing);
        }
Esempio n. 2
0
        /// <summary>
        /// Initialize a new instance of the DragTargetWorkspaceEdge class.
        /// </summary>
        /// <param name="screenRect">Rectangle for screen area.</param>
        /// <param name="hotRect">Rectangle for hot area.</param>
        /// <param name="drawRect">Rectangle for draw area.</param>
        /// <param name="hint">Target hint which should be one of the edges.</param>
        /// <param name="workspace">Control instance for drop.</param>
        /// <param name="allowFlags">Only drop pages that have one of these flags defined.</param>
        public DragTargetWorkspaceEdge(Rectangle screenRect,
                                       Rectangle hotRect,
                                       Rectangle drawRect,
                                       DragTargetHint hint,
                                       KryptonWorkspace workspace,
                                       KryptonPageFlags allowFlags)
            : base(screenRect, hotRect, drawRect, hint, workspace, allowFlags)
        {
            // Find the orientation by looking for a matching hint (we need to exclude flags from the hint enum)
            switch (hint & DragTargetHint.ExcludeFlags)
            {
            case DragTargetHint.Transfer:
            case DragTargetHint.EdgeLeft:
                Edge = VisualOrientation.Left;
                break;

            case DragTargetHint.EdgeRight:
                Edge = VisualOrientation.Right;
                break;

            case DragTargetHint.EdgeTop:
                Edge = VisualOrientation.Top;
                break;

            case DragTargetHint.EdgeBottom:
                Edge = VisualOrientation.Bottom;
                break;

            default:
                Debug.Assert(false);
                throw new ArgumentOutOfRangeException(nameof(hint), @"Hint must be an edge value.");
            }
        }
        /// <summary>
        /// Process the drag pages in the context of a target navigator.
        /// </summary>
        /// <param name="workspace">Target workspace instance.</param>
        /// <param name="target">Target workspace cell instance.</param>
        /// <param name="data">Dragged page data.</param>
        /// <returns>Last page to be transferred.</returns>
        protected KryptonPage ProcessDragEndData(KryptonWorkspace workspace,
                                                 KryptonWorkspaceCell target,
                                                 PageDragEndData data)
        {
            KryptonPage ret = null;

            // Add each source page to the target
            foreach (KryptonPage page in data.Pages)
            {
                // Only add the page if one of the allow flags is set
                if ((page.Flags & (int)AllowFlags) != 0)
                {
                    // Use event to allow decision on if the page should be dropped
                    // (or even swap the page for a different page to be dropped)
                    PageDropEventArgs e = new PageDropEventArgs(page);
                    workspace.OnPageDrop(e);

                    if (!e.Cancel && (e.Page != null))
                    {
                        target.Pages.Add(e.Page);
                        ret = e.Page;
                    }
                }
            }

            return(ret);
        }
Esempio n. 4
0
        /// <summary>
        /// Request this sequence save its information about children.
        /// </summary>
        /// <param name="workspace">Reference to owning workspace instance.</param>
        /// <param name="xmlWriter">Xml writer to save information into.</param>
        public void SaveToXml(KryptonWorkspace workspace, XmlWriter xmlWriter)
        {
            // Output standard values appropriate for all Sequence instances
            xmlWriter.WriteStartElement("WS");
            workspace.WriteSequenceElement(xmlWriter, this);

            // Persist each child sequence/cell in turn
            foreach (object child in Children)
            {
                KryptonWorkspaceSequence sequence = child as KryptonWorkspaceSequence;
                if (sequence != null)
                {
                    sequence.SaveToXml(workspace, xmlWriter);
                }

                KryptonWorkspaceCell cell = child as KryptonWorkspaceCell;
                if (cell != null)
                {
                    cell.SaveToXml(workspace, xmlWriter);
                }
            }

            // Terminate the workspace element
            xmlWriter.WriteEndElement();
        }
Esempio n. 5
0
 /// <summary>
 /// Initialize a new instance of the PageLoadingEventArgs class.
 /// </summary>
 /// <param name="workspace">Reference to owning workspace control.</param>
 /// <param name="page">Reference to owning workspace cell page.</param>
 /// <param name="xmlReader">Xml reader for persisting custom data.</param>
 public PageLoadingEventArgs(KryptonWorkspace workspace,
                             KryptonPage page,
                             XmlReader xmlReader)
     : base(workspace, xmlReader)
 {
     Page = page;
 }
 /// <summary>
 /// Initialize a new instance of the DragTargetWorkspaceEdge class.
 /// </summary>
 /// <param name="screenRect">Rectangle for screen area.</param>
 /// <param name="hotRect">Rectangle for hot area.</param>
 /// <param name="drawRect">Rectangle for draw area.</param>
 /// <param name="hint">Target hint which should be one of the edges.</param>
 /// <param name="workspace">Control instance for drop.</param>
 /// <param name="allowFlags">Only drop pages that have one of these flags defined.</param>
 public DragTargetWorkspaceEdge(Rectangle screenRect,
                                Rectangle hotRect,
                                Rectangle drawRect,
                                DragTargetHint hint,
                                KryptonWorkspace workspace,
                                KryptonPageFlags allowFlags)
     : base(screenRect, hotRect, drawRect, hint, workspace, allowFlags)
 {
     // Find the orientation by looking for a matching hint (we need to exclude flags from the hint enum)
     switch (hint & DragTargetHint.ExcludeFlags)
     {
         case DragTargetHint.Transfer:
         case DragTargetHint.EdgeLeft:
             _edge = VisualOrientation.Left;
             break;
         case DragTargetHint.EdgeRight:
             _edge = VisualOrientation.Right;
             break;
         case DragTargetHint.EdgeTop:
             _edge = VisualOrientation.Top;
             break;
         case DragTargetHint.EdgeBottom:
             _edge = VisualOrientation.Bottom;
             break;
         default:
             Debug.Assert(false);
             throw new ArgumentOutOfRangeException("Hint must be an edge value.");
     }
 }
        /// <summary>
        /// Initializes the designer with the specified component.
        /// </summary>
        /// <param name="component">The IComponent to associate with the designer.</param>
        public override void Initialize(IComponent component)
        {
            // Validate the parameter reference
            if (component == null)
            {
                throw new ArgumentNullException(nameof(component));
            }

            // Let base class do standard stuff
            base.Initialize(component);

            // The resizing handles around the control need to change depending on the
            // value of the AutoSize and AutoSizeMode properties. When in AutoSize you
            // do not get the resizing handles, otherwise you do.
            AutoResizeHandles = true;

            // Remember the actual control being designed
            _workspace = (KryptonWorkspace)component;

            // Get access to the services
            _changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));

            // We need to know when we are being removed/changed
            _changeService.ComponentRemoving += OnComponentRemoving;
        }
Esempio n. 8
0
        /// <summary>
        /// Request this cell save its information.
        /// </summary>
        /// <param name="workspace">Reference to owning workspace instance..</param>
        /// <param name="xmlWriter">Xml writer to save information into.</param>
        public void SaveToXml(KryptonWorkspace workspace, XmlWriter xmlWriter)
        {
            // Output cell values but not the actual customization of appearance
            xmlWriter.WriteStartElement("WC");
            workspace.WriteCellElement(xmlWriter, this);

            // Persist each child page in turn
            foreach (KryptonPage page in Pages)
            {
                // Are we allowed to save the page?
                if (page.AreFlagsSet(KryptonPageFlags.AllowConfigSave))
                {
                    xmlWriter.WriteStartElement("KP");
                    workspace.WritePageElement(xmlWriter, page);

                    // Give event handlers a chance to save custom data with the page
                    xmlWriter.WriteStartElement("CPD");
                    workspace.OnPageSaving(new PageSavingEventArgs(workspace, page, xmlWriter));
                    xmlWriter.WriteEndElement();

                    // Terminate the page element
                    xmlWriter.WriteEndElement();
                }
            }

            // Terminate the cell element
            xmlWriter.WriteEndElement();
        }
 /// <summary>
 /// Initialize a new instance of the PageLoadingEventArgs class.
 /// </summary>
 /// <param name="workspace">Reference to owning workspace control.</param>
 /// <param name="page">Reference to owning workspace cell page.</param>
 /// <param name="xmlReader">Xml reader for persisting custom data.</param>
 public PageLoadingEventArgs(KryptonWorkspace workspace,
                             KryptonPage page,
                             XmlReader xmlReader)
     : base(workspace, xmlReader)
 {
     _page = page;
 }
Esempio n. 10
0
 /// <summary>
 /// Initialize a new instance of the PageSavingEventArgs class.
 /// </summary>
 /// <param name="workspace">Reference to owning workspace control.</param>
 /// <param name="page">Reference to owning workspace cell page.</param>
 /// <param name="xmlWriter">Xml writer for persisting custom data.</param>
 public PageSavingEventArgs(KryptonWorkspace workspace,
                            KryptonPage page,
                            XmlWriter xmlWriter)
     : base(workspace, xmlWriter)
 {
     Page = page;
 }
 /// <summary>
 /// Initialize a new instance of the PageSavingEventArgs class.
 /// </summary>
 /// <param name="workspace">Reference to owning workspace control.</param>
 /// <param name="page">Reference to owning workspace cell page.</param>
 /// <param name="xmlWriter">Xml writer for persisting custom data.</param>
 public PageSavingEventArgs(KryptonWorkspace workspace,
                            KryptonPage page,
                            XmlWriter xmlWriter)
     : base(workspace, xmlWriter)
 {
     _page = page;
 }
Esempio n. 12
0
 /// <summary>
 /// Initialize a new instance of the DragTargetWorkspace class.
 /// </summary>
 /// <param name="screenRect">Rectangle for screen area.</param>
 /// <param name="hotRect">Rectangle for hot area.</param>
 /// <param name="drawRect">Rectangle for draw area.</param>
 /// <param name="hint">Target hint which should be one of the edges.</param>
 /// <param name="workspace">Control instance for drop.</param>
 /// <param name="allowFlags">Only drop pages that have one of these flags defined.</param>
 protected DragTargetWorkspace(Rectangle screenRect,
                               Rectangle hotRect,
                               Rectangle drawRect,
                               DragTargetHint hint,
                               KryptonWorkspace workspace,
                               KryptonPageFlags allowFlags)
     : base(screenRect, hotRect, drawRect, hint, allowFlags) =>
        /// <summary>
        /// Initialize a new instance of the KryptonWorkspaceActionList class.
        /// </summary>
        /// <param name="owner">Designer that owns this action list instance.</param>
        public KryptonWorkspaceActionList(KryptonWorkspaceDesigner owner)
            : base(owner.Component)
        {
            // Remember designer and actual component instance being designed
            _workspace = (KryptonWorkspace)owner.Component;

            // Cache service used to notify when a property has changed
            _service = (IComponentChangeService)GetService(typeof(IComponentChangeService));
        }
Esempio n. 14
0
        /// <summary>
        /// Initialize a new instance of the KryptonWorkspaceActionList class.
        /// </summary>
        /// <param name="owner">Designer that owns this action list instance.</param>
        public KryptonWorkspaceActionList(KryptonWorkspaceDesigner owner)
            : base(owner.Component)
        {
            // Remember designer and actual component instance being designed
            _workspace = (KryptonWorkspace)owner.Component;

            // Cache service used to notify when a property has changed
            _service = (IComponentChangeService)GetService(typeof(IComponentChangeService));
        }
Esempio n. 15
0
        /// <summary>
        /// Release unmanaged and optionally managed resources.
        /// </summary>
        /// <param name="disposing">Called from Dispose method.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _workspace = null;
            }

            base.Dispose(disposing);
        }
Esempio n. 16
0
 /// <summary>
 /// Initialize a new instance of the DragTargetWorkspace class.
 /// </summary>
 /// <param name="screenRect">Rectangle for screen area.</param>
 /// <param name="hotRect">Rectangle for hot area.</param>
 /// <param name="drawRect">Rectangle for draw area.</param>
 /// <param name="hint">Target hint which should be one of the edges.</param>
 /// <param name="workspace">Control instance for drop.</param>
 /// <param name="allowFlags">Only drop pages that have one of these flags defined.</param>
 public DragTargetWorkspace(Rectangle screenRect,
                            Rectangle hotRect,
                            Rectangle drawRect,
                            DragTargetHint hint,
                            KryptonWorkspace workspace,
                            KryptonPageFlags allowFlags)
     : base(screenRect, hotRect, drawRect, hint, allowFlags)
 {
     _workspace = workspace;
 }
 /// <summary>
 /// Initialize a new instance of the ViewDrawWorkspaceSeparator class.
 /// </summary>
 /// <param name="workspace">Associated workspace instance.</param>
 /// <param name="workspaceItem">Associated workspace item.</param>
 /// <param name="orientation">Visual orientation of the content.</param>
 public ViewDrawWorkspaceSeparator(KryptonWorkspace workspace,
                                   IWorkspaceItem workspaceItem,
                                   Orientation orientation)
     : base(workspace.StateDisabled.Separator, workspace.StateNormal.Separator, workspace.StateTracking, workspace.StatePressed,
            workspace.StateDisabled.Separator, workspace.StateNormal.Separator, workspace.StateTracking, workspace.StatePressed,
            CommonHelper.SeparatorStyleToMetricPadding(workspace.SeparatorStyle), orientation)
 {
     _workspace = workspace;
     _workspaceItem = workspaceItem;
 }
Esempio n. 18
0
 /// <summary>
 /// Initialize a new instance of the ViewDrawWorkspaceSeparator class.
 /// </summary>
 /// <param name="workspace">Associated workspace instance.</param>
 /// <param name="workspaceItem">Associated workspace item.</param>
 /// <param name="orientation">Visual orientation of the content.</param>
 public ViewDrawWorkspaceSeparator(KryptonWorkspace workspace,
                                   IWorkspaceItem workspaceItem,
                                   Orientation orientation)
     : base(workspace.StateDisabled.Separator, workspace.StateNormal.Separator, workspace.StateTracking, workspace.StatePressed,
            workspace.StateDisabled.Separator, workspace.StateNormal.Separator, workspace.StateTracking, workspace.StatePressed,
            CommonHelper.SeparatorStyleToMetricPadding(workspace.SeparatorStyle), orientation)
 {
     _workspace     = workspace;
     _workspaceItem = workspaceItem;
 }
 /// <summary>
 /// Initialize a new instance of the DragTargetWorkspaceCellTransfer class.
 /// </summary>
 /// <param name="screenRect">Rectangle for screen area.</param>
 /// <param name="hotRect">Rectangle for hot area.</param>
 /// <param name="drawRect">Rectangle for draw area.</param>
 /// <param name="workspace">Control instance for drop.</param>
 /// <param name="cell">Workspace cell as target for drop.</param>
 /// <param name="allowFlags">Only drop pages that have one of these flags defined.</param>
 public DragTargetWorkspaceCellTransfer(Rectangle screenRect,
                                        Rectangle hotRect,
                                        Rectangle drawRect,
                                        KryptonWorkspace workspace,
                                        KryptonWorkspaceCell cell,
                                        KryptonPageFlags allowFlags)
     : base(screenRect, hotRect, drawRect, DragTargetHint.Transfer, workspace, allowFlags)
 {
     _cell = cell;
     _notDraggedPagesFromCell = -1;
 }
Esempio n. 20
0
 /// <summary>
 /// Initialize a new instance of the DragTargetWorkspaceCellTransfer class.
 /// </summary>
 /// <param name="screenRect">Rectangle for screen area.</param>
 /// <param name="hotRect">Rectangle for hot area.</param>
 /// <param name="drawRect">Rectangle for draw area.</param>
 /// <param name="workspace">Control instance for drop.</param>
 /// <param name="cell">Workspace cell as target for drop.</param>
 /// <param name="allowFlags">Only drop pages that have one of these flags defined.</param>
 public DragTargetWorkspaceCellTransfer(Rectangle screenRect,
                                        Rectangle hotRect,
                                        Rectangle drawRect,
                                        KryptonWorkspace workspace,
                                        KryptonWorkspaceCell cell,
                                        KryptonPageFlags allowFlags)
     : base(screenRect, hotRect, drawRect, DragTargetHint.Transfer, workspace, allowFlags)
 {
     _cell = cell;
     _notDraggedPagesFromCell = -1;
 }
Esempio n. 21
0
 /// <summary>
 /// Initialize a new instance of the DragTargetWorkspaceCellEdge class.
 /// </summary>
 /// <param name="screenRect">Rectangle for screen area.</param>
 /// <param name="hotRect">Rectangle for hot area.</param>
 /// <param name="drawRect">Rectangle for draw area.</param>
 /// <param name="hint">Target hint which should be one of the edges.</param>
 /// <param name="workspace">Workspace instance that contains cell.</param>
 /// <param name="cell">Workspace cell as target for drop.</param>
 /// <param name="allowFlags">Only drop pages that have one of these flags defined.</param>
 public DragTargetWorkspaceCellEdge(Rectangle screenRect,
     Rectangle hotRect,
     Rectangle drawRect,
     DragTargetHint hint,
     KryptonWorkspace workspace,
     KryptonWorkspaceCell cell,
     KryptonPageFlags allowFlags)
     : base(screenRect, hotRect, drawRect, hint, workspace, allowFlags)
 {
     _cell = cell;
     _visibleNotDraggedPages = -1;
 }
Esempio n. 22
0
 /// <summary>
 /// Initialize a new instance of the DragTargetWorkspaceCellEdge class.
 /// </summary>
 /// <param name="screenRect">Rectangle for screen area.</param>
 /// <param name="hotRect">Rectangle for hot area.</param>
 /// <param name="drawRect">Rectangle for draw area.</param>
 /// <param name="hint">Target hint which should be one of the edges.</param>
 /// <param name="workspace">Workspace instance that contains cell.</param>
 /// <param name="cell">Workspace cell as target for drop.</param>
 /// <param name="allowFlags">Only drop pages that have one of these flags defined.</param>
 public DragTargetWorkspaceCellEdge(Rectangle screenRect,
                                    Rectangle hotRect,
                                    Rectangle drawRect,
                                    DragTargetHint hint,
                                    KryptonWorkspace workspace,
                                    KryptonWorkspaceCell cell,
                                    KryptonPageFlags allowFlags)
     : base(screenRect, hotRect, drawRect, hint, workspace, allowFlags)
 {
     Cell = cell;
     _visibleNotDraggedPages = -1;
 }
        /// <summary>
        /// Request this sequence load and recreate children.
        /// </summary>
        /// <param name="workspace">Reference to owning workspace instance.</param>
        /// <param name="xmlReader">Xml reader for loading information.</param>
        /// <param name="existingPages">Dictionary on existing pages before load.</param>
        public void LoadFromXml(KryptonWorkspace workspace,
                                XmlReader xmlReader,
                                UniqueNameToPage existingPages)
        {
            // Load the sequence details
            workspace.ReadSequenceElement(xmlReader, this);

            // If the sequence contains nothing then exit immediately
            if (!xmlReader.IsEmptyElement)
            {
                do
                {
                    // Read the next Element
                    if (!xmlReader.Read())
                    {
                        throw new ArgumentException("An element was expected but could not be read in.");
                    }

                    // Is this the end of the sequence
                    if (xmlReader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }

                    // Is it another sequence?
                    switch (xmlReader.Name)
                    {
                    case "WS":
                        KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence();
                        sequence.LoadFromXml(workspace, xmlReader, existingPages);
                        Children.Add(sequence);
                        break;

                    case "WC":
                        KryptonWorkspaceCell cell = new KryptonWorkspaceCell();
                        cell.LoadFromXml(workspace, xmlReader, existingPages);
                        Children.Add(cell);
                        break;

                    default:
                        throw new ArgumentException("Unknown element was encountered.");
                    }
                }while (true);
            }
        }
        private void OnComponentRemoving(object sender, ComponentEventArgs e)
        {
            // If our sequence is being removed
            if (e.Component == _sequence)
            {
                // Need access to host in order to delete a component
                IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

                // Climb the workspace item tree to get the top most sequence
                KryptonWorkspace workspace     = null;
                IWorkspaceItem   workspaceItem = _sequence;
                while (workspaceItem.WorkspaceParent != null)
                {
                    workspaceItem = workspaceItem.WorkspaceParent;
                }

                // Grab the workspace control that contains the top most sequence
                if ((workspaceItem != null) && (workspaceItem is KryptonWorkspaceSequence))
                {
                    KryptonWorkspaceSequence sequence = (KryptonWorkspaceSequence)workspaceItem;
                    workspace = sequence.WorkspaceControl;
                }

                // We need to remove all children from the sequence
                for (int j = _sequence.Children.Count - 1; j >= 0; j--)
                {
                    Component comp = _sequence.Children[j] as Component;

                    // If the component is a control...
                    if ((comp is Control) && (workspace != null))
                    {
                        // We need to manually remove it from the workspace controls collection
                        KryptonReadOnlyControls readOnlyControls = (KryptonReadOnlyControls)workspace.Controls;
                        readOnlyControls.RemoveInternal(comp as Control);
                    }

                    host.DestroyComponent(comp);

                    // Must remove the child after it has been destroyed otherwise the component destroy method
                    // will not be able to climb the sequence chain to find the parent workspace instance
                    _sequence.Children.Remove(comp);
                }
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Initializes the designer with the specified component.
        /// </summary>
        /// <param name="component">The IComponent to associate with the designer.</param>
        public override void Initialize(IComponent component)
        {
            // Let base class do standard stuff
            base.Initialize(component);

            Debug.Assert(component != null);

            // The resizing handles around the control need to change depending on the
            // value of the AutoSize and AutoSizeMode properties. When in AutoSize you
            // do not get the resizing handles, otherwise you do.
            AutoResizeHandles = true;

            // Remember the actual control being designed
            _workspace = component as KryptonWorkspace;

            // Get access to the services
            _changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));

            // We need to know when we are being removed/changed
            _changeService.ComponentRemoving += OnComponentRemoving;
        }
Esempio n. 26
0
 /// <summary>
 /// Initialize a new instance of the WorkspaceMenus class.
 /// </summary>
 public WorkspaceMenus(KryptonWorkspace workspace)
 {
     // Default values
     TextClose               = DEFAULT_TEXT_CLOSE;
     TextCloseAllButThis     = DEFAULT_TEXT_CLOSE_ALL_BUT_THIS;
     TextMoveNext            = DEFAULT_TEXT_MOVE_NEXT;
     TextMovePrevious        = DEFAULT_TEXT_MOVE_PREVIOUS;
     TextSplitVertical       = DEFAULT_TEXT_SPLIT_VERTICAL;
     TextSplitHorizontal     = DEFAULT_TEXT_SPLIT_HORIZONTAL;
     TextRebalance           = DEFAULT_TEXT_REBALANCE;
     TextMaximize            = DEFAULT_TEXT_MAXIMIZE;
     TextRestore             = DEFAULT_TEXT_RESTORE;
     ShortcutClose           = DEFAULT_SHORTCUT_CLOSE;
     ShortcutCloseAllButThis = DEFAULT_SHORTCUT_CLOSE_ALL_BUT_THIS;
     ShortcutMoveNext        = DEFAULT_SHORTCUT_MOVE_NEXT;
     ShortcutMovePrevious    = DEFAULT_SHORTCUT_MOVE_PREVIOUS;
     ShortcutSplitVertical   = DEFAULT_SHORTCUT_SPLIT_VERTICAL;
     ShortcutSplitHorizontal = DEFAULT_SHORTCUT_SPLIT_HORIZONTAL;
     ShortcutRebalance       = DEFAULT_SHORTCUT_REBALANCE;
     ShortcutMaximizeRestore = DEFAULT_SHORTCUT_MAXIMIZE_RESTORE;
     ShowContextMenu         = true;
 }
Esempio n. 27
0
 /// <summary>
 /// Initialize a new instance of the WorkspaceMenus class.
 /// </summary>
 public WorkspaceMenus(KryptonWorkspace workspace)
 {
     // Default values
     _textClose               = _defaultTextClose;
     _textCloseAllButThis     = _defaultTextCloseAllButThis;
     _textMoveNext            = _defaultTextMoveNext;
     _textMovePrevious        = _defaultTextMovePrevious;
     _textSplitVertical       = _defaultTextSplitVertical;
     _textSplitHorizontal     = _defaultTextSplitHorizontal;
     _textRebalance           = _defaultTextRebalance;
     _textMaximize            = _defaultTextMaximize;
     _textRestore             = _defaultTextRestore;
     _shortcutClose           = _defaultShortcutClose;
     _shortcutCloseAllButThis = _defaultShortcutCloseAllButThis;
     _shortcutMoveNext        = _defaultShortcutMoveNext;
     _shortcutMovePrevious    = _defaultShortcutMovePrevious;
     _shortcutSplitVertical   = _defaultShortcutSplitVertical;
     _shortcutSplitHorizontal = _defaultShortcutSplitHorizontal;
     _shortcutRebalance       = _defaultShortcutRebalance;
     _shortcutMaximizeRestore = _defaultShortcutMaximizeRestore;
     _showContextMenu         = true;
 }
Esempio n. 28
0
 /// <summary>
 /// Initialize a new instance of the WorkspaceMenus class.
 /// </summary>
 public WorkspaceMenus(KryptonWorkspace workspace)
     : base(workspace)
 {
     // Default values
     _textClose = _defaultTextClose;
     _textCloseAllButThis = _defaultTextCloseAllButThis;
     _textMoveNext = _defaultTextMoveNext;
     _textMovePrevious = _defaultTextMovePrevious;
     _textSplitVertical = _defaultTextSplitVertical;
     _textSplitHorizontal = _defaultTextSplitHorizontal;
     _textRebalance = _defaultTextRebalance;
     _textMaximize = _defaultTextMaximize;
     _textRestore = _defaultTextRestore;
     _shortcutClose = _defaultShortcutClose;
     _shortcutCloseAllButThis = _defaultShortcutCloseAllButThis;
     _shortcutMoveNext = _defaultShortcutMoveNext;
     _shortcutMovePrevious = _defaultShortcutMovePrevious;
     _shortcutSplitVertical = _defaultShortcutSplitVertical;
     _shortcutSplitHorizontal = _defaultShortcutSplitHorizontal;
     _shortcutRebalance = _defaultShortcutRebalance;
     _shortcutMaximizeRestore = _defaultShortcutMaximizeRestore;
     _showContextMenu = true;
 }
Esempio n. 29
0
 /// <summary>
 /// Initialize a new instance of the PagesUnmatchedEventArgs class.
 /// </summary>
 /// <param name="workspace">Reference to owning workspace control.</param>
 /// <param name="unmatched">List of pages unmatched during the load process.</param>
 public PagesUnmatchedEventArgs(KryptonWorkspace workspace,
     List<KryptonPage> unmatched)
 {
     _workspace = workspace;
     _unmatched = unmatched;
 }
 /// <summary>
 /// Initialize a new instance of the XmlSavingEventArgs class.
 /// </summary>
 /// <param name="workspace">Reference to owning workspace control.</param>
 /// <param name="xmlWriter">Xml writer for persisting custom data.</param>
 public XmlSavingEventArgs(KryptonWorkspace workspace,
                           XmlWriter xmlWriter)
 {
     _workspace = workspace;
     _xmlWriter = xmlWriter;
 }
 /// <summary>
 /// Initialize a new instance of the CellPageNotify class.
 /// </summary>
 /// <param name="workspace">Reference to owning workspace.</param>
 public CellPageNotify(KryptonWorkspace workspace)
 {
     _workspace = workspace;
 }
Esempio n. 32
0
 /// <summary>
 /// Initialize a new instance of the WorkspacePageMenuBase class.
 /// </summary>
 /// <param name="workspace">Reference to owning workspace.</param>
 public WorkspacePageMenuBase(KryptonWorkspace workspace)
 {
 }
Esempio n. 33
0
 /// <summary>
 /// Initialize a new instance of the CellPageNotify class.
 /// </summary>
 /// <param name="workspace">Reference to owning workspace.</param>
 public CellPageNotify(KryptonWorkspace workspace)
 {
     _workspace = workspace;
 }
Esempio n. 34
0
        /// <summary>
        /// Request this cell load and update state.
        /// </summary>
        /// <param name="workspace">Reference to owning workspace instance.</param>
        /// <param name="xmlReader">Xml reader for loading information.</param>
        /// <param name="existingPages">Dictionary on existing pages before load.</param>
        public void LoadFromXml(KryptonWorkspace workspace,
                                XmlReader xmlReader,
                                UniqueNameToPage existingPages)
        {
            // Load the cell details and return the unique name of the selected page for the cell
            string      selectedPageUniqueName = workspace.ReadCellElement(xmlReader, this);
            KryptonPage selectedPage           = null;

            // If the cell contains nothing then exit immediately
            if (!xmlReader.IsEmptyElement)
            {
                do
                {
                    // Read the next Element
                    if (!xmlReader.Read())
                    {
                        throw new ArgumentException("An element was expected but could not be read in.");
                    }

                    // Is this the end of the cell
                    if (xmlReader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }

                    if (xmlReader.Name == "KP")
                    {
                        // Load the page details and optionally recreate the page
                        string      uniqueName = CommonHelper.XmlAttributeToText(xmlReader, "UN");
                        KryptonPage page       = workspace.ReadPageElement(xmlReader, uniqueName, existingPages);

                        if (xmlReader.Name != "CPD")
                        {
                            throw new ArgumentException("Expected 'CPD' element was not found");
                        }

                        bool finished = xmlReader.IsEmptyElement;

                        // Generate event so custom data can be loaded and/or the page to be added can be modified
                        PageLoadingEventArgs plea = new PageLoadingEventArgs(workspace, page, xmlReader);
                        workspace.OnPageLoading(plea);
                        page = plea.Page;

                        // Read everything until we get the end of custom data marker
                        while (!finished)
                        {
                            // Check it has the expected name
                            if (xmlReader.NodeType == XmlNodeType.EndElement)
                            {
                                finished = (xmlReader.Name == "CPD");
                            }

                            if (!finished)
                            {
                                if (!xmlReader.Read())
                                {
                                    throw new ArgumentException("An element was expected but could not be read in.");
                                }
                            }
                        }

                        // Read past the end of page element
                        if (!xmlReader.Read())
                        {
                            throw new ArgumentException("An element was expected but could not be read in.");
                        }

                        // Check it has the expected name
                        if (xmlReader.NodeType != XmlNodeType.EndElement)
                        {
                            throw new ArgumentException("End of 'KP' element expected but missing.");
                        }

                        // PageLoading event might have nulled the page value to prevent it being added
                        if (page != null)
                        {
                            // Remember the page that should become selected
                            if (!string.IsNullOrEmpty(page.UniqueName) && (page.UniqueName == selectedPageUniqueName))
                            {
                                // Can only selected a visible page
                                if (page.LastVisibleSet)
                                {
                                    selectedPage = page;
                                }
                            }

                            Pages.Add(page);
                        }
                    }
                    else
                    {
                        throw new ArgumentException("Unknown element was encountered.");
                    }
                }while (true);
            }

            // Did we find a matching page that should become selected?
            // (and we are allowed to have selected tabs)
            if ((selectedPage != null) && AllowTabSelect)
            {
                SelectedPage = selectedPage;
            }
        }
Esempio n. 35
0
 /// <summary>
 /// Initialize a new instance of the PagesUnmatchedEventArgs class.
 /// </summary>
 /// <param name="workspace">Reference to owning workspace control.</param>
 /// <param name="unmatched">List of pages unmatched during the load process.</param>
 public PagesUnmatchedEventArgs(KryptonWorkspace workspace,
                                List <KryptonPage> unmatched)
 {
     Workspace = workspace;
     Unmatched = unmatched;
 }
 /// <summary>
 /// Initialize a new instance of the WorkspacePageMenuBase class.
 /// </summary>
 /// <param name="workspace">Reference to owning workspace.</param>
 public WorkspacePageMenuBase(KryptonWorkspace workspace)
 {
 }
        /// <summary>
        /// Initialize a new instance of the WorkspacePageMenuBase class.
        /// </summary>
        /// <param name="workspace">Reference to owning workspace.</param>
        public WorkspacePageMenuBase(KryptonWorkspace workspace)
        {
            // Define the encryted licence information
            EncryptedLicenseProvider.SetParameters(_licenseParameters);

            // If an error has already been shown, then no need to test license again
            bool validated = _usageShown;
            if (!validated)
            {
                // Is there a valid license registered?
                License license = null;
                validated = LicenseManager.IsValid(typeof(KryptonWorkspace), this, out license);

                // Valid license is not enough!
                if (validated)
                {
                    validated = false;
                    EncryptedLicense encryptedLicense = license as EncryptedLicense;
                    string[] productInfo = encryptedLicense.ProductInfo.Split(',');

                    // Must contain two fields separated by a comma
                    if (productInfo.Length == 2)
                    {
                        // Both fields must not be empty
                        if (!string.IsNullOrEmpty(productInfo[0]) &&
                            !string.IsNullOrEmpty(productInfo[1]))
                        {
                            // Product code must be ...
                            //    'S' = Krypton Suite
                            // And version number...
                            //    '400'
                            validated = (productInfo[1].Equals("400")) && (productInfo[0][0] == 'S');
                        }
                    }
                }

                // Remember to release resources no longer needed
                if (license != null)
                    license.Dispose();
            }

            // If we need to indicate the invalid licensing state...
            if (!validated)
            {
                // Get hold of the assembly version number
                Version thisVersion = Assembly.GetExecutingAssembly().GetName().Version;

                // We want a unique 30 day evaluation period for each major/minor version
                EvaluationMonitor monitor = new EvaluationMonitor(_monitorId + thisVersion.Major.ToString() + thisVersion.Minor.ToString());

                // If the first time we have failed to get the licence or
                // the 30 days evaluation period has expired or the component
                // has been created over a 3000 times then...
                if ((monitor.UsageCount == 0) ||
                    (monitor.UsageCount > 3000) ||
                    (monitor.DaysInUse > 30))
                {
                    // At runtime show a NAG screen to prevent unauthorized use of the control
                    if (LicenseManager.CurrentContext.UsageMode == LicenseUsageMode.Runtime)
                    {
                        MessageBox.Show("This application was created using an unlicensed version of\n" +
                                        "the Krypton Suite control from Component Factory Pty Ltd.\n\n" +
                                        "You must contact your software supplier in order to resolve\n" +
                                        "the licencing issue.",
                                        "Unlicensed Application",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                    else
                    {
                        LicenseInstallForm form = new LicenseInstallForm();
                        form.ShowDialog(typeof(KryptonWorkspace));
                    }
                }
            }

            // No need to perform check check more than once
            _usageShown = true;
        }
 /// <summary>
 /// Initialize a new instance of the XmlLoadingEventArgs class.
 /// </summary>
 /// <param name="workspace">Reference to owning workspace control.</param>
 /// <param name="xmlReading">Xml reader for persisting custom data.</param>
 public XmlLoadingEventArgs(KryptonWorkspace workspace,
                            XmlReader xmlReading)
 {
     Workspace = workspace;
     XmlReader = xmlReading;
 }
 /// <summary>
 /// Initialize a new instance of the XmlLoadingEventArgs class.
 /// </summary>
 /// <param name="workspace">Reference to owning workspace control.</param>
 /// <param name="xmlReading">Xml reader for persisting custom data.</param>
 public XmlLoadingEventArgs(KryptonWorkspace workspace,
                            XmlReader xmlReading)
 {
     _workspace = workspace;
     _xmlReader = xmlReading;
 }
Esempio n. 40
0
 /// <summary>
 /// Initialize a new instance of the XmlSavingEventArgs class.
 /// </summary>
 /// <param name="workspace">Reference to owning workspace control.</param>
 /// <param name="xmlWriter">Xml writer for persisting custom data.</param>
 public XmlSavingEventArgs(KryptonWorkspace workspace,
                           XmlWriter xmlWriter)
 {
     _workspace = workspace;
     _xmlWriter = xmlWriter;
 }
Esempio n. 41
0
        /// <summary>
        /// Initialize a new instance of the WorkspacePageMenuBase class.
        /// </summary>
        /// <param name="workspace">Reference to owning workspace.</param>
        public WorkspacePageMenuBase(KryptonWorkspace workspace)
        {
            // Define the encryted licence information
            EncryptedLicenseProvider.SetParameters(_licenseParameters);

            // If an error has already been shown, then no need to test license again
            bool validated = _usageShown;

            if (!validated)
            {
                // Is there a valid license registered?
                License license = null;
                validated = LicenseManager.IsValid(typeof(KryptonWorkspace), this, out license);

                // Valid license is not enough!
                if (validated)
                {
                    validated = false;
                    EncryptedLicense encryptedLicense = license as EncryptedLicense;
                    string[]         productInfo      = encryptedLicense.ProductInfo.Split(',');

                    // Must contain two fields separated by a comma
                    if (productInfo.Length == 2)
                    {
                        // Both fields must not be empty
                        if (!string.IsNullOrEmpty(productInfo[0]) &&
                            !string.IsNullOrEmpty(productInfo[1]))
                        {
                            // Product code must be ...
                            //    'S' = Krypton Suite
                            // And version number...
                            //    '400'
                            validated = (productInfo[1].Equals("400")) && (productInfo[0][0] == 'S');
                        }
                    }
                }

                // Remember to release resources no longer needed
                if (license != null)
                {
                    license.Dispose();
                }
            }

            // If we need to indicate the invalid licensing state...
            if (!validated)
            {
                // Get hold of the assembly version number
                Version thisVersion = Assembly.GetExecutingAssembly().GetName().Version;

                // We want a unique 30 day evaluation period for each major/minor version
                EvaluationMonitor monitor = new EvaluationMonitor(_monitorId + thisVersion.Major.ToString() + thisVersion.Minor.ToString());

                // If the first time we have failed to get the licence or
                // the 30 days evaluation period has expired or the component
                // has been created over a 3000 times then...
                if ((monitor.UsageCount == 0) ||
                    (monitor.UsageCount > 3000) ||
                    (monitor.DaysInUse > 30))
                {
                    // At runtime show a NAG screen to prevent unauthorized use of the control
                    if (LicenseManager.CurrentContext.UsageMode == LicenseUsageMode.Runtime)
                    {
                        MessageBox.Show("This application was created using an unlicensed version of\n" +
                                        "the Krypton Suite control from Component Factory Pty Ltd.\n\n" +
                                        "You must contact your software supplier in order to resolve\n" +
                                        "the licencing issue.",
                                        "Unlicensed Application",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                    else
                    {
                        LicenseInstallForm form = new LicenseInstallForm();
                        form.ShowDialog(typeof(KryptonWorkspace));
                    }
                }
            }

            // No need to perform check check more than once
            _usageShown = true;
        }
        /// <summary>
        /// Request this sequence load and recreate children.
        /// </summary>
        /// <param name="workspace">Reference to owning workspace instance.</param>
        /// <param name="xmlReader">Xml reader for loading information.</param>
        /// <param name="existingPages">Dictionary on existing pages before load.</param>
        public void LoadFromXml(KryptonWorkspace workspace, 
                                XmlReader xmlReader,
                                UniqueNameToPage existingPages)
        {
            // Load the sequence details
            workspace.ReadSequenceElement(xmlReader, this);

            // If the sequence contains nothing then exit immediately
            if (!xmlReader.IsEmptyElement)
            {
                do
                {
                    // Read the next Element
                    if (!xmlReader.Read())
                        throw new ArgumentException("An element was expected but could not be read in.");

                    // Is this the end of the sequence
                    if (xmlReader.NodeType == XmlNodeType.EndElement)
                        break;

                    // Is it another sequence?
                    if (xmlReader.Name == "WS")
                    {
                        KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence();
                        sequence.LoadFromXml(workspace, xmlReader, existingPages);
                        Children.Add(sequence);
                    }
                    else if (xmlReader.Name == "WC")
                    {
                        KryptonWorkspaceCell cell = new KryptonWorkspaceCell();
                        cell.LoadFromXml(workspace, xmlReader, existingPages);
                        Children.Add(cell);
                    }
                    else
                        throw new ArgumentException("Unknown element was encountered.");
                }
                while (true);
            }
        }
        /// <summary>
        /// Request this sequence save its information about children.
        /// </summary>
        /// <param name="workspace">Reference to owning workspace instance.</param>
        /// <param name="xmlWriter">Xml writer to save information into.</param>
        public void SaveToXml(KryptonWorkspace workspace, XmlWriter xmlWriter)
        {
            // Output standard values appropriate for all Sequence instances
            xmlWriter.WriteStartElement("WS");
            workspace.WriteSequenceElement(xmlWriter, this);

            // Persist each child sequence/cell in turn
            foreach (object child in Children)
            {
                KryptonWorkspaceSequence sequence = child as KryptonWorkspaceSequence;
                if (sequence != null)
                    sequence.SaveToXml(workspace, xmlWriter);

                KryptonWorkspaceCell cell = child as KryptonWorkspaceCell;
                if (cell != null)
                    cell.SaveToXml(workspace, xmlWriter);
            }

            // Terminate the workspace element
            xmlWriter.WriteEndElement();
        }
Esempio n. 44
0
        /// <summary>
        /// Process the drag pages in the context of a target navigator.
        /// </summary>
        /// <param name="workspace">Target workspace instance.</param>
        /// <param name="target">Target workspace cell instance.</param>
        /// <param name="data">Dragged page data.</param>
        /// <returns>Last page to be transferred.</returns>
        protected KryptonPage ProcessDragEndData(KryptonWorkspace workspace,
                                                 KryptonWorkspaceCell target,
                                                 PageDragEndData data)
        {
            KryptonPage ret = null;

            // Add each source page to the target
            foreach (KryptonPage page in data.Pages)
            {
                // Only add the page if one of the allow flags is set
                if ((page.Flags & (int)AllowFlags) != 0)
                {
                    // Use event to allow decision on if the page should be dropped
                    // (or even swap the page for a different page to be dropped)
                    PageDropEventArgs e = new PageDropEventArgs(page);
                    workspace.OnPageDrop(e);

                    if (!e.Cancel && (e.Page != null))
                    {
                        target.Pages.Add(e.Page);
                        ret = e.Page;
                    }
                }
            }

            return ret;
        }
        /// <summary>
        /// Initializes the designer with the specified component.
        /// </summary>
        /// <param name="component">The IComponent to associate with the designer.</param>
        public override void Initialize(IComponent component)
        {
            // Validate the parameter reference
            if (component == null) throw new ArgumentNullException("component");

            // Let base class do standard stuff
            base.Initialize(component);

            // The resizing handles around the control need to change depending on the
            // value of the AutoSize and AutoSizeMode properties. When in AutoSize you
            // do not get the resizing handles, otherwise you do.
            AutoResizeHandles = true;

            // Remember the actual control being designed
            _workspace = (KryptonWorkspace)component;

            // Get access to the services
            _changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));

            // We need to know when we are being removed/changed
            _changeService.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving);
        }