-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #617 from lilla28/icon-handling
fix(icon-handling) - Disposing icon after ImageSource is created from its handle
- Loading branch information
Showing
19 changed files
with
191 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/shared/dotnet/src/MorganStanley.ComposeUI.Utilities/NativeMethods.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Morgan Stanley makes this available to you under the Apache License, | ||
* Version 2.0 (the "License"). You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* See the NOTICE file distributed with this work for additional information | ||
* regarding copyright ownership. Unless required by applicable law or agreed | ||
* to in writing, software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
|
||
using System.Runtime.InteropServices; | ||
using System; | ||
|
||
namespace MorganStanley.ComposeUI.Utilities; | ||
|
||
public static class NativeMethods | ||
{ | ||
[DllImport("gdi32.dll", SetLastError = true)] | ||
public static extern bool DeleteObject(in IntPtr hObject); | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
// /* | ||
// * Morgan Stanley makes this available to you under the Apache License, | ||
// * Version 2.0 (the "License"). You may obtain a copy of the License at | ||
// * | ||
// * http://www.apache.org/licenses/LICENSE-2.0. | ||
// * | ||
// * See the NOTICE file distributed with this work for additional information | ||
// * regarding copyright ownership. Unless required by applicable law or agreed | ||
// * to in writing, software distributed under the License is distributed on an | ||
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
// * or implied. See the License for the specific language governing permissions | ||
// * and limitations under the License. | ||
// */ | ||
|
||
namespace MorganStanley.ComposeUI.Shell.Utilities | ||
using System; | ||
|
||
namespace MorganStanley.ComposeUI.Shell.Utilities; | ||
|
||
internal class DiagnosticInfo | ||
{ | ||
internal class DiagnosticInfo | ||
{ | ||
public DateTime StartupTime { get; set; } | ||
public string ShellVersion { get; set; } | ||
} | ||
} | ||
public DateTime StartupTime { get; set; } | ||
public string ShellVersion { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// /* | ||
// * Morgan Stanley makes this available to you under the Apache License, | ||
// * Version 2.0 (the "License"). You may obtain a copy of the License at | ||
// * | ||
// * http://www.apache.org/licenses/LICENSE-2.0. | ||
// * | ||
// * See the NOTICE file distributed with this work for additional information | ||
// * regarding copyright ownership. Unless required by applicable law or agreed | ||
// * to in writing, software distributed under the License is distributed on an | ||
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
// * or implied. See the License for the specific language governing permissions | ||
// * and limitations under the License. | ||
// */ | ||
|
||
using System.Drawing; | ||
using System.Drawing.Imaging; | ||
using System.IO; | ||
using System.Windows.Media.Imaging; | ||
using MorganStanley.ComposeUI.Utilities; | ||
|
||
namespace MorganStanley.ComposeUI.Shell.Utilities; | ||
public static class IconUtilities | ||
{ | ||
public static System.Windows.Media.ImageSource ToImageSource(this Bitmap bitmap) | ||
{ | ||
try | ||
{ | ||
using var memoryStream = new MemoryStream(); | ||
|
||
bitmap.Save(memoryStream, ImageFormat.Png); | ||
memoryStream.Position = 0; | ||
|
||
var bitmapImage = new BitmapImage(); | ||
|
||
bitmapImage.BeginInit(); | ||
bitmapImage.StreamSource = memoryStream; | ||
bitmapImage.CacheOption = BitmapCacheOption.OnLoad; | ||
bitmapImage.EndInit(); | ||
bitmapImage.Freeze(); | ||
|
||
return bitmapImage; | ||
} | ||
finally | ||
{ | ||
NativeMethods.DeleteObject(bitmap.GetHbitmap()); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.