diff --git a/src/OutlookGoogleCalendarSync/Forms/MainForm.Designer.cs b/src/OutlookGoogleCalendarSync/Forms/MainForm.Designer.cs index 467dac64..c8b110d8 100644 --- a/src/OutlookGoogleCalendarSync/Forms/MainForm.Designer.cs +++ b/src/OutlookGoogleCalendarSync/Forms/MainForm.Designer.cs @@ -259,6 +259,7 @@ private void InitializeComponent() { this.AboutColumnLabel = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.AboutColumnValue = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.cbExcludeDeclinedInvites = new System.Windows.Forms.CheckBox(); + this.cbSingleCategoryOnly = new System.Windows.Forms.CheckBox(); this.tabApp.SuspendLayout(); this.tabPage_Sync.SuspendLayout(); this.consolePanel.SuspendLayout(); @@ -1673,6 +1674,7 @@ private void InitializeComponent() { // this.gbSyncOptions_What.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.gbSyncOptions_What.Controls.Add(this.cbSingleCategoryOnly); this.gbSyncOptions_What.Controls.Add(this.btColourMap); this.gbSyncOptions_What.Controls.Add(this.cbCloakEmail); this.gbSyncOptions_What.Controls.Add(this.lDNDand); @@ -3140,6 +3142,18 @@ private void InitializeComponent() { this.cbExcludeDeclinedInvites.UseVisualStyleBackColor = true; this.cbExcludeDeclinedInvites.CheckedChanged += new System.EventHandler(this.cbExcludeDeclinedInvites_CheckedChanged); // + // cbSingleCategoryOnly + // + this.cbSingleCategoryOnly.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cbSingleCategoryOnly.ForeColor = System.Drawing.SystemColors.ControlText; + this.cbSingleCategoryOnly.Location = new System.Drawing.Point(226, 96); + this.cbSingleCategoryOnly.Name = "cbSingleCategoryOnly"; + this.cbSingleCategoryOnly.Size = new System.Drawing.Size(121, 18); + this.cbSingleCategoryOnly.TabIndex = 47; + this.cbSingleCategoryOnly.Text = "Single category only"; + this.cbSingleCategoryOnly.UseVisualStyleBackColor = true; + this.cbSingleCategoryOnly.CheckedChanged += new System.EventHandler(this.cbSingleCategoryOnly_CheckedChanged); + // // Main // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -3431,5 +3445,6 @@ private void InitializeComponent() { private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn4; private System.Windows.Forms.ComboBox ddAvailabilty; private System.Windows.Forms.CheckBox cbExcludeDeclinedInvites; + private System.Windows.Forms.CheckBox cbSingleCategoryOnly; } } diff --git a/src/OutlookGoogleCalendarSync/Forms/MainForm.cs b/src/OutlookGoogleCalendarSync/Forms/MainForm.cs index aa78edc8..847fd6bb 100644 --- a/src/OutlookGoogleCalendarSync/Forms/MainForm.cs +++ b/src/OutlookGoogleCalendarSync/Forms/MainForm.cs @@ -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."); @@ -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 @@ -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; @@ -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(); @@ -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); @@ -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)) { @@ -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 diff --git a/src/OutlookGoogleCalendarSync/GoogleOgcs/EventColour.cs b/src/OutlookGoogleCalendarSync/GoogleOgcs/EventColour.cs index 4381f497..f52a6339 100644 --- a/src/OutlookGoogleCalendarSync/GoogleOgcs/EventColour.cs +++ b/src/OutlookGoogleCalendarSync/GoogleOgcs/EventColour.cs @@ -225,7 +225,7 @@ public void Get() { /// Google ID 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; diff --git a/src/OutlookGoogleCalendarSync/OutlookOgcs/OutlookCalendar.cs b/src/OutlookGoogleCalendarSync/OutlookOgcs/OutlookCalendar.cs index 5ee29bc1..84fb8eba 100644 --- a/src/OutlookGoogleCalendarSync/OutlookOgcs/OutlookCalendar.cs +++ b/src/OutlookGoogleCalendarSync/OutlookOgcs/OutlookCalendar.cs @@ -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(); + 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()); } diff --git a/src/OutlookGoogleCalendarSync/Settings.cs b/src/OutlookGoogleCalendarSync/Settings.cs index 7597a58d..d4894d26 100644 --- a/src/OutlookGoogleCalendarSync/Settings.cs +++ b/src/OutlookGoogleCalendarSync/Settings.cs @@ -302,6 +302,8 @@ public String GaccountEmail_masked() { Namespace = "http://schemas.datacontract.org/2004/07/OutlookGoogleCalendarSync" )] public class ColourMappingDictionary : Dictionary { } + /// Only allow Outlook to have one category assigned + [DataMember] public Boolean SingleCategoryOnly { get; set; } //Obfuscation [DataMember] public Obfuscate Obfuscation { get; set; } @@ -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.");