//Display the card of the selected file private void ShowCard(IEdmFolder5 folder, int fileID) { try { if (vault1 == null) { vault1 = new EdmVault5(); } if (!vault1.IsLoggedIn) { vault1.LoginAuto(VaultsComboBox.Text, this.Handle.ToInt32()); } IEdmVault10 vault = (IEdmVault10)vault1; EdmCardViewParams @params = default(EdmCardViewParams); @params.mlFileID = fileID; @params.mlFolderID = folder.ID; @params.mlCardID = 0; @params.mlX = 40; @params.mlY = 300; @params.mhParentWindow = this.Handle.ToInt32(); @params.mlEdmCardViewFlags = (int)EdmCardViewFlag.EdmCvf_Normal; //Create the card view interface view = vault.CreateCardViewEx2(@params, this); if (view == null) { Interaction.MsgBox("The file does not have a card."); return; } //Set input focus to the first control in the card view.SetFocus(0); //Enable all controls in the card view.Update(EdmCardViewUpdateType.EdmCvut_EnableCtrl); //Get the size needed to display the card int width = 0; int height = 0; view.GetCardSize(out width, out height); //Resize the form window to make room for the card this.Width = (width + 100); this.Height = (height + 400); view.ShowWindow(true); SaveCard.Enabled = false; } catch (System.Runtime.InteropServices.COMException ex) { MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void Form1_Load(System.Object sender, System.EventArgs e) { try { vault1 = new EdmVault5(); IEdmVault10 vault = (IEdmVault10)vault1; EdmViewInfo[] Views = null; vault.GetVaultViews(out Views, false); VaultsComboBox.Items.Clear(); foreach (EdmViewInfo View in Views) { VaultsComboBox.Items.Add(View.mbsVaultName); } if (VaultsComboBox.Items.Count > 0) { VaultsComboBox.Text = (string)VaultsComboBox.Items[0]; } } catch (System.Runtime.InteropServices.COMException ex) { MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void OnCmd(ref EdmCmd poCmd, ref EdmCmdData[] ppoData) { IEdmVault10 edmVault = (IEdmVault10)poCmd.mpoVault; switch (poCmd.meCmdType) { case EdmCmdType.EdmCmd_Menu: // match the CmdID with the command ID specified above switch (poCmd.mlCmdID) { case 100: // CustomAddin -> Action1 string message = ""; for (int i = 0; i < ppoData.Length; i++) { message += ppoData[i].mbsStrData1 + "\n"; } edmVault.MsgBox(0, message); break; case 200: // CustomAddin -> Assy Only BOM for (int i = 0; i < ppoData.Length; i++) { IEdmFile10 file = (IEdmFile10)edmVault.GetObject(EdmObjectType.EdmObject_File, ppoData[i].mlObjectID1); IEdmBomView3 bomView = (IEdmBomView3)file.GetComputedBOM("BOM", 0, "@", (int)EdmBomFlag.EdmBf_AsBuilt | (int)EdmBomFlag.EdmBf_ShowSelected); string tempFileName = System.IO.Path.GetTempFileName(); bomView.SaveToCSV(tempFileName, true); string[] lines = System.IO.File.ReadAllLines(tempFileName); string csvFile = System.IO.Path.GetTempFileName() + ".csv"; using (System.IO.TextWriter writer = new System.IO.StreamWriter(csvFile)) { for (int j = 0; j < lines.Length; j++) { if (j == 0) { writer.WriteLine(lines[j]); } else if (lines[j].ToUpper().Contains("SLDASM")) { writer.WriteLine(lines[j]); } } System.Diagnostics.Process.Start(csvFile); } } break; default: break; } break; } }