コード例 #1
0
        /// <summary>
        /// Registers the control and adds it to a visible form</summary>
        /// <param name="control">Control</param>
        /// <param name="controlInfo">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(System.Windows.Forms.Control control, Sce.Atf.Applications.ControlInfo controlInfo, Sce.Atf.Applications.IControlHostClient client)
        {
            var clientAdapter = GetOrCreateClientAdapter(client);

            // WPF control host service requires a unique control ID in order to be able to reload window layouts
            // on app startup.
            // This is a problem as we do not have one here.
            // The best we can do is try and generate a unique hash
            int uniqueId = GenerateId(control, controlInfo, client);

            IControlInfo contentInfo = m_adaptee.RegisterControl(control, controlInfo.Name, controlInfo.Description, controlInfo.Group, uniqueId.ToString(), clientAdapter);

            controlInfo.Control = control;

            m_info.Add(controlInfo, contentInfo);
            TransferControlInfoValues(controlInfo);
            controlInfo.Changed += (s, e) => TransferControlInfoValues(s as Sce.Atf.Applications.ControlInfo);
        }
コード例 #2
0
        private void TransferControlInfoValues(Sce.Atf.Applications.ControlInfo controlInfo)
        {
            IControlInfo contentInfo;

            if (m_info.TryGetValue(controlInfo, out contentInfo))
            {
                contentInfo.Name           = controlInfo.Name;
                contentInfo.Description    = controlInfo.Description;
                contentInfo.ImageSourceKey = controlInfo.Image;

                if (controlInfo.Image != null)
                {
                    // Creates a WPF image source resource and adds it to App resources
                    // with key or old image
                    Util.GetOrCreateResourceForEmbeddedImage(controlInfo.Image);
                }
            }
        }