Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…alendarSync into release

Resolves #1068
  • Loading branch information
phw198 committed Nov 22, 2020
2 parents 4719f5a + f6bc4c2 commit 11f3aa2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 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 @@ -399,6 +402,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 @@ -1265,6 +1270,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 @@ -1288,6 +1294,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 @@ -1298,6 +1305,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 @@ -1624,6 +1632,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 @@ -1632,6 +1641,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
2 changes: 1 addition & 1 deletion src/OutlookGoogleCalendarSync/GoogleOgcs/EventColour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public void Get() {
/// <param name="colourId">Google ID</param>
public Palette GetColour(String colourId) {
Palette gColour = this.ActivePalette.Where(x => x.Id == colourId).FirstOrDefault();
if (gColour != null)
if (colourId != "0" && gColour != null)
return gColour;
else
return Palette.NullPalette;
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 @@ -302,6 +302,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 @@ -519,6 +521,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 11f3aa2

Please sign in to comment.