Beispiel #1
0
        protected override void OnClose(ISmartPart smartPart)
        {
            TabInfo ti = m_smartPartTabs.Find(t => t.SmartPart == smartPart);

            if (ti == null)
            {
                throw new Exception("Tab not found");
            }

            // "hiding" is removing it from the tabcontrol
            int index = m_tabs.TabPages.IndexOf(ti.Page);

            m_tabs.TabPages.RemoveAt(index);

            RaiseSmartPartDeactivated(smartPart);
            RaiseSmartPartClosing(smartPart);
            m_smartPartTabs.Remove(ti);

            // this call will also call Dispose on any IDisposable items
            RootWorkItem.SmartParts.Remove(smartPart);

            if (smartPart == ActiveSmartPart)
            {
                ActiveSmartPart = null;
            }
        }
Beispiel #2
0
        private void CheckSmartPartExists(ISmartPart smartPart)
        {
            if (smartPart == null)
            {
                throw new ArgumentNullException("smartPart");
            }
            var control = smartPart as Control;

            if (control == null)
            {
                throw new ArgumentException("smartPart must be a Control");
            }

            if (!SmartParts.Contains(smartPart))
            {
                // check to see if it's the RootWorkItem SmartParts collection (i.e. added to the RootWorkItem.SmartParts directly)
                if (RootWorkItem.SmartParts.ContainsObject(smartPart))
                {
                    m_smartParts.Add(smartPart);
                    this.Controls.Add(control);
                }
                else
                {
                    throw new Exception("ISmartPart not in Workspace");
                }
            }
        }
Beispiel #3
0
 protected void AddSmartPartToCollectionIfRequired(ISmartPart smartPart)
 {
     if (!SmartParts.Contains(smartPart))
     {
         m_smartParts.Add(smartPart);
     }
 }
Beispiel #4
0
        /// <summary>
        /// Adds a SmartPart to the Workspace without showing it
        /// </summary>
        /// <param name="smartPart"></param>
        public virtual void Add(ISmartPart smartPart)
        {
            if (smartPart == null)
            {
                throw new ArgumentNullException("smartPart");
            }

            this.InvokeIfRequired(() =>
            {
                var control = smartPart as Control;
                if (control == null)
                {
                    throw new ArgumentException("smartPart must be a Control");
                }

                if (!SmartParts.Contains(smartPart))
                {
                    smartPart.Workspace = this;
                    m_smartParts.Add(smartPart);
                    if (!RootWorkItem.SmartParts.ContainsObject(smartPart))
                    {
                        RootWorkItem.SmartParts.Add(smartPart, Guid.NewGuid().ToString());
                    }
                    if (!this.Controls.Contains(control))
                    {
                        this.Controls.Add(control);
                    }

                    EnableGesturesForControl(smartPart, true);
                }
            });
        }
Beispiel #5
0
 protected void EnableGesturesForControl(ISmartPart smartPart, bool enable)
 {
     if (GesturesEnabled)
     {
         HookClicks(smartPart as Control, enable);
     }
 }
 private void OnSmartPartShown(ISmartPart smartPartShown)
 {
     if (SmartPartShown != null)
     {
         SmartPartShown(this, new SmartPartPlaceholderEventArgs(smartPartShown));
     }
 }
Beispiel #7
0
        protected override void OnActivate(ISmartPart smartPart)
        {
            if (smartPart == null)
            {
                throw new ArgumentNullException("smartPart");
            }

            ShowTab(smartPart, null, true);
        }
Beispiel #8
0
        protected virtual void OnHide(ISmartPart smartPart)
        {
            if (smartPart == null)
            {
                throw new ArgumentNullException("smartPart");
            }

            Deactivate(smartPart);
        }
        internal void Remove(ISmartPart smartPart)
        {
            if (smartPart == null)
            {
                throw new ArgumentNullException();
            }

            m_smartParts.Remove(smartPart);
        }
Beispiel #10
0
        protected void RaiseSmartPartDeactivated(ISmartPart smartPart)
        {
            if (SmartPartDeactivated == null)
            {
                return;
            }

            SmartPartDeactivated(this, new DataEventArgs <ISmartPart>(smartPart));
        }
        internal void Add(ISmartPart smartPart)
        {
            if (smartPart == null)
            {
                throw new ArgumentNullException();
            }

            m_smartParts.Add(smartPart);
        }
Beispiel #12
0
        protected void RaiseSmartPartClosing(ISmartPart smartPart)
        {
            if (SmartPartClosing == null)
            {
                return;
            }

            SmartPartClosing(this, new DataEventArgs <ISmartPart>(smartPart));
        }
Beispiel #13
0
        protected override void OnDeactivate(ISmartPart smartPart)
        {
            // we must override becasue the base "hides" the deactivated control and for a tab, we want to stay visible
            if (smartPart == null)
            {
                throw new ArgumentNullException("smartPart");
            }

            smartPart.OnDeactivated();

            RaiseSmartPartDeactivated(smartPart);
        }
Beispiel #14
0
        public void Show(ISmartPart smartPart, ISmartPartInfo smartPartInfo)
        {
            if (smartPart == null)
            {
                throw new ArgumentNullException("smartPart");
            }

            this.BeginInvokeIfRequired(() =>
            {
                OnShow(smartPart, smartPartInfo);
            });
        }
Beispiel #15
0
        public virtual void DestroySmartPart(string key)
        {
            ISmartPart smartPart = null;

            if (HasSmartPart(key))
            {
                smartPart = _smartParts[key] as ISmartPart;
            }
            smartPart.Deinit();
            smartPart.Destroy();

            _smartParts.Remove(key);
        }
Beispiel #16
0
        public void Close(ISmartPart smartPart)
        {
            if (smartPart == null)
            {
                throw new ArgumentNullException("smartPart");
            }

            CheckSmartPartExists(smartPart);

            this.InvokeIfRequired(() =>
            {
                OnClose(smartPart);
            });
        }
Beispiel #17
0
        public virtual ISmartPart GetSmartPart(string key)
        {
            Debug.Assert(HasSmartPart(key),
                         String.Format("Can't get SmartPart {0} value, because it doesn't exist.", key));

            ISmartPart smartPart = null;

            if (HasSmartPart(key))
            {
                smartPart = _smartParts[key] as ISmartPart;
            }

            return(smartPart);
        }
        /// <summary>
        /// Removes the current SmartPart from the placeholder
        /// </summary>
        public void RemoveSmartPart()
        {
            if (_smartPart != null && _smartPart.Control is Control)
            {
                //A previous smartpart exists
                var ctrl = _smartPart.Control as Control;
                ctrl.Hide();
                //Deinit smart part
                _smartPart.Deinit();
                _smartPart = null;

                Controls.Clear();
            }
        }
Beispiel #19
0
        public void Deactivate(ISmartPart smartPart)
        {
            if (smartPart == null)
            {
                throw new ArgumentNullException("smartPart");
            }

            this.InvokeIfRequired(() =>
            {
                CheckSmartPartExists(smartPart);

                OnDeactivate(smartPart);
            });
        }
Beispiel #20
0
        protected override void OnHide(ISmartPart smartPart)
        {
            TabInfo ti = m_smartPartTabs.Find(t => t.SmartPart == smartPart);

            if (ti == null)
            {
                throw new Exception("Tab not found");
            }

            // "hiding" is removing it from the tabcontrol
            int index = m_tabs.TabPages.IndexOf(ti.Page);

            m_tabs.TabPages.RemoveAt(index);
            Deactivate(smartPart);
        }
Beispiel #21
0
        public void Hide(ISmartPart smartPart)
        {
            if (smartPart == null)
            {
                throw new ArgumentNullException("smartPart");
            }

            CheckSmartPartExists(smartPart);

            this.InvokeIfRequired(() =>
            {
                OnHide(smartPart);

                RaiseSmartPartDeactivated(smartPart);
            });
        }
Beispiel #22
0
        protected virtual void OnShow(ISmartPart smartPart, ISmartPartInfo smartPartInfo)
        {
            if (smartPart == null)
            {
                throw new ArgumentNullException("smartPart");
            }

            var control = smartPart as Control;

            if (control == null)
            {
                throw new ArgumentException("smartPart must be a Control");
            }
            control.Dock = DockStyle.Fill;

            Add(smartPart);
            Activate(smartPart);
        }
Beispiel #23
0
        public virtual void AddSmartPart(string key, ISmartPart smartPart)
        {
            Debug.Assert(!HasSmartPart(key), String.Format("Can't add SmartPart {0}, because it is already added.", key));

            if (HasSmartPart(key))
            {
                throw new InvalidOperationException(
                          String.Format("Can't add SmartPart {0}, because it is already added.", key));
            }

            if (smartPart.DisplayName == null)
            {
                smartPart.DisplayName = key;
            }

            smartPart.Key = key;

            _smartParts.Add(key, smartPart);
        }
Beispiel #24
0
        protected virtual void OnDeactivate(ISmartPart smartPart)
        {
            if (smartPart == null)
            {
                throw new ArgumentNullException("smartPart");
            }

            if (smartPart.Visible)
            {
                smartPart.Visible = false;
            }
            else
            {
                smartPart.OnDeactivated();
            }

            if (smartPart == ActiveSmartPart)
            {
                ActiveSmartPart = null;
            }

            RaiseSmartPartDeactivated(smartPart);
        }
Beispiel #25
0
        protected virtual void OnActivate(ISmartPart smartPart)
        {
            if (smartPart == null)
            {
                throw new ArgumentNullException("smartPart");
            }

            if (!smartPart.Visible)
            {
                // this will call OnActivated for us
                smartPart.Visible = true;
            }
            else
            {
                // for activation of an already-visible SmartPart
                smartPart.OnActivated();
            }

            RaiseSmartPartActivated(smartPart);

            smartPart.BringToFront();
            smartPart.Focus();
        }
Beispiel #26
0
        public void Activate(ISmartPart smartPart)
        {
            if (smartPart == null)
            {
                throw new ArgumentNullException("smartPart");
            }

            this.InvokeIfRequired(() =>
            {
                AddSmartPartToCollectionIfRequired(smartPart);

                if (smartPart == ActiveSmartPart)
                {
                    return;
                }

                if (ActiveSmartPart != null)
                {
                    OnDeactivate(ActiveSmartPart);
                }
                ActiveSmartPart = smartPart;
                OnActivate(smartPart);
            });
        }
Beispiel #27
0
        protected virtual void OnClose(ISmartPart smartPart)
        {
            if (smartPart == null)
            {
                throw new ArgumentNullException("smartPart");
            }

            Control control = smartPart as Control;

            if (control == null)
            {
                throw new ArgumentException("smartPart must be a Control");
            }

            RaiseSmartPartDeactivated(smartPart);
            RaiseSmartPartClosing(smartPart);

            smartPart.Visible   = false;
            smartPart.Workspace = null;

            this.Controls.Remove(control);

            EnableGesturesForControl(smartPart, false);

            m_smartParts.Remove(smartPart);

            // this call will also call Dispose on any IDisposable items
            RootWorkItem.SmartParts.Remove(smartPart);

            if (smartPart == ActiveSmartPart)
            {
                ActiveSmartPart = null;
            }

            smartPart = null;
        }
Beispiel #28
0
 public void Show(ISmartPart smartPart)
 {
     this.Show(smartPart, null);
 }
Beispiel #29
0
 protected override void OnShow(ISmartPart smartPart, ISmartPartInfo smartPartInfo)
 {
     ShowTab(smartPart, smartPartInfo, true);
 }
Beispiel #30
0
        private void ShowTab(ISmartPart smartPart, ISmartPartInfo smartPartInfo, bool createIfNew)
        {
            if (m_inShowTab)
            {
                return;
            }
            m_inShowTab = true;
            try
            {
                TabInfo ti = m_smartPartTabs.Find(t => t.SmartPart == smartPart);

                if (ti == null)
                {
                    if (!createIfNew)
                    {
                        throw new Exception("Tab not found");
                    }

                    TabPage page = new TabPage();
                    page.Text = smartPartInfo == null ? smartPart.Name : smartPartInfo.Title;
#if !WindowsCE
                    var iconInfo = smartPartInfo as IconicSmartPartInfo;
                    if ((iconInfo != null) && (iconInfo.Icon != null))
                    {
                        int imageIndex = m_tabImages.Images.Count;
                        m_tabImages.Images.Add(iconInfo.Icon);
                        page.ImageIndex = imageIndex;
                    }
#endif
                    var ctl = smartPart as Control;
                    if (ctl != null)
                    {
                        ctl.Dock = System.Windows.Forms.DockStyle.Fill;
                    }
                    page.ClientRectangle.Inflate(-2, -2);
                    page.Controls.Add((Control)smartPart);
                    m_tabs.TabPages.Add(page);

                    ti = new TabInfo {
                        Page = page, SmartPart = smartPart, SmartPartInfo = smartPartInfo
                    };

                    m_smartPartTabs.Add(ti);
                    EnableGesturesForControl(smartPart, true);
                    OnTabPageAdded(page);
                }
                int index = m_tabs.TabPages.IndexOf(ti.Page);
                if (index < 0)
                {
                    m_tabs.TabPages.Add(ti.Page);
                    index = m_tabs.TabPages.IndexOf(ti.Page);
                }
                m_tabs.SelectedIndex = index;

                AddSmartPartToCollectionIfRequired(smartPart);

                Activate(smartPart);
                //            RaiseSmartPartActivated(smartPart);
                smartPart.OnActivated();
            }
            finally
            {
                m_inShowTab = false;
            }
        }