Example #1
0
        void paramMapButt_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            fs_in = Inputs[0] as dynFamilySymbolBySelection;
            array_in = Inputs[1] as dynElementArray;

            if (fs_in != null && fs_in.FamilyInst != null)
            {
                map.Clear();

                //clear all the inputs but the first one
                //which is the family instance
                //first kill all the connectors
                for (int i = 2; i < InPorts.Count; i++)
                {
                    dynPort p = InPorts[i];

                    //must remove the connectors iteratively
                    //do not use a foreach here!
                    while(p.Connectors.Count > 0)
                    {
                        dynConnector c = p.Connectors[p.Connectors.Count-1] as dynConnector;
                        c.Kill();
                    }
                }

                //then remove all the ports
                while (InPorts.Count > 2)
                {
                    InPorts.RemoveAt(InPorts.Count - 1);
                    InPortData.RemoveAt(InPorts.Count - 1);
                    Inputs.RemoveAt(InPorts.Count - 1);
                }

                while (gridLeft.RowDefinitions.Count > 2)
                {
                    //remove the port from the children list
                    gridLeft.Children.RemoveAt(gridLeft.RowDefinitions.Count - 1);
                    portNamesLeft.Children.RemoveAt(gridLeft.RowDefinitions.Count - 1);

                    gridLeft.RowDefinitions.RemoveAt(gridLeft.RowDefinitions.Count - 1);
                    portNamesLeft.RowDefinitions.RemoveAt(gridLeft.RowDefinitions.Count - 1);
                }

                foreach (Parameter p in fs_in.FamilyInst.Parameters)
                {
                    if (p.StorageType == StorageType.Double)
                    {
                        Inputs.Add(null);   //add a placeholder for the dynDouble
                        //InPortData.Add(new PortData(p.Definition.Name[0].ToString(), p.Definition.Name, typeof(dynDouble)));
                        InPortData.Add(new PortData(p.Definition.Name[0].ToString(), p.Definition.Name, typeof(dynElementArray)));
                    }
                }

                //resize this thing
                base.ResizeElementForInputs();

                //base.RegisterInputs();
                //add back new ports
                double yDiv = this.Height / Inputs.Count;
                //foreach (dynElement o in inputs)
                for(int i=2; i<Inputs.Count; i++)
                {
                    dynElement o = Inputs[i] as dynElement;

                    RowDefinition rd = new RowDefinition();
                    gridLeft.RowDefinitions.Add(rd);

                    RowDefinition nameRd = new RowDefinition();
                    portNamesLeft.RowDefinitions.Add(nameRd);

                    //add a port for each input
                    //distribute the ports along the
                    //edges of the icon
                    AddPort(o, true, InPortData[i].NickName, i);
                }

                base.SetToolTips();

            }
        }
Example #2
0
        public override void Draw()
        {
            fs_in = Inputs[0] as dynFamilySymbolBySelection;
            array_in = Inputs[1] as dynElementArray;

            //refresh the parameter map
            map.Clear();

            if (array_in != null)
            {
                int ptCount = 0;
                foreach (dynElement el in array_in.Elements)
                {
                    dynParamData dpd = new dynParamData();
                    for(int i=2; i<InPortData.Count;i++)
                    {
                        dynPoint p = el as dynPoint;
                        if (p != null)
                        {
                            dynDoubleArray d = Inputs[i] as dynDoubleArray;

                            dpd.ParamNames.Add(InPortData[i].NickName);

                            if (d != null)
                            {
                                dynDouble dd = d.Elements[ptCount] as dynDouble;
                                if (dd != null)
                                {
                                    dpd.ParamValues.Add(dd.D);
                                }
                            }
                            else
                            {
                                dpd.ParamValues.Add(0.0);
                            }
                        }
                    }
                    map.Add(dpd);
                    ptCount++;
                }
            }

            //base.Draw();
        }