public override bool Process(Pic.DAL.SQLite.PPDataContext db, TreeNode tn)
        {
            if (!tn.IsComponent) return true;
            try
            {
                string filePath = tn.Documents(db)[0].File.Path(db);
                Pic.Plugin.Component comp = _compLoader.LoadComponent(filePath);
                if (null != _callback && null != comp)
                    _callback.Info(string.Format("Successfully loaded component {0}", tn.Name));
                else
                    _callback.Error(string.Format("Failed to load component {0}", tn.Name));

                Pic.Plugin.ParameterStack stack = comp.BuildParameterStack(null);
                foreach (Pic.Plugin.Parameter param in stack)
                {
                    if (param.IsMajoration)
                        continue;
                    // only add parameter description
                    TryAndAddString( param.Description );
                    // ParameterMulti ? 
                    Pic.Plugin.ParameterMulti paramMulti = param as Pic.Plugin.ParameterMulti;
                    if (null != paramMulti)
                    {
                        foreach (string sText in paramMulti.DisplayList)
                            TryAndAddString(sText);
                    }
                }
            }
            catch (Exception ex)
            {
                if (null != _callback)
                    _callback.Error(ex.Message);
            }
            return true;
        }
예제 #2
0
 public void OnToolStripEditComponentCode(object sender, EventArgs e)
 {
     try
     {
         if (!(treeView.SelectedNode.Tag is NodeTag nodeTag))
         {
             return;
         }
         PPDataContext           db       = new PPDataContext();
         Pic.DAL.SQLite.TreeNode treeNode = Pic.DAL.SQLite.TreeNode.GetById(db, nodeTag.TreeNode);
         if (null == treeNode)
         {
             return;
         }
         Document doc = treeNode.Documents(db)[0];
         if (null == doc)
         {
             return;
         }
         Pic.DAL.SQLite.Component comp = doc.Components[0];
         if (null == comp)
         {
             return;
         }
         // output Guid / path
         Guid   outputGuid = Guid.NewGuid();
         string outputPath = Pic.DAL.SQLite.File.GuidToPath(db, outputGuid, "dll");
         // form plugin editor
         FormPluginEditor editorForm = new FormPluginEditor();
         editorForm.PluginPath = doc.File.Path(db);
         editorForm.OutputPath = outputPath;
         if (DialogResult.OK == editorForm.ShowDialog())
         {
             _log.Info("Component successfully modified!");
             doc.File.Guid = outputGuid;
             db.SubmitChanges();
             // clear component cache in plugin viewer
             ComponentLoader.ClearCache();
             // update pluginviewer
             pluginViewCtrl.PluginPath = outputPath;
         }
     }
     catch (Exception ex)
     {
         _log.Error(ex.ToString());
     }
 }
예제 #3
0
        private void OnSelectionChanged(object sender, NodeEventArgs e, string name)
        {
            try
            {
                // storing current tag
                TagCurrent = e.NodeTag;
                // change view name (seen in tab)
                Text = TagCurrent.Name;
                // show / hide browsing controls
                branchViewCtrl.Visible        = IsBranch;
                pluginViewCtrl.Visible        = false;
                factoryViewCtrl.Visible       = false;
                webBrowser4PDF.Visible        = false;
                unknownFormatViewCtrl.Visible = false;

                if (IsDocument)
                {
                    PPDataContext           db       = new PPDataContext();
                    Pic.DAL.SQLite.TreeNode treeNode = Pic.DAL.SQLite.TreeNode.GetById(db, e.NodeTag.TreeNode);
                    Document doc = treeNode.Documents(db)[0];

                    // select document handler depending on document type
                    string docTypeName = doc.DocumentType.Name;
                    string filePath    = doc.File.Path(db);
                    string fileExt     = Path.GetExtension(filePath).Trim('.').ToLower();

                    log4net.Config.XmlConfigurator.Configure();
                    if (!System.IO.File.Exists(filePath))
                    {
                        MessageBox.Show($"File {filePath} not found!");
                    }
                    else
                    {
                        _log.Info($"Loading file {filePath}...");
                    }

                    switch (fileExt)
                    {
                    case "dll":
                        LoadComponent(filePath);
                        break;

                    case "des":
                    case "dxf":
                    case "cf2":
                    case "cff2":
                        LoadDrawing(filePath, fileExt);
                        break;

                    case "pdf":
                        LoadPdf(filePath);
                        break;

                    case "png":
                    case "bmp":
                    case "jpg":
                    case "jpeg":
                        LoadImageFile(filePath);
                        break;

                    case "des3":
                    case "doc":
                    case "xls":
                    case "dwg":
                    case "ai":
                    case "sxw":
                    case "stw":
                    case "sxc":
                    case "stc":
                    case "ard":
                    default:
                        LoadUnknownFileFormat(filePath, TagCurrent.Name);
                        break;
                    }
                }
                // update other branch/tree view control
                if (sender != branchViewCtrl)
                {
                    branchViewCtrl.ShowBranch(TagCurrent);
                }
                if (sender != treeView)
                {
                    treeView.SelectNode(TagCurrent);
                }
            }
            catch (ParameterNotFound ex)
            { _log.Error(ex.Message); }
            catch (Exception ex)
            { _log.Error(ex.ToString()); }

            SelectionChanged?.Invoke(this);
        }