Skip to content

Commit

Permalink
Improved updating of the "test map" dropdowns
Browse files Browse the repository at this point in the history
Bugfixes
  • Loading branch information
phw198 committed Oct 1, 2021
1 parent 51d8828 commit 5c72683
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 24 deletions.
6 changes: 2 additions & 4 deletions src/OutlookGoogleCalendarSync/Forms/ColourMap.Designer.cs

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

15 changes: 14 additions & 1 deletion src/OutlookGoogleCalendarSync/Forms/ColourMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public ColourMap() {
OutlookOgcs.Calendar.Disconnect(true);
}

private void ColourMap_Shown(object sender, EventArgs e) {
ddOutlookColour_SelectedIndexChanged(null, null);
}

private void loadConfig() {
try {
if (Forms.Main.Instance.ActiveCalendarProfile.ColourMaps.Count > 0) colourGridView.Rows.Clear();
Expand All @@ -38,7 +42,7 @@ private void loadConfig() {
if (ddGoogleColour.Items.Count > 0)
ddGoogleColour.SelectedIndex = 0;

} catch (System.Exception ex) {
} catch (System.Exception ex) {
OGCSexception.Analyse("Populating gridview cells from Settings.", ex);
}
}
Expand Down Expand Up @@ -257,5 +261,14 @@ private void colourGridView_SelectionChanged(object sender, EventArgs e) {
OGCSexception.Analyse(ex);
}
}

private void colourGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e) {
if (!this.Visible) return;

if (colourGridView.CurrentCell.ColumnIndex == 0)
ddGoogleColour_SelectedIndexChanged(null, null);
else if (colourGridView.CurrentCell.ColumnIndex == 1)
ddOutlookColour_SelectedIndexChanged(null, null);
}
}
}
3 changes: 1 addition & 2 deletions src/OutlookGoogleCalendarSync/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ public void UpdateGUIsettings_Profile() {
theFolder = (MAPIFolder)OutlookOgcs.Calendar.ReleaseObject(theFolder);
}
}
theFolders = (Folders)OutlookOgcs.Calendar.ReleaseObject(theFolders);
ddMailboxName.Items.AddRange(folderIDs.Keys.ToArray());
ddMailboxName.SelectedItem = profile.MailboxName;

Expand Down Expand Up @@ -588,7 +587,7 @@ private void applyProxy() {
}

private void buildAvailabilityDropdown() {
SettingsStore.Calendar profile = Settings.Instance.ProfileInPlay();
SettingsStore.Calendar profile = Forms.Main.Instance.ActiveCalendarProfile;
try {
this.ddAvailabilty.SelectedIndexChanged -= new System.EventHandler(this.ddAvailabilty_SelectedIndexChanged);
ddAvailabilty.DataSource = null;
Expand Down
12 changes: 8 additions & 4 deletions src/OutlookGoogleCalendarSync/GoogleOgcs/EventColour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public enum Type {
Event
}
private Type colourType = Type.Event;
public String Id { get; }
public String Id { get; internal set; }

private String hexValue;
public String HexValue {
Expand All @@ -41,13 +41,17 @@ public String HexValue {
private Color rgbValue;
public Color RgbValue {
get {
if (UseWebAppColours)
return OutlookOgcs.Categories.Map.RgbColour(HexValue);
if (UseWebAppColours) {
if (rgbConvertedFromHex.IsEmpty && HexValue != null) rgbConvertedFromHex = OutlookOgcs.Categories.Map.RgbColour(HexValue);
return rgbConvertedFromHex;
}
return rgbValue;
}
internal set { rgbValue = value; }
}

private Color rgbConvertedFromHex;

public String Name {
get {
String name = "";
Expand Down Expand Up @@ -178,7 +182,7 @@ public List<Palette> ActivePalette {

if (profile.UseGoogleCalendar.ColourId == "0") {
GoogleOgcs.Calendar.Instance.GetCalendars();
profile.UseGoogleCalendar.ColourId = GoogleOgcs.Calendar.Instance.CalendarList.Find(c => c.Id == profile.UseGoogleCalendar.Id).ColourId;
profile.UseGoogleCalendar.ColourId = GoogleOgcs.Calendar.Instance.CalendarList.Find(c => c.Id == profile.UseGoogleCalendar.Id)?.ColourId ?? "0";
}

//Palette currentCal = calendarPalette.Find(p => p.Id == profile.UseGoogleCalendar.ColourId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ private String getColour(String gColourId, String oColour) {
public String GetCategoryColour(String gColourId, Boolean createMissingCategory = true) {
OlCategoryColor? outlookColour = null;

SettingsStore.Calendar profile = Sync.Engine.Calendar.Instance.Profile;
SettingsStore.Calendar profile = Settings.Instance.ProfileInPlay();
if (profile.ColourMaps.Count > 0) {
KeyValuePair<String, String> kvp = profile.ColourMaps.FirstOrDefault(cm => cm.Value == gColourId);
if (kvp.Key != null) {
Expand Down
16 changes: 7 additions & 9 deletions src/OutlookGoogleCalendarSync/SettingsStore/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,6 @@ public void LogSettings() {
log.Info(" Custom Timezone Mapping:-");
TimezoneMaps.ToList().ForEach(tz => log.Info(" " + tz.Key + " => " + tz.Value));
}
log.Info(" Disconnect Between Sync: " + DisconnectOutlookBetweenSync);
if (TimezoneMaps.Count > 0) {
log.Info(" Custom Timezone Mapping:-");
TimezoneMaps.ToList().ForEach(tz => log.Info(" " + tz.Key + " => " + tz.Value));
}

log.Info("GOOGLE SETTINGS:-");
log.Info(" Personal API Keys: " + UsingPersonalAPIkeys());
log.Info(" Client Identifier: " + PersonalClientIdentifier);
Expand Down Expand Up @@ -436,7 +430,8 @@ public SettingsStore.Calendar ProfileInPlay() {
StackTrace stackTrace = new StackTrace();
StackFrame[] stackFrames = stackTrace.GetFrames().Reverse().ToArray();

String[] FormMethods = new String[] { "updateGUIsettings", "UpdateGUIsettings_Profile", "<StartSync>b__0", "miCatRefresh_Click", "GetMyGoogleCalendars_Click" };
String[] FormMethods = new String[] { "updateGUIsettings", "UpdateGUIsettings_Profile", "<StartSync>b__0", "miCatRefresh_Click", "GetMyGoogleCalendars_Click",
"btColourMap_Click", "ColourPicker_Enter", "ddGoogleColour_SelectedIndexChanged" };
String[] TimerMethods = new String[] { "OnTick" };

foreach (StackFrame frame in stackFrames) {
Expand All @@ -446,8 +441,11 @@ public SettingsStore.Calendar ProfileInPlay() {
else if (TimerMethods.Contains(frame.GetMethod().Name))
return Sync.Engine.Calendar.Instance.Profile;
}
log.Warn(stackFrames.ToString());
return null;
String stackString = "";
stackFrames.Reverse().ToList().ForEach(sf => stackString += sf.GetMethod().Name + " < ");
log.Warn(stackString);
log.Error("Unknown profile being referenced.");
return Forms.Main.Instance.ActiveCalendarProfile;
}

/// <summary>
Expand Down
8 changes: 5 additions & 3 deletions src/OutlookGoogleCalendarSync/Sync/Timer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public DateTime? NextSyncDate {
DateTime theDate = (DateTime)nextSyncDate;
var profile = owningProfile as SettingsStore.Calendar;
NextSyncDateText = theDate.ToLongDateString() + " @ " + theDate.ToLongTimeString() + (profile.OutlookPush ? " + Push" : "");
log.Info("Next sync scheduled for " + NextSyncDateText);
}
}
}
Expand All @@ -40,6 +39,9 @@ public SyncTimer(Object owningProfile) {
this.Tick += new EventHandler(ogcsTimer_Tick);
this.Interval = int.MaxValue;

if (owningProfile is SettingsStore.Calendar)
this.LastSyncDate = (owningProfile as SettingsStore.Calendar).LastSyncDate;

SetNextSync();
}

Expand Down Expand Up @@ -82,9 +84,10 @@ public void SetNextSync(int delayMins, Boolean fromNow = false, Boolean calculat

if (syncInterval != 0) {
DateTime now = DateTime.Now;
this.nextSyncDate = fromNow ? now.AddMinutes(delayMins) : LastSyncDate.AddMinutes(delayMins);
this.nextSyncDate = fromNow ? now.AddMinutes(delayMins) : this.LastSyncDate.AddMinutes(delayMins);
if (calculateInterval) CalculateInterval();
else this.NextSyncDate = this.nextSyncDate;
log.Info("Next sync scheduled for " + this.NextSyncDateText);
} else {
this.NextSyncDateText = "Inactive";
Activate(false);
Expand All @@ -108,7 +111,6 @@ public void CalculateInterval() {
else
this.Interval = (int)Math.Min((interval * 60000), int.MaxValue);
this.NextSyncDate = now.AddMilliseconds(this.Interval);
return;
}
Activate(true);
}
Expand Down

0 comments on commit 5c72683

Please sign in to comment.