Esempio n. 1
0
        private ComposerComponent AddComponentToPanel(IComponentCreator creator, ItemConfiguration config)
        {
            try
            {
                ComposerComponent component = creator.FromConfiguration(config);

                Size  newSize     = new Size();
                Point newLocation = new Point();

                newSize.Width  = (config.Size.Width * panelBuilder.Width) / config.Resolution.Width;
                newSize.Height = (config.Size.Height * panelBuilder.Height) / config.Resolution.Height;

                newLocation.X = (config.Location.X * panelBuilder.Width) / config.Resolution.Width;
                newLocation.Y = (config.Location.Y * panelBuilder.Height) / config.Resolution.Height;

                component.Size     = newSize;
                component.Location = newLocation;

                component.Configuration.Resolution      = panelBuilder.Size;
                component.Configuration.FinalResolution = finalResolution;
                component.Configuration.Size            = component.Size;

                component.ContextMenuStrip = contextMenuStripComponents;

                if (component is TVComposer)
                {
                    (component as TVComposer).SetOptionsWindowConnection(Connection);
                }

                component.DoubleClick += component_DoubleClick;

                panelBuilder.Controls.Add(component);

                return(component);
            }
            catch (Exception ex)
            {
#if DEBUG
                MessageBox.Show(ex.Message);
                return(null);
#endif
            }
        }