Permalink
Browse files

fix exceptions in app item related to uninstalling

  • Loading branch information...
1 parent f559a06 commit f5ff2d26bb8f8f0f538abd835c4cab35f59cdf03 @philc committed Jan 11, 2007
Showing with 28 additions and 71 deletions.
  1. +1 −1 InstallPad.csproj
  2. +18 −62 src/ApplicationItem.cs
  3. +9 −8 src/InstallPad.cs
View
@@ -95,7 +95,7 @@
<DependentUpon>AppListErrorDialog.cs</DependentUpon>
</Compile>
<Compile Include="src\ControlList.cs">
- <SubType>Component</SubType>
+ <SubType>UserControl</SubType>
</Compile>
<Compile Include="src\ControlList.Designer.cs">
<DependentUpon>ControlList.cs</DependentUpon>
View
@@ -134,6 +134,10 @@ public string UnInstallString
get { return uninstallString; }
}
+ /// <summary>
+ /// Detect the version that's already installed.
+ /// </summary>
+ /// <returns></returns>
public bool DetectVersion()
{
RegistryKey UninstallKey = Registry.LocalMachine;
@@ -149,14 +153,23 @@ public bool DetectVersion()
try
{
- string displayname = pkg.GetValue(Resources.DisplayName).ToString();
+ object pkgValue = pkg.GetValue(Resources.DisplayName);
+ if (pkgValue == null)
+ continue;
+ string displayName=pkgValue.ToString();
- if (displayname.Contains(name) || name.Contains(displayname))
+ if (displayName.Contains(name) || name.Contains(displayName))
{
try
{
- detectedVersion = pkg.GetValue(Resources.DisplayVersion).ToString();
- uninstallString = pkg.GetValue("UninstallString").ToString();
+ object versionValue = pkg.GetValue(Resources.DisplayVersion);
+ if (versionValue!=null)
+ detectedVersion = versionValue.ToString();
+
+ object uninstallValue = pkg.GetValue("UninstallString").ToString();
+ if (uninstallValue != null)
+ uninstallString = uninstallValue.ToString();
+
return true;
}
catch
@@ -262,64 +275,7 @@ private string SearchLeftForInt(int index)
return s;
}
- private void ParseDownloadUrl2()
- {
-
- List<int> intsEncountered = new List<int>();
- List<int> indexOfInt = new List<int>();
-
- // Search from right to left find integers separated by periods.
- // We interpret this pattern as being the version.
- for (int i = DownloadUrl.Length - 1; i > 0; i--)
- {
- // If we have a delimeter, search for an int after it
- if (IsDelimeterCharacter(DownloadUrl[i]))
- {
- int n = FindInteger(DownloadUrl, i - 1);
- if (n > -1)
- {
- //store in reverse order that we found them
- intsEncountered.Insert(0, n);
-
- // Digit can be two chars big
- int sizeOfInt = n < 10 ? 1 : 2;
- i = i - sizeOfInt;
- indexOfInt.Insert(0, i);
-
- }
- }
- else
- {
- // If we found a revision that's two lengths long, and now we're no
- // longer near a delimeter, go ahead and say we're done.
- if (intsEncountered.Count < 2)
- {
- // Otherwise, clear what we thought was a version number and keep searching
- intsEncountered.Clear();
- indexOfInt.Clear();
- }
- else
- // Found a version string with two or more elements. That's good enough. We're done.
- break;
- }
- if (intsEncountered.Count >= 4)
- // We're done. 4 is enough version parts.
- break;
- }
-
- this.parsedDownloadUrl = this.DownloadUrl;
-
- // Replace all the integers we found with {0} etc.
- // Go backwards so that when we start replacing characters with {0} etc., the stored indices don't get all jacked up.
- for (int i = indexOfInt.Count - 1; i >= 0; i--)
- {
- this.parsedDownloadUrl = this.parsedDownloadUrl.Remove(indexOfInt[i], (intsEncountered[i] < 10 ? 1 : 2));
- this.parsedDownloadUrl = this.parsedDownloadUrl.Insert(indexOfInt[i], "{" + i + "}");
- }
-
- // This is the original version we've picked up from our parsed url.
- this.originalVersion = intsEncountered;
- }
+
private bool IsDelimeterCharacter(char c)
{
View
@@ -224,7 +224,7 @@ void controlList_ListItemDoubleClicked(object sender, MouseEventArgs e)
/// <param name="e"></param>
void controlList_ListItemClicked(object sender, MouseEventArgs e)
{
- // TODO: I'm turning this off for now. When you left click on an
+ // TODO: I'm (philc) turning this off for now. When you left click on an
// app item, the toggling is very slow - it can miss clicks
// which is super annoying. Also, if you click on the label of an app item,
// the click on that label is not registered as a click on the app
@@ -234,14 +234,15 @@ void controlList_ListItemClicked(object sender, MouseEventArgs e)
return;
// Only interpret left clicks. Right clicks are for opening context menus
- if (e.Button != MouseButtons.Left)
- return;
- ApplicationListItem item = (ApplicationListItem)sender;
- item.Checked = !item.Checked;
- // Highlight the item we clicked on
- controlList.Unhighlight(controlList.HighlightedEntry);
- controlList.Highlight((Control)sender);
+ //if (e.Button != MouseButtons.Left)
+ // return;
+ //ApplicationListItem item = (ApplicationListItem)sender;
+ //item.Checked = !item.Checked;
+
+ //// Highlight the item we clicked on
+ //controlList.Unhighlight(controlList.HighlightedEntry);
+ //controlList.Highlight((Control)sender);
}
protected override void OnClick(EventArgs e)
{

0 comments on commit f5ff2d2

Please sign in to comment.