Skip to content
This repository has been archived by the owner on May 31, 2020. It is now read-only.

Commit

Permalink
Fix to make interface work again
Browse files Browse the repository at this point in the history
  • Loading branch information
eltoncezar committed Jun 8, 2018
1 parent 6801915 commit 2b103fd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
12 changes: 6 additions & 6 deletions Spofy/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="310" Width="200"
Background="{StaticResource BackgroundColor}">
Background="Transparent">
<Window.TaskbarItemInfo>
<TaskbarItemInfo Description="Control your media" ThumbnailClipMargin="5">
<TaskbarItemInfo.ThumbButtonInfos>
<ThumbButtonInfoCollection>
<ThumbButtonInfo x:Name="ThumbPlayButton"
DismissWhenClicked="False"
Description="Play"
ImageSource="Images/previous.png"/>
Description="Play"
ImageSource="Images/previous.png" />
<ThumbButtonInfo x:Name="ThumbStopButton"
DismissWhenClicked="False"
Description="Stop" ImageSource="Images/play.png" Click="ThumbPlayButton_Click"/>
Description="Stop" ImageSource="Images/play.png" Click="ThumbPlayButton_Click" />
<ThumbButtonInfo x:Name="ThumbPauseInfo"
DismissWhenClicked="False"
Description="Pause" ImageSource="Images/next.png" />
Expand Down Expand Up @@ -47,6 +47,6 @@
</ContextMenu>
</Window.ContextMenu>

<Grid x:Name="mainContent">
<Grid x:Name="mainContent" Background="{StaticResource BackgroundColor}">
</Grid>
</Window>
</Window>
37 changes: 20 additions & 17 deletions Spofy/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/// https://www.simple-talk.com/dotnet/.net-framework/creating-tray-applications-in-.net-a-practical-guide/
/// http://labs.bjfocus.co.uk/2013/06/add-a-notification-icon-to-your-wpf-program/
/// http://www.hardcodet.net/wpf-notifyicon // https://visualstudiogallery.msdn.microsoft.com/aacbc77c-4ef6-456f-80b7-1f157c2909f7/
///
///
/// DESKBAND C#
/// http://www.codeproject.com/Articles/39189/Shell-Extensibility-Explorer-Desk-Band-Tray-Notifi
/// http://stackoverflow.com/questions/5758840/deskband-in-windows-7-x64-c
Expand All @@ -28,13 +28,14 @@
/// https://social.msdn.microsoft.com/Forums/en-US/7b799b8a-888b-47f2-b20f-6f9ab969cfba/make-a-deskband-how-to?forum=Vsexpressvb
/// https://msdn.microsoft.com/en-us/library/windows/desktop/dd378460(v=vs.85).aspx
/// https://msdn.microsoft.com/en-us/library/windows/desktop/cc144099(v=vs.85).aspx#desk_bands
///
///

using Spofy.Classes;
using Spofy.Views;
using System;
using System.Windows;
using System.Windows.Controls;

//using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Interop;
Expand All @@ -48,7 +49,7 @@ public partial class MainWindow : Window
protected override void OnInitialized(EventArgs e)
{
Title = SpofyManager.appName;
AllowsTransparency = false;
AllowsTransparency = true;
ResizeMode = ResizeMode.NoResize;
WindowStartupLocation = WindowStartupLocation.Manual;
WindowStyle = WindowStyle.None;
Expand All @@ -60,7 +61,7 @@ protected override void OnInitialized(EventArgs e)
MouseUp += Window_MouseUp;
Loaded += Window_Loaded;

SourceInitialized += HandleSourceInitialized;
//SourceInitialized += HandleSourceInitialized;
base.OnInitialized(e);
}

Expand All @@ -72,7 +73,7 @@ public MainWindow()
SpofyManager.Instance.Register(this.Dispatcher);
}

#endregion
#endregion Init

private void CheckSettings()
{
Expand All @@ -85,12 +86,15 @@ private void CheckSettings()
case 0:
view = new LargeCover();
break;

case 1:
view = new SmallCover();
break;

case 2:
view = new MinimalCover();
break;

default:
view = new LargeCover();
break;
Expand All @@ -114,10 +118,9 @@ private void CheckSettings()

private void ThumbPlayButton_Click(object sender, EventArgs e)
{

}

#endregion
#endregion Buttons

#region Shadows

Expand All @@ -127,16 +130,15 @@ private void ThumbPlayButton_Click(object sender, EventArgs e)
/// Handles the source initialized.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="System.EventArgs"/>
/// <param name="e">The <see cref="System.EventArgs"/>
/// instance containing the event data.</param>
private void HandleSourceInitialized(Object sender, EventArgs e)
{
m_hwndSource = (HwndSource)PresentationSource.FromVisual(this);

// Returns the HwndSource object for the window
// which presents WPF content in a Win32 window.
HwndSource.FromHwnd(m_hwndSource.Handle).AddHook(
new HwndSourceHook(NativeMethods.WindowProc));
HwndSource.FromHwnd(m_hwndSource.Handle).AddHook(new HwndSourceHook(NativeMethods.WindowProc));

// http://msdn.microsoft.com/en-us/library/aa969524(VS.85).aspx
Int32 DWMWA_NCRENDERING_POLICY = 2;
Expand All @@ -150,7 +152,7 @@ private void HandleSourceInitialized(Object sender, EventArgs e)
NativeMethods.ShowShadowUnderWindow(m_hwndSource.Handle);
}

#endregion
#endregion Shadows

#region ContextMenu

Expand All @@ -161,7 +163,7 @@ private void cmiSettings_Click(object sender, RoutedEventArgs e)
settingsWindow.Closed += settingsWindow_Closed;
}

void settingsWindow_Closed(object sender, EventArgs e)
private void settingsWindow_Closed(object sender, EventArgs e)
{
CheckSettings();
}
Expand All @@ -175,7 +177,8 @@ private void cmiExit_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
#endregion

#endregion ContextMenu

#region Snap to Edges

Expand All @@ -190,7 +193,7 @@ private void cmiExit_Click(object sender, RoutedEventArgs e)
// This will be the flag for the automatic positioning.
private bool dragging = false;

// Wait until window is lodaded, but prior to being rendered to set position. This
// Wait until window is lodaded, but prior to being rendered to set position. This
// is done because prior to being loaded you'll get NaN for this.Height and 0 for
// this.ActualHeight.
private void Window_Loaded(object sender, RoutedEventArgs e)
Expand All @@ -215,7 +218,7 @@ private void Window_MouseDown(object sender, System.Windows.Input.MouseButtonEve
}
}

// Similar to MouseDown. We're setting dragging flag to false to allow automatic
// Similar to MouseDown. We're setting dragging flag to false to allow automatic
// positioning.
private void Window_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
Expand Down Expand Up @@ -277,6 +280,6 @@ private void InitializeWindowPositionMonitoring()
timer.Start();
}

#endregion
#endregion Snap to Edges
}
}
}

0 comments on commit 2b103fd

Please sign in to comment.