Esempio n. 1
0
        /// <summary>
        /// Build parameter stack
        /// IPluginExt1 simply returns a static list of parameters or the same current list
        /// IpluginExt2 builds a new list depending on the current list state
        /// </summary>
        public ParameterStack BuildParameterStack(ParameterStack stackIn1)
        {
            ParameterStack stackIn = (null != stackIn1) ? ConvertIn(stackIn1) : null;
            ParameterStack stackOut;

            if (null != _ext1)
            {
                if (null != stackIn && stackIn.Count > 0)
                {
                    stackOut = stackIn;
                }
                else
                {
                    stackOut = Plugin.Parameters;
                }
            }
            else if (null != _ext2)
            {
                stackOut = _ext2.BuildParameterStack(stackIn);
            }
            else if (null != _ext3)
            {
                stackOut = _ext3.BuildParameterStack(stackIn);
            }
            else if (null != _ext4)
            {
                stackOut = _ext4.BuildParameterStack(stackIn);
            }
            else
            {
                stackOut = new ParameterStack();
            }

            // adding thickness parameters
            // these parameters are always available but are not shown in the list of parameters in the plugin viewer
            // ep1 and th1 are reserved name
            double defaultThickness = Host.Properties.Settings.Default.Thickness;

            if (!stackOut.HasParameter("th1"))
            {
                stackOut.AddDoubleParameter("th1", "Thickness"
                                            , null != stackIn && stackIn.HasParameter("th1") ? stackIn.GetDoubleParameterValue("th1") : defaultThickness);
            }
            if (!stackOut.HasParameter("ep1"))
            {
                stackOut.AddDoubleParameter("ep1", "Thickness"
                                            , null != stackIn && stackIn.HasParameter("ep1") ? stackIn.GetDoubleParameterValue("ep1") : defaultThickness);
            }

            return(ConvertOut(stackOut));
        }
        void textBox_TextChanged(object sender, EventArgs e)
        {
            string filePath           = fileSelectCtrl.FileName;
            string fileExt            = System.IO.Path.GetExtension(filePath);
            bool   successfullyLoaded = false;

            if (System.IO.File.Exists(filePath) && (fileExt == ".dll"))
            {
                // try and load plugin
                try
                {
                    // load component
                    Pic.Plugin.Component component = null;
                    using (Pic.Plugin.ComponentLoader loader = new ComponentLoader())
                    {
                        loader.SearchMethod = new ComponentSearchMethodDB();
                        component           = loader.LoadComponent(filePath);
                    }
                    if (null == component)
                    {
                        return;
                    }
                    _componentGuid = component.Guid;

                    // generate image
                    Image image;
                    using (Pic.Plugin.Tools pluginTools = new Pic.Plugin.Tools(component, new ComponentSearchMethodDB()))
                    {
                        pluginTools.ShowCotations = false;
                        pluginTools.GenerateImage(pictureBoxFileView.Size, out image);
                    }
                    pictureBoxFileView.Image = image;

                    // get parameters
                    Pic.Plugin.ParameterStack stack = null;
                    stack = component.Parameters;
                    // fill name/description if empty
                    if (textBoxName.Text.Length == 0)
                    {
                        textBoxName.Text = component.Name;
                    }
                    if (textBoxDescription.Text.Length == 0)
                    {
                        textBoxDescription.Text = component.Description;
                    }

                    // insert majoration label and textbox controls
                    int lblX = 16, lblY = 41;
                    int offsetX = 100, offsetY = 29;
                    int tabIndex = comboBoxProfile.TabIndex;
                    groupBoxMajorations.Controls.Clear();
                    int iCount = 0;
                    for (int i = 1; i < 16; ++i)
                    {
                        string paramName = string.Format("m{0}", i);
                        if (!stack.HasParameter(paramName))
                        {
                            continue;
                        }

                        Label lbl = new Label();
                        lbl.Name     = string.Format("lbl_m{0}", i);
                        lbl.Text     = string.Format("m{0}", i);
                        lbl.Location = new Point(
                            lblX + (iCount / 4) * offsetX
                            , lblY + (iCount % 4) * offsetY);
                        lbl.Size     = new Size(24, 13);
                        lbl.TabIndex = ++tabIndex;
                        groupBoxMajorations.Controls.Add(lbl);

                        TextBox tb = new TextBox();
                        tb.Name     = string.Format("tb_m{0}", i);
                        tb.Text     = string.Format("{0:0.##}", stack.GetDoubleParameterValue(paramName));
                        tb.Location = new Point(
                            lblX + (iCount / 4) * offsetX + lbl.Size.Width + 1
                            , lblY + (iCount % 4) * offsetY);
                        tb.Size     = new Size(50, 20);
                        tb.TabIndex = ++tabIndex;
                        groupBoxMajorations.Controls.Add(tb);

                        ++iCount;
                    }

                    // Ok button enabled!
                    successfullyLoaded = true;
                }
                catch (Exception ex)
                {
                    Logger.Write(ex.ToString(), Category.General, Priority.Highest);
                }
            }

            // enable Ok button
            bnOk.Enabled = (textBoxName.TextLength != 0 && textBoxDescription.TextLength != 0 && successfullyLoaded);
        }
Esempio n. 3
0
        /// <summary>
        /// Build parameter stack
		/// IPluginExt1 simply returns a static list of parameters or the same current list
		/// IpluginExt2 builds a new list depending on the current list state
        /// </summary>
        public ParameterStack BuildParameterStack(ParameterStack stackIn)
        {
            ParameterStack stackOut = null;
            if (null != _ext1)
			{
                if (null != stackIn)
                    stackOut = stackIn;
                else
                    stackOut = _instance.Parameters;
			}
            else if (null != _ext2)
                stackOut = _ext2.BuildParameterStack(stackIn);
            else  if (null != _ext3)
                stackOut = _ext3.BuildParameterStack(stackIn);
            else
                stackOut = new ParameterStack();


            // adding thickness parameters 
            // these parameters are always available but are not shown in the list of parameters in the plugin viewer
            // ep1 and th1 are reserved name
            double defaultThickness = Pic.Plugin.Host.Properties.Settings.Default.Thickness;
            if (!stackOut.HasParameter("ep1"))
                stackOut.AddDoubleParameter("ep1", "Epaisseur"
                    , null != stackIn && stackIn.HasParameter("ep1") ? stackIn.GetDoubleParameterValue("ep1") : defaultThickness);
            if (!stackOut.HasParameter("th1"))
                stackOut.AddDoubleParameter("th1", "Thickness"
                    , null != stackIn && stackIn.HasParameter("th1") ? stackIn.GetDoubleParameterValue("th1") : defaultThickness);

            return stackOut;
        }