示例#1
0
        void addComponentForm(IcarusNetProject.Components.Component component, Form componentForm)
        {
            componentForm.TopLevel = false;
            //this.Controls.Add(frm);
            this.pnlComponentZoo.Controls.Add(componentForm);

            //processTab(componentForm);


            if (component.WindowState != IcarusNetProject.Components.WindowState.Closed)
            {
                componentForm.Show();
            }
            else
            {
                componentForm.Hide();
            }

            ((IProjectComponentForm)componentForm).Initialize(component);

            if (component.X < 0 || component.X >= pnlComponentZoo.Width)
            {
                componentForm.Left = 0;
            }
            if (component.Y < 0 || component.Y >= pnlComponentZoo.Height)
            {
                componentForm.Top = 0;
            }

            repopulateComponentSelectors();

            componentForm.FormClosed  += componentForm_FormClosed;
            componentForm.FormClosing += componentForm_FormClosing;
            componentForm.SizeChanged += componentForm_SizeChanged;

            recursivelyAddMouseDown(
                componentForm,
                (object sender, MouseEventArgs args) => { bringFormToFrontAndSelectInListbox(componentForm); }
                );

            componentForm.GotFocus       += componentForm_GotFocus;
            componentForm.VisibleChanged += componentForm_VisibleChanged;

            nameToComponentForm.Add(component.Name, (IProjectComponentForm)componentForm);

            component.PreSave += () =>
            {
                component.WindowState = FormToIcarusWindowState(componentForm);
                return(null);
            };

            return;
        }
示例#2
0
        void OnComponentRemovedFromProject(IcarusNetProject.Components.Component component)
        {
            if (nameToComponentForm.ContainsKey(component.Name))
            {
                nameToComponentForm.Remove(component.Name);
            }
            var toRemove = pnlComponentZoo.Controls.OfType <Control>().Where(c => ((IProjectComponentForm)c).GetComponent() == component);

            if (toRemove.Count() != 0)
            {
                pnlComponentZoo.Controls.Remove(toRemove.First());
            }
            lbProjectControls.Items.Remove(component.Name);
        }
示例#3
0
        void swapControlBuildOrders(IcarusNetProject.Components.Component ctrlToLower, IcarusNetProject.Components.Component ctrlToIncrease)
        {
            if (ctrlToLower.BuildOrder == ctrlToIncrease.BuildOrder)
            {
                ctrlToIncrease.BuildOrder++;
            }

            int oldToLowerOrder = ctrlToLower.BuildOrder;

            ctrlToLower.BuildOrder    = ctrlToIncrease.BuildOrder;
            ctrlToIncrease.BuildOrder = oldToLowerOrder;

            ctrlToLower.PropertyChangedOutsideNormalView();
            ctrlToIncrease.PropertyChangedOutsideNormalView();

            repopulateComponentSelectors();
        }
示例#4
0
        /// <summary>
        /// Call after adding to form and showing
        /// </summary>
        public void Initialize(IcarusNetProject.Components.Component component)
        {
            this.ProjectEditorComponent = (AssemblyEditor)component;

            assemblerToTextbox();
            this.Left   = ProjectEditorComponent.X;
            this.Top    = ProjectEditorComponent.Y;
            this.Width  = ProjectEditorComponent.Width;
            this.Height = ProjectEditorComponent.Height;

            component.PreBuild += () => { textboxToAssembler(true, false); return(null); };
            component.PreSave  += () => { textboxToAssembler(true); return(null); };

            component.PropertyChangedOutsideNormalView += () =>
            {
                assemblerToTextbox();
                this.txtOrder.Text = component.BuildOrder.ToString();
            };
        }
示例#5
0
 void OnComponentAddedToProject(IcarusNetProject.Components.Component component)
 {
     foreach (var t in Assembly.GetExecutingAssembly().GetTypes())
     {
         var attribs = t.GetCustomAttributes(typeof(IcarusNetComponentAttribute), false);
         if (attribs.Length != 1)
         {
             continue;
         }
         var attrib = (IcarusNetComponentAttribute)attribs.First();
         if (attrib.ComponentType == component.GetType())
         {
             var componentForm = (Form)Activator.CreateInstance(t);
             addComponentForm(component, componentForm);
             return;
         }
     }
     throw new NotImplementedException("No form found for control");
 }