JumpList con argumentos

Por daniel en junio 6, 2010

Hace tiempo que no escribía un post sobre código así que hoy es el día xD, esto esta relacionado con las JumpList de Windows 7 y como manejar los eventos que ocurren al hacer clic en los elementos, el código que mas se acercaba a lo que buscaba lo encontré en wpftutorial y gracias a unas pequeñas modificaciones funciona para mostrar ventanas, mensajes, etc. lo bueno es que ocupa el .NET Framework 4.0 con lo que se evita WindowsAPICode aunque solo funciona con WPF (Windows Presentation Foundation) … creo … la próxima codificación de Apágalo :eek:

using System;
using System.Configuration;
using System.Data;
using System.Windows;
using System.Windows.Shell;
using System.Reflection;

namespace WpfApplication2
{
    /// <summary>
    /// Lógica de interacción para App.xaml
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            if (e.Args.Count() > 0)
            {
                if(e.Args.GetValue(0).Equals("/browser"))
                {
                   // Abre una ventana
                    Window w = new Window1();
                    w.ShowDialog();
                }

                else if(e.Args.GetValue(0).Equals("/update"))
                {
                    MessageBox.Show("Update...!");
                    Shutdown();
                }
            }

            JumpTask task = new JumpTask
            {
                Title = "Check for Updates",
                Arguments = "/update",
                Description = "Cheks for Software Updates",
                CustomCategory = "Actions",
                IconResourcePath = Assembly.GetEntryAssembly().CodeBase,
                ApplicationPath = Assembly.GetEntryAssembly().CodeBase
            };

            JumpTask task2 = new JumpTask
            {
                Title = "Open Browser",
                Arguments = "/browser",
                CustomCategory = "Actions",
                IconResourcePath = Assembly.GetEntryAssembly().CodeBase,
                ApplicationPath = Assembly.GetEntryAssembly().CodeBase
            };

            JumpList jumpList = new JumpList();
            jumpList.JumpItems.Add(task);
            jumpList.JumpItems.Add(task2);
            jumpList.ShowFrequentCategory = false;
            jumpList.ShowRecentCategory = false;

            JumpList.SetJumpList(Application.Current, jumpList);
        }
    }
}

Codigo Fuente (13 descargas)

16 comentarios

Chile #chi

Por daniel en 16 junio, 2010 a las 15:15. #



El sitio no se actualizará más y en algunas semanas dejará de funcionar por completo (por si quieres rescatar algún cachureo).

x