Skip to content

Commit

Permalink
1.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavo.gvs authored and gustavo.gvs committed Sep 15, 2023
1 parent 447cc3e commit f6ff3eb
Show file tree
Hide file tree
Showing 25 changed files with 1,201 additions and 351 deletions.
100 changes: 62 additions & 38 deletions PeriTAB/Class_AnyButtonClick_Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,92 @@
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;

namespace PeriTAB
{
internal class Class_AnyButtonClick_Event
{
public void Evento_AnyButtonClick()
public void Evento_AnyButtonClick(MyUserControl UC)
{
foreach (RibbonGroup g in Globals.Ribbons.Ribbon1.tab.Groups) //Loop botoes do Ribbon
//foreach (RibbonGroup g in Globals.Ribbons.Ribbon1.tab.Groups) //Loop botoes do Ribbon
//{
// foreach (RibbonControl c in g.Items)
// {
// if ((c.GetType()).Name == "RibbonButtonImpl")
// {
// RibbonButton b = (RibbonButton)c;
// b.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(Metodo_AnyButtonClick_Ribbon);
// }
// }
//}
if (Globals.ThisAddIn.Application.Documents.Count > 0 & Globals.ThisAddIn.iMyUserControl != null)
{
foreach (RibbonControl c in g.Items)
//MyUserControl MUC = Globals.ThisAddIn.Dicionario_Doc_e_UserControl[Globals.ThisAddIn.Application.ActiveDocument];
foreach (System.Windows.Forms.Button b1 in UC.Controls) //Loop botoes do Taskpane
{
if ((c.GetType()).Name == "RibbonButtonImpl")
if ((b1.GetType()).Name == "Button")
{
RibbonButton b = (RibbonButton)c;
b.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(Metodo_AnyButtonClick_Ribbon);
b1.Click += new System.EventHandler(Metodo_AnyButtonClick_TaskPane);
}
}
}
foreach (System.Windows.Forms.Button b1 in Globals.ThisAddIn.iUserControl1.Controls) //Loop botoes do Taskpane
{
if ((b1.GetType()).Name == "Button")
{
b1.Click += new System.EventHandler(Metodo_AnyButtonClick_TaskPane);
}
}
}

private void Metodo_AnyButtonClick_Ribbon(object sender, RibbonControlEventArgs e)
{
}
//private void Metodo_AnyButtonClick_Ribbon(object sender, RibbonControlEventArgs e)
//{
//}

private void Metodo_AnyButtonClick_TaskPane(object sender, EventArgs e)
{
//MessageBox.Show("AnyButtonClick_TaskPane");
//Revisa a habilitação do botao "Reinicia Lista" do TaskPane
Globals.ThisAddIn.iUserControl1.Habilita_button9(true);
if (Globals.ThisAddIn.Application.Selection.Paragraphs.Count > 1 | Globals.ThisAddIn.Application.Selection.Range.ListFormat.ListType == 0 | Globals.ThisAddIn.Application.Selection.Range.ListFormat.ListValue == 1) { Globals.ThisAddIn.iUserControl1.Habilita_button9(false); }
if (Globals.ThisAddIn.CustomTaskPanes.Count > 0)
{
Globals.ThisAddIn.iMyUserControl.Habilita_button9(true);
if (Globals.ThisAddIn.Application.Selection.Paragraphs.Count > 1 | Globals.ThisAddIn.Application.Selection.Range.ListFormat.ListType == WdListType.wdListNoNumbering | Globals.ThisAddIn.Application.Selection.Range.ListFormat.ListValue == 1) { Globals.ThisAddIn.iMyUserControl.Habilita_button9(false); }
}

//Revisa o destaque dos botoes do TaskPane
Globals.ThisAddIn.iUserControl1.Remove_Destaque_Botoes();
Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); //inicia cronometro
foreach (Microsoft.Office.Interop.Word.Paragraph p in Globals.ThisAddIn.Application.Selection.Paragraphs)
{
if (stopWatch.Elapsed.TotalSeconds > 0.2) break; //limita tempo de processamento
Microsoft.Office.Interop.Word.Style s = p.Range.get_Style();
if (s != null)
if (Globals.ThisAddIn.CustomTaskPanes.Count > 0){
Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); //inicia cronometro
MyUserControl MUC = Globals.ThisAddIn.Dicionario_Doc_e_UserControl[Globals.ThisAddIn.Application.ActiveDocument];
Globals.ThisAddIn.iMyUserControl.Remove_Destaque_Botoes(MUC);
foreach (Microsoft.Office.Interop.Word.Paragraph p in Globals.ThisAddIn.Application.Selection.Paragraphs)
{
if (s.NameLocal == "01 - Sem Formatação (PeriTAB)") Globals.ThisAddIn.iUserControl1.Habilita_Destaca_button1(true, true);
if (s.NameLocal == "02 - Corpo do Texto (PeriTAB)") Globals.ThisAddIn.iUserControl1.Habilita_Destaca_button2(true, true);
if (s.NameLocal == "03 - Citações (PeriTAB)") Globals.ThisAddIn.iUserControl1.Habilita_Destaca_button3(true, true);
if (s.NameLocal == "04a - Seção_1 (PeriTAB)") Globals.ThisAddIn.iUserControl1.Habilita_Destaca_button4(true, true);
if (s.NameLocal == "04b - Seção_2 (PeriTAB)") Globals.ThisAddIn.iUserControl1.Habilita_Destaca_button5(true, true);
if (s.NameLocal == "04c - Seção_3 (PeriTAB)") Globals.ThisAddIn.iUserControl1.Habilita_Destaca_button6(true, true);
if (s.NameLocal == "04d - Seção_4 (PeriTAB)") Globals.ThisAddIn.iUserControl1.Habilita_Destaca_button7(true, true);
if (s.NameLocal == "05 - Enumerações (PeriTAB)") Globals.ThisAddIn.iUserControl1.Habilita_Destaca_button8(true, true);
if (s.NameLocal == "06 - Figuras (PeriTAB)") Globals.ThisAddIn.iUserControl1.Habilita_Destaca_button10(true, true);
if (s.NameLocal == "07 - Legendas de Figuras (PeriTAB)") Globals.ThisAddIn.iUserControl1.Habilita_Destaca_button11(true, true);
if (s.NameLocal == "08 - Legendas de Tabelas (PeriTAB)") Globals.ThisAddIn.iUserControl1.Habilita_Destaca_button12(true, true);
if (s.NameLocal == "09 - Quesitos (PeriTAB)") Globals.ThisAddIn.iUserControl1.Habilita_Destaca_button13(true, true);
if (stopWatch.Elapsed.TotalSeconds > 0.2) break; //limita tempo de processamento
Microsoft.Office.Interop.Word.Style s = null;
try { s = p.Range.get_Style(); } catch (System.Runtime.InteropServices.COMException ex) { }
if (s != null)
{
if (s.NameLocal == "01 - Sem Formatação (PeriTAB)") MUC.Habilita_Destaca_button1(true, true);
if (s.NameLocal == "02 - Corpo do Texto (PeriTAB)") MUC.Habilita_Destaca_button2(true, true);
if (s.NameLocal == "03 - Citações (PeriTAB)") MUC.Habilita_Destaca_button3(true, true);
if (s.NameLocal == "04a - Seção_1 (PeriTAB)") MUC.Habilita_Destaca_button4(true, true);
if (s.NameLocal == "04b - Seção_2 (PeriTAB)") MUC.Habilita_Destaca_button5(true, true);
if (s.NameLocal == "04c - Seção_3 (PeriTAB)") MUC.Habilita_Destaca_button6(true, true);
if (s.NameLocal == "04d - Seção_4 (PeriTAB)") MUC.Habilita_Destaca_button7(true, true);
if (s.NameLocal == "05 - Enumerações (PeriTAB)") MUC.Habilita_Destaca_button8(true, true);
if (s.NameLocal == "06 - Figuras (PeriTAB)") MUC.Habilita_Destaca_button10(true, true);
if (s.NameLocal == "07 - Legendas de Figuras (PeriTAB)") MUC.Habilita_Destaca_button11(true, true);
if (s.NameLocal == "08 - Legendas de Tabelas (PeriTAB)") MUC.Habilita_Destaca_button12(true, true);
if (s.NameLocal == "09 - Quesitos (PeriTAB)") MUC.Habilita_Destaca_button13(true, true);
//if (s.NameLocal == "01 - Sem Formatação (PeriTAB)") Globals.ThisAddIn.iMyUserControl.Habilita_Destaca_button1(true, true);
//if (s.NameLocal == "02 - Corpo do Texto (PeriTAB)") Globals.ThisAddIn.iMyUserControl.Habilita_Destaca_button2(true, true);
//if (s.NameLocal == "03 - Citações (PeriTAB)") Globals.ThisAddIn.iMyUserControl.Habilita_Destaca_button3(true, true);
//if (s.NameLocal == "04a - Seção_1 (PeriTAB)") Globals.ThisAddIn.iMyUserControl.Habilita_Destaca_button4(true, true);
//if (s.NameLocal == "04b - Seção_2 (PeriTAB)") Globals.ThisAddIn.iMyUserControl.Habilita_Destaca_button5(true, true);
//if (s.NameLocal == "04c - Seção_3 (PeriTAB)") Globals.ThisAddIn.iMyUserControl.Habilita_Destaca_button6(true, true);
//if (s.NameLocal == "04d - Seção_4 (PeriTAB)") Globals.ThisAddIn.iMyUserControl.Habilita_Destaca_button7(true, true);
//if (s.NameLocal == "05 - Enumerações (PeriTAB)") Globals.ThisAddIn.iMyUserControl.Habilita_Destaca_button8(true, true);
//if (s.NameLocal == "06 - Figuras (PeriTAB)") Globals.ThisAddIn.iMyUserControl.Habilita_Destaca_button10(true, true);
//if (s.NameLocal == "07 - Legendas de Figuras (PeriTAB)") Globals.ThisAddIn.iMyUserControl.Habilita_Destaca_button11(true, true);
//if (s.NameLocal == "08 - Legendas de Tabelas (PeriTAB)") Globals.ThisAddIn.iMyUserControl.Habilita_Destaca_button12(true, true);
//if (s.NameLocal == "09 - Quesitos (PeriTAB)") Globals.ThisAddIn.iMyUserControl.Habilita_Destaca_button13(true, true);
}
}
}
}

}
}
4 changes: 2 additions & 2 deletions PeriTAB/Class_Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public void button_limpa_estilos_Default()

public void toggleButton_estilos_Default()
{
Globals.Ribbons.Ribbon1.toggleButton_estilos.Checked = bool.Parse(preferences.painel_de_estilos);
Globals.ThisAddIn.TaskPane1.Visible = bool.Parse(preferences.painel_de_estilos);
Globals.Ribbons.Ribbon1.toggleButton_painel_de_estilos_velho.Checked = bool.Parse(preferences.painel_de_estilos);
//Globals.ThisAddIn.TaskPane1.Visible = bool.Parse(preferences.painel_de_estilos);
}

public void button_cola_imagem_Default()
Expand Down
35 changes: 35 additions & 0 deletions PeriTAB/Class_DocumentBeforeClose_Event .cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Word;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;

namespace PeriTAB
{
internal class Class_DocumentBeforeClose_Event
{
public void Evento_DocumentBeforeClose()
{
Globals.ThisAddIn.Application.DocumentBeforeClose += new ApplicationEvents4_DocumentBeforeCloseEventHandler(Metodo_DocumentBeforeClose);
}
private void Metodo_DocumentBeforeClose(Document Doc, ref bool Cancel)
{
//Class_New_or_Open_Event.list_TaskPane.Remove(Class_New_or_Open_Event.TaskPane_1);
//bool b = Globals.ThisAddIn.CustomTaskPanes.Remove(Class_New_or_Open_Event.TaskPane_1);
try
{
Microsoft.Office.Tools.CustomTaskPane CTP = Class_New_or_Open_Event.Dicionario_Doc_e_TaskPane[Doc];
//bool b = Globals.ThisAddIn.CustomTaskPanes.Remove(CTP);
Globals.ThisAddIn.CustomTaskPanes.Remove(CTP);
Class_New_or_Open_Event.Dicionario_Doc_e_TaskPane.Remove(Doc);
Globals.ThisAddIn.Dicionario_Doc_e_UserControl.Remove(Doc);
}
catch (System.Collections.Generic.KeyNotFoundException ex) { }
//if (b) MessageBox.Show("Taskpane removed");
}
}
}
Loading

0 comments on commit f6ff3eb

Please sign in to comment.