Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 17:02

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Notifyicon beim Minimieren | WPF | C#

Discussion on Notifyicon beim Minimieren | WPF | C# within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1

 
Entonsammler's Avatar
 
elite*gold: 100
Join Date: Jan 2016
Posts: 577
Received Thanks: 50
Notifyicon beim Minimieren | WPF | C#

Bräuchte Hilfe bei einem Notifyicon welches sich beim Minimieren des Fenstern öffnen soll, und beim anklicken das Fenster öffnen soll und dann wieder verschwindet .

Bin grad total verwirrt von dem Zeugs .
Entonsammler is offline  
Old 08/27/2016, 05:32   #2
 
atom0s's Avatar
 
elite*gold: 0
Join Date: May 2013
Posts: 175
Received Thanks: 123
You can use the following with your main window:

PHP Code:
namespace YourApplicationName.View
{
    
using System;
    
using System.Windows;
    
using System.Windows.Forms;

    
/// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    
public partial class MainWindow
    
{
        
/// <summary>
        /// Notification icon object.
        /// </summary>
        
private readonly NotifyIcon m_NotifyIcon;


        
/// <summary>
        /// Default Constructor
        /// </summary>
        
public MainWindow()
        {
            
this.InitializeComponent();


            try
            {
                
// Attempt to obtain the icon stream..
                
var iconUri = new Uri("/YourApplicationName;component/Assets/appicon.ico"UriKind.RelativeOrAbsolute);
                var 
iconStream System.Windows.Application.GetResourceStream(iconUri);
                if (
iconStream == null)
                    return;


                
// Prepare the notify icon..
                
this.m_NotifyIcon = new NotifyIcon
                
{
                    
Icon = new System.Drawing.Icon(iconStream.Stream),
                    
Text "YourApplicationName",
                    
Visible true
                
};


                
// Handle double click event..
                
this.m_NotifyIcon.MouseDoubleClick += (senderargs) =>
                {
                    
this.WindowState this.WindowState == WindowState.Normal WindowState.Minimized WindowState.Normal;
                    
this.ShowInTaskbar this.WindowState != WindowState.Minimized;
                };


                
// Register to window events..
                
this.Closed += this.OnClosed;
                
this.StateChanged += this.OnStateChanged;
            }
            catch (
Exception)
            {
            }
        }


        
/// <summary>
        /// Closed event callback.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        
private void OnClosed(object senderEventArgs e)
        {
            if (
this.m_NotifyIcon != null)
            {
                
this.m_NotifyIcon.Visible false;
                
this.m_NotifyIcon.Dispose();
            }
        }


        
/// <summary>
        /// StateChanged event callback.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        
private void OnStateChanged(object senderEventArgs e)
        {
            
// Handle minimized state changes for tray icon..
            
if (this.m_NotifyIcon != null)
                
this.ShowInTaskbar this.WindowState != WindowState.Minimized;
        }
    }

atom0s is offline  
Old 08/27/2016, 09:49   #3

 
Entonsammler's Avatar
 
elite*gold: 100
Join Date: Jan 2016
Posts: 577
Received Thanks: 50
thanks but i'm using a WPF not a windows Form
Entonsammler is offline  
Old 08/27/2016, 20:07   #4

 
Njahs's Avatar
 
elite*gold: 574
Join Date: Nov 2010
Posts: 2,498
Received Thanks: 726
Quote:
Originally Posted by Themanwhoisit View Post
thanks but i'm using a WPF not a windows Form
befindet sich im Namespace.

Eine Alternative für WPF wäre .

Grüße
Njahs is offline  
Old 08/28/2016, 21:14   #5
 
atom0s's Avatar
 
elite*gold: 0
Join Date: May 2013
Posts: 175
Received Thanks: 123
Quote:
Originally Posted by Themanwhoisit View Post
thanks but i'm using a WPF not a windows Form
That code is for WPF.
atom0s is offline  
Reply


Similar Threads Similar Threads
Amnesia The Dark Descent Maus hängt beim minimieren
02/15/2013 - Off Topic - 2 Replies
Hey, wenn ich Amnesia starte und zurück auf den Desktop will hängt sich meine Maus oben links auf, ich kann mit der Tastatur noch steuern aber es geht nichts.Habe ich schon Taskmanager probiert der geht aber auch nicht. Hoffe auf Hilfe Mfg PS: Ich starte das Game über Steam und sonst gingen Mw3 usw. auch immer zu Minimieren
Freeze beim Minimieren
03/30/2012 - Technical Support - 2 Replies
Hallo, Manchmal wenn ich Battlefield zocke oder ich während des Ladens der Map das Spiel minimiere dann passiert es manchmal das der PC einfriert also er startet nicht neu oder so er bleibt einfach hängen und ich darf ihn dann mit dem Reset Knopf unten am PC neustarten. An was könnte das liegen?
Wie kann ich verhindern das dekaron beim minimieren abstürzT?
02/18/2010 - Dekaron - 1 Replies
ich hab ein prob.nähmlich immer wenn ich dekaron minimiere schliest es weis wer wie ich das verhindern kann ohne das ich es in ein fenster machen muss?
Wie kann ich verhindern das dekaron beim minimieren abstürzT?
02/18/2010 - Dekaron - 0 Replies
ich hab ein prob.nähmlich immer wenn ich dekaron minimiere schliest es weis wer wie ich das verhindern kann ohne das ich es in ein fenster machen muss?
ro freezt beim minimieren
05/03/2008 - Ragnarok Online - 1 Replies
ja wie oben beschrieben wenn ich raustabbe freezt ro allerdings nur bei mir iwie?? oO hab core4quad und winxp 32 bit kann jemand helfen?



All times are GMT +2. The time now is 17:02.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.