private void btnConnect_Click(object sender, EventArgs e) { try { try { try { m_App = Marshal.GetActiveObject("PIProcessBook.Application.2") as PBObjLib.Application; } catch (Exception ex) { m_App = null; } if (m_App == null) { m_App = new PBObjLib.Application { Visible = true, RunMode = false }; } m_Database.Refresh(); } catch (Exception ex) { MessageBox.Show(this, "ProcessBook cann't be opened or activated", "", MessageBoxButtons.OK, MessageBoxIcon.Error); m_App = null; } } finally { } }
public static void Execute(PBObjLib.Application app) { Display ThisDisplay = app.ActiveDisplay; for (int i = 1; i <= ThisDisplay.SelectedSymbols.Count; i++) { try { Symbol s = ThisDisplay.SelectedSymbols.Item(i); if (s.Type == 7) { Value obj = (Value)ThisDisplay.SelectedSymbols.Item(i); //((PBSymLib.Text)obj).CanonicalNumberFormat = obj.NumberFormat = "0.0"; obj.ShowUOM = true; //((Symbol)obj).Font. = pbLeft; //string[] strArray = obj.GetTagName(1).Split('\\'); //obj.SetTagName(@"\\10.53.87.143\\" + (strArray[strArray.Length - 1])); } /* * if (ThisDisplay.Symbols.Item(i).IsMultiState == true) * { * PBObjLib.MultiState mState; * string tagN;//As String * mState = ThisDisplay.Symbols.Item(i).GetMultiState(); * tagN = mState.GetPtTagName(); * mState.SetPtTagName(tagN); * } * bool AVEAlignProp = true; * * if (AVEAlignProp) * { * if (ThisDisplay.Symbols.Item(i).Type == 10) * {// ������ id trend * Trend objTrend = (Trend)ThisDisplay.Symbols.Item(i); * if (objTrend.Name == "Trend1") * { * objTrend.Top = 15000; * objTrend.Left = -12651; * objTrend.Width = 289; * objTrend.Height = 93; * } * } * * if (ThisDisplay.Symbols.Item(i).Name.IndexOf("AVExtension") >= 0) * { * ThisDisplay.Symbols.Item(i).Top = 15000; * ThisDisplay.Symbols.Item(i).Left = -13023; * ThisDisplay.Symbols.Item(i).Width = 373; * ThisDisplay.Symbols.Item(i).Height = 93; * } * } */ } catch { } } }
public frmAbout(PBObjLib.Application app) { m_App = app; InitializeComponent(); string tmp = Path.GetTempPath() + @"\mPBScript.cs"; if (!File.Exists(tmp)) { File.Create(tmp).Close(); } editor.LoadFile(tmp); editor.Dock = DockStyle.Fill; // this.groupBox2.Controls.Add(editor); }
public static void SearchSymbolByTagName(PBObjLib.Application app) { Display ThisDisplay = app.ActiveDisplay; for (int i = 1; i <= ThisDisplay.Symbols.Count; i++) { try { Symbol s = ThisDisplay.Symbols.Item(i); if (s.Type == 7) { ThisDisplay.Symbols.Item(i).Selected = true; } } catch { } } }
public AlarmManager(PBObjLib.Application Application, Connect con) { m_App = Application; connect = con; InitializeComponent(); if (connect.treeNode != null) { try { //treeView1.Nodes.Clear(); connect.treeNode.TreeView.Nodes.Clear(); //treeView1.Nodes.Add(connect.treeNode); } catch (Exception e) { MessageBox.Show(e.Message); } } //treeView1.Nodes.Add(connect.treeNode); }
public ScriptForm(PBObjLib.Application app) { m_App = app; InitializeComponent(); editor.ShowEOLMarkers = false; editor.ShowSpaces = false; editor.ShowTabs = false; editor.ShowInvalidLines = false; editor.SetHighlighting("C#"); workDir = Path.GetTempPath() + "gPBToolKit\\"; fullPathDummyFile = workDir + DummyFileName; if (!Directory.Exists(workDir)) { Directory.CreateDirectory(workDir); } if (!Directory.Exists(workDir + "\\CSharpCodeCompletion\\")) { Directory.CreateDirectory(workDir + "\\CSharpCodeCompletion"); } string indexFile = workDir + "CSharpCodeCompletion\\index.dat"; if (!File.Exists(fullPathDummyFile)) { string sh = @"using System; using System.Collections.Generic; using System.Text; using PBObjLib; using PBSymLib; using VBIDE; using System.Windows.Forms; namespace gPBToolKit { public class gkScript { // ���������� �������� ������� public static void StartScript(Display d) { foreach (Symbol s in d.Symbols) { if (s.Type == 7) { Value v = (Value)s; v.BackgroundColor = 32768; v.ShowUOM = true; } } Action(d.Application); } public static void Action(PBObjLib.Application m_App) { try { VBProject project = null; CodeModule codeModule = null; for (int i = 1; i <= ((VBE)m_App.VBE).VBProjects.Count; i++) { VBProject bufProject = ((VBE)m_App.VBE).VBProjects.Item(i); if (bufProject.FileName.ToLower() == m_App.ActiveDisplay.Path.ToLower()) // ���� �� ��������� ����� ������ { project = bufProject; break; } } if (project == null) { MessageBox.Show(""VBProject not found""); return; } codeModule = project.VBComponents.Item(""ThisDisplay"").CodeModule; try { string procName = ""Display_Open""; int procCountLine = -1, procStart = -1; try{ procStart = codeModule.get_ProcBodyLine(procName, vbext_ProcKind.vbext_pk_Proc); procCountLine = codeModule.get_ProcCountLines(procName, vbext_ProcKind.vbext_pk_Proc); } catch{} if (procStart > 0) codeModule.DeleteLines(procStart, procCountLine); string srvName = ""do51-dc1-du-pis.sgpz.gpp.gazprom.ru""; string rootModule = ""����""; string dispOpenText = string.Format(@"" Private Sub Display_Open() AVExtension1.Initialize """"{0}"""", """"{1}"""", ThisDisplay, Trend1 End Sub"", srvName, rootModule); codeModule.AddFromString(dispOpenText); } catch (Exception ex) { MessageBox.Show(ex.Message + "" ""+ ex.StackTrace); } } catch { } } } } "; UTF8Encoding asciEncoding = new UTF8Encoding(); FileStream fs = File.Create(fullPathDummyFile); fs.Write(asciEncoding.GetBytes(sh), 0, asciEncoding.GetByteCount(sh)); fs.Close(); } if (!File.Exists(indexFile)) { File.Create(indexFile).Close(); } editor.LoadFile(fullPathDummyFile); refList.Items.Add("System.dll"); refList.Items.Add("System.Drawing.dll"); refList.Items.Add("System.Windows.Forms.dll"); refList.Items.Add(@"C:\Program Files (x86)\PIPC\Procbook\OSIsoft.PBObjLib.dll"); refList.Items.Add(@"C:\Program Files (x86)\PIPC\Procbook\OSIsoft.PBSymLib.dll"); refList.Items.Add(@"C:\Program Files (x86)\PIPC\Procbook\Interop.VBIDE.dll"); CodeCompletionKeyHandler.Attach(this, editor); HostCallbackImplementation.Register(this); pcRegistry = new Dom.ProjectContentRegistry(); // Default .NET 2.0 registry // Persistence caches referenced project contents for faster loading. // It also activates loading XML documentation files and caching them // for faster loading and lower memory usage. pcRegistry.ActivatePersistence(Path.Combine(workDir, "CSharpCodeCompletion")); myProjectContent = new Dom.DefaultProjectContent(); myProjectContent.Language = Dom.LanguageProperties.CSharp; }
public MultiStateMinMax(PBObjLib.Application app) { m_App = app; InitializeComponent(); }
public static void Execute(PBObjLib.Application app) { }
public ReplaceForm(PBObjLib.Application app) { m_App = app; InitializeComponent(); }
public void OnConnection(object Application, Extensibility.ext_ConnectMode ConnectMode, object AddInInst, ref System.Array custom) { try { m_theApp = (PBObjLib.Application)Application; #region command bar //this code attaches the add-in to the add-in command bar bool bPropertyExist = false; bool bMakeCoolExist = false; bool bUOMExist = false; bool bAlarmExist = false; bool bReplaceExist = false; bool bSearchTag = false; bool bScript = false; //delete this code if you do not desire to have the add-in added //to the commandbar as a button //add the command bar if it is not there..... PBObjLib.PBCommandBar pbCommandBar = m_theApp.CommandBars.Item("Add-Ins"); if (pbCommandBar == null) { m_theApp.CommandBars.Add("Add-Ins", 1, false, false); pbCommandBar = m_theApp.CommandBars.Item("Add-Ins"); } if (pbCommandBar != null) { PBObjLib.PBCommandBarControls pbControls = (PBObjLib.PBCommandBarControls)pbCommandBar.Controls; System.Collections.IEnumerator enumerator = pbControls.GetEnumerator(); while (enumerator.MoveNext()) { PBObjLib.PBCommandBarControl cb = (PBObjLib.PBCommandBarControl)enumerator.Current; //cb.Delete(); string strCurrName = cb.Caption.ToString(); if (strCurrName == m_strAddInName) { bPropertyExist = true; } if (strCurrName == m_strAddInName2) { bMakeCoolExist = true; } if (strCurrName == m_strAddInName3) { bUOMExist = true; } if (strCurrName == m_strAddInName4) { bAlarmExist = true; } if (strCurrName == m_strAddInName5) { bReplaceExist = true; } if (strCurrName == m_strAddInName6) { bSearchTag = true; } if (strCurrName == m_strAddInName7) { bScript = true; } } if (!bPropertyExist) { m_pbControl = (PBObjLib.PBCommandBarControl)pbControls.Add((Object)PBObjLib.pbControlType.pbControlButton, 1, null, null, false); m_pbControl.Caption = m_strAddInName; m_pbControl.ToolTipText = Res2.m_pbControlSettingsToolTipText; ((ECommandBarButtonEvents_Event)m_pbControl).Click += new PBObjLib.ECommandBarButtonEvents_ClickEventHandler(this.AddInClicked); } else { m_pbControl = (PBObjLib.PBCommandBarControl)pbControls.Item(m_strAddInName); } if (!bMakeCoolExist) { m_pbControlAlign = (PBObjLib.PBCommandBarControl)pbControls.Add((Object)PBObjLib.pbControlType.pbControlButton, 1, null, null, false); m_pbControlAlign.Caption = m_strAddInName2; ((ECommandBarButtonEvents_Event)m_pbControlAlign).Click += new PBObjLib.ECommandBarButtonEvents_ClickEventHandler(this.FillGood); } else { m_pbControlAlign = (PBObjLib.PBCommandBarControl)pbControls.Item(m_strAddInName2); } if (!bUOMExist) { m_pbControlUOM = (PBObjLib.PBCommandBarControl)pbControls.Add((Object)PBObjLib.pbControlType.pbControlButton, 1, null, null, false); m_pbControlUOM.Caption = m_strAddInName3; ((ECommandBarButtonEvents_Event)m_pbControlUOM).Click += new PBObjLib.ECommandBarButtonEvents_ClickEventHandler(this.SetUOM); } else { m_pbControlUOM = (PBObjLib.PBCommandBarControl)pbControls.Item(m_strAddInName3); } if (!bAlarmExist) { m_pbControlAlarm = (PBObjLib.PBCommandBarControl)pbControls.Add((Object)PBObjLib.pbControlType.pbControlButton, 1, null, null, false); m_pbControlAlarm.Caption = m_strAddInName4; ((ECommandBarButtonEvents_Event)m_pbControlAlarm).Click += new PBObjLib.ECommandBarButtonEvents_ClickEventHandler(this.ChangeAlarm); } else { m_pbControlAlarm = (PBObjLib.PBCommandBarControl)pbControls.Item(m_strAddInName4); } if (!bReplaceExist) { m_pbControlReplace = (PBObjLib.PBCommandBarControl)pbControls.Add((Object)PBObjLib.pbControlType.pbControlButton, 1, null, null, false); m_pbControlReplace.Caption = m_strAddInName5; ((ECommandBarButtonEvents_Event)m_pbControlReplace).Click += new PBObjLib.ECommandBarButtonEvents_ClickEventHandler(this.ReplaceInValue); } else { m_pbControlReplace = (PBObjLib.PBCommandBarControl)pbControls.Item(m_strAddInName5); } if (!bSearchTag) { m_pbControlSearch = (PBObjLib.PBCommandBarControl)pbControls.Add((Object)PBObjLib.pbControlType.pbControlButton, 1, null, null, false); m_pbControlSearch.Caption = m_strAddInName6; ((ECommandBarButtonEvents_Event)m_pbControlSearch).Click += new PBObjLib.ECommandBarButtonEvents_ClickEventHandler(this.SearchValue); } else { m_pbControlSearch = (PBObjLib.PBCommandBarControl)pbControls.Item(m_strAddInName6); } if (!bScript) { m_pbControlScript = (PBObjLib.PBCommandBarControl)pbControls.Add((Object)PBObjLib.pbControlType.pbControlButton, 1, null, null, false); m_pbControlScript.Caption = m_strAddInName7; ((ECommandBarButtonEvents_Event)m_pbControlScript).Click += new PBObjLib.ECommandBarButtonEvents_ClickEventHandler(this.ShowScriptForm); } else { m_pbControlScript = (PBObjLib.PBCommandBarControl)pbControls.Item(m_strAddInName7); } } #endregion } catch (Exception ex) { MessageBox.Show("Exception in OnConnection=" + ex.Message); } }
public SearchForm(PBObjLib.Application app) { m_App = app; InitializeComponent(); }