private void bnComponentRef_Click(object sender, EventArgs e) { try { string libraryPath = Path.Combine(_localPluginDirectory, "Library"); if (!Directory.Exists(libraryPath)) { MessageBox.Show(string.Format("Directory {0} does not exist...", libraryPath)); return; } PluginLibraryBrowser form = new PluginLibraryBrowser(libraryPath); if (DialogResult.OK == form.ShowDialog()) { // tools ComponentLoader loader = new ComponentLoader(); loader.SearchMethod = new ComponentSearchDirectory(libraryPath); Component component = loader.LoadComponent(form._guid); Pic.Plugin.Tools tools = new Pic.Plugin.Tools(component, new ComponentSearchDirectory(libraryPath)); // insert generated code string sCode = codeEditorCtrl.Text; int startIndex = sCode.IndexOf("factory.AddEntities(fTemp, transform);"); sCode = sCode.Insert(startIndex, tools.GetInsertionCode()); codeEditorCtrl.Text = sCode; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
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; }
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); }
/// <summary> /// Loads a component and get its sources /// </summary> /// <param name="strGenerator"></param> public void setComponentFilePath(string pluginPath) { // load plugin and get source code using (Pic.Plugin.Tools pluginTools = new Pic.Plugin.Tools(pluginPath, ComponentSearchMethod)) { // path _pluginPath = pluginPath; // guid txtGuid.Text = pluginTools.Guid.ToString(); // name / description txtName.Text = pluginTools.Name; txtDescription.Text = pluginTools.Description; // source codeEditorCtrl.Document.HighlightingStrategy = ICSharpCode.TextEditor.Document.HighlightingStrategyFactory.CreateHighlightingStrategyForFile(@"PluginCode.cs"); codeEditorCtrl.Text = pluginTools.SourceCode; // version PluginVersion = pluginTools.Version; } }
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); }
private void bnComponentRef_Click(object sender, EventArgs e) { try { string libraryPath = Path.Combine(_localPluginDirectory, "Library"); if (!Directory.Exists(libraryPath)) { MessageBox.Show( string.Format("Directory {0} does not exist...", libraryPath) ); return; } PluginLibraryBrowser form = new PluginLibraryBrowser(libraryPath); if (DialogResult.OK == form.ShowDialog()) { // tools ComponentLoader loader = new ComponentLoader(); loader.SearchMethod = new ComponentSearchDirectory(libraryPath); Component component = loader.LoadComponent(form._guid); Pic.Plugin.Tools tools = new Pic.Plugin.Tools(component, new ComponentSearchDirectory(libraryPath)); // insert generated code string sCode = codeEditorCtrl.Text; int startIndex = sCode.IndexOf("factory.AddEntities(fTemp, transform);"); sCode = sCode.Insert(startIndex, tools.GetInsertionCode()); codeEditorCtrl.Text = sCode; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// Loads a component and get its sources /// </summary> /// <param name="strGenerator"></param> public void setComponentFilePath(string pluginPath) { // load plugin and get source code using (Pic.Plugin.Tools pluginTools = new Pic.Plugin.Tools(pluginPath, ComponentSearchMethod )) { // path _pluginPath = pluginPath; // guid txtGuid.Text = pluginTools.Guid.ToString(); // name / description txtName.Text = pluginTools.Name; txtDescription.Text = pluginTools.Description; // source codeEditorCtrl.Document.HighlightingStrategy = ICSharpCode.TextEditor.Document.HighlightingStrategyFactory.CreateHighlightingStrategyForFile(@"PluginCode.cs"); codeEditorCtrl.Text = pluginTools.SourceCode; // version PluginVersion = pluginTools.Version; } }
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); }