public static void InitInstance(VSWindowTitleChangerPackage package) { Debug.Assert(m_Globals == null); if (m_Globals == null) { m_Globals = new PackageGlobals(package); } }
protected override void Initialize() { Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); base.Initialize(); // We do delayed initialization because DTE is currently null... PackageGlobals.BeginInvokeOnUIThread(DelayedInit); }
public static void DeinitInstance() { Debug.Assert(m_Globals != null); if (m_Globals != null) { m_Globals.Cleanup(); m_Globals = null; } }
public void Update() { #if VS2010_AND_LATER if (m_TitleTextBlock == null && PackageGlobals.Instance().DTEMajorVersion > 10) { TryfindTitleTextBlock(); } #endif UpdateAppActive(); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { IWindowsFormsEditorService edsvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edsvc != null) { // Intentionally showing a non-modal dialog to allow the user to // play around with the IDE/ while changing the plugin settings. PackageGlobals.Instance().ShowTitleExpressionEditor(); return(value); } } return(value); }
void StartCompilation(int undo_entry_id) { m_MostRecentUndoEntryId = undo_entry_id; if (m_CompilerThread == null || m_ExpressionTextBox == null || m_CompileTimeConstants == null) { return; } Parser parser = new Parser(m_ExpressionTextBox.Text, PackageGlobals.Instance().ExecFuncEvaluator, m_CompileTimeConstants); ExpressionCompilerJob job = new ExpressionCompilerJob(parser, PackageGlobals.Instance().CreateFreshEvalContext(), true, null); job.OnCompileFinished += OnCompileFinished; job.UserData = (IntPtr)m_MostRecentUndoEntryId; m_CompilerThread.RemoveAllJobs(); m_CompilerThread.AddJob(job); }
public void Write(string msg) { Debug.Write(msg); if (m_Package == null) { return; } PackageGlobals.InvokeOnUIThread(delegate() { IVsOutputWindowPane output_pane = m_Package.GetOutputPane(GuidList.guidVSWindowTitleChangerCmdSet, "VSWindowTitleChanger"); if (output_pane != null) { output_pane.OutputString(msg); } }); }
void VariablesChanged() { #if !DEBUG_GUI PackageGlobals globals = PackageGlobals.Instance(); bool first_time = m_VariableNameToLVI.Count == 0; List <string> variable_names = new List <string>(m_Variables.Keys); if (first_time) { variable_names.AddRange(globals.CompileTimeConstants.VariableValues.Keys); } variable_names.Sort(); foreach (string name in variable_names) { if (first_time) { // Skipping the "true" and "false" compile time constants. if (name.Equals("true", StringComparison.OrdinalIgnoreCase) || name.Equals("false", StringComparison.OrdinalIgnoreCase)) { continue; } Value val; if (!m_Variables.TryGetValue(name, out val)) { val = globals.CompileTimeConstants.VariableValues[name]; } ListViewItem lvi = new ListViewItem(name); lvi.Font = editTitleExpression.Font; ListViewItem.ListViewSubItem lvsi = lvi.SubItems.Add(val.ToString()); lvsi.Font = lvi.Font; lvsi = lvi.SubItems.Add(val.GetType().ToString().ToLower()); lvsi.Font = lvi.Font; listVariables.Items.Add(lvi); m_VariableNameToLVI[name] = lvi; } else { Value val = m_Variables[name]; ListViewItem lvi = m_VariableNameToLVI[name]; lvi.SubItems[1].Text = val.ToString(); lvi.SubItems[2].Text = val.GetType().ToString().ToLower(); } } #endif m_BackgroundExpressionCompiler.ForceRecompile(); }
public virtual void Execute() { Debug.Assert(m_Error == null && m_Expression == null); try { if (m_Cache != null) { CompiledExpression compiled_expression = m_Cache.GetEntry(m_Parser.Text); m_Expression = compiled_expression.expression; m_Error = compiled_expression.compile_error; m_ContainsExec = compiled_expression.contains_exec; } else { m_Expression = m_Parser.Parse(); m_ContainsExec = m_Parser.ContainsExec; } if (m_Expression != null && m_EvalContext != null) { m_EvalResult = m_Expression.Evaluate(new SafeEvalContext(m_EvalContext)); if (m_CollectUnresolvedVariables) { m_SortedUnresolvedVariables = m_Expression.CollectUnresolvedVariables(m_EvalContext); m_SortedUnresolvedVariables.Sort(new VariablePosComparer()); } } } catch (Exception ex) { m_Error = ex; } PackageGlobals.BeginInvokeOnUIThread(delegate() { if (OnCompileFinished != null) { OnCompileFinished(this); } }); }
protected override void Dispose(bool disposing) { Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Dispose() of: {0}", this.ToString())); Debug.Assert(disposing); if (m_ExpressionCompilerThread != null) { m_ExpressionCompilerThread.Dispose(); m_ExpressionCompilerThread = null; } PackageGlobals.DeinitInstance(); if (m_UpdateTimer != null) { m_UpdateTimer.Stop(); } IVsSolution vs_solution = (IVsSolution)GetService(typeof(IVsSolution)); if (vs_solution != null) { vs_solution.UnadviseSolutionEvents(m_SolutionEventsCookie); } IVsDebugger debugger = (IVsDebugger)GetService(typeof(IVsDebugger)); if (debugger != null) { debugger.UnadviseDebuggerEvents(m_DebuggerEventsCookie); } if (m_VSMainWindow != null) { m_VSMainWindow.Deinitialize(); m_VSMainWindow = null; } base.Dispose(disposing); }
private void DelayedInit() { DTE dte = (DTE)GetService(typeof(DTE)); if (dte == null) { // Usually this branch never executes but I want to make sure... PackageGlobals.BeginInvokeOnUIThread(DelayedInit); return; } m_VSMainWindow = new VSMainWindow(); m_VSMainWindow.Initialize((IntPtr)dte.MainWindow.HWnd); m_VSMainWindow.OnWindowTitleUpdateNeeded += m_VSMainWindow_OnWindowTitleUpdateNeeded; m_UpdateTimer = new System.Windows.Forms.Timer(); m_UpdateTimer.Tick += UpdateTimer_Tick; m_UpdateTimer.Interval = UPDATE_PERIOD_MILLISECS; m_UpdateTimer.Start(); IVsSolution vs_solution = (IVsSolution)GetService(typeof(IVsSolution)); vs_solution.AdviseSolutionEvents(this, out m_SolutionEventsCookie); IVsDebugger debugger = (IVsDebugger)GetService(typeof(IVsDebugger)); debugger.AdviseDebuggerEvents(this, out m_DebuggerEventsCookie); PackageGlobals.InitInstance(this); m_PrevVariableValues = PackageGlobals.Instance().CreateFreshEvalContext().VariableValues; m_ExpressionCompilerThread = new ExpressionCompilerThread(); // During normal use the expression doesn't change except when configuring so a cache size of 1 does the job quite well. // Usually what changes is the variables. m_CompiledExpressionCache = new CompiledExpressionCache(PackageGlobals.Instance().ExecFuncEvaluator, PackageGlobals.Instance().CompileTimeConstants, 1); UpdateWindowTitle(); }
void TitleSetupEditor_VisibleChanged(object sender, EventArgs e) { if (Visible) { m_ClosingWithOK = false; #if !DEBUG_GUI m_BackgroundExpressionCompiler.CompileTimeConstants = PackageGlobals.Instance().CompileTimeConstants; #endif m_BackgroundExpressionCompiler.Enabled = true; } else { m_BackgroundExpressionCompiler.Enabled = false; TitleSetup = new TitleSetup(); // Don't fill an empty string into editTitleExpression.Text because its a know bug that // it resets the tabsize we previously set with SetTabStopChars(). editTitleExpression.Text = " "; editTitleExpression.ClearUndo(); } UpdateExecDebug(); }
void UpdateExecDebug() { PackageGlobals.Instance().ExecFuncEvaluator.DebugMode = Visible && checkBoxDebugExec.Checked; }
void Schedule_UpdateWindowTitle() { PackageGlobals.BeginInvokeOnUIThread(UpdateWindowTitle); }
private void UpdateWindowTitle() { m_VSMainWindow.Update(); PackageGlobals globals = PackageGlobals.Instance(); EvalContext eval_ctx = globals.CreateFreshEvalContext(); bool variables_changed = !CompareVariables(eval_ctx.VariableValues, m_PrevVariableValues); if (variables_changed) { m_PrevVariableValues = eval_ctx.VariableValues; globals.TitleSetupEditor.Variables = eval_ctx.VariableValues; } ToolOptions options = (ToolOptions)GetDialogPage(typeof(ToolOptions)); #if VS2010_AND_LATER if (m_DebugPrintTitleControlHierarchyCount < 5 && options.Debug) { ++m_DebugPrintTitleControlHierarchyCount; m_VSMainWindow.DebugPrintTitleControlHierarchy(); } #endif PackageGlobals.VSMultiInstanceInfo multi_instance_info; globals.GetVSMultiInstanceInfo(out multi_instance_info); bool extension_active; switch (options.ExtensionActivationRule) { case EExtensionActivationRule.ActiveWithMultipleVSInstances: extension_active = multi_instance_info.multiple_instances; break; case EExtensionActivationRule.ActiveWithMultipleVSInstancesOfTheSameVersion: extension_active = multi_instance_info.multiple_instances_same_version; break; case EExtensionActivationRule.AlwaysInactive: extension_active = false; break; default: extension_active = true; break; } if (extension_active) { TitleSetup title_setup = globals.TitleSetup; if (m_ExpressionContainsExec || variables_changed || m_PrevExtensionActivationRule != options.ExtensionActivationRule || title_setup.TitleExpression != m_PrevTitleExpressionStr) { Parser parser = new Parser(title_setup.TitleExpression, globals.ExecFuncEvaluator, globals.CompileTimeConstants);; ExpressionCompilerJob job = new ExpressionCompilerJob(parser, globals.CreateFreshEvalContext(), false, m_CompiledExpressionCache); job.OnCompileFinished += OnCompileFinished; m_ExpressionCompilerThread.RemoveAllJobs(); m_ExpressionCompilerThread.AddJob(job); } m_PrevTitleExpressionStr = title_setup.TitleExpression; } else { m_VSMainWindow.SetTitle(m_VSMainWindow.OriginalTitle); } m_PrevExtensionActivationRule = options.ExtensionActivationRule; }
public void PrintControlHierarchy(PackageGlobals.DebugOutputInterface debug_output, DependencyObject node, int level) { string indent = new string(' ', level * 4); for (int i = 0, e = VisualTreeHelper.GetChildrenCount(node); i < e; ++i) { DependencyObject child = VisualTreeHelper.GetChild(node, i); if (child != null) { Type type = child.GetType(); if (type == typeof(System.Windows.Controls.TextBlock) || type.IsSubclassOf(typeof(System.Windows.Controls.TextBlock))) { System.Windows.Controls.TextBlock text_block = (System.Windows.Controls.TextBlock)child; debug_output.WriteLine(indent + type.FullName + " \"" + text_block.Text + "\""); } else { debug_output.WriteLine(indent + type.FullName); } PrintControlHierarchy(debug_output, child, level + 1); } } }
public static void InitInstance(VSWindowTitleChangerPackage package) { Debug.Assert(m_Globals == null); if (m_Globals == null) m_Globals = new PackageGlobals(package); }