Skip to content

Commit

Permalink
Setting to allow only a single Outlook category to be synced to Outlook.
Browse files Browse the repository at this point in the history
  • Loading branch information
phw198 committed Oct 31, 2020
1 parent 0ccc6a0 commit 2a69c8d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/OutlookGoogleCalendarSync/Forms/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/OutlookGoogleCalendarSync/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ private void updateGUIsettings() {
ToolTips.SetToolTip(cbCloakEmail,
"Google has been known to send meeting updates to attendees without your consent.\n" +
"This option safeguards against that by appending '"+ GoogleOgcs.EventAttendee.EmailCloak +"' to their email address.");
ToolTips.SetToolTip(cbSingleCategoryOnly,
"Only allow a single Outlook category - ie 1:1 sync with Google.\n" +
"Otherwise, for multiple categories and only one synced with OGCS, manually prefix the category name(s) with \"OGCS \".");
ToolTips.SetToolTip(cbReminderDND,
"Do Not Disturb: Don't sync reminders to Google if they will trigger between these times.");

Expand Down Expand Up @@ -398,6 +401,8 @@ private void updateGUIsettings() {
dtDNDend.Value = Settings.Instance.ReminderDNDend;
cbAddColours.Checked = Settings.Instance.AddColours;
btColourMap.Enabled = Settings.Instance.AddColours;
cbSingleCategoryOnly.Checked = Settings.Instance.SingleCategoryOnly;
cbSingleCategoryOnly.Enabled = Settings.Instance.AddColours && Settings.Instance.SyncDirection.Id != Sync.Direction.OutlookToGoogle.Id;
this.gbSyncOptions_What.ResumeLayout();
#endregion
#endregion
Expand Down Expand Up @@ -1261,6 +1266,7 @@ private void syncDirection_SelectedIndexChanged(object sender, EventArgs e) {
tbTargetCalendar.Items.Remove("target calendar");
tbTargetCalendar.SelectedIndex = 0;
tbTargetCalendar.Enabled = true;
cbSingleCategoryOnly.Visible = true;
} else {
cbObfuscateDirection.Enabled = false;
cbObfuscateDirection.SelectedIndex = Settings.Instance.SyncDirection.Id - 1;
Expand All @@ -1284,6 +1290,7 @@ private void syncDirection_SelectedIndexChanged(object sender, EventArgs e) {
this.lDNDand.Visible = false;
this.ddGoogleColour.Visible = false;
this.ddOutlookColour.Visible = true;
this.cbSingleCategoryOnly.Visible = true;
}
if (Settings.Instance.SyncDirection == Sync.Direction.OutlookToGoogle) {
Sync.Engine.Instance.RegisterForPushSync();
Expand All @@ -1294,6 +1301,7 @@ private void syncDirection_SelectedIndexChanged(object sender, EventArgs e) {
this.lDNDand.Visible = true;
this.ddGoogleColour.Visible = true;
this.ddOutlookColour.Visible = false;
this.cbSingleCategoryOnly.Visible = false;
}
cbAddAttendees_CheckedChanged(null, null);
cbAddReminders_CheckedChanged(null, null);
Expand Down Expand Up @@ -1620,6 +1628,7 @@ private void cbCloakEmail_CheckedChanged(object sender, EventArgs e) {
private void cbAddColours_CheckedChanged(object sender, EventArgs e) {
Settings.Instance.AddColours = cbAddColours.Checked;
btColourMap.Enabled = Settings.Instance.AddColours;
cbSingleCategoryOnly.Enabled = Settings.Instance.AddColours;
}
private void btColourMap_Click(object sender, EventArgs e) {
if (Settings.Instance.UseGoogleCalendar == null || string.IsNullOrEmpty(Settings.Instance.UseGoogleCalendar.Id)) {
Expand All @@ -1628,6 +1637,9 @@ private void btColourMap_Click(object sender, EventArgs e) {
}
new Forms.ColourMap().ShowDialog(this);
}
private void cbSingleCategoryOnly_CheckedChanged(object sender, EventArgs e) {
Settings.Instance.SingleCategoryOnly = cbSingleCategoryOnly.Checked;
}
#endregion
#endregion
#region Application settings
Expand Down
8 changes: 6 additions & 2 deletions src/OutlookGoogleCalendarSync/OutlookOgcs/OutlookCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,12 @@ public Boolean UpdateCalendarEntry(ref AppointmentItem ai, Event ev, ref int ite
}
String gCategoryName = getColour(ev.ColorId, oCategoryName ?? "");
if (Sync.Engine.CompareAttribute("Category/Colour", Sync.Direction.GoogleToOutlook, gCategoryName, oCategoryName, sb, ref itemModified)) {
//Only allow one OGCS category at a time (Google Events can only have one colour)
aiCategories.RemoveAll(x => x.StartsWith("OGCS ") || x == gCategoryName);
if (Settings.Instance.SingleCategoryOnly)
aiCategories = new List<string>();
else {
//Only allow one OGCS category at a time (Google Events can only have one colour)
aiCategories.RemoveAll(x => x.StartsWith("OGCS ") || x == gCategoryName);
}
aiCategories.Insert(0, gCategoryName);
ai.Categories = String.Join(Categories.Delimiter, aiCategories.ToArray());
}
Expand Down
3 changes: 3 additions & 0 deletions src/OutlookGoogleCalendarSync/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ public String GaccountEmail_masked() {
Namespace = "http://schemas.datacontract.org/2004/07/OutlookGoogleCalendarSync"
)]
public class ColourMappingDictionary : Dictionary<String, String> { }
/// <summary>Only allow Outlook to have one category assigned</summary>
[DataMember] public Boolean SingleCategoryOnly { get; set; }

//Obfuscation
[DataMember] public Obfuscate Obfuscation { get; set; }
Expand Down Expand Up @@ -516,6 +518,7 @@ public void LogSettings() {
ColourMaps.ToList().ForEach(c => log.Info(" " + OutlookOgcs.Calendar.Categories.OutlookColour(c.Key) + ":" + c.Key + " <=> " +
c.Value + ":" + GoogleOgcs.EventColour.Palette.GetColourName(c.Value)));
}
log.Info(" SingleCategoryOnly: " + SingleCategoryOnly);
log.Info(" Obfuscate Words: " + Obfuscation.Enabled);
if (Obfuscation.Enabled) {
if (Settings.Instance.Obfuscation.FindReplace.Count == 0) log.Info(" No regex defined.");
Expand Down

0 comments on commit 2a69c8d

Please sign in to comment.