This forum is read-only - Please use our new Citavi Forum instead.
Dieses Forum dient nur zur Recherche - Bitte nutzen Sie das neue Citavi Forum für Ihre Fragen.

Erste Schritte bei der Programmierung von Citavi Add-Ons

Installationsanleitung und allgemeine Informationen zu Citavi Add-Ons

Erste Schritte bei der Programmierung von Citavi Add-Ons

Postby Thomas Schempp » 2012-04-02 17:15

Am 29. März 2012 fand ein Webinar zum Thema "Citavi Add-Ons entwickeln" statt. Wir stellen hier die Unterlagen dieses Webinars zum Download zur Verfügung.


PowerPoint - Citavi 3 Architektur.pdf
(214.19 KiB) Downloaded 606 times





Code-Snippet 1
Code: Select all
public string GetFilterResult(Reference reference, out bool handled)
{
   handled = true;
   return "Hello World (" + reference.Title.Substring(0, Math.Min(15, reference.Title.Length)) + "...)";
}


Code-Snippet 2
Code: Select all
protected override void OnHostingFormLoaded(System.Windows.Forms.Form hostingForm)
{
   if (Reference.ShortTitleFilter == null)
   {
      Reference.ShortTitleFilter = new Filter();
   }

   base.OnHostingFormLoaded(hostingForm);
}


Code-Snippet 3
Code: Select all
MainForm mainForm = (MainForm)hostingForm;
         mainForm.GetMainCommandbarManager().GetReferenceEditorCommandbar(MainFormReferenceEditorCommandbarId.Menu).GetCommandbarMenu(MainFormReferenceEditorCommandbarMenuId.Tools).AddCommandbarButton("GenerateShortTitle", "Re-build all short titles");


Code-Snippet 4
Code: Select all
protected override void OnBeforePerformingCommand(SwissAcademic.Controls.BeforePerformingCommandEventArgs e)
{
   switch (e.Key)
   {
      case "GenerateShortTitle":
         {
            e.Handled = true;

            var filter = new Filter();
            bool handled;
            var mainForm = (MainForm)e.Form;

            foreach (var reference in mainForm.Project.References.ToList())
            {
               reference.ShortTitle = filter.GetFilterResult(reference, out handled);
               reference.ShortTitleUpdateType = UpdateType.Manual;
            }

            System.Windows.Forms.MessageBox.Show("Fertig");
         }
         break;
   }
   base.OnBeforePerformingCommand(e);
}


Code-Snippet 5
Code: Select all
public override AddOnHostingForm HostingForm
{
   get { return AddOnHostingForm.PersonList; }
}

protected override void OnHostingFormLoaded(System.Windows.Forms.Form hostingForm)
{
   var personList = (PersonList)hostingForm;

   var menuEntry = personList.GetCommandbar(PersonListCommandbarId.Menu).GetCommandbarMenu(PersonListCommandbarMenuId.Persons).AddCommandbarButton("ApplyRelatedReferencesAsSelection", "Apply related references as selection");
   menuEntry.HasSeparator = true;
   menuEntry.Image = SwissAcademic.Citavi.Shell.Properties.Resources.Filter;

   base.OnHostingFormLoaded(hostingForm);
}

protected override void OnBeforePerformingCommand(SwissAcademic.Controls.BeforePerformingCommandEventArgs e)
{
   switch (e.Key)
   {
      case "ApplyRelatedReferencesAsSelection":
         {
            e.Handled = true;

            var personList = (PersonList)e.Form;

            var references = new List<Reference>();

            foreach (var person in personList.GetSelectedPersons())
            {
               foreach (var reference in person.References)
               {
                  if (!references.Contains(reference))
                  {
                     references.Add(reference);
                  }
               }
            }

            var mainForm = personList.ProjectShell.PrimaryMainForm;

            var referenceFilter = new ReferenceFilter(references, "List of persons");
            var filters = new List<ReferenceFilter> { referenceFilter };

            mainForm.ReferenceEditorFilterSet.Filters.ReplaceBy(filters);

            Program.ActivateForm(mainForm);
         }
         break;
   }

   base.OnBeforePerformingCommand(e);
}
Thomas Schempp
Citavi Customer Service
 

Return to Über Citavi Add-Ons