/// <summary>
        /// Called when the <see cref="OpenCommand"/>  is executed.
        /// </summary>
        protected override void OnOpen()
        {
            Task task = Task.Factory.StartNew(
                () =>
            {
                Logger.Debug("Ejecución de un acceso directo ({0})", this.Target);

                using (Process process = new Process())
                {
                    process.StartInfo.FileName        = this.Target.ToString();
                    process.StartInfo.UseShellExecute = true;
                    process.StartInfo.LoadUserProfile = true;
                    process.Start();
                }
            })
                        .ContinueWith((t) =>
            {
                Logger.ErrorException("Error durante la ejecución de un acceso directo ({0})", t.Exception.InnerException);

                IShowMessageViewService showMessageService = this.GetViewService <IShowMessageViewService>();

                showMessageService.ButtonSetup = DialogButton.Ok;
                showMessageService.Caption     = "Problema con el acceso directo";
                showMessageService.Text        =
                    String.Format(
                        "Ha ocurrido un error durante la ejecución del acceso directo '{0}'",
                        this.Title);

                if (showMessageService.ShowMessage() == DialogResult.Yes)
                {
                    this.GetService <IVirtualDesktopManager>().Close(this.Id);
                }
            }, TaskContinuationOptions.OnlyOnFaulted);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called when the related view is being closed.
        /// </summary>
        public override void Close()
        {
            IShowMessageViewService showMessageService = this.GetViewService <IShowMessageViewService>();

            showMessageService.ButtonSetup = DialogButton.YesNo;
            showMessageService.Caption     = "Eliminar grupo de accesos directos";
            showMessageService.Text        =
                String.Format(
                    "¿Está seguro de que desea eliminar permanentemente este grupo de accesos directos? {0}{1}",
                    Environment.NewLine,
                    this.Title);

            if (showMessageService.ShowMessage() == DialogResult.Yes)
            {
                Logger.Debug("Eliminando grupo de accesos directos '{0}'", this.Title);

                base.Close();

                this.iconStyle = null;

                if (this.shortcuts != null)
                {
                    this.shortcuts.Clear();
                    this.shortcuts = null;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Process the given <see cref="NavigationResponse"/> instance
        /// </summary>
        /// <param name="response"></param>
        void INavigationHandler.ProcessResponse(NavigationResponse response)
        {
            // basic check
            if (response == null)
            {
                throw new ArgumentNullException("response");
            }

            // we check if the navigation was successfull or not
            if (response.Status != ResponseStatus.Success)
            {
                this.PublishNavigationFailedInfo(response.Request);

                IShowMessageViewService showMessageService = ViewServiceLocator.GetViewService <IShowMessageViewService>();

                showMessageService.ButtonSetup = DialogButton.Ok;
                showMessageService.Caption     = "Chronos - Error en la navegación";
                showMessageService.Text        =
                    ((response.Error != null) ? response.Error.Message : String.Format("No ha sido posible resolver la navegación solicitada ({0})", response.Request.RequestUrl));

                showMessageService.ShowMessage();
            }
            else
            {
                Application.Current.Dispatcher.BeginInvoke
                (
                    DispatcherPriority.Background,
                    new ThreadStart
                    (
                        () =>
                {
                    WindowElement window = response.Content as WindowElement;

                    if (response.ResponseParameters != null &&
                        response.ResponseParameters.Count > 0)
                    {
                        ISupportNavigationLifecycle supporter = nRoute.Navigation.NavigationService.GetSupporter <ISupportNavigationLifecycle>(response.Content);

                        if (supporter != null)
                        {
                            supporter.Initialize(response.ResponseParameters);
                        }
                    }

                    this.PublishNavigatedInfo(window.Title, response);

                    if (response.Request.NavigationMode == NavigateMode.Modal)
                    {
                        ServiceLocator.GetService <IVirtualDesktopManager>().ShowDialog(window);
                    }
                    else
                    {
                        ServiceLocator.GetService <IVirtualDesktopManager>().Show(window);
                    }
                }
                    )
                );
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Performs the navigation to the given target
        /// </summary>
        /// <param name="target"></param>
        public void Navigate(NavigateMode mode, string target, params object[] args)
        {
            if (String.IsNullOrEmpty(target))
            {
                IShowMessageViewService showMessageService = ViewServiceLocator.GetViewService <IShowMessageViewService>();

                showMessageService.ButtonSetup = DialogButton.Ok;
                showMessageService.Caption     = "Warning";
                showMessageService.Text        = "Option not mapped to a view.";

                showMessageService.ShowMessage();

                return;
            }

            Application.Current.Dispatcher.BeginInvoke
            (
                DispatcherPriority.Background,
                new ThreadStart
                (
                    delegate
            {
                ParametersCollection navParams = null;
                string area = null;

                if (args != null && args.Length > 0)
                {
                    navParams = new ParametersCollection();
                    navParams.Add(NavigationParams.NavigationParamsKey, args);
                }

                var smnode = SiteMapService.SiteMap.RootNode.ChildNodes
                             .OfType <NavigationNode>()
                             .Traverse <NavigationNode>(node => ((node.ChildNodes) != null ? node.ChildNodes.OfType <NavigationNode>() : null))
                             .Where(n => n.Url == target).SingleOrDefault();

                if (smnode != null)
                {
                    area = smnode.SiteArea;
                }

                NavigationRequest request   = new NavigationRequest(target, navParams, area, mode);
                IDisposable navigationToken = nRoute.Navigation.NavigationService.Navigate(request);

                if (navigationToken != null)
                {
                    navigationToken.Dispose();
                    navigationToken = null;
                }
            }
                )
            );
        }
Ejemplo n.º 5
0
        private static void SaveFile(string filename, XElement xElement)
        {
            try
            {
                xElement.Save(filename);
            }
            catch (Exception)
            {
                IShowMessageViewService showMessageService = ViewServiceLocator.GetViewService <IShowMessageViewService>();

                showMessageService.ButtonSetup = DialogButton.Ok;
                showMessageService.Caption     = "Chronos - Error al guardar el estado del escritorio";
                showMessageService.Text        = "No ha sido posible al guardar el estado del escritorio.";

                showMessageService.ShowMessage();
            }
        }
Ejemplo n.º 6
0
        private static XElement LoadFromFile(string filename)
        {
            try
            {
                if (File.Exists(filename))
                {
                    return(XElement.Load(filename));
                }
            }
            catch (Exception)
            {
                IShowMessageViewService showMessageService = ViewServiceLocator.GetViewService <IShowMessageViewService>();

                showMessageService.ButtonSetup = DialogButton.Ok;
                showMessageService.Caption     = "Chronos - Error en la carga del escritorio";
                showMessageService.Text        = "No ha sido posible realizar la carga del escritorio.";

                showMessageService.ShowMessage();
            }

            return(null);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Called when the related view is being closed.
        /// </summary>
        public override void Close()
        {
            IShowMessageViewService showMessageService = this.GetViewService <IShowMessageViewService>();

            showMessageService.ButtonSetup = DialogButton.YesNo;
            showMessageService.Caption     = "Eliminar acceso directo";
            showMessageService.Text        =
                String.Format(
                    "¿Está seguro de que desea eliminar permanentemente este acceso directo? {0}{1}",
                    Environment.NewLine,
                    this.Title);

            if (showMessageService.ShowMessage() == DialogResult.Yes)
            {
                Logger.Debug("Eliminando acceso directo '{0}'", this.Target);

                base.Close();

                this.target      = null;
                this.parameters  = null;
                this.iconStyle   = null;
                this.openCommand = null;
            }
        }