예제 #1
0
 private void ActivateClient(IControlHostClient client, bool activating)
 {
     foreach (ControlInfo info in m_registeredContents)
     {
         if (client == info.Client)
         {
             m_dockPanel.ShowContent(info.DockContent);
         }
     }
 }
 private void ActivateClient(IControlHostClient client, bool activating)
 {
     foreach (ControlInfo info in m_controls)
     {
         if (client == info.Client)
         {
             DockContent dockContent = FindContent(info);
             dockContent.BringToFront();
         }
     }
 }
예제 #3
0
 /// <summary>
 /// Registers a control with the control host service</summary>
 /// <param name="controlHostService">Control host service</param>
 /// <param name="control">Control</param>
 /// <param name="name">Control name</param>
 /// <param name="description">Control description</param>
 /// <param name="group">Initial location of control on main form</param>
 /// <param name="client">Client that owns control, or null</param>
 /// <returns>ControlInfo for registered control</returns>
 public static ControlInfo RegisterControl(
     this IControlHostService controlHostService,
     Control control,
     string name,
     string description,
     StandardControlGroup group,
     IControlHostClient client)
 {
     var info = new ControlInfo(name, description, group);
     controlHostService.RegisterControl(control, info, client);
     return info;
 }
예제 #4
0
 /// <summary>
 /// Registers a control with the control host service</summary>
 /// <param name="controlHostService">Control host service</param>
 /// <param name="control">Control</param>
 /// <param name="name">Control name</param>
 /// <param name="description">Control description</param>
 /// <param name="group">Initial location of control on main form</param>
 /// <param name="id">Unique ID for control</param>
 /// <param name="client">Client that owns control, or null</param>
 /// <returns>IControlInfo for registered control</returns>
 public static IControlInfo RegisterControl(
     this IControlHostService controlHostService,
     object control,
     string name,
     string description,
     Sce.Atf.Applications.StandardControlGroup group,
     string id,
     IControlHostClient client)
 {
     var def = new ControlDef() { Name = name, Description = description, Group = group, Id = id };
     return controlHostService.RegisterControl(def, control, client);
 }
예제 #5
0
 /// <summary>
 /// Registers a control with the control host service</summary>
 /// <param name="controlHostService">Control host service</param>
 /// <param name="control">Control</param>
 /// <param name="name">Control name</param>
 /// <param name="description">Control description</param>
 /// <param name="group">Initial location of control on main form</param>
 /// <param name="id">Unique ID for control</param>
 /// <param name="client">Client that owns control, or null</param>
 /// <returns>IControlInfo for registered control</returns>
 public static IControlInfo RegisterControl(
     this IControlHostService controlHostService,
     object control,
     string name,
     string description,
     Sce.Atf.Applications.StandardControlGroup group,
     string id,
     IControlHostClient client)
 {
     var def = new ControlDef() { Name = name, Description = description, Group = group, Id = id };
     return controlHostService.RegisterControl(def, control, client);
 }
예제 #6
0
        /// <summary>
        /// Registers a control with the control host service</summary>
        /// <param name="controlHostService">Control host service</param>
        /// <param name="control">Control</param>
        /// <param name="name">Control name</param>
        /// <param name="description">Control description</param>
        /// <param name="group">Initial location of control on main form</param>
        /// <param name="client">Client that owns control, or null</param>
        /// <returns>ControlInfo for registered control</returns>
        public static ControlInfo RegisterControl(
            this IControlHostService controlHostService,
            Control control,
            string name,
            string description,
            StandardControlGroup group,
            IControlHostClient client)
        {
            var info = new ControlInfo(name, description, group);

            controlHostService.RegisterControl(control, info, client);
            return(info);
        }
예제 #7
0
        public ControlInfo(string name, string description, string id, Sce.Atf.Applications.StandardControlGroup group, object imageKey, IDockContent dockContent, IControlHostClient client)
        {
            Requires.NotNullOrEmpty(id, "id");
            Requires.NotNull(dockContent, "dockContent");
            Requires.NotNull(client, "client");

            DockContent = dockContent;
            dockContent.PropertyChanged += DockContent_PropertyChanged;
            Name = name;
            Description = description;
            Id = id;
            Group = group;
            ImageSourceKey = imageKey;
            Client = client;
        }
예제 #8
0
파일: ControlInfo.cs 프로젝트: zparr/ATF
        /// <summary>
        /// Constructor</summary>
        /// <param name="name">Control's name, which may be displayed as the title of
        /// the hosting control or form</param>
        /// <param name="description">Control's description, which may be displayed as
        /// a tooltop when hovering over the control</param>
        /// <param name="id">Unique ID for the control</param>
        /// <param name="group">Initial control group for the control</param>
        /// <param name="imageKey">The control's image, which may be displayed on the
        /// hosting control or form</param>
        /// <param name="dockContent">The IDockContent representing the control</param>
        /// <param name="client">The client that registered this control</param>
        public ControlInfo(string name, string description, string id, Sce.Atf.Applications.StandardControlGroup group, object imageKey, IDockContent dockContent, IControlHostClient client)
        {
            Requires.NotNullOrEmpty(id, "id");
            Requires.NotNull(dockContent, "dockContent");
            Requires.NotNull(client, "client");

            DockContent = dockContent;
            dockContent.PropertyChanged += DockContent_PropertyChanged;
            Name           = name;
            Description    = description;
            Id             = id;
            Group          = group;
            ImageSourceKey = imageKey;
            Client         = client;
        }
예제 #9
0
        /// <summary>
        /// Registers a control with the control host service</summary>
        /// <param name="def">Control definition</param>
        /// <param name="control">Control</param>
        /// <param name="client">Client that owns the control and receives notifications
        /// about its status, or null if no notifications are needed</param>
        /// <returns>IControlInfo for registered control</returns>
        public IControlInfo RegisterControl(ControlDef def, object control, IControlHostClient client)
        {
            Requires.NotNull(def, "def");
            Requires.NotNull(control, "control");
            Requires.NotNullOrEmpty(def.Id, "def.Id");
            Requires.NotNull(client, "client");

            if (m_registeredContents.Any <ControlInfo>(x => x.Id == def.Id))
            {
                throw new ArgumentException("Content with id " + def.Id + " already registered");
            }

            IDockContent dockContent = m_dockPanel.RegisterContent(control, def.Id, ControlGroupToDockTo(def.Group));

            dockContent.IsFocusedChanged += new EventHandler <BooleanArgs>(DockContent_IsFocusedChanged);

            ControlInfo contentInfo = new ControlInfo(def.Name, def.Description, def.Id, def.Group, def.ImageSourceKey, dockContent, client);

            m_registeredContents.Add(contentInfo);

            if (m_commandService != null)
            {
                var command = m_commandService.RegisterCommand(
                    new CommandDef(
                        dockContent,
                        StandardMenu.Window,
                        StandardCommandGroup.WindowDocuments,
                        contentInfo.Name,
                        null,
                        "Activate Control".Localize(),
                        null, null, CommandVisibility.Menu),
                    this);

                contentInfo.Command = command;
            }

            ActivateClient(client, true);

            Show(control);

            return(contentInfo);
        }
예제 #10
0
 public virtual void RegisterControl(DiagramDocument doc, Control control, ControlInfo controlInfo, IControlHostClient client)
 {
     _controls.Add(doc, new Pair <Control, ControlInfo>(control, controlInfo));
     _hostService.RegisterControl(control, controlInfo, client);
 }
예제 #11
0
 /// <summary>
 /// Registers the control for the circuit node</summary>
 /// <param name="circuitNode">Circuit DomNode</param>
 /// <param name="control">Control registered for DomNode</param>
 /// <param name="controlInfo">ControlInfo for control</param>
 /// <param name="client">Control IControlHostClient</param>
 public virtual void RegisterControl(DomNode circuitNode, Control control, ControlInfo controlInfo, IControlHostClient client)
 {
     m_circuitNodeControls.Add(circuitNode, new Pair <Control, ControlInfo>(control, controlInfo));
     m_controlHostService.RegisterControl(control, controlInfo, client);
 }
예제 #12
0
 public virtual void RegisterControl(DiagramDocument doc, Control control, ControlInfo controlInfo, IControlHostClient client)
 {
     _controls.Add(doc, new Pair<Control, ControlInfo>(control, controlInfo));
     _hostService.RegisterControl(control, controlInfo, client);
 }
예제 #13
0
 private void ActivateClient(IControlHostClient client, bool activating)
 {
     foreach (ControlInfo info in m_registeredContents)
     {
         if (client == info.Client)
         {
             m_dockPanel.ShowContent(info.DockContent);
         }
     }
 }
예제 #14
0
        /// <summary>
        /// Registers a control with the control host service</summary>
        /// <param name="def">Control definition</param>
        /// <param name="control">Control</param>
        /// <param name="client">Client that owns the control and receives notifications
        /// about its status, or null if no notifications are needed</param>
        /// <returns>IControlInfo for registered control</returns>
        public IControlInfo RegisterControl(ControlDef def, object control, IControlHostClient client)
        {
            Requires.NotNull(def, "def");
            Requires.NotNull(control, "control");
            Requires.NotNullOrEmpty(def.Id, "def.Id");
            Requires.NotNull(client, "client");

            if (m_registeredContents.Any<ControlInfo>(x => x.Id == def.Id))
                throw new ArgumentException("Content with id " + def.Id + " already registered");

            IDockContent dockContent = m_dockPanel.RegisterContent(control, def.Id, ControlGroupToDockTo(def.Group));
            dockContent.IsFocusedChanged += DockContent_IsFocusedChanged;
            dockContent.Closing += DockContentOnClosing; 
            ControlInfo contentInfo = new ControlInfo(def.Name, def.Description, def.Id, def.Group, def.ImageSourceKey, dockContent, client);

            m_registeredContents.Add(contentInfo);

            if (m_commandService != null)
            {
                contentInfo.Command = m_commandService.RegisterCommand(
                    dockContent,
                    StandardMenu.Window,
                    StandardCommandGroup.WindowDocuments,
                    contentInfo.Name,
                    "Activate Control".Localize(),
                    Keys.None, null, CommandVisibility.Menu,
                    this).GetCommandItem();
            }

            ActivateClient(client, true);

            return contentInfo;
        }
예제 #15
0
        /// <summary>
        /// Registers a control so it becomes visible as part of the main form</summary>
        /// <param name="control">Control</param>
        /// <param name="info">Control display information</param>
        /// <param name="client">Client that owns the control and receives notifications
        /// about its status, or null if no notifications are needed</param>
        /// <remarks>If IControlHostClient.Close() has been called, the IControlHostService
        /// also calls UnregisterControl. Call RegisterControl again to re-register the Control.</remarks>
        public void RegisterControl(Control control, ControlInfo info, IControlHostClient client)
        {
            if (control == null)
                throw new ArgumentNullException("control");
            if (info == null)
                throw new ArgumentNullException("info");

            if (FindControlInfo(control) != null)
                throw new ArgumentException("Control already registered");

            // allow null client
            if (client == null)
                client = Global<DefaultClient>.Instance;

            info.Client = client;
            info.Control = control;
            info.Changed += info_Changed;

            DockContent dockContent = null;
            bool useControlInfoLayout = true;
            if (info.IsDocument.HasValue && info.IsDocument.Value)
            {
                foreach (DockContent unregisteredContent in m_unregisteredContents)
                {
                    if (unregisteredContent.Name == DocumentContentPrefix + info.Description)
                    {
                        dockContent = unregisteredContent;
                        m_unregisteredContents.Remove(unregisteredContent);
                        useControlInfoLayout = false;
                        break;
                    }
                }
            }

            if (dockContent == null)
            {
                dockContent = new DockContent(this);
                // set persistence id one time only.
                // do not update dockContent.Name            
                // dockContent.Text is used for titlebar.
                dockContent.Name = GetPersistenceId(info);
            }

            if (!string.IsNullOrEmpty(info.HelpUrl))
                dockContent.AddHelp(info.HelpUrl);

   
            UpdateDockContent(dockContent, info);

            m_dockContent.Add(info, dockContent);
            m_controls.ActiveItem = info;

            info.HostControl = dockContent;

            // Any property we set on this Control needs to be restored in UnregisterControl.
            //  For example, QuadPanelControl was broken by setting Dock property but not restoring it.
            info.OriginalDock = control.Dock;
            control.Dock = DockStyle.Fill;

            dockContent.Controls.Add(control);

            dockContent.FormClosing += dockContent_FormClosing;

            ShowDockContent(dockContent, useControlInfoLayout ? info : null);

            if (info.ShowInMenu)
            {
                if (info.IsDocument.HasValue && info.IsDocument.Value)
                {
                    // description( and the tooltip) for a document control by convention is the full path of the document
                    RegisterMenuCommand(info, "@" + info.Description);
                }
                else 
                    RegisterMenuCommand(info, "@" + dockContent.Text); // tells m_commandService not to interpret slashes as submenus
            }

            // Bring all the Controls for this client to the front.
            BringClientToFront(client);

            // Call the IControlHostClient's Activate method. Seems to be required when driving
            //  the app from a script and if the user clicks on another app at the wrong moment.
            ActivateClient(control);
        }
        /// <summary>
        /// Registers a control so it becomes visible as part of the main form</summary>
        /// <param name="control">Control to register</param>
        /// <param name="info">Control display information</param>
        /// <param name="client">Client that owns the control and will receive notifications
        /// about its status, or null if no notifications are needed</param>
        public void RegisterControl(Control control, ControlInfo info, IControlHostClient client)
        {
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            if (FindControlInfo(control) != null)
            {
                throw new ArgumentException("Control already registered");
            }

            // allow null client
            if (client == null)
            {
                client = Global <DefaultClient> .Instance;
            }

            info.Client  = client;
            info.Control = control;

            info.Changed += new EventHandler(info_Changed);

            DockContent dockContent = new DockContent(this);

            UpdateDockContent(dockContent, info);

            m_dockContent.Add(info, dockContent);
            m_controls.ActiveItem = info;

            info.HostControl = dockContent;

            // Any property we set on this Control needs to be restored in UnregisterControl.
            //  For example, QuadPanelControl was broken by setting Dock property but not restoring it.
            info.OriginalDock = control.Dock;
            control.Dock      = DockStyle.Fill;

            dockContent.Controls.Add(control);

            dockContent.FormClosing += new FormClosingEventHandler(dockContent_FormClosing);

            if (IsCenterGroup(info.Group))
            {
                dockContent.Show(m_dockPanel, DockState.Document);

                RegisterMenuCommand(control, "@" + dockContent.Text); // tells m_commandService not to interpret slashes as submenus
            }
            else
            {
                DockState state;
                switch (info.Group)
                {
                case StandardControlGroup.Left:
                    state = DockState.DockLeft;
                    break;

                case StandardControlGroup.Right:
                    state = DockState.DockRight;
                    break;

                case StandardControlGroup.Top:
                    state = DockState.DockTop;
                    break;

                case StandardControlGroup.Bottom:
                    state = DockState.DockBottom;
                    break;

                case StandardControlGroup.Floating:
                    state = DockState.Float;
                    break;

                default:
                    state = DockState.DockLeftAutoHide;
                    break;
                }

                dockContent.Show(m_dockPanel, state);

                RegisterMenuCommand(control, dockContent.Text); // tells m_commandService not to interpret slashes as submenus
            }

            UpdateContent(control);

            ActivateClient(client, true);
            Show(control);
        }
예제 #17
0
 /// <summary>
 /// Registers the control for the circuit node</summary>
 /// <param name="circuitNode">Circuit DomNode</param>
 /// <param name="control">Control registered for DomNode</param>
 /// <param name="controlInfo">ControlInfo for control</param>
 /// <param name="client">Control IControlHostClient</param>
 public virtual void RegisterControl(DomNode circuitNode, Control control, ControlInfo controlInfo, IControlHostClient client)
 {
     m_circuitNodeControls.Add(circuitNode, new Pair<Control, ControlInfo>(control, controlInfo));
     m_controlHostService.RegisterControl(control, controlInfo, client);
 }
예제 #18
0
 private void ActivateClient(IControlHostClient client, bool activating)
 {
     foreach (ControlInfo info in m_controls)
     {
         if (client == info.Client)
         {
             DockContent dockContent = FindContent(info);
             dockContent.BringToFront();
         }
    }
 }
예제 #19
0
        /// <summary>
        /// Registers a control so it becomes visible as part of the main form</summary>
        /// <param name="control">Control to register</param>
        /// <param name="info">Control display information</param>
        /// <param name="client">Client that owns the control and will receive notifications
        /// about its status, or null if no notifications are needed</param>
        public void RegisterControl(Control control, ControlInfo info, IControlHostClient client)
        {
            if (control == null)
                throw new ArgumentNullException("control");
            if (info == null)
                throw new ArgumentNullException("info");

            if (FindControlInfo(control) != null)
                throw new ArgumentException("Control already registered");

            // allow null client
            if (client == null)
                client = Global<DefaultClient>.Instance;

            info.Client = client;
            info.Control = control;

            info.Changed += new EventHandler(info_Changed);

            DockContent dockContent = new DockContent(this);
            UpdateDockContent(dockContent, info);

            m_dockContent.Add(info, dockContent);
            m_controls.ActiveItem = info;

            info.HostControl = dockContent;
            
            // Any property we set on this Control needs to be restored in UnregisterControl.
            //  For example, QuadPanelControl was broken by setting Dock property but not restoring it.
            info.OriginalDock = control.Dock;
            control.Dock = DockStyle.Fill;

            dockContent.Controls.Add(control);

            dockContent.FormClosing += new FormClosingEventHandler(dockContent_FormClosing);

            if (IsCenterGroup(info.Group))
            {
                dockContent.Show(m_dockPanel, DockState.Document);

                RegisterMenuCommand(control, "@" + dockContent.Text); // tells m_commandService not to interpret slashes as submenus
            }
            else
            {
                DockState state;
                switch (info.Group)
                {
                    case StandardControlGroup.Left:
                        state = DockState.DockLeft;
                        break;

                    case StandardControlGroup.Right:
                        state = DockState.DockRight;
                        break;

                    case StandardControlGroup.Top:
                        state = DockState.DockTop;
                        break;

                    case StandardControlGroup.Bottom:
                        state = DockState.DockBottom;
                        break;

                    case StandardControlGroup.Floating:
                        state = DockState.Float;
                        break;

                    default:
                        state = DockState.DockLeftAutoHide;
                        break;
                }

                dockContent.Show(m_dockPanel, state);

                RegisterMenuCommand(control, dockContent.Text); // tells m_commandService not to interpret slashes as submenus
            }

            UpdateContent(control);

            ActivateClient(client, true);
            Show(control);
        }
예제 #20
0
 public ControlInfo(string name, string description, string id, Sce.Atf.Applications.StandardControlGroup group, IDockContent dockContent, IControlHostClient client)
     : this(name, description, id, group, null, dockContent, client)
 {
 }
예제 #21
0
파일: ControlInfo.cs 프로젝트: zparr/ATF
 /// <summary>
 /// Constructor</summary>
 /// <param name="name">Control's name, which may be displayed as the title of
 /// the hosting control or form</param>
 /// <param name="description">Control's description, which may be displayed as
 /// a tooltop when hovering over the control</param>
 /// <param name="id">Unique ID for the control</param>
 /// <param name="group">Initial control group for the control</param>
 /// <param name="dockContent">The IDockContent representing the control</param>
 /// <param name="client">The client that registered this control</param>
 public ControlInfo(string name, string description, string id, Sce.Atf.Applications.StandardControlGroup group, IDockContent dockContent, IControlHostClient client)
     : this(name, description, id, group, null, dockContent, client)
 {
 }