大家都知道,citavi的文献管理非常方便,还有很好用的宏可以扩展功能
以下是我整理的一些自己常用的宏功能:
1、将Citavi的Group(分组)转为Category/Categories(分类)
我将endnote数据库导入到Citavi后,endnote的分组(Group)无损转换成了Group,但是想要变成Citavi的Category怎么办呢,毕竟Category可以多层级,利用宏就可以实现:
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Linq;
using SwissAcademic.Citavi;
using SwissAcademic.Citavi.Shell;
// 将Groups的分组平移到categories里,保留住相应的文献, citavi 6.8亲测
// 新奥尔良烤乳猪 qq3060191344; 小明 qq1429851250
//citavi交流群 202835945
public static class CitaviMacro
{
public static void Main()
{
if (Program.ProjectShells.Count == 0) return; //no project open
if (IsBackupAvailable() == false) return; //user wants to backup his/her project first
List<Reference> references = Program.ActiveProjectShell.PrimaryMainForm.GetFilteredReferences();
//reference to active Project
Project activeProject = Program.ActiveProjectShell.Project;
if (activeProject == null) return;
Dictionary<string, Category> categoryDictionary = new Dictionary<string, Category>();
foreach(Group keyword in activeProject.Groups)
{
Category category = activeProject.Categories.FirstOrDefault(item => item.Name.Equals(keyword.FullName, StringComparison.OrdinalIgnoreCase));
if (category == null)
{
category = activeProject.Categories.Add(keyword.FullName);
}
categoryDictionary[keyword.FullName] = category;
}
foreach (Reference reference in activeProject.References)
{
foreach(Group referenceGroup in reference.Groups)
{
reference.Categories.Add(categoryDictionary[referenceGroup.FullName]);
}
}
}
// Ask whether backup is available
private static bool IsBackupAvailable()
{
string warning = String.Concat("Important: This macro will make irreversible changes to your project.",
"\r\n\r\n", "Make sure you have a current backup of your project before you run this macro.",
"\r\n", "If you aren't sure, click Cancel and then, in the main Citavi window, on the File menu, click Create backup.",
"\r\n\r\n", "Do you want to continue?"
);
return (MessageBox.Show(warning, "Citavi", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.OK);
}
}
宏的使用
打开macro editor操作面板,Citavi的宏其实类似于一个临时插件,用一次加载一次。
把宏代码输入进去,run就可以了。
2、Citavi界面太小了,放大citavi的字体
还是用宏:
using System;
using System.Linq;
using System.ComponentModel;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using SwissAcademic.Citavi;
using SwissAcademic.Citavi.Metadata;
using SwissAcademic.Citavi.Shell;
using SwissAcademic.Collections;
using System.Drawing;
//citavi 6.8亲测
// 新奥尔良烤乳猪 qq3060191344; 小明 qq1429851250
//citavi交流群 202835945
public static class CitaviMacro
{
public static void Main()
{
Project project = Program.ActiveProjectShell.Project;
MainForm mainForm = Program.ActiveProjectShell.PrimaryMainForm;
Font font = new Font(mainForm.Font.FontFamily,14); // 在此处指定所需的字体名称和字体大小
mainForm.Font = font;
// MessageBox.Show("设置成功");
}
}
//citavi交流群 202835945