/// <summary>
        /// Delete a specific HostsFile-Profile.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">An <see cref="ExecutedRoutedEventArgs"/> that contains the event data.</param>
        private void CommandBindingDeleteSpecificProfileExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            HostsFileProfile profile = e.Parameter as HostsFileProfile;

            if (this.ViewModel != null && profile != null)
            {
                this.ViewModel.DeleteProfile(profile);
            }
        }
        /// <summary>
        /// Loads the specified <see cref="HostsFileProfile"/>.
        /// </summary>
        /// <param name="sourceProfile">A <see cref="HostsFileProfile"/> object.</param>
        public void LoadProfile(HostsFileProfile sourceProfile)
        {
            if (sourceProfile == null)
            {
                throw new ArgumentNullException("sourceProfile");
            }

            if (this.InnerViewModel != null)
            {
                this.innerViewModel.LoadProfile(sourceProfile);
            }
        }
        /// <summary>Check if the <see cref="CommandBindingDeleteSpecificProfileExecuted"/> function can be executed in the current context.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">An <see cref="CanExecuteRoutedEventArgs"/> that contains the event data.</param>
        private void CommandBindingDeleteSpecificProfileCanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            HostsFileProfile profile = e.Parameter as HostsFileProfile;

            if (this.ViewModel != null && profile != null)
            {
                e.CanExecute = true;
            }
            else
            {
                e.CanExecute = false;
            }
        }
        /// <summary>
        /// Loads the specified <see cref="HostsFileProfile"/>.
        /// </summary>
        /// <param name="sourceProfile">A <see cref="HostsFileProfile"/> object.</param>
        /// <returns>True if the specified <paramref name="sourceProfile"/> was loaded successfully; otherwise false.</returns>
        public bool LoadProfile(HostsFileProfile sourceProfile)
        {
            if (this.HostFileInstance != null)
            {
                HostFile hf = HostfileManager.Current.GetProfile(sourceProfile.ProfilePath);
                if (hf != null)
                {
                    this.HostFileInstance = hf;
                    return(true);
                }
            }

            return(false);
        }
        /// <summary>
        /// Saves the current application state to the specified <paramref name="targetProfile"/> object.
        /// </summary>
        /// <param name="targetProfile">A <paramref name="targetProfile"/> object.</param>
        /// <returns>True if the current application state was successfully saved to the specified <paramref name="targetProfile"/>; Otherwise false.</returns>
        public bool SaveToProfile(HostsFileProfile targetProfile)
        {
            if (targetProfile == null)
            {
                throw new ArgumentNullException("targetProfile");
            }

            if (this.InnerViewModel != null)
            {
                if (this.InnerViewModel.HostFileInstance != null)
                {
                    return(HostfileManager.Current.SaveToProfile(this.InnerViewModel.HostFileInstance, targetProfile.ProfilePath));
                }
            }

            return(false);
        }
예제 #6
0
 /// <summary>
 /// Delete the specified <paramref name="profile"/> from the users hard-disk.
 /// </summary>
 /// <param name="profile">A <see cref="HostsFileProfile"/> object.</param>
 /// <returns>True if the specified <paramref name="profile"/> has been deleted from the users hard-disk; otherwise false.</returns>
 public bool DeleteProfile(HostsFileProfile profile)
 {
     return(profile != null && this.DataAccess.DeleteProfile(profile.ProfilePath));
 }
 /// <summary>
 /// Delete the specified <paramref name="targetProfile"/> from the user's hard-disk.
 /// </summary>
 /// <param name="targetProfile">A <paramref name="targetProfile"/> object.</param>
 /// <returns>True if the specified <paramref name="targetProfile"/> has been successfully deleted; otherwise false.</returns>
 public bool DeleteProfile(HostsFileProfile targetProfile)
 {
     return(HostfileManager.Current.DeleteProfile(targetProfile));
 }
 /// <summary>
 /// Delete the specified <paramref name="profile"/> from the users hard-disk.
 /// </summary>
 /// <param name="profile">A <see cref="HostsFileProfile"/> object.</param>
 /// <returns>True if the specified <paramref name="profile"/> has been deleted from the users hard-disk; otherwise false.</returns>
 public bool DeleteProfile(HostsFileProfile profile)
 {
     return profile != null && this.DataAccess.DeleteProfile(profile.ProfilePath);
 }