public Image getThumbnailImageFromDocument(string filePath, string fileType, Size size)
 {
     Image image;
     using (Tools pluginTools = new Pic.Plugin.Tools(filePath, new ComponentSearchMethodDB()))
     {
         pluginTools.ShowCotations = false;
         pluginTools.GenerateImage(size, out image);
     }
     return image;
 }
Beispiel #2
0
        public Image getThumbnailImageFromDocument(string filePath, string fileType, Size size)
        {
            Image image;

            using (Tools pluginTools = new Pic.Plugin.Tools(filePath, new ComponentSearchMethodDB()))
            {
                pluginTools.ShowCotations = false;
                pluginTools.GenerateImage(size, out image);
            }
            return(image);
        }
        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);
        }
        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);
        }