+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="BackupState.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-namespace SimpleBackup.Core.Models
-{
- public enum BackupState
- {
- /// <summary>
- /// The to do
- /// </summary>
- Todo,
-
- /// <summary>
- /// The in progress
- /// </summary>
- InProgress,
-
- /// <summary>
- /// The success
- /// </summary>
- Success,
-
- /// <summary>
- /// The failed
- /// </summary>
- Failed,
-
- /// <summary>
- /// The cancelled
- /// </summary>
- Cancelled,
-
- /// <summary>
- /// The skipped
- /// </summary>
- Skipped,
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="IBackupInfo.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.ComponentModel;
-using System.Xml.Linq;
-using SimpleBackup.Models;
-
-namespace SimpleBackup.Core.Models
-{
- /// <summary>
- /// A model of single backup information.
- /// </summary>
- public interface IBackupInfo : INotifyPropertyChanged
- {
- /// <summary>
- /// Occurs when a property which has to be saved in setting file is changed.
- /// </summary>
- event EventHandler<EventArgs> SettingFilePropertyChanged;
-
- /// <summary>
- /// Gets or sets the identifier.
- /// </summary>
- Guid Id { get; set; }
-
- /// <summary>
- /// Gets or sets the label.
- /// </summary>
- string Label { get; set; }
-
- /// <summary>
- /// Gets or sets the type of the backup source.
- /// </summary>
- BackupSourceType BackupSourceType { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether the backup is enabled.
- /// </summary>
- bool IsEnabled { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether the backup is zip archive.
- /// </summary>
- bool IsZipArchive { get; set; }
-
- /// <summary>
- /// Gets or sets the source path.
- /// </summary>
- string SourcePath { get; set; }
-
- /// <summary>
- /// Gets or sets the destination folder path.
- /// </summary>
- string DestinationFolderPath { get; set; }
-
- /// <summary>
- /// Gets or sets the state of the backup.
- /// </summary>
- BackupState BackupState { get; set; }
-
- /// <summary>
- /// Gets or sets the name of the latest successful backup target.
- /// </summary>
- string LatestSuccessfulBackupTargetName { get; set; }
-
- /// <summary>
- /// Saves this instance to a XElement.
- /// </summary>
- /// <returns>The generated XElement.</returns>
- XElement ToXml();
-
- /// <summary>
- /// Gets the binary representation of this instance.
- /// </summary>
- /// <returns>The binary representation of this instance.</returns>
- byte[] ToBinary();
-
- /// <summary>
- /// Gets the text representation of this instance.
- /// </summary>
- /// <returns>The text representation of this instance.</returns>
- string ToText();
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="IBackupSetting.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Collections.Generic;
-using System.Xml.Linq;
-using SimpleBackup.Models;
-
-namespace SimpleBackup.Core.Models
-{
- public interface IBackupSetting
- {
- /// <summary>
- /// Occurs when backup setting is modified.
- /// </summary>
- event EventHandler SettingModified;
-
- /// <summary>
- /// Gets the name of the setting.
- /// </summary>
- string SettingName { get; }
-
- /// <summary>
- /// Gets or sets the name of the setting file.
- /// </summary>
- string SettingFileName { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether this <see cref="IBackupSetting"/> is modified.
- /// </summary>
- bool Modified { get; set; }
-
- IReadOnlyCollection<IBackupInfo> BackupInfos { get; }
-
- int Count { get; }
-
- IBackupInfo FirstOrDefault(Guid id);
-
- /// <summary>
- /// Inserts the specified index.
- /// </summary>
- /// <param name="index">The index.</param>
- /// <param name="backupInfo">The backup information.</param>
- void Insert(int index, IBackupInfo backupInfo);
-
- /// <summary>
- /// Removes the specified removing backup information.
- /// </summary>
- /// <param name="removingBackupInfo">The removing backup information.</param>
- void Remove(IBackupInfo removingBackupInfo);
-
- void MoveItem(Guid backupInfoId, ItemMovingDirection movingDirection);
-
- XElement ToXml();
- }
-}
\ No newline at end of file
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="IResultInfo.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-namespace SimpleBackup.Core.Models
-{
- public interface IResultInfo
- {
- BackupState Category { get; }
-
- string Description { get; }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="ItemMovingDirection.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-namespace SimpleBackup.Core.Models
-{
- public enum ItemMovingDirection
- {
- /// <summary>
- /// The move up
- /// </summary>
- MoveUp,
-
- /// <summary>
- /// The move down
- /// </summary>
- MoveDown
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="FileBackupProgressEventArgs.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using SimpleBackup.Models;
-
-namespace SimpleBackup.Core.Services
-{
- public class FileBackupProgressEventArgs : EventArgs
- {
- public FileBackupProgressEventArgs(double progressValue, ResultInfo latestResultInfo)
- {
- this.ProgressValue = progressValue;
- this.LatestResultInfo = latestResultInfo;
- }
-
- public double ProgressValue { get; private set; }
-
- public ResultInfo LatestResultInfo { get; private set; }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="IBackupService.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Threading;
-using SimpleBackup.Models;
-
-namespace SimpleBackup.Core.Services
-{
- /// <summary>
- /// Provides backup function.
- /// </summary>
- public interface IBackupService
- {
- /// <summary>
- /// Occurs when file backup progress is updated.
- /// </summary>
- event EventHandler<FileBackupProgressEventArgs> NofityFileBackupProgress;
-
- /// <summary>
- /// Gets a value indicating whether this service is ready for backup.
- /// </summary>
- bool IsReadyForBackup { get; }
-
- /// <summary>
- /// Gets a value indicating whether this service is executing backup.
- /// </summary>
- bool IsExecutingBackup { get; }
-
- /// <summary>
- /// Backups multipul files.
- /// </summary>
- /// <param name="cancellationToken">The cancellation token.</param>
- /// <param name="resultInfos">The array of result information.</param>
- void BackupMultipulFiles(CancellationToken cancellationToken, out ResultInfo[] resultInfos);
-
- /// <summary>
- /// Backups single file.
- /// </summary>
- /// <param name="backupInfoId">The backup information identifier.</param>
- /// <returns>The result information.</returns>
- ResultInfo BackupSingleFile(Guid backupInfoId);
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="IBackupSettingService.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using SimpleBackup.Core.Models;
-using SimpleBackup.Models;
-
-namespace SimpleBackup.Core.Services
-{
- /// <summary>
- /// Provides backup setting management function.
- /// </summary>
- public interface IBackupSettingService
- {
- /// <summary>
- /// Occurs when backup setting is created.
- /// </summary>
- event EventHandler<SettingFileEventArgs> BackupSettingCreated;
-
- /// <summary>
- /// Occurs when backup setting is opened.
- /// </summary>
- event EventHandler<SettingFileEventArgs> BackupSettingOpened;
-
- /// <summary>
- /// Occurs when backup setting is modified.
- /// </summary>
- event EventHandler<SettingFileEventArgs> BackupSettingModified;
-
- /// <summary>
- /// Occurs when backup setting is saved.
- /// </summary>
- event EventHandler<SettingFileEventArgs> BackupSettingSaved;
-
- /// <summary>
- /// Occurs when backup setting is closed.
- /// </summary>
- event EventHandler<SettingFileEventArgs> BackupSettingClosed;
-
- /// <summary>
- /// Gets the current setting.
- /// </summary>
- IBackupSetting CurrentSetting { get; }
-
- /// <summary>
- /// Creates the backup setting.
- /// </summary>
- /// <returns><c>true</c> if the new backup setting is created; otherwise, <c>false</c>.</returns>
- bool CreateBackupSetting();
-
- /// <summary>
- /// Opens the backup setting.
- /// </summary>
- /// <param name="resultMessage">The result message.</param>
- /// <returns>
- /// <c>true</c> if backup setting is successfully loaded; otherwise, <c>false</c>.
- /// </returns>
- bool OpenBackupSetting(out string resultMessage);
-
- /// <summary>
- /// Opens the default backup setting.
- /// </summary>
- /// <param name="resultMessage">The result message.</param>
- /// <returns>
- /// <c>true</c> if succeeded, otherwise; <c>false</c>.
- /// </returns>
- bool OpenDefaultBackupSetting(out string resultMessage);
-
- /// <summary>
- /// Closes the backup setting.
- /// </summary>
- void CloseBackupSetting();
-
- /// <summary>
- /// Overwrites the currnt backup setting.
- /// </summary>
- /// <returns><c>true</c> if the backup setting is saved; otherwise, <c>false</c>.</returns>
- bool OverWriteCurrntBackupSetting();
-
- /// <summary>
- /// Saves the current backup setting as a new file.
- /// </summary>
- /// <returns><c>true</c> if the backup setting is saved; otherwise, <c>false</c>.</returns>
- bool SaveCurrentBackupSettingAsNewFile();
-
- /// <summary>
- /// Creates the backup information.
- /// </summary>
- /// <param name="index">The index.</param>
- /// <returns>The created backup information.</returns>
- /// <exception cref="System.ArgumentOutOfRangeException"><paramref name="index"/></exception>
- IBackupInfo CreateBackupInfo(int index);
-
- /// <summary>
- /// Copies the backup information.
- /// </summary>
- /// <param name="sourceBackupInfo">The source backup information.</param>
- /// <returns>The copied backup information.</returns>
- /// <exception cref="System.ArgumentNullException"><paramref name="sourceBackupInfo"/></exception>
- IBackupInfo CopyBackupInfo(IBackupInfo sourceBackupInfo);
-
- /// <summary>
- /// Inserts the backup information.
- /// </summary>
- /// <param name="index">The index.</param>
- /// <param name="backupInfo">The backup information.</param>
- /// <exception cref="System.ArgumentOutOfRangeException"><paramref name="index"/></exception>
- /// <exception cref="System.ArgumentNullException"><paramref name="backupInfo"/></exception>
- void InsertBackupInfo(int index, IBackupInfo backupInfo);
-
- /// <summary>
- /// Removes the backup information.
- /// </summary>
- /// <param name="backupInfoId">The backup information identifier.</param>
- void RemoveBackupInfo(Guid backupInfoId);
- }
-}
\ No newline at end of file
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="IClipboardService.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Windows;
-
-namespace SimpleBackup.Core.Services
-{
- /// <summary>
- /// Provides clip board access.
- /// </summary>
- public interface IClipboardService
- {
- /// <summary>
- /// Sets the data object.
- /// </summary>
- /// <param name="dataObject">The data object.</param>
- /// <exception cref="ArgumentNullException">The data object is null.</exception>
- void SetDataObject(IDataObject dataObject);
-
- /// <summary>
- /// Gets the data.
- /// </summary>
- /// <typeparam name="T">The type.</typeparam>
- /// <param name="format">The format.</param>
- /// <returns>
- /// The data.
- /// </returns>
- /// <exception cref="ArgumentException">The format string is null or empty.</exception>
- T GetData<T>(string format);
-
- /// <summary>
- /// Gets a boolean value indicating whether the clipboard data contains data in specified format.
- /// </summary>
- /// <param name="format">The format.</param>
- /// <exception cref="ArgumentException">The format string is null or empty.</exception>
- /// <returns>True if the specified format is contained in the Clipboard.</returns>
- bool DoesClipboardDataContain(string format);
-
- /// <summary>
- /// Clears the clipbord.
- /// </summary>
- void ClearClipbord();
- }
-}
\ No newline at end of file
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="IUndoRedoService.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-
-namespace SimpleBackup.Core.Services
-{
- /// <summary>
- /// Provides undo/redo function.
- /// </summary>
- public interface IUndoRedoService
- {
- /// <summary>
- /// Commits the specified redo action with related undo action and the context information.
- /// </summary>
- /// <param name="redoAction">The redo action.</param>
- /// <param name="undoAction">The undo action.</param>
- /// <param name="context">The context.</param>
- /// <exception cref="ArgumentNullException">The redoAction is null.</exception>
- /// <exception cref="ArgumentNullException">The undoAction is null.</exception>
- void Commit(Action<object> redoAction, Action<object> undoAction, object context);
-
- /// <summary>
- /// Executes undo action.
- /// </summary>
- void Undo();
-
- /// <summary>
- /// Determines whether the undo action is executable.
- /// </summary>
- /// <returns>true if the undo action can be executable; otherwise, false.</returns>
- bool CanExecuteUndo();
-
- /// <summary>
- /// Executes redo action.
- /// </summary>
- void Redo();
-
- /// <summary>
- /// Determines whether the redo action is executable.
- /// </summary>
- /// <returns>true if the redo action can be executable; otherwise, false.</returns>
- bool CanExecuteRedo();
-
- /// <summary>
- /// Clears the undo redo buffer.
- /// </summary>
- void ClearUndoRedoBuffer();
- }
-}
\ No newline at end of file
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="SettingFileEventArgs.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using SimpleBackup.Core.Utilities;
-
-namespace SimpleBackup.Core.Services
-{
- /// <summary>
- /// Setting file event argument
- /// </summary>
- public class SettingFileEventArgs : EventArgs
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="SettingFileEventArgs"/> class.
- /// </summary>
- /// <param name="settingName">Name of the setting.</param>
- /// <exception cref="ArgumentNullException">The provided setting name is null.</exception>
- public SettingFileEventArgs(string settingName)
- {
- settingName.ThrowsArgumentNullException("settingName");
-
- this.SettingName = settingName;
- }
-
- /// <summary>
- /// Gets the name of the setting.
- /// </summary>
- public string SettingName { get; private set; }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="Constants.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System.Text.RegularExpressions;
-
-namespace SimpleBackup.Core.Utilities
-{
- public static class Constants
- {
- /// <summary>
- /// The backup information clipboard format: "BackupInfoClipboardFormat"
- /// </summary>
- public const string BackupInfoClipboardFormat = "BackupInfoClipboardFormat";
-
- /// <summary>
- /// The end path segment regex: "[^\\]*$"
- /// </summary>
- public static readonly Regex EndPathSegmentRegex = new Regex(@"[^\\]*$", RegexOptions.Compiled);
-
- /// <summary>
- /// The end path separator regex: "\\$"
- /// </summary>
- public static readonly Regex EndPathSeparatorRegex = new Regex(@"\\$", RegexOptions.Compiled);
-
- /// <summary>
- /// The file name regex: "^.*(?=\.)"
- /// </summary>
- public static readonly Regex FileNameRegex = new Regex(@"^.*(?=\.)", RegexOptions.Compiled);
-
- /// <summary>
- /// The extension regex: "[^\.]*$"
- /// </summary>
- public static readonly Regex ExtensionRegex = new Regex(@"[^\.]*$", RegexOptions.Compiled);
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="HelperExtensions.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.IO;
-using System.Windows;
-using System.Windows.Media;
-using SimpleBackup.Core.Models;
-
-namespace SimpleBackup.Core.Utilities
-{
- using SimpleBackup.Resources;
-
- public static class HelperExtensions
- {
- public static void ThrowsArgumentNullException(this object source, string parameterName)
- {
- if (source == null)
- {
- throw new ArgumentNullException(parameterName);
- }
- }
-
- public static void ThrowsArgumentExceptionIfNullOrEmpty(this string source, string parameterName)
- {
- if (string.IsNullOrEmpty(source))
- {
- throw new ArgumentException("provided text is null or empty.", parameterName);
- }
- }
-
- public static T SearchUpParentWithSelf<T>(this DependencyObject source)
- where T : DependencyObject
- {
- if (source == null)
- {
- return null;
- }
-
- if (source is T)
- {
- return (T)source;
- }
-
- DependencyObject parent = VisualTreeHelper.GetParent(source);
- while (true)
- {
- parent = VisualTreeHelper.GetParent(parent);
- if ((parent == null) || (parent is Window))
- {
- return null;
- }
-
- if (parent is T)
- {
- return (T)parent;
- }
- }
- }
-
- public static T GetVisualChild<T>(this Visual source) where T : Visual
- {
- T targetChild = default(T);
- int childrenCount = VisualTreeHelper.GetChildrenCount(source);
- for (int i = 0; i < childrenCount; i++)
- {
- var childVisual = (Visual)VisualTreeHelper.GetChild(source, i);
- targetChild = childVisual as T ?? GetVisualChild<T>(childVisual);
- if (targetChild != null)
- {
- break;
- }
- }
-
- return targetChild;
- }
-
- public static object GetVisualChild(this Visual source, Type targeType)
- {
- object targetChild = null;
- int childrenCount = VisualTreeHelper.GetChildrenCount(source);
- for (int i = 0; i < childrenCount; i++)
- {
- var childVisual = (Visual)VisualTreeHelper.GetChild(source, i);
- if (childVisual.GetType() == targeType)
- {
- targetChild = childVisual;
- break;
- }
-
- targetChild = GetVisualChild(childVisual, targeType);
- }
-
- return targetChild;
- }
-
- public static bool IsValidFileOrDirectoryPath(this string pathText)
- {
- if (string.IsNullOrWhiteSpace(pathText))
- {
- return false;
- }
-
- return File.Exists(pathText) || Directory.Exists(pathText);
- }
-
- public static bool IsValidFilePath(this string pathText)
- {
- if (string.IsNullOrWhiteSpace(pathText))
- {
- return false;
- }
-
- return File.Exists(pathText);
- }
-
- public static bool IsValidDirectoryPath(this string pathText)
- {
- if (string.IsNullOrWhiteSpace(pathText))
- {
- return false;
- }
-
- return Directory.Exists(pathText);
- }
-
- public static bool IsExistingFileOrDirectoryPath(this string pathText)
- {
- if (string.IsNullOrWhiteSpace(pathText))
- {
- return false;
- }
-
- if (File.Exists(pathText))
- {
- return true;
- }
-
- if (Directory.Exists(pathText))
- {
- return true;
- }
-
- return false;
- }
-
- public static string AddTailPathSeparatorIfNotExist(this string text)
- {
- if (string.IsNullOrWhiteSpace(text))
- {
- return text;
- }
-
- if (text.EndsWith("\\") == false)
- {
- return text + "\\";
- }
-
- return text;
- }
-
- /// <summary>
- /// Translates the specified backup state.
- /// </summary>
- /// <param name="backupState">State of the backup.</param>
- /// <returns>The translated text.</returns>
- public static string Translate(this BackupState backupState)
- {
- switch (backupState)
- {
- case BackupState.Todo:
- return Resources.BackupState_Todo;
- case BackupState.InProgress:
- return Resources.BackupState_InProgress;
- case BackupState.Success:
- return Resources.BackupState_Success;
- case BackupState.Failed:
- return Resources.BackupState_Failed;
- case BackupState.Cancelled:
- return Resources.BackupState_Cancelled;
- case BackupState.Skipped:
- return Resources.BackupState_Skipped;
- default:
- return string.Empty;
- }
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="Helpers.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Diagnostics;
-using System.Globalization;
-using System.IO;
-using System.Windows;
-using System.Windows.Threading;
-using SimpleBackup.Resources;
-
-namespace SimpleBackup.Core.Utilities
-{
- /// <summary>
- /// Defines helper methods.
- /// </summary>
- internal static class Helpers
- {
- #region WPF
-
- public static void UpdateWpfGui()
- {
- var frame = new DispatcherFrame();
- var callback = new DispatcherOperationCallback(obj =>
- {
- ((DispatcherFrame)obj).Continue = false;
- return null;
- });
- Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, callback, frame);
- Dispatcher.PushFrame(frame);
- }
-
- #endregion
-
- #region Files and directories
-
- public static bool TryExtractValidFolderPath(string sourcePath, out string extractedPath)
- {
- extractedPath = string.Empty;
-
- if (string.IsNullOrEmpty(sourcePath))
- {
- return false;
- }
-
- string testPath = sourcePath;
- while (true)
- {
- if (Directory.Exists(testPath))
- {
- extractedPath = testPath;
- return true;
- }
-
- testPath = Path.GetDirectoryName(testPath);
- if (string.IsNullOrEmpty(testPath))
- {
- break;
- }
- }
-
- return false;
- }
-
- /// <summary>
- /// Creates the display path text.
- /// </summary>
- /// <param name="fullPath">The full path.</param>
- /// <returns>The display path text.</returns>
- public static string CreateDisplayPathText(string fullPath)
- {
- if (string.IsNullOrWhiteSpace(fullPath))
- {
- return string.Empty;
- }
-
- string fileName = Path.GetFileName(fullPath);
- string directoryName = Path.GetDirectoryName(fullPath);
-
- return string.Format(CultureInfo.CurrentCulture, "{0} ({1})", fileName, directoryName);
- }
-
- public static void OpenFolder(string path)
- {
- if (string.IsNullOrWhiteSpace(path))
- {
- MessageBox.Show(
- string.Format(Resources.Resources.FileAccess_InvalidPathFormat, path));
- return;
- }
-
- if (Directory.Exists(path))
- {
- Process.Start("explorer.exe", string.Format("/n, /e, {0}", path));
- }
- else
- {
- MessageBox.Show(
- string.Format(Resources.Resources.FileAccess_FolderPathNotExistFormat, path));
- }
- }
-
- /// <summary>
- /// Opens the parent folder and select the specified file or folder.
- /// </summary>
- /// <param name="path">The path.</param>
- public static void OpenParentFolderAndSelect(string path)
- {
- if (path.IsExistingFileOrDirectoryPath() == false)
- {
- MessageBox.Show(
- string.Format(Resources.Resources.FileAccess_InvalidPathFormat, path));
- return;
- }
-
- Process.Start("explorer.exe", string.Format("/n, /e, /select,{0}", path));
- }
-
- /// <summary>
- /// Opens the file.
- /// </summary>
- /// <param name="fileName">Name of the file.</param>
- public static void OpenFile(string fileName)
- {
- if (fileName.IsExistingFileOrDirectoryPath() == false)
- {
- MessageBox.Show(
- string.Format(Resources.Resources.FileAccess_InvalidPathFormat, fileName));
- return;
- }
-
- var processStartInfo = new ProcessStartInfo
- {
- FileName = fileName,
- UseShellExecute = true
- };
-
- try
- {
- Process.Start(processStartInfo);
- }
- catch
- {
- MessageBox.Show(
- string.Format(Resources.Resources.FileAccess_FailedToOpenFormat, fileName));
- }
- }
-
- #endregion
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="IdIndexPair.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-
-namespace SimpleBackup.Core.Utilities
-{
- /// <summary>
- /// A pair of Guid and index.
- /// </summary>
- public class IdIndexPair
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="IdIndexPair"/> class.
- /// </summary>
- /// <param name="id">The identifier.</param>
- /// <param name="index">The index.</param>
- /// <exception cref="ArgumentException">The provided GUID is zero.</exception>
- /// <exception cref="ArgumentException">The provided index is a minus value.</exception>
- public IdIndexPair(Guid id, int index)
- {
- if (id == default(Guid))
- {
- throw new ArgumentException("The provided GUID is zero.", "id");
- }
-
- if (index < 0)
- {
- throw new ArgumentException("The provided index is a minus value.", "index");
- }
-
- this.Id = id;
- this.Index = index;
- }
-
- /// <summary>
- /// Gets the identifier.
- /// </summary>
- public Guid Id { get; private set; }
-
- /// <summary>
- /// Gets the index.
- /// </summary>
- public int Index { get; private set; }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="PropertyChangeNotificationBase.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System.ComponentModel;
-
-namespace SimpleBackup.Core.Utilities
-{
- public class PropertyChangeNotificationBase : INotifyPropertyChanged
- {
- public event PropertyChangedEventHandler PropertyChanged;
-
- protected void NotifyPropertyChanged(string propertyName)
- {
- if (this.PropertyChanged != null)
- {
- this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
- }
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="BackupInfoPathType.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-namespace SimpleBackup.Core.ViewModels
-{
- /// <summary>
- /// Represents backup information path type.
- /// </summary>
- public enum BackupInfoPathType
- {
- /// <summary>
- /// The source
- /// </summary>
- Source,
-
- /// <summary>
- /// The destination
- /// </summary>
- Destination
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="FocusOnGridRowEventArgs.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-
-namespace SimpleBackup.Core.ViewModels
-{
- /// <summary>
- /// Event argument of FocusOnGridRow event.
- /// </summary>
- public class FocusOnGridRowEventArgs : EventArgs
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="FocusOnGridRowEventArgs"/> class.
- /// </summary>
- /// <param name="index">The index.</param>
- /// <exception cref="System.ArgumentOutOfRangeException">The provided index is out of the range.</exception>
- public FocusOnGridRowEventArgs(int index)
- {
- if (index < 0)
- {
- throw new ArgumentOutOfRangeException("index");
- }
-
- this.Index = index;
- }
-
- /// <summary>
- /// Gets the index.
- /// </summary>
- public int Index { get; private set; }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="IMainWindowViewModel.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using SimpleBackup.Core.Views;
-
-namespace SimpleBackup.Core.ViewModels
-{
- /// <summary>
- /// Interface of a main window view model.
- /// </summary>
- public interface IMainWindowViewModel
- {
- event EventHandler<EventArgs> FocusOnGrid;
-
- event EventHandler<FocusOnGridRowEventArgs> FocusOnGridRow;
-
- RelayCommand SaveBackupSettingRelayCommand { get; }
-
- void OnEscKeyPressed();
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="ExDataGridSelectedFirstCellItemChangedEventArgs.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-
-namespace SimpleBackup.Core.Views
-{
- public class ExDataGridSelectedFirstCellItemChangedEventArgs : EventArgs
- {
- public ExDataGridSelectedFirstCellItemChangedEventArgs(
- int selectedFirstCellItemIndex,
- object selectedFirstCellItem)
- {
- this.SelectedFirstCellItemIndex = selectedFirstCellItemIndex;
- this.SelectedFirstCellItem = selectedFirstCellItem;
- }
-
- public int SelectedFirstCellItemIndex { get; private set; }
-
- public object SelectedFirstCellItem { get; private set; }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="IMainWindow.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SimpleBackup.Core.Views
-{
- public interface IMainWindow
- {
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="RelayCommand.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Diagnostics;
-using System.Windows.Input;
-
-namespace SimpleBackup.Core.Views
-{
- /// <summary>
- /// A relay command for WPF MVVM pattern.
- /// See WPF Apps With The Model-View-ViewModel Design Pattern http://msdn.microsoft.com/en-us/magazine/dd419663.aspx#id0090030
- /// in MSDN Magazine > Issues and Downloads > 2009 > February.
- /// </summary>
- public class RelayCommand : ICommand
- {
- #region Fields
-
- private readonly Action<object> executeAction;
-
- private readonly Predicate<object> canExecutePredicate;
-
- #endregion // Fields
-
- #region Constructors
-
- public RelayCommand(Action<object> executeAction)
- : this(executeAction, null)
- {
- }
-
- public RelayCommand(Action<object> executeAction, Predicate<object> canExecutePredicate)
- {
- if (executeAction == null)
- {
- throw new ArgumentNullException("executeAction");
- }
-
- this.executeAction = executeAction;
- this.canExecutePredicate = canExecutePredicate;
- }
-
- #endregion // Constructors
-
- #region ICommand Members
-
- public event EventHandler CanExecuteChanged
- {
- add
- {
- CommandManager.RequerySuggested += value;
- }
-
- remove
- {
- CommandManager.RequerySuggested -= value;
- }
- }
-
- public void Execute(object parameter)
- {
- this.executeAction(parameter);
- }
-
- [DebuggerStepThrough]
- public bool CanExecute(object parameter)
- {
- return this.canExecutePredicate == null || this.canExecutePredicate(parameter);
- }
-
- #endregion // ICommand Members
- }
-}
\ No newline at end of file
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="BackupInfo.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.IO;
-using System.Xml.Linq;
-using SimpleBackup.Core.Models;
-using SimpleBackup.Core.Utilities;
-
-namespace SimpleBackup.Models
-{
- using SimpleBackup.Resources;
-
- /// <summary>
- /// A model of single backup information.
- /// </summary>
- public class BackupInfo : PropertyChangeNotificationBase, IBackupInfo
- {
- private Guid innerId = Guid.NewGuid();
- private string innerLabel = string.Empty;
- private BackupSourceType innerBackupSourceType = BackupSourceType.File;
- private bool innerIsEnabled = true;
- private bool innerIsZipArchive;
- private string innerSourcePath = string.Empty;
- private string innerDestinationFolderPath = string.Empty;
- private BackupState innerBackupState = BackupState.Todo;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="BackupInfo"/> class.
- /// </summary>
- public BackupInfo()
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="BackupInfo"/> class.
- /// </summary>
- /// <param name="sourceBackupInfo">The source backup information.</param>
- /// <exception cref="System.ArgumentNullException">The index is out of range.</exception>
- public BackupInfo(IBackupInfo sourceBackupInfo)
- {
- sourceBackupInfo.ThrowsArgumentNullException("sourceBackupInfo");
-
- this.Id = Guid.NewGuid();
- this.BackupState = BackupState.Todo;
-
- this.Label = sourceBackupInfo.Label;
- this.BackupSourceType = sourceBackupInfo.BackupSourceType;
- this.IsEnabled = sourceBackupInfo.IsEnabled;
- this.IsZipArchive = sourceBackupInfo.IsZipArchive;
- this.SourcePath = sourceBackupInfo.SourcePath;
- this.DestinationFolderPath = sourceBackupInfo.DestinationFolderPath;
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="BackupInfo"/> class.
- /// </summary>
- /// <param name="label">The label.</param>
- /// <param name="backupSourceType">Type of the backup source.</param>
- /// <param name="isEnabled">if set to <c>true</c> the backup is enabled.</param>
- /// <param name="isZipArchive">if set to <c>true</c> zip archive switch is on.</param>
- /// <param name="sourcePath">The source path.</param>
- /// <param name="destinationFolderPath">The destination folder path.</param>
- /// <exception cref="System.ArgumentNullException">The label is null.</exception>
- /// <exception cref="System.ArgumentNullException">The source path is null.</exception>
- /// <exception cref="System.ArgumentNullException">The destination folder path is null.</exception>
- public BackupInfo(
- string label,
- BackupSourceType backupSourceType,
- bool isEnabled,
- bool isZipArchive,
- string sourcePath,
- string destinationFolderPath)
- {
- label.ThrowsArgumentNullException("label");
- sourcePath.ThrowsArgumentNullException("sourcePath");
- destinationFolderPath.ThrowsArgumentNullException("destinationFolderPath");
-
- this.Id = Guid.NewGuid();
- this.BackupState = BackupState.Todo;
-
- this.Label = label;
- this.BackupSourceType = backupSourceType;
- this.IsEnabled = isEnabled;
- this.IsZipArchive = isZipArchive;
- this.SourcePath = sourcePath;
- this.DestinationFolderPath = destinationFolderPath;
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="BackupInfo" /> class.
- /// </summary>
- /// <param name="id">The identifier.</param>
- /// <param name="label">The label.</param>
- /// <param name="backupSourceType">Type of the backup source.</param>
- /// <param name="isEnabled">if set to <c>true</c> the backup is enabled.</param>
- /// <param name="isZipArchive">if set to <c>true</c> zip archive switch is on.</param>
- /// <param name="sourcePath">The source path.</param>
- /// <param name="destinationFolderPath">The destination folder path.</param>
- /// <exception cref="System.ArgumentNullException">The label is null.</exception>
- /// <exception cref="System.ArgumentNullException">The label is null.</exception>
- /// <exception cref="System.ArgumentNullException">The label is null.</exception>
- public BackupInfo(
- Guid id,
- string label,
- BackupSourceType backupSourceType,
- bool isEnabled,
- bool isZipArchive,
- string sourcePath,
- string destinationFolderPath)
- {
- label.ThrowsArgumentNullException("label");
- sourcePath.ThrowsArgumentNullException("sourcePath");
- destinationFolderPath.ThrowsArgumentNullException("destinationFolderPath");
-
- this.Id = id;
- this.BackupState = BackupState.Todo;
-
- this.Label = label;
- this.BackupSourceType = backupSourceType;
- this.IsEnabled = isEnabled;
- this.IsZipArchive = isZipArchive;
- this.SourcePath = sourcePath;
- this.DestinationFolderPath = destinationFolderPath;
- }
-
- /// <summary>
- /// Occurs when a property which has to be saved in setting file is changed.
- /// </summary>
- public event EventHandler<EventArgs> SettingFilePropertyChanged;
-
- /// <summary>
- /// Gets or sets the identifier.
- /// </summary>
- public Guid Id
- {
- get
- {
- return this.innerId;
- }
-
- set
- {
- if (this.innerId != value)
- {
- this.innerId = value;
- this.NotifyPropertyChanged("Id");
- this.NotifySettingFilePropertyChanged();
- }
- }
- }
-
- /// <summary>
- /// Gets or sets the label.
- /// </summary>
- public string Label
- {
- get
- {
- return this.innerLabel;
- }
-
- set
- {
- if (this.innerLabel != value)
- {
- this.innerLabel = value;
- this.NotifyPropertyChanged("Label");
- this.NotifySettingFilePropertyChanged();
- }
- }
- }
-
- /// <summary>
- /// Gets or sets the type of the backup source.
- /// </summary>
- public BackupSourceType BackupSourceType
- {
- get
- {
- return this.innerBackupSourceType;
- }
-
- set
- {
- if (this.innerBackupSourceType != value)
- {
- this.innerBackupSourceType = value;
- this.NotifyPropertyChanged("BackupSourceType");
- this.NotifySettingFilePropertyChanged();
- }
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether the backup is enabled.
- /// </summary>
- public bool IsEnabled
- {
- get
- {
- return this.innerIsEnabled;
- }
-
- set
- {
- if (this.innerIsEnabled != value)
- {
- this.innerIsEnabled = value;
- this.NotifyPropertyChanged("IsEnabled");
- this.NotifySettingFilePropertyChanged();
- }
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether the backup is zip archive.
- /// </summary>
- public bool IsZipArchive
- {
- get
- {
- return this.innerIsZipArchive;
- }
-
- set
- {
- if (this.innerIsZipArchive != value)
- {
- this.innerIsZipArchive = value;
- this.NotifyPropertyChanged("IsZipArchive");
- this.NotifySettingFilePropertyChanged();
- }
- }
- }
-
- /// <summary>
- /// Gets or sets the source path.
- /// </summary>
- public string SourcePath
- {
- get
- {
- return this.innerSourcePath;
- }
-
- set
- {
- if (this.innerSourcePath != value)
- {
- this.innerSourcePath = value;
- this.NotifyPropertyChanged("SourcePath");
- this.NotifySettingFilePropertyChanged();
- }
- }
- }
-
- /// <summary>
- /// Gets or sets the destination folder path.
- /// </summary>
- public string DestinationFolderPath
- {
- get
- {
- return this.innerDestinationFolderPath;
- }
-
- set
- {
- if (this.innerDestinationFolderPath != value)
- {
- this.innerDestinationFolderPath = value;
- this.NotifyPropertyChanged("DestinationFolderPath");
- this.NotifySettingFilePropertyChanged();
- }
- }
- }
-
- /// <summary>
- /// Gets or sets the state of the backup.
- /// </summary>
- public BackupState BackupState
- {
- get
- {
- return this.innerBackupState;
- }
-
- set
- {
- if (this.innerBackupState != value)
- {
- this.innerBackupState = value;
- this.NotifyPropertyChanged("BackupState");
- }
- }
- }
-
- /// <summary>
- /// Gets or sets the name of the latest successful backup target.
- /// </summary>
- public string LatestSuccessfulBackupTargetName { get; set; }
-
- /// <summary>
- /// Restores from binary.
- /// </summary>
- /// <param name="binaryData">The binary data.</param>
- /// <param name="copySuffixNeeded">if set to <c>true</c> [copy suffix needed].</param>
- /// <returns>The restored backup information.</returns>
- public static BackupInfo FromBinary(byte[] binaryData, bool copySuffixNeeded)
- {
- using (var memoryStream = new MemoryStream(binaryData))
- using (var binaryReader = new BinaryReader(memoryStream))
- {
- string label = binaryReader.ReadString();
- var backupSourceType = (BackupSourceType)Enum.ToObject(typeof(BackupSourceType), binaryReader.ReadInt32());
- bool isEnabled = binaryReader.ReadBoolean();
- bool isZipArchive = binaryReader.ReadBoolean();
- string sourcePath = binaryReader.ReadString();
- string destinationFolderPath = binaryReader.ReadString();
-
- return new BackupInfo(
- copySuffixNeeded ? string.Format("{0} - {1}", label, Resources.Edit_CopySuffix) : label,
- backupSourceType,
- isEnabled,
- isZipArchive,
- sourcePath,
- destinationFolderPath);
- }
- }
-
- /// <summary>
- /// Saves this instance to a XElement.
- /// </summary>
- /// <returns>The generated XElement.</returns>
- public XElement ToXml()
- {
- var element = new XElement("BackupInfo");
- element.Add(new XElement("Id", this.Id));
- element.Add(new XElement("Label", this.Label));
- element.Add(new XElement("BackupSourceType", this.BackupSourceType));
- element.Add(new XElement("IsEnabled", this.IsEnabled));
- element.Add(new XElement("IsZipArchive", this.IsZipArchive));
- element.Add(new XElement("SourcePath", this.SourcePath));
- element.Add(new XElement("DestinationFolderPath", this.DestinationFolderPath));
-
- return element;
- }
-
- /// <summary>
- /// Gets the binary representation of this instance.
- /// </summary>
- /// <returns>The binary representation of this instance.</returns>
- public byte[] ToBinary()
- {
- using (var memoryStream = new MemoryStream())
- using (var binaryWriter = new BinaryWriter(memoryStream))
- {
- binaryWriter.Write(this.Label);
- binaryWriter.Write((int)this.BackupSourceType);
- binaryWriter.Write(this.IsEnabled);
- binaryWriter.Write(this.IsZipArchive);
- binaryWriter.Write(this.SourcePath);
- binaryWriter.Write(this.DestinationFolderPath);
-
- memoryStream.Flush();
- return memoryStream.GetBuffer();
- }
- }
-
- /// <summary>
- /// Gets the text representation of this instance.
- /// TODO: ToString()
- /// </summary>
- /// <returns>The text representation of this instance.</returns>
- public string ToText()
- {
- return string.Format(
- "{0}\t{1}\t{2}\t{3}\t{4}\t{5}",
- this.Label,
- this.BackupSourceType,
- this.IsEnabled,
- this.IsZipArchive,
- this.SourcePath,
- this.DestinationFolderPath);
- }
-
- /// <summary>
- /// Notifies the setting file property is changed.
- /// </summary>
- private void NotifySettingFilePropertyChanged()
- {
- if (this.SettingFilePropertyChanged != null)
- {
- this.SettingFilePropertyChanged(this, new EventArgs());
- }
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="BackupSetting.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Xml.Linq;
-using SimpleBackup.Core.Models;
-using SimpleBackup.Resources;
-
-namespace SimpleBackup.Models
-{
- /// <summary>
- /// Represents a backup setting.
- /// </summary>
- public class BackupSetting : IBackupSetting
- {
- private readonly List<BackupInfo> backupInfoList = new List<BackupInfo>();
-
- /// <summary>
- /// Initializes a new instance of the <see cref="BackupSetting"/> class.
- /// </summary>
- public BackupSetting()
- {
- this.SettingFileName = string.Empty;
- }
-
- public BackupSetting(
- string settingFileName,
- IEnumerable<BackupInfo> backupInfoCollection)
- {
- this.SettingFileName = settingFileName;
- this.backupInfoList.AddRange(backupInfoCollection);
- foreach (BackupInfo backupInfo in this.backupInfoList)
- {
- backupInfo.SettingFilePropertyChanged += this.OnBackupInfoSettingFilePropertyChanged;
- }
- }
-
- /// <summary>
- /// Occurs when backup setting is modified.
- /// </summary>
- public event EventHandler SettingModified;
-
- /// <summary>
- /// Gets the name of the setting.
- /// </summary>
- public string SettingName
- {
- get
- {
- if (string.IsNullOrEmpty(this.SettingFileName))
- {
- return Resources.Resources.Views_NewBackupSettingName;
- }
-
- return this.SettingFileName;
- }
- }
-
- /// <summary>
- /// Gets or sets the name of the setting file.
- /// </summary>
- public string SettingFileName { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether this <see cref="BackupSetting"/> is modified.
- /// </summary>
- public bool Modified { get; set; }
-
- public IReadOnlyCollection<IBackupInfo> BackupInfos
- {
- get
- {
- return this.backupInfoList.AsReadOnly();
- }
- }
-
- public int Count
- {
- get
- {
- return this.backupInfoList.Count;
- }
- }
-
- /// <summary>
- /// Inserts the specified index.
- /// </summary>
- /// <param name="index">The index.</param>
- /// <param name="backupInfo">The backup information.</param>
- public void Insert(int index, IBackupInfo backupInfo)
- {
- backupInfo.SettingFilePropertyChanged += this.OnBackupInfoSettingFilePropertyChanged;
- this.backupInfoList.Insert(index, (BackupInfo)backupInfo);
-
- this.MarkAsModifiedAndPublishNotification();
- }
-
- /// <summary>
- /// Removes the specified removing backup information.
- /// </summary>
- /// <param name="removingBackupInfo">The removing backup information.</param>
- public void Remove(IBackupInfo removingBackupInfo)
- {
- removingBackupInfo.SettingFilePropertyChanged -= this.OnBackupInfoSettingFilePropertyChanged;
- this.backupInfoList.Remove((BackupInfo)removingBackupInfo);
-
- this.MarkAsModifiedAndPublishNotification();
- }
-
- public IBackupInfo FirstOrDefault(Guid id)
- {
- return this.backupInfoList.FirstOrDefault(p => p.Id == id);
- }
-
- public void MoveItem(Guid backupInfoId, ItemMovingDirection movingDirection)
- {
- IBackupInfo movingBackupInfo = null;
- int currentIndex = 0;
- for (int i = 0; i < this.backupInfoList.Count; i++)
- {
- if (this.backupInfoList[i].Id == backupInfoId)
- {
- currentIndex = i;
- movingBackupInfo = this.backupInfoList[i];
- break;
- }
- }
-
- if (movingBackupInfo != null)
- {
- int newIndex = -1;
- switch (movingDirection)
- {
- case ItemMovingDirection.MoveUp:
- if (currentIndex > 0)
- {
- newIndex = currentIndex - 1;
- }
-
- break;
- case ItemMovingDirection.MoveDown:
- if (currentIndex < this.backupInfoList.Count - 1)
- {
- newIndex = currentIndex + 1;
- }
-
- break;
- default:
- throw new InvalidOperationException("Not supported direction.");
- }
-
- if (newIndex != -1)
- {
- IBackupInfo temp = this.backupInfoList[newIndex];
- this.backupInfoList[newIndex] = this.backupInfoList[currentIndex];
- this.backupInfoList[currentIndex] = (BackupInfo)temp;
- }
-
- this.MarkAsModifiedAndPublishNotification();
- }
- }
-
- public XElement ToXml()
- {
- var backupSettingElement = new XElement("BackupSetting");
- backupSettingElement.SetAttributeValue("Version", "1.0");
- backupSettingElement.SetAttributeValue("RequiredToolVersion", "1.0.0.181");
-
- var items = new XElement("Items");
- foreach (IBackupInfo backupInfo in this.BackupInfos)
- {
- items.Add(backupInfo.ToXml());
- }
-
- backupSettingElement.Add(items);
- return backupSettingElement;
- }
-
- private void OnBackupInfoSettingFilePropertyChanged(object sender, EventArgs e)
- {
- this.MarkAsModifiedAndPublishNotification();
- }
-
- private void MarkAsModifiedAndPublishNotification()
- {
- this.Modified = true;
- if (this.SettingModified != null)
- {
- this.SettingModified(this, new EventArgs());
- }
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="BackupSourceType.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-namespace SimpleBackup.Models
-{
- public enum BackupSourceType
- {
- /// <summary>
- /// The file
- /// </summary>
- File,
-
- /// <summary>
- /// The folder
- /// </summary>
- Folder
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="DestinationPathInfo.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-namespace SimpleBackup.Models
-{
- public class DestinationPathInfo
- {
- public DestinationPathInfo(BackupSourceType backupSourceType, string path)
- {
- this.BackupSourceType = backupSourceType;
- this.Path = path;
- }
-
- public BackupSourceType BackupSourceType { get; private set; }
-
- public string Path { get; private set; }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="ModelHelper.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Xml.Linq;
-
-namespace SimpleBackup.Models
-{
- /// <summary>
- /// Provides helper function for models.
- /// </summary>
- internal static class ModelHelper
- {
- /// <summary>
- /// Restores the backup setting from XML.
- /// </summary>
- /// <param name="xml">The XML.</param>
- /// <param name="fileName">Name of the file.</param>
- /// <returns>The restored backup setting.</returns>
- public static BackupSetting RestoreBackupSettingFromXml(XElement xml, string fileName)
- {
- if (xml.Name != "BackupSetting")
- {
- return null;
- }
-
- XElement itemsElement = xml.Elements("Items").FirstOrDefault();
- if (itemsElement == null)
- {
- return null;
- }
-
- var backupInfoList = new List<BackupInfo>();
- foreach (XElement element in itemsElement.Elements())
- {
- BackupInfo backupInfo = RestoreBackupInfoFromXml(element);
- backupInfoList.Add(backupInfo);
- }
-
- return new BackupSetting(fileName, backupInfoList);
- }
-
- /// <summary>
- /// Restores the backup information from XML.
- /// </summary>
- /// <param name="xml">The XML.</param>
- /// <returns>The restored backup information.</returns>
- private static BackupInfo RestoreBackupInfoFromXml(XElement xml)
- {
- if (xml.Name != "BackupInfo")
- {
- return null;
- }
-
- XElement idElement = xml.Elements("Id").FirstOrDefault();
- XElement labelElement = xml.Elements("Label").FirstOrDefault();
- XElement backupSourceTypeElement = xml.Elements("BackupSourceType").FirstOrDefault();
- XElement enabledElement = xml.Elements("IsEnabled").FirstOrDefault();
- XElement zipArchiveElement = xml.Elements("IsZipArchive").FirstOrDefault();
- XElement sourcePathElement = xml.Elements("SourcePath").FirstOrDefault();
- XElement destinationFolderPathElement = xml.Elements("DestinationFolderPath").FirstOrDefault();
-
- if ((idElement == null) ||
- (labelElement == null) ||
- (backupSourceTypeElement == null) ||
- (enabledElement == null) ||
- (zipArchiveElement == null) ||
- (sourcePathElement == null) ||
- (destinationFolderPathElement == null))
- {
- return null;
- }
-
- Guid id;
- if (Guid.TryParse(idElement.Value, out id) == false)
- {
- return null;
- }
-
- BackupSourceType backupSourceType;
- if (Enum.TryParse(backupSourceTypeElement.Value, out backupSourceType) == false)
- {
- return null;
- }
-
- bool isEnabled;
- if (bool.TryParse(enabledElement.Value, out isEnabled) == false)
- {
- return null;
- }
-
- bool isZipArchive;
- if (bool.TryParse(zipArchiveElement.Value, out isZipArchive) == false)
- {
- return null;
- }
-
- return new BackupInfo(
- id,
- labelElement.Value,
- backupSourceType,
- isEnabled,
- isZipArchive,
- sourcePathElement.Value,
- destinationFolderPathElement.Value);
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="ResultInfo.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using SimpleBackup.Core.Models;
-
-namespace SimpleBackup.Models
-{
- public class ResultInfo : IResultInfo
- {
- public ResultInfo(BackupState category, string description)
- {
- this.Category = category;
- this.Description = description ?? string.Empty;
- }
-
- public BackupState Category { get; private set; }
-
- public string Description { get; private set; }
- }
-}
+++ /dev/null
-This is a Git repository for Simple Backup Tool.
+++ /dev/null
-//------------------------------------------------------------------------------
-// <auto-generated>
-// このコードはツールによって生成されました。
-// ランタイム バージョン:4.0.30319.34014
-//
-// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
-// コードが再生成されるときに損失したりします。
-// </auto-generated>
-//------------------------------------------------------------------------------
-
-namespace SimpleBackup.Resources {
- using System;
-
-
- /// <summary>
- /// ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。
- /// </summary>
- // このクラスは StronglyTypedResourceBuilder クラスが ResGen
- // または Visual Studio のようなツールを使用して自動生成されました。
- // メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に
- // ResGen を実行し直すか、または VS プロジェクトをビルドし直します。
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources() {
- }
-
- /// <summary>
- /// このクラスで使用されているキャッシュされた ResourceManager インスタンスを返します。
- /// </summary>
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SimpleBackup.Resources.Resources", typeof(Resources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- /// <summary>
- /// 厳密に型指定されたこのリソース クラスを使用して、すべての検索リソースに対し、
- /// 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。
- /// </summary>
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
-
- /// <summary>
- /// Backup... に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Backup_ExecutingBackup {
- get {
- return ResourceManager.GetString("Backup_ExecutingBackup", resourceCulture);
- }
- }
-
- /// <summary>
- /// The backup information has not been prepared. に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Backup_Failed_BackupInfomationNotPrepared {
- get {
- return ResourceManager.GetString("Backup_Failed_BackupInfomationNotPrepared", resourceCulture);
- }
- }
-
- /// <summary>
- /// The destination Folder does not exist. に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Backup_Failed_DestinationNotExist {
- get {
- return ResourceManager.GetString("Backup_Failed_DestinationNotExist", resourceCulture);
- }
- }
-
- /// <summary>
- /// Failed to copy the file. に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Backup_Failed_FailedToCopy {
- get {
- return ResourceManager.GetString("Backup_Failed_FailedToCopy", resourceCulture);
- }
- }
-
- /// <summary>
- /// The source does not exist. に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Backup_Failed_SourceNotExist {
- get {
- return ResourceManager.GetString("Backup_Failed_SourceNotExist", resourceCulture);
- }
- }
-
- /// <summary>
- /// From に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Backup_From {
- get {
- return ResourceManager.GetString("Backup_From", resourceCulture);
- }
- }
-
- /// <summary>
- /// The backup has been skipped. に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Backup_Skipped {
- get {
- return ResourceManager.GetString("Backup_Skipped", resourceCulture);
- }
- }
-
- /// <summary>
- /// Done! に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Backup_Succeeded {
- get {
- return ResourceManager.GetString("Backup_Succeeded", resourceCulture);
- }
- }
-
- /// <summary>
- /// To に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Backup_To {
- get {
- return ResourceManager.GetString("Backup_To", resourceCulture);
- }
- }
-
- /// <summary>
- /// Failed to open the backup setting. The file name is empty: {0} に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string BackupSetting_FailedToOpenSetting_EmptyFileNameFormat {
- get {
- return ResourceManager.GetString("BackupSetting_FailedToOpenSetting_EmptyFileNameFormat", resourceCulture);
- }
- }
-
- /// <summary>
- /// Failed to open the backup setting. Invalid major version value: {0} に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string BackupSetting_FailedToOpenSetting_InvalidMajorVersionFormat {
- get {
- return ResourceManager.GetString("BackupSetting_FailedToOpenSetting_InvalidMajorVersionFormat", resourceCulture);
- }
- }
-
- /// <summary>
- /// Failed to open the backup setting. Invalid minor version value: {0} に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string BackupSetting_FailedToOpenSetting_InvalidMinorVersionFormat {
- get {
- return ResourceManager.GetString("BackupSetting_FailedToOpenSetting_InvalidMinorVersionFormat", resourceCulture);
- }
- }
-
- /// <summary>
- /// Failed to open the backup setting. Invalid "RequiredToolVersion" value: {0} に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string BackupSetting_FailedToOpenSetting_InvalidRequiredToolVersionFormat {
- get {
- return ResourceManager.GetString("BackupSetting_FailedToOpenSetting_InvalidRequiredToolVersionFormat", resourceCulture);
- }
- }
-
- /// <summary>
- /// Failed to open the backup setting. Invalid "Version" value: {0} に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string BackupSetting_FailedToOpenSetting_InvalidVersionFormat {
- get {
- return ResourceManager.GetString("BackupSetting_FailedToOpenSetting_InvalidVersionFormat", resourceCulture);
- }
- }
-
- /// <summary>
- /// Failed to open the backup setting. There is no "BackupSetting" tag: {0} に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string BackupSetting_FailedToOpenSetting_NoBackupSettingElementFormat {
- get {
- return ResourceManager.GetString("BackupSetting_FailedToOpenSetting_NoBackupSettingElementFormat", resourceCulture);
- }
- }
-
- /// <summary>
- /// Failed to open the backup setting. There is no "Version" tag: {0} に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string BackupSetting_FailedToOpenSetting_NoVersionElementFormat {
- get {
- return ResourceManager.GetString("BackupSetting_FailedToOpenSetting_NoVersionElementFormat", resourceCulture);
- }
- }
-
- /// <summary>
- /// Failed to read the backup setting data because it is incomatible. To read the backup setting data, please use Simple Backup Ver.{0} or later. に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string BackupSetting_IncompatibleMajorVersionFormat {
- get {
- return ResourceManager.GetString("BackupSetting_IncompatibleMajorVersionFormat", resourceCulture);
- }
- }
-
- /// <summary>
- /// Failed to read some part of the backup setting data because they are incompatible. To read all the backup setting data, please use Simple Backup Ver.{0} or later. に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string BackupSetting_IncompatibleMinorVersionFormat {
- get {
- return ResourceManager.GetString("BackupSetting_IncompatibleMinorVersionFormat", resourceCulture);
- }
- }
-
- /// <summary>
- /// The backup setting is opened: {0} に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string BackupSetting_SettingOpenedFormat {
- get {
- return ResourceManager.GetString("BackupSetting_SettingOpenedFormat", resourceCulture);
- }
- }
-
- /// <summary>
- /// Cancelled に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string BackupState_Cancelled {
- get {
- return ResourceManager.GetString("BackupState_Cancelled", resourceCulture);
- }
- }
-
- /// <summary>
- /// Fail に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string BackupState_Failed {
- get {
- return ResourceManager.GetString("BackupState_Failed", resourceCulture);
- }
- }
-
- /// <summary>
- /// In Progress に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string BackupState_InProgress {
- get {
- return ResourceManager.GetString("BackupState_InProgress", resourceCulture);
- }
- }
-
- /// <summary>
- /// Skipped に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string BackupState_Skipped {
- get {
- return ResourceManager.GetString("BackupState_Skipped", resourceCulture);
- }
- }
-
- /// <summary>
- /// Success に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string BackupState_Success {
- get {
- return ResourceManager.GetString("BackupState_Success", resourceCulture);
- }
- }
-
- /// <summary>
- /// TODO に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string BackupState_Todo {
- get {
- return ResourceManager.GetString("BackupState_Todo", resourceCulture);
- }
- }
-
- /// <summary>
- /// Copy に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Edit_CopySuffix {
- get {
- return ResourceManager.GetString("Edit_CopySuffix", resourceCulture);
- }
- }
-
- /// <summary>
- /// Failed to open the file: {0} に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string FileAccess_FailedToOpenFormat {
- get {
- return ResourceManager.GetString("FileAccess_FailedToOpenFormat", resourceCulture);
- }
- }
-
- /// <summary>
- /// The folder path does not exist: {0} に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string FileAccess_FolderPathNotExistFormat {
- get {
- return ResourceManager.GetString("FileAccess_FolderPathNotExistFormat", resourceCulture);
- }
- }
-
- /// <summary>
- /// The path is not valid: {0} に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string FileAccess_InvalidPathFormat {
- get {
- return ResourceManager.GetString("FileAccess_InvalidPathFormat", resourceCulture);
- }
- }
-
- /// <summary>
- /// Copyright© 2015 Takayoshi Matsuyama に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Version_Copyright {
- get {
- return ResourceManager.GetString("Version_Copyright", resourceCulture);
- }
- }
-
- /// <summary>
- /// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
- ///
- ///This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- ///
- ///You should have received a copy [残りの文字列は切り詰められました]"; に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Version_CopyrightDescription {
- get {
- return ResourceManager.GetString("Version_CopyrightDescription", resourceCulture);
- }
- }
-
- /// <summary>
- /// Add に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_AddButtonToolTipText {
- get {
- return ResourceManager.GetString("Views_AddButtonToolTipText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Destination に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_BackupDestinationColumnHeaderText {
- get {
- return ResourceManager.GetString("Views_BackupDestinationColumnHeaderText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Source に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_BackupSourceColumnHeaderText {
- get {
- return ResourceManager.GetString("Views_BackupSourceColumnHeaderText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Cancel Multi Backup に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_CancelMultiBackupButtonToolTipText {
- get {
- return ResourceManager.GetString("Views_CancelMultiBackupButtonToolTipText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Confirmation に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_ConfirmationDialogTitle {
- get {
- return ResourceManager.GetString("Views_ConfirmationDialogTitle", resourceCulture);
- }
- }
-
- /// <summary>
- /// Backup に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_ContextMenu_Backup {
- get {
- return ResourceManager.GetString("Views_ContextMenu_Backup", resourceCulture);
- }
- }
-
- /// <summary>
- /// Edit に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_ContextMenu_Edit {
- get {
- return ResourceManager.GetString("Views_ContextMenu_Edit", resourceCulture);
- }
- }
-
- /// <summary>
- /// Open Destination に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_ContextMenu_OpenDestination {
- get {
- return ResourceManager.GetString("Views_ContextMenu_OpenDestination", resourceCulture);
- }
- }
-
- /// <summary>
- /// Open File に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_ContextMenu_OpenFile {
- get {
- return ResourceManager.GetString("Views_ContextMenu_OpenFile", resourceCulture);
- }
- }
-
- /// <summary>
- /// Open Source Folder に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_ContextMenu_OpenSourceFolder {
- get {
- return ResourceManager.GetString("Views_ContextMenu_OpenSourceFolder", resourceCulture);
- }
- }
-
- /// <summary>
- /// Select Destination に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_ContextMenu_SelectDestination {
- get {
- return ResourceManager.GetString("Views_ContextMenu_SelectDestination", resourceCulture);
- }
- }
-
- /// <summary>
- /// Select Source に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_ContextMenu_SelectSource {
- get {
- return ResourceManager.GetString("Views_ContextMenu_SelectSource", resourceCulture);
- }
- }
-
- /// <summary>
- /// Copy に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_CopyButtonToolTipText {
- get {
- return ResourceManager.GetString("Views_CopyButtonToolTipText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Simple Backup に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_CopyrightApplicationName {
- get {
- return ResourceManager.GetString("Views_CopyrightApplicationName", resourceCulture);
- }
- }
-
- /// <summary>
- /// Cut に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_CutButtonToolTipText {
- get {
- return ResourceManager.GetString("Views_CutButtonToolTipText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Simple Backup に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_DefaultWindowTitle {
- get {
- return ResourceManager.GetString("Views_DefaultWindowTitle", resourceCulture);
- }
- }
-
- /// <summary>
- /// Label に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_LabelColumnHeaderText {
- get {
- return ResourceManager.GetString("Views_LabelColumnHeaderText", resourceCulture);
- }
- }
-
- /// <summary>
- /// _Close に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_MainMenu_Close {
- get {
- return ResourceManager.GetString("Views_MainMenu_Close", resourceCulture);
- }
- }
-
- /// <summary>
- /// E_xit に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_MainMenu_Exit {
- get {
- return ResourceManager.GetString("Views_MainMenu_Exit", resourceCulture);
- }
- }
-
- /// <summary>
- /// _File に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_MainMenu_File {
- get {
- return ResourceManager.GetString("Views_MainMenu_File", resourceCulture);
- }
- }
-
- /// <summary>
- /// _Help に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_MainMenu_Help {
- get {
- return ResourceManager.GetString("Views_MainMenu_Help", resourceCulture);
- }
- }
-
- /// <summary>
- /// _New に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_MainMenu_New {
- get {
- return ResourceManager.GetString("Views_MainMenu_New", resourceCulture);
- }
- }
-
- /// <summary>
- /// _Open に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_MainMenu_Open {
- get {
- return ResourceManager.GetString("Views_MainMenu_Open", resourceCulture);
- }
- }
-
- /// <summary>
- /// Open Current Setting File Location に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_MainMenu_OpenCurrentSettingFileLocation {
- get {
- return ResourceManager.GetString("Views_MainMenu_OpenCurrentSettingFileLocation", resourceCulture);
- }
- }
-
- /// <summary>
- /// _Save に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_MainMenu_Save {
- get {
- return ResourceManager.GetString("Views_MainMenu_Save", resourceCulture);
- }
- }
-
- /// <summary>
- /// Save _As に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_MainMenu_SaveAs {
- get {
- return ResourceManager.GetString("Views_MainMenu_SaveAs", resourceCulture);
- }
- }
-
- /// <summary>
- /// Show Help (_V) に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_MainMenu_ShowHelp {
- get {
- return ResourceManager.GetString("Views_MainMenu_ShowHelp", resourceCulture);
- }
- }
-
- /// <summary>
- /// Show Version Information (_A) に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_MainMenu_ShowVersionInformation {
- get {
- return ResourceManager.GetString("Views_MainMenu_ShowVersionInformation", resourceCulture);
- }
- }
-
- /// <summary>
- /// Move down に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_MoveDownButtonToolTipText {
- get {
- return ResourceManager.GetString("Views_MoveDownButtonToolTipText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Move up に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_MoveUpButtonToolTipText {
- get {
- return ResourceManager.GetString("Views_MoveUpButtonToolTipText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Multiple Backup に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_MultipleBackupButtonToolTipText {
- get {
- return ResourceManager.GetString("Views_MultipleBackupButtonToolTipText", resourceCulture);
- }
- }
-
- /// <summary>
- /// New Backup に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_NewBackupSettingName {
- get {
- return ResourceManager.GetString("Views_NewBackupSettingName", resourceCulture);
- }
- }
-
- /// <summary>
- /// New に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_NewFileButtonToolTipText {
- get {
- return ResourceManager.GetString("Views_NewFileButtonToolTipText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Open Backup Setting に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_OpenBackupSettingButtonToolTipText {
- get {
- return ResourceManager.GetString("Views_OpenBackupSettingButtonToolTipText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Open Backup Setting に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_OpenFileDialogTitle {
- get {
- return ResourceManager.GetString("Views_OpenFileDialogTitle", resourceCulture);
- }
- }
-
- /// <summary>
- /// Clear に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_OutputWindowContextMenu_Clear {
- get {
- return ResourceManager.GetString("Views_OutputWindowContextMenu_Clear", resourceCulture);
- }
- }
-
- /// <summary>
- /// Paste に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_PasteButtonToolTipText {
- get {
- return ResourceManager.GetString("Views_PasteButtonToolTipText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Redo に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_RedoButtonToolTipText {
- get {
- return ResourceManager.GetString("Views_RedoButtonToolTipText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Refresh に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_RefreshButtonToolTipText {
- get {
- return ResourceManager.GetString("Views_RefreshButtonToolTipText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Remove に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_RemoveButtonToolTipText {
- get {
- return ResourceManager.GetString("Views_RemoveButtonToolTipText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Save Backup Setting に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_SaveBackupSettingButtonToolTipText {
- get {
- return ResourceManager.GetString("Views_SaveBackupSettingButtonToolTipText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Save the changes? に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_SaveConfirmationMessage {
- get {
- return ResourceManager.GetString("Views_SaveConfirmationMessage", resourceCulture);
- }
- }
-
- /// <summary>
- /// Save Backup Setting に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_SaveFileDialogTitle {
- get {
- return ResourceManager.GetString("Views_SaveFileDialogTitle", resourceCulture);
- }
- }
-
- /// <summary>
- /// Single Backup に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_SingleBackupButtonToolTipText {
- get {
- return ResourceManager.GetString("Views_SingleBackupButtonToolTipText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Undo に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_UndoButtonToolTipText {
- get {
- return ResourceManager.GetString("Views_UndoButtonToolTipText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Version Information of Simple Backup に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_VersionWindowTitle {
- get {
- return ResourceManager.GetString("Views_VersionWindowTitle", resourceCulture);
- }
- }
-
- /// <summary>
- /// Simple Backup - {0} に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_WindowTitleFormat {
- get {
- return ResourceManager.GetString("Views_WindowTitleFormat", resourceCulture);
- }
- }
-
- /// <summary>
- /// Zip Encoding に類似しているローカライズされた文字列を検索します。
- /// </summary>
- internal static string Views_ZipEncodingTitleText {
- get {
- return ResourceManager.GetString("Views_ZipEncodingTitleText", resourceCulture);
- }
- }
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<root>
- <!--
- Microsoft ResX Schema
-
- Version 2.0
-
- The primary goals of this format is to allow a simple XML format
- that is mostly human readable. The generation and parsing of the
- various data types are done through the TypeConverter classes
- associated with the data types.
-
- Example:
-
- ... ado.net/XML headers & schema ...
- <resheader name="resmimetype">text/microsoft-resx</resheader>
- <resheader name="version">2.0</resheader>
- <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
- <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
- <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
- <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
- <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
- <value>[base64 mime encoded serialized .NET Framework object]</value>
- </data>
- <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
- <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
- <comment>This is a comment</comment>
- </data>
-
- There are any number of "resheader" rows that contain simple
- name/value pairs.
-
- Each data row contains a name, and value. The row also contains a
- type or mimetype. Type corresponds to a .NET class that support
- text/value conversion through the TypeConverter architecture.
- Classes that don't support this are serialized and stored with the
- mimetype set.
-
- The mimetype is used for serialized objects, and tells the
- ResXResourceReader how to depersist the object. This is currently not
- extensible. For a given mimetype the value must be set accordingly:
-
- Note - application/x-microsoft.net.object.binary.base64 is the format
- that the ResXResourceWriter will generate, however the reader can
- read any of the formats listed below.
-
- mimetype: application/x-microsoft.net.object.binary.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.soap.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.bytearray.base64
- value : The object must be serialized into a byte array
- : using a System.ComponentModel.TypeConverter
- : and then encoded with base64 encoding.
- -->
- <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
- <xsd:element name="root" msdata:IsDataSet="true">
- <xsd:complexType>
- <xsd:choice maxOccurs="unbounded">
- <xsd:element name="metadata">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- <xsd:attribute name="name" use="required" type="xsd:string" />
- <xsd:attribute name="type" type="xsd:string" />
- <xsd:attribute name="mimetype" type="xsd:string" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="assembly">
- <xsd:complexType>
- <xsd:attribute name="alias" type="xsd:string" />
- <xsd:attribute name="name" type="xsd:string" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="data">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
- <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
- <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="resheader">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:schema>
- <resheader name="resmimetype">
- <value>text/microsoft-resx</value>
- </resheader>
- <resheader name="version">
- <value>2.0</value>
- </resheader>
- <resheader name="reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <resheader name="writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <data name="BackupState_Cancelled" xml:space="preserve">
- <value>キャンセル</value>
- </data>
- <data name="BackupState_Failed" xml:space="preserve">
- <value>失敗</value>
- </data>
- <data name="BackupState_InProgress" xml:space="preserve">
- <value>進行中</value>
- </data>
- <data name="BackupState_Skipped" xml:space="preserve">
- <value>スキップ</value>
- </data>
- <data name="BackupState_Success" xml:space="preserve">
- <value>成功</value>
- </data>
- <data name="BackupState_Todo" xml:space="preserve">
- <value>実行待ち</value>
- </data>
- <data name="Backup_ExecutingBackup" xml:space="preserve">
- <value>バックアップ実行中...</value>
- </data>
- <data name="Backup_Failed_SourceNotExist" xml:space="preserve">
- <value>バックアップ対象がありません。</value>
- </data>
- <data name="Backup_Failed_BackupInfomationNotPrepared" xml:space="preserve">
- <value>バックアップ情報が準備できていません。</value>
- </data>
- <data name="Backup_Skipped" xml:space="preserve">
- <value>バックアップはスキップされました。</value>
- </data>
- <data name="Backup_From" xml:space="preserve">
- <value>バックアップ対象</value>
- </data>
- <data name="Backup_To" xml:space="preserve">
- <value>バックアップ先</value>
- </data>
- <data name="Edit_CopySuffix" xml:space="preserve">
- <value>コピー</value>
- </data>
- <data name="Views_AddButtonToolTipText" xml:space="preserve">
- <value>追加</value>
- </data>
- <data name="Views_BackupDestinationColumnHeaderText" xml:space="preserve">
- <value>バックアップ先</value>
- </data>
- <data name="Views_BackupSourceColumnHeaderText" xml:space="preserve">
- <value>バックアップ対象</value>
- </data>
- <data name="Views_CancelMultiBackupButtonToolTipText" xml:space="preserve">
- <value>マルチバックアップをキャンセル</value>
- </data>
- <data name="Views_ContextMenu_Backup" xml:space="preserve">
- <value>バックアップ</value>
- </data>
- <data name="Views_ContextMenu_Edit" xml:space="preserve">
- <value>編集</value>
- </data>
- <data name="Views_ContextMenu_OpenDestination" xml:space="preserve">
- <value>バックアップ先の場所を開く</value>
- </data>
- <data name="Views_ContextMenu_OpenFile" xml:space="preserve">
- <value>ファイルを開く</value>
- </data>
- <data name="Views_ContextMenu_OpenSourceFolder" xml:space="preserve">
- <value>バックアップ対象の場所を開く</value>
- </data>
- <data name="Views_ContextMenu_SelectDestination" xml:space="preserve">
- <value>バックアップ先を選ぶ</value>
- </data>
- <data name="Views_ContextMenu_SelectSource" xml:space="preserve">
- <value>バックアップ対象を選ぶ</value>
- </data>
- <data name="Views_CopyButtonToolTipText" xml:space="preserve">
- <value>コピー</value>
- </data>
- <data name="Views_CutButtonToolTipText" xml:space="preserve">
- <value>切り取り</value>
- </data>
- <data name="Views_DefaultWindowTitle" xml:space="preserve">
- <value>バックアップツール</value>
- </data>
- <data name="Views_LabelColumnHeaderText" xml:space="preserve">
- <value>ラベル</value>
- </data>
- <data name="Views_MainMenu_Close" xml:space="preserve">
- <value>閉じる(_C)</value>
- </data>
- <data name="Views_MainMenu_Exit" xml:space="preserve">
- <value>終了(_X)</value>
- </data>
- <data name="Views_MainMenu_File" xml:space="preserve">
- <value>ファイル(_F)</value>
- </data>
- <data name="Views_MainMenu_Help" xml:space="preserve">
- <value>ヘルプ(_H)</value>
- </data>
- <data name="Views_MainMenu_New" xml:space="preserve">
- <value>新規作成(_N)</value>
- </data>
- <data name="Views_MainMenu_Open" xml:space="preserve">
- <value>開く(_O)</value>
- </data>
- <data name="Views_MainMenu_OpenCurrentSettingFileLocation" xml:space="preserve">
- <value>現在の設定ファイルの場所を開く</value>
- </data>
- <data name="Views_MainMenu_ShowHelp" xml:space="preserve">
- <value>ヘルプの表示(_V)</value>
- </data>
- <data name="Views_MainMenu_ShowVersionInformation" xml:space="preserve">
- <value>バージョン情報(_A)</value>
- </data>
- <data name="Views_MoveDownButtonToolTipText" xml:space="preserve">
- <value>下へ移動</value>
- </data>
- <data name="Views_MoveUpButtonToolTipText" xml:space="preserve">
- <value>上へ移動</value>
- </data>
- <data name="Views_MultipleBackupButtonToolTipText" xml:space="preserve">
- <value>マルチバックアップ</value>
- </data>
- <data name="Views_NewBackupSettingName" xml:space="preserve">
- <value>新しいバックアップ</value>
- </data>
- <data name="Views_NewFileButtonToolTipText" xml:space="preserve">
- <value>新規作成</value>
- </data>
- <data name="Views_OpenBackupSettingButtonToolTipText" xml:space="preserve">
- <value>バックアップ設定を開く</value>
- </data>
- <data name="Views_OutputWindowContextMenu_Clear" xml:space="preserve">
- <value>クリア</value>
- </data>
- <data name="Views_PasteButtonToolTipText" xml:space="preserve">
- <value>貼り付け</value>
- </data>
- <data name="Views_RedoButtonToolTipText" xml:space="preserve">
- <value>やり直し</value>
- </data>
- <data name="Views_RefreshButtonToolTipText" xml:space="preserve">
- <value>リフレッシュ</value>
- </data>
- <data name="Views_RemoveButtonToolTipText" xml:space="preserve">
- <value>削除</value>
- </data>
- <data name="Views_SaveBackupSettingButtonToolTipText" xml:space="preserve">
- <value>バックアップ設定を保存する</value>
- </data>
- <data name="Views_SingleBackupButtonToolTipText" xml:space="preserve">
- <value>シングルバックアップ</value>
- </data>
- <data name="Views_UndoButtonToolTipText" xml:space="preserve">
- <value>元に戻す</value>
- </data>
- <data name="Views_VersionWindowTitle" xml:space="preserve">
- <value>バックアップツールのバージョン情報</value>
- </data>
- <data name="Views_WindowTitleFormat" xml:space="preserve">
- <value>バックアップツール - {0}</value>
- </data>
- <data name="Backup_Failed_DestinationNotExist" xml:space="preserve">
- <value>バックアップ先のフォルダががありません。</value>
- </data>
- <data name="Backup_Failed_FailedToCopy" xml:space="preserve">
- <value>ファイルのコピーに失敗しました。</value>
- </data>
- <data name="Backup_Succeeded" xml:space="preserve">
- <value>バックアップを完了しました。</value>
- </data>
- <data name="Views_MainMenu_Save" xml:space="preserve">
- <value>保存(_S)</value>
- </data>
- <data name="Views_MainMenu_SaveAs" xml:space="preserve">
- <value>名前を付けて保存(_A)</value>
- </data>
- <data name="Views_ZipEncodingTitleText" xml:space="preserve">
- <value>Zipエンコード</value>
- </data>
- <data name="Views_OpenFileDialogTitle" xml:space="preserve">
- <value>バックアップ設定を開く</value>
- </data>
- <data name="Views_SaveFileDialogTitle" xml:space="preserve">
- <value>バックアップ設定の保存</value>
- </data>
- <data name="BackupSetting_IncompatibleMajorVersionFormat" xml:space="preserve">
- <value>互換性がないため、バックアップ設定データの読み込みに失敗しました。このバックアップ設定データを読み込むには、Ver.{0}以降のバックアップツールを入手してください。</value>
- </data>
- <data name="BackupSetting_IncompatibleMinorVersionFormat" xml:space="preserve">
- <value>互換性がないため、一部のバックアップ設定データの読み込みに失敗しました。全てのバックアップ設定データを読み込むには、Ver.{0}以降のバックアップツールを入手してください。</value>
- </data>
- <data name="BackupSetting_SettingOpenedFormat" xml:space="preserve">
- <value>バックアップ設定を開きました。{0}</value>
- </data>
- <data name="BackupSetting_FailedToOpenSetting_EmptyFileNameFormat" xml:space="preserve">
- <value>バックアップ設定の読み込みに失敗しました。ファイル名が空です。{0}</value>
- </data>
- <data name="BackupSetting_FailedToOpenSetting_InvalidMajorVersionFormat" xml:space="preserve">
- <value>バックアップ設定の読み込みに失敗しました。メジャーバージョン値が不正です。{0}</value>
- </data>
- <data name="BackupSetting_FailedToOpenSetting_InvalidMinorVersionFormat" xml:space="preserve">
- <value>バックアップ設定の読み込みに失敗しました。マイナーバージョン値が不正です。{0}</value>
- </data>
- <data name="BackupSetting_FailedToOpenSetting_InvalidRequiredToolVersionFormat" xml:space="preserve">
- <value>バックアップ設定の読み込みに失敗しました。"RequiredToolVersion"値が不正です。{0}</value>
- </data>
- <data name="BackupSetting_FailedToOpenSetting_InvalidVersionFormat" xml:space="preserve">
- <value>バックアップ設定の読み込みに失敗しました。"Version"値が不正です。{0}</value>
- </data>
- <data name="BackupSetting_FailedToOpenSetting_NoBackupSettingElementFormat" xml:space="preserve">
- <value>バックアップ設定の読み込みに失敗しました。"BackupSetting"タグが見つかりません。{0}</value>
- </data>
- <data name="BackupSetting_FailedToOpenSetting_NoVersionElementFormat" xml:space="preserve">
- <value>バックアップ設定の読み込みに失敗しました。"Version"タグが見つかりません。{0}</value>
- </data>
- <data name="FileAccess_FailedToOpenFormat" xml:space="preserve">
- <value>ファイルオープンに失敗しました。 {0}</value>
- </data>
- <data name="FileAccess_FolderPathNotExistFormat" xml:space="preserve">
- <value>存在しないフォルダです。 {0}</value>
- </data>
- <data name="FileAccess_InvalidPathFormat" xml:space="preserve">
- <value>不正なパスです。 {0}</value>
- </data>
- <data name="Views_ConfirmationDialogTitle" xml:space="preserve">
- <value>確認</value>
- </data>
- <data name="Views_SaveConfirmationMessage" xml:space="preserve">
- <value>変更を保存しますか?</value>
- </data>
-</root>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<root>
- <!--
- Microsoft ResX Schema
-
- Version 2.0
-
- The primary goals of this format is to allow a simple XML format
- that is mostly human readable. The generation and parsing of the
- various data types are done through the TypeConverter classes
- associated with the data types.
-
- Example:
-
- ... ado.net/XML headers & schema ...
- <resheader name="resmimetype">text/microsoft-resx</resheader>
- <resheader name="version">2.0</resheader>
- <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
- <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
- <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
- <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
- <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
- <value>[base64 mime encoded serialized .NET Framework object]</value>
- </data>
- <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
- <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
- <comment>This is a comment</comment>
- </data>
-
- There are any number of "resheader" rows that contain simple
- name/value pairs.
-
- Each data row contains a name, and value. The row also contains a
- type or mimetype. Type corresponds to a .NET class that support
- text/value conversion through the TypeConverter architecture.
- Classes that don't support this are serialized and stored with the
- mimetype set.
-
- The mimetype is used for serialized objects, and tells the
- ResXResourceReader how to depersist the object. This is currently not
- extensible. For a given mimetype the value must be set accordingly:
-
- Note - application/x-microsoft.net.object.binary.base64 is the format
- that the ResXResourceWriter will generate, however the reader can
- read any of the formats listed below.
-
- mimetype: application/x-microsoft.net.object.binary.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.soap.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.bytearray.base64
- value : The object must be serialized into a byte array
- : using a System.ComponentModel.TypeConverter
- : and then encoded with base64 encoding.
- -->
- <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
- <xsd:element name="root" msdata:IsDataSet="true">
- <xsd:complexType>
- <xsd:choice maxOccurs="unbounded">
- <xsd:element name="metadata">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- <xsd:attribute name="name" use="required" type="xsd:string" />
- <xsd:attribute name="type" type="xsd:string" />
- <xsd:attribute name="mimetype" type="xsd:string" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="assembly">
- <xsd:complexType>
- <xsd:attribute name="alias" type="xsd:string" />
- <xsd:attribute name="name" type="xsd:string" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="data">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
- <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
- <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="resheader">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:schema>
- <resheader name="resmimetype">
- <value>text/microsoft-resx</value>
- </resheader>
- <resheader name="version">
- <value>2.0</value>
- </resheader>
- <resheader name="reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <resheader name="writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <data name="BackupState_Cancelled" xml:space="preserve">
- <value>Cancelled</value>
- </data>
- <data name="BackupState_Failed" xml:space="preserve">
- <value>Fail</value>
- </data>
- <data name="BackupState_InProgress" xml:space="preserve">
- <value>In Progress</value>
- </data>
- <data name="BackupState_Skipped" xml:space="preserve">
- <value>Skipped</value>
- </data>
- <data name="BackupState_Success" xml:space="preserve">
- <value>Success</value>
- </data>
- <data name="BackupState_Todo" xml:space="preserve">
- <value>TODO</value>
- </data>
- <data name="Backup_ExecutingBackup" xml:space="preserve">
- <value>Backup...</value>
- </data>
- <data name="Backup_Failed_SourceNotExist" xml:space="preserve">
- <value>The source does not exist.</value>
- </data>
- <data name="Backup_Failed_BackupInfomationNotPrepared" xml:space="preserve">
- <value>The backup information has not been prepared.</value>
- </data>
- <data name="Backup_Skipped" xml:space="preserve">
- <value>The backup has been skipped.</value>
- </data>
- <data name="Backup_From" xml:space="preserve">
- <value>From</value>
- </data>
- <data name="Backup_To" xml:space="preserve">
- <value>To</value>
- </data>
- <data name="Edit_CopySuffix" xml:space="preserve">
- <value>Copy</value>
- </data>
- <data name="Version_Copyright" xml:space="preserve">
- <value>Copyright© 2015 Takayoshi Matsuyama</value>
- </data>
- <data name="Version_CopyrightDescription" xml:space="preserve">
- <value>This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.</value>
- </data>
- <data name="Views_AddButtonToolTipText" xml:space="preserve">
- <value>Add</value>
- </data>
- <data name="Views_BackupDestinationColumnHeaderText" xml:space="preserve">
- <value>Destination</value>
- </data>
- <data name="Views_BackupSourceColumnHeaderText" xml:space="preserve">
- <value>Source</value>
- </data>
- <data name="Views_CancelMultiBackupButtonToolTipText" xml:space="preserve">
- <value>Cancel Multi Backup</value>
- </data>
- <data name="Views_ContextMenu_Backup" xml:space="preserve">
- <value>Backup</value>
- </data>
- <data name="Views_ContextMenu_Edit" xml:space="preserve">
- <value>Edit</value>
- </data>
- <data name="Views_ContextMenu_OpenDestination" xml:space="preserve">
- <value>Open Destination</value>
- </data>
- <data name="Views_ContextMenu_OpenFile" xml:space="preserve">
- <value>Open File</value>
- </data>
- <data name="Views_ContextMenu_OpenSourceFolder" xml:space="preserve">
- <value>Open Source Folder</value>
- </data>
- <data name="Views_ContextMenu_SelectDestination" xml:space="preserve">
- <value>Select Destination</value>
- </data>
- <data name="Views_ContextMenu_SelectSource" xml:space="preserve">
- <value>Select Source</value>
- </data>
- <data name="Views_CopyButtonToolTipText" xml:space="preserve">
- <value>Copy</value>
- </data>
- <data name="Views_CopyrightApplicationName" xml:space="preserve">
- <value>Simple Backup</value>
- </data>
- <data name="Views_CutButtonToolTipText" xml:space="preserve">
- <value>Cut</value>
- </data>
- <data name="Views_DefaultWindowTitle" xml:space="preserve">
- <value>Simple Backup</value>
- </data>
- <data name="Views_LabelColumnHeaderText" xml:space="preserve">
- <value>Label</value>
- </data>
- <data name="Views_MainMenu_Close" xml:space="preserve">
- <value>_Close</value>
- </data>
- <data name="Views_MainMenu_Exit" xml:space="preserve">
- <value>E_xit</value>
- </data>
- <data name="Views_MainMenu_File" xml:space="preserve">
- <value>_File</value>
- </data>
- <data name="Views_MainMenu_Help" xml:space="preserve">
- <value>_Help</value>
- </data>
- <data name="Views_MainMenu_New" xml:space="preserve">
- <value>_New</value>
- </data>
- <data name="Views_MainMenu_Open" xml:space="preserve">
- <value>_Open</value>
- </data>
- <data name="Views_MainMenu_OpenCurrentSettingFileLocation" xml:space="preserve">
- <value>Open Current Setting File Location</value>
- </data>
- <data name="Views_MainMenu_ShowHelp" xml:space="preserve">
- <value>Show Help (_V)</value>
- </data>
- <data name="Views_MainMenu_ShowVersionInformation" xml:space="preserve">
- <value>Show Version Information (_A)</value>
- </data>
- <data name="Views_MoveDownButtonToolTipText" xml:space="preserve">
- <value>Move down</value>
- </data>
- <data name="Views_MoveUpButtonToolTipText" xml:space="preserve">
- <value>Move up</value>
- </data>
- <data name="Views_MultipleBackupButtonToolTipText" xml:space="preserve">
- <value>Multiple Backup</value>
- </data>
- <data name="Views_NewBackupSettingName" xml:space="preserve">
- <value>New Backup</value>
- </data>
- <data name="Views_NewFileButtonToolTipText" xml:space="preserve">
- <value>New</value>
- </data>
- <data name="Views_OpenBackupSettingButtonToolTipText" xml:space="preserve">
- <value>Open Backup Setting</value>
- </data>
- <data name="Views_OutputWindowContextMenu_Clear" xml:space="preserve">
- <value>Clear</value>
- </data>
- <data name="Views_PasteButtonToolTipText" xml:space="preserve">
- <value>Paste</value>
- </data>
- <data name="Views_RedoButtonToolTipText" xml:space="preserve">
- <value>Redo</value>
- </data>
- <data name="Views_RefreshButtonToolTipText" xml:space="preserve">
- <value>Refresh</value>
- </data>
- <data name="Views_RemoveButtonToolTipText" xml:space="preserve">
- <value>Remove</value>
- </data>
- <data name="Views_SaveBackupSettingButtonToolTipText" xml:space="preserve">
- <value>Save Backup Setting</value>
- </data>
- <data name="Views_SingleBackupButtonToolTipText" xml:space="preserve">
- <value>Single Backup</value>
- </data>
- <data name="Views_UndoButtonToolTipText" xml:space="preserve">
- <value>Undo</value>
- </data>
- <data name="Views_VersionWindowTitle" xml:space="preserve">
- <value>Version Information of Simple Backup</value>
- </data>
- <data name="Views_WindowTitleFormat" xml:space="preserve">
- <value>Simple Backup - {0}</value>
- </data>
- <data name="Backup_Failed_DestinationNotExist" xml:space="preserve">
- <value>The destination Folder does not exist.</value>
- </data>
- <data name="Backup_Failed_FailedToCopy" xml:space="preserve">
- <value>Failed to copy the file.</value>
- </data>
- <data name="Backup_Succeeded" xml:space="preserve">
- <value>Done!</value>
- </data>
- <data name="Views_MainMenu_Save" xml:space="preserve">
- <value>_Save</value>
- </data>
- <data name="Views_MainMenu_SaveAs" xml:space="preserve">
- <value>Save _As</value>
- </data>
- <data name="Views_ZipEncodingTitleText" xml:space="preserve">
- <value>Zip Encoding</value>
- </data>
- <data name="Views_OpenFileDialogTitle" xml:space="preserve">
- <value>Open Backup Setting</value>
- </data>
- <data name="Views_SaveFileDialogTitle" xml:space="preserve">
- <value>Save Backup Setting</value>
- </data>
- <data name="BackupSetting_IncompatibleMajorVersionFormat" xml:space="preserve">
- <value>Failed to read the backup setting data because it is incomatible. To read the backup setting data, please use Simple Backup Ver.{0} or later.</value>
- </data>
- <data name="BackupSetting_IncompatibleMinorVersionFormat" xml:space="preserve">
- <value>Failed to read some part of the backup setting data because they are incompatible. To read all the backup setting data, please use Simple Backup Ver.{0} or later.</value>
- </data>
- <data name="BackupSetting_SettingOpenedFormat" xml:space="preserve">
- <value>The backup setting is opened: {0}</value>
- </data>
- <data name="BackupSetting_FailedToOpenSetting_EmptyFileNameFormat" xml:space="preserve">
- <value>Failed to open the backup setting. The file name is empty: {0}</value>
- </data>
- <data name="BackupSetting_FailedToOpenSetting_InvalidMajorVersionFormat" xml:space="preserve">
- <value>Failed to open the backup setting. Invalid major version value: {0}</value>
- </data>
- <data name="BackupSetting_FailedToOpenSetting_InvalidMinorVersionFormat" xml:space="preserve">
- <value>Failed to open the backup setting. Invalid minor version value: {0}</value>
- </data>
- <data name="BackupSetting_FailedToOpenSetting_InvalidRequiredToolVersionFormat" xml:space="preserve">
- <value>Failed to open the backup setting. Invalid "RequiredToolVersion" value: {0}</value>
- </data>
- <data name="BackupSetting_FailedToOpenSetting_InvalidVersionFormat" xml:space="preserve">
- <value>Failed to open the backup setting. Invalid "Version" value: {0}</value>
- </data>
- <data name="BackupSetting_FailedToOpenSetting_NoBackupSettingElementFormat" xml:space="preserve">
- <value>Failed to open the backup setting. There is no "BackupSetting" tag: {0}</value>
- </data>
- <data name="BackupSetting_FailedToOpenSetting_NoVersionElementFormat" xml:space="preserve">
- <value>Failed to open the backup setting. There is no "Version" tag: {0}</value>
- </data>
- <data name="FileAccess_FailedToOpenFormat" xml:space="preserve">
- <value>Failed to open the file: {0}</value>
- </data>
- <data name="FileAccess_FolderPathNotExistFormat" xml:space="preserve">
- <value>The folder path does not exist: {0}</value>
- </data>
- <data name="FileAccess_InvalidPathFormat" xml:space="preserve">
- <value>The path is not valid: {0}</value>
- </data>
- <data name="Views_ConfirmationDialogTitle" xml:space="preserve">
- <value>Confirmation</value>
- </data>
- <data name="Views_SaveConfirmationMessage" xml:space="preserve">
- <value>Save the changes?</value>
- </data>
-</root>
\ No newline at end of file
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="BackupService.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.IO.Compression;
-using System.Linq;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Threading;
-using SimpleBackup.Core.Models;
-using SimpleBackup.Core.Services;
-using SimpleBackup.Core.Utilities;
-using SimpleBackup.Models;
-
-namespace SimpleBackup.Services
-{
- using SimpleBackup.Resources;
-
- /// <summary>
- /// Backup service.
- /// </summary>
- public class BackupService : IBackupService
- {
- /// <summary>
- /// The synchronize root
- /// </summary>
- private static readonly object SyncRoot = new object();
-
- /// <summary>
- /// The instance of SettingFileService.
- /// </summary>
- private static volatile BackupService instance;
-
- /// <summary>
- /// Prevents a default instance of the <see cref="BackupService"/> class from being created.
- /// </summary>
- private BackupService()
- {
- BackupSettingService.Instance.BackupSettingCreated += OnBackupSettingCreated;
- BackupSettingService.Instance.BackupSettingOpened += this.OnBackupSettingOpened;
- BackupSettingService.Instance.BackupSettingClosed += this.OnBackupSettingClosed;
- }
-
- /// <summary>
- /// Occurs when file backup progress is updated.
- /// </summary>
- public event EventHandler<FileBackupProgressEventArgs> NofityFileBackupProgress;
-
- /// <summary>
- /// Gets the instance.
- /// </summary>
- public static IBackupService Instance
- {
- get
- {
- if (instance == null)
- {
- lock (SyncRoot)
- {
- if (instance == null)
- {
- instance = new BackupService();
- }
- }
- }
-
- return instance;
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether this service is ready for backup.
- /// </summary>
- public bool IsReadyForBackup { get; private set; }
-
- /// <summary>
- /// Gets a value indicating whether this service is executing backup.
- /// </summary>
- public bool IsExecutingBackup { get; private set; }
-
- /// <summary>
- /// Backups multipul files.
- /// </summary>
- /// <param name="cancellationToken">The cancellation token.</param>
- /// <param name="resultInfos">The array of result information.</param>
- public void BackupMultipulFiles(CancellationToken cancellationToken, out ResultInfo[] resultInfos)
- {
- this.IsExecutingBackup = true;
- var resultList = new List<ResultInfo>();
- if (this.IsReadyForBackup == false)
- {
- resultList.Add(new ResultInfo(BackupState.Failed, Resources.Backup_Failed_BackupInfomationNotPrepared));
- resultInfos = resultList.ToArray();
- return;
- }
-
- try
- {
- this.NotifyBackupProgress(0, null);
-
- int processedCount = 0;
-
- foreach (IBackupInfo backupInfo in BackupSettingService.Instance.CurrentSetting.BackupInfos)
- {
- cancellationToken.ThrowIfCancellationRequested();
- backupInfo.BackupState = BackupState.InProgress;
-
- Thread.Sleep(100);
-
- ResultInfo resultInfo = null;
- double progressValue = 0;
-
- if (backupInfo.IsEnabled == false)
- {
- string description = string.Format(
- "{0}\r\n\t{1}: {2}",
- Resources.Backup_Skipped,
- Resources.Backup_From,
- backupInfo.SourcePath);
- resultInfo = new ResultInfo(BackupState.Skipped, description);
- processedCount++;
- progressValue = processedCount * 100.0 / BackupSettingService.Instance.CurrentSetting.Count;
- this.NotifyBackupProgress(progressValue, resultInfo);
- backupInfo.BackupState = BackupState.Skipped;
- continue;
- }
-
- // Check the source.
- if (((backupInfo.BackupSourceType == BackupSourceType.File) && (File.Exists(backupInfo.SourcePath) == false)) ||
- ((backupInfo.BackupSourceType == BackupSourceType.Folder) && (Directory.Exists(backupInfo.SourcePath) == false)))
- {
- string description = string.Format(
- "{0}\r\n\t{1}: {2}\r\n\t{3}: {4}",
- Resources.Backup_Failed_SourceNotExist,
- Resources.Backup_From,
- backupInfo.SourcePath,
- Resources.Backup_To,
- backupInfo.DestinationFolderPath);
- resultInfo = new ResultInfo(BackupState.Failed, description);
- resultList.Add(resultInfo);
- processedCount++;
- progressValue = processedCount * 100.0 / BackupSettingService.Instance.CurrentSetting.Count;
- this.NotifyBackupProgress(progressValue, resultInfo);
- backupInfo.BackupState = BackupState.Failed;
- continue;
- }
-
- // Check the destination.
- if ((backupInfo.DestinationFolderPath == "\\") ||
- (Directory.Exists(backupInfo.DestinationFolderPath) == false))
- {
- string description = string.Format(
- "{0}\r\n\t{1}: {2}\r\n\t{3}: {4}",
- Resources.Backup_Failed_DestinationNotExist,
- Resources.Backup_From,
- backupInfo.SourcePath,
- Resources.Backup_To,
- backupInfo.DestinationFolderPath);
- resultInfo = new ResultInfo(BackupState.Failed, description);
- resultList.Add(resultInfo);
- processedCount++;
- progressValue = processedCount * 100.0 / BackupSettingService.Instance.CurrentSetting.Count;
- this.NotifyBackupProgress(progressValue, resultInfo);
- backupInfo.BackupState = BackupState.Failed;
- continue;
- }
-
- var destinationFileNames = new DestinationPathInfo[0];
- try
- {
- if (backupInfo.IsZipArchive)
- {
- if (backupInfo.BackupSourceType == BackupSourceType.File)
- {
- BackupFileToZip(backupInfo, out destinationFileNames);
- }
- else if (backupInfo.BackupSourceType == BackupSourceType.Folder)
- {
- BackupFolerToZip(backupInfo, out destinationFileNames);
- }
- }
- else
- {
- if (backupInfo.BackupSourceType == BackupSourceType.File)
- {
- BackupFile(backupInfo, out destinationFileNames);
- }
- else if (backupInfo.BackupSourceType == BackupSourceType.Folder)
- {
- BackupFolder(backupInfo, out destinationFileNames);
- }
- }
- }
- catch (Exception e)
- {
- string description = string.Format(
- "{0}\r\n\t{1}: {2}\r\n\t{3}: {4}\r\n{5}",
- Resources.Backup_Failed_FailedToCopy,
- Resources.Backup_From,
- backupInfo.SourcePath,
- Resources.Backup_To,
- destinationFileNames.FirstOrDefault(),
- e.Message);
- resultInfo = new ResultInfo(BackupState.Failed, description);
- resultList.Add(resultInfo);
- processedCount++;
- progressValue = processedCount * 100.0 / BackupSettingService.Instance.CurrentSetting.Count;
- this.NotifyBackupProgress(progressValue, resultInfo);
- backupInfo.BackupState = BackupState.Failed;
- continue;
- }
-
- if (CheckExistence(destinationFileNames))
- {
- string description = string.Format(
- "{0}\r\n\t{1}: {2}\r\n\t{3}: {4}",
- Resources.Backup_Succeeded,
- Resources.Backup_From,
- backupInfo.SourcePath,
- Resources.Backup_To,
- destinationFileNames.First().Path);
- resultInfo = new ResultInfo(BackupState.Success, description);
- resultList.Add(resultInfo);
- backupInfo.BackupState = BackupState.Success;
- backupInfo.LatestSuccessfulBackupTargetName = destinationFileNames.First().Path;
- }
-
- processedCount++;
- progressValue = processedCount * 100.0 / BackupSettingService.Instance.CurrentSetting.Count;
- this.NotifyBackupProgress(progressValue, resultInfo);
- }
-
- this.NotifyBackupProgress(100.0, null);
- }
- catch (OperationCanceledException)
- {
- var resultInfo = new ResultInfo(BackupState.Cancelled, Resources.BackupState_Cancelled);
- resultList.Add(resultInfo);
- this.NotifyBackupProgress(100.0, resultInfo);
- }
- finally
- {
- resultInfos = resultList.ToArray();
- this.IsExecutingBackup = false;
- }
- }
-
- /// <summary>
- /// Backups single file.
- /// </summary>
- /// <param name="backupInfoId">The backup information identifier.</param>
- /// <returns>The result information.</returns>
- public ResultInfo BackupSingleFile(Guid backupInfoId)
- {
- IBackupInfo backupInfo = BackupSettingService.Instance.CurrentSetting.FirstOrDefault(backupInfoId);
- if (backupInfo == null)
- {
- return new ResultInfo(
- BackupState.Failed,
- Resources.Backup_Failed_BackupInfomationNotPrepared);
- }
-
- backupInfo.BackupState = BackupState.InProgress;
- Helpers.UpdateWpfGui();
-
- ResultInfo resultInfo = null;
- string description = string.Empty;
-
- // Check the source.
- if (((backupInfo.BackupSourceType == BackupSourceType.File) && (File.Exists(backupInfo.SourcePath) == false)) ||
- ((backupInfo.BackupSourceType == BackupSourceType.Folder) && (Directory.Exists(backupInfo.SourcePath) == false)))
- {
- description = string.Format(
- "{0}\r\n\t{1}: {2}\r\n\t{3}: {4}",
- Resources.Backup_Failed_SourceNotExist,
- Resources.Backup_From,
- backupInfo.SourcePath,
- Resources.Backup_To,
- backupInfo.DestinationFolderPath);
- resultInfo = new ResultInfo(BackupState.Failed, description);
- backupInfo.BackupState = BackupState.Failed;
- return resultInfo;
- }
-
- // Check the destination.
- if (Directory.Exists(backupInfo.DestinationFolderPath) == false)
- {
- description = string.Format(
- "{0}\r\n\t{1}: {2}\r\n\t{3}: {4}",
- Resources.Backup_Failed_DestinationNotExist,
- Resources.Backup_From,
- backupInfo.SourcePath,
- Resources.Backup_To,
- backupInfo.DestinationFolderPath);
- resultInfo = new ResultInfo(BackupState.Failed, description);
- backupInfo.BackupState = BackupState.Failed;
- return resultInfo;
- }
-
- var destinationFileNames = new DestinationPathInfo[0];
- try
- {
- if (backupInfo.IsZipArchive)
- {
- if (backupInfo.BackupSourceType == BackupSourceType.File)
- {
- BackupFileToZip(backupInfo, out destinationFileNames);
- }
- else if (backupInfo.BackupSourceType == BackupSourceType.Folder)
- {
- BackupFolerToZip(backupInfo, out destinationFileNames);
- }
- }
- else
- {
- if (backupInfo.BackupSourceType == BackupSourceType.File)
- {
- BackupFile(backupInfo, out destinationFileNames);
- }
- else if (backupInfo.BackupSourceType == BackupSourceType.Folder)
- {
- BackupFolder(backupInfo, out destinationFileNames);
- }
- }
- }
- catch (Exception e)
- {
- description = string.Format(
- "{0}\r\n\t{1}: {2}\r\n\t{3}: {4}\r\n{5}",
- Resources.Backup_Failed_FailedToCopy,
- Resources.Backup_From,
- backupInfo.SourcePath,
- Resources.Backup_To,
- destinationFileNames.FirstOrDefault(),
- e.Message);
- resultInfo = new ResultInfo(BackupState.Failed, description);
- backupInfo.BackupState = BackupState.Failed;
- return resultInfo;
- }
-
- if (CheckExistence(destinationFileNames))
- {
- description = string.Format(
- "{0}\r\n\t{1}: {2}\r\n\t{3}: {4}",
- Resources.Backup_Succeeded,
- Resources.Backup_From,
- backupInfo.SourcePath,
- Resources.Backup_To,
- destinationFileNames.First().Path);
- resultInfo = new ResultInfo(BackupState.Success, description);
- backupInfo.BackupState = BackupState.Success;
- backupInfo.LatestSuccessfulBackupTargetName = destinationFileNames.First().Path;
- return resultInfo;
- }
-
- description = string.Format(
- "{0}\r\n\t{1}: {2}\r\n\t{3}: {4}",
- Resources.Backup_Failed_FailedToCopy,
- Resources.Backup_From,
- backupInfo.SourcePath,
- Resources.Backup_To,
- destinationFileNames.FirstOrDefault());
- return new ResultInfo(BackupState.Failed, description);
- }
-
- private static void BackupFileToZip(IBackupInfo backupInfo, out DestinationPathInfo[] destinationPathInfoArray)
- {
- var innerDestinationPathInfoList = new List<DestinationPathInfo>();
-
- Match lastPathSegmentMatch = Constants.EndPathSegmentRegex.Match(backupInfo.SourcePath);
- Match fileNameMatch = Constants.FileNameRegex.Match(lastPathSegmentMatch.Value);
- Match extensionMatch = Constants.ExtensionRegex.Match(lastPathSegmentMatch.Value);
-
- string destinationFolderPath = backupInfo.DestinationFolderPath.AddTailPathSeparatorIfNotExist();
- string destinationTempFolderPath = destinationFolderPath + fileNameMatch.Value +
- " - " + DateTime.Now.ToString("yyyyMMdd-HHmmss") + "-tmp";
- string destinationTempFileName = destinationTempFolderPath + "\\" + fileNameMatch.Value +
- " - " + DateTime.Now.ToString("yyyyMMdd-HHmmss") + "." + extensionMatch.Value;
- try
- {
- try
- {
- Directory.CreateDirectory(destinationTempFolderPath);
- }
- catch (Exception e)
- {
- throw new InvalidOperationException(
- string.Format(
- "Failed to create the folder: {0}\r\n{1}",
- destinationTempFolderPath,
- e.Message),
- e);
- }
-
- try
- {
- File.Copy(backupInfo.SourcePath, destinationTempFileName);
- }
- catch (Exception e)
- {
- throw new InvalidOperationException(
- string.Format(
- "Failed to copy the file.\r\n\tFrom: {0}\r\n\tTo: {1}\r\n{2}",
- backupInfo.SourcePath,
- destinationTempFolderPath,
- e.Message),
- e);
- }
-
- var destinationFileName = destinationFolderPath + fileNameMatch.Value
- + " - " + DateTime.Now.ToString("yyyyMMdd-HHmmss") + ".zip";
- innerDestinationPathInfoList.Add(new DestinationPathInfo(BackupSourceType.File, destinationFileName));
-
- try
- {
- ZipFile.CreateFromDirectory(
- destinationTempFolderPath,
- destinationFileName,
- CompressionLevel.Optimal,
- false,
- Encoding.GetEncoding(Properties.Settings.Default.DefaultZipEncodingKeyText));
- }
- catch (Exception e)
- {
- backupInfo.BackupState = BackupState.Failed;
- throw new InvalidOperationException(
- string.Format(
- "Failed to create the zip archive.\r\n\tFrom: {0}\r\n\tTo: {1}\r\n{2}",
- destinationTempFolderPath,
- destinationFileName,
- e.Message),
- e);
- }
- }
- finally
- {
- destinationPathInfoArray = innerDestinationPathInfoList.ToArray();
-
- if (File.Exists(destinationTempFileName))
- {
- File.Delete(destinationTempFileName);
- }
-
- if (Directory.Exists(destinationTempFolderPath))
- {
- Directory.Delete(destinationTempFolderPath);
- }
- }
- }
-
- private static void BackupFolerToZip(IBackupInfo backupInfo, out DestinationPathInfo[] destinationPathInfoArray)
- {
- var innerDestinationPathInfoList = new List<DestinationPathInfo>();
-
- Match lastPathSegmentMatch = Constants.EndPathSegmentRegex.Match(backupInfo.SourcePath);
-
- string destinationFolderPath = backupInfo.DestinationFolderPath.AddTailPathSeparatorIfNotExist();
- var destinationFileName = destinationFolderPath
- + lastPathSegmentMatch.Value + " - "
- + DateTime.Now.ToString("yyyyMMdd-HHmmss")
- + ".zip";
- innerDestinationPathInfoList.Add(new DestinationPathInfo(BackupSourceType.File, destinationFileName));
-
- try
- {
- ZipFile.CreateFromDirectory(
- backupInfo.SourcePath,
- destinationFileName,
- CompressionLevel.Optimal,
- false,
- Encoding.GetEncoding(SimpleBackup.Properties.Settings.Default.DefaultZipEncodingKeyText));
- }
- catch (Exception e)
- {
- backupInfo.BackupState = BackupState.Failed;
- throw new InvalidOperationException(
- string.Format(
- "Failed to create the zip archive.\r\n\tFrom: {0}\r\n\tTo: {1}\r\n{2}",
- backupInfo.SourcePath,
- destinationFileName,
- e.Message),
- e);
- }
- finally
- {
- destinationPathInfoArray = innerDestinationPathInfoList.ToArray();
- }
- }
-
- private static void BackupFile(IBackupInfo backupInfo, out DestinationPathInfo[] destinationPathInfoArray)
- {
- var innerDestinationPathInfoList = new List<DestinationPathInfo>();
-
- Match lastPathSegmentMatch = Constants.EndPathSegmentRegex.Match(backupInfo.SourcePath);
- Match fileNameMatch = Constants.FileNameRegex.Match(lastPathSegmentMatch.Value);
- Match extensionMatch = Constants.ExtensionRegex.Match(lastPathSegmentMatch.Value);
-
- string destinationFolderPath = backupInfo.DestinationFolderPath.AddTailPathSeparatorIfNotExist();
- var destinationFileName = destinationFolderPath + fileNameMatch.Value
- + " - " + DateTime.Now.ToString("yyyyMMdd-HHmmss") + "." + extensionMatch.Value;
- innerDestinationPathInfoList.Add(new DestinationPathInfo(BackupSourceType.File, destinationFileName));
-
- try
- {
- File.Copy(backupInfo.SourcePath, destinationFileName);
- }
- finally
- {
- destinationPathInfoArray = innerDestinationPathInfoList.ToArray();
- }
- }
-
- private static void BackupFolder(IBackupInfo backupInfo, out DestinationPathInfo[] destinationPathInfoArray)
- {
- var innerDestinationPathInfoList = new List<DestinationPathInfo>();
-
- Match lastPathSegmentMatch = Constants.EndPathSegmentRegex.Match(backupInfo.SourcePath);
-
- //// 方法 : ディレクトリをコピーする
- //// http://msdn.microsoft.com/ja-jp/library/bb762914(v=vs.110).aspx
- string destinationFolderPath = backupInfo.DestinationFolderPath.AddTailPathSeparatorIfNotExist();
- var destinationFolderName = destinationFolderPath
- + lastPathSegmentMatch.Value + " - " + DateTime.Now.ToString("yyyyMMdd-HHmmss");
- innerDestinationPathInfoList.Add(new DestinationPathInfo(BackupSourceType.Folder, destinationFolderName));
-
- try
- {
- FolderCopy(backupInfo.SourcePath, destinationFolderName, true);
- }
- finally
- {
- destinationPathInfoArray = innerDestinationPathInfoList.ToArray();
- }
- }
-
- private static void FolderCopy(string sourceFolderPath, string destinationFolderPath, bool copySubFolders)
- {
- var sourceDirectoryInfo = new DirectoryInfo(sourceFolderPath);
- DirectoryInfo[] subDirectoryInfos = sourceDirectoryInfo.GetDirectories();
-
- if (sourceDirectoryInfo.Exists == false)
- {
- throw new DirectoryNotFoundException(
- "Source directory does not exist or could not be found: "
- + sourceFolderPath);
- }
-
- // If the destination directory doesn't exist, create it.
- if (Directory.Exists(destinationFolderPath) == false)
- {
- Directory.CreateDirectory(destinationFolderPath);
- }
-
- // Get the files in the directory and copy them to the new location.
- FileInfo[] files = sourceDirectoryInfo.GetFiles();
- foreach (FileInfo file in files)
- {
- string temppath = Path.Combine(destinationFolderPath, file.Name);
- file.CopyTo(temppath, false);
- }
-
- // If copying subdirectories, copy them and their contents to new location.
- if (copySubFolders)
- {
- foreach (DirectoryInfo subDirectoryInfo in subDirectoryInfos)
- {
- string temppath = Path.Combine(destinationFolderPath, subDirectoryInfo.Name);
- FolderCopy(subDirectoryInfo.FullName, temppath, copySubFolders);
- }
- }
- }
-
- private static bool CheckExistence(DestinationPathInfo[] destinationPathInfoArray)
- {
- return (destinationPathInfoArray != null) &&
- (destinationPathInfoArray.Length != 0) &&
- destinationPathInfoArray.All(
- destinationPathInfo =>
- {
- if (destinationPathInfo.BackupSourceType == BackupSourceType.File)
- {
- return File.Exists(destinationPathInfo.Path);
- }
-
- return Directory.Exists(destinationPathInfo.Path);
- });
- }
-
- private void OnBackupSettingCreated(object sender, SettingFileEventArgs settingFileEventArgs)
- {
- this.IsReadyForBackup = true;
- }
-
- private void OnBackupSettingOpened(object sender, SettingFileEventArgs settingFileEventArgs)
- {
- this.IsReadyForBackup = true;
- }
-
- private void OnBackupSettingClosed(object sender, SettingFileEventArgs settingFileEventArgs)
- {
- this.IsReadyForBackup = false;
- }
-
- private void NotifyBackupProgress(double progressValue, ResultInfo latestResultInfo)
- {
- if (this.NofityFileBackupProgress != null)
- {
- this.NofityFileBackupProgress(this, new FileBackupProgressEventArgs(progressValue, latestResultInfo));
- }
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="BackupSettingService.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.IO;
-using System.Linq;
-using System.Windows;
-using System.Windows.Input;
-using System.Xml.Linq;
-using SimpleBackup.Core.Models;
-using SimpleBackup.Core.Services;
-using SimpleBackup.Core.Utilities;
-using SimpleBackup.Models;
-
-namespace SimpleBackup.Services
-{
- using SimpleBackup.Resources;
-
- using Application = System.Windows.Application;
- using Cursors = System.Windows.Input.Cursors;
- using MessageBox = System.Windows.MessageBox;
- using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
- using SaveFileDialog = Microsoft.Win32.SaveFileDialog;
-
- /// <summary>
- /// Backup Setting service.
- /// </summary>
- public class BackupSettingService : IBackupSettingService
- {
- /// <summary>
- /// The supported major version
- /// </summary>
- private const int SupportedMajorVersion = 1;
-
- /// <summary>
- /// The supported minor version
- /// </summary>
- private const int SupportedMinorVersion = 0;
-
- /// <summary>
- /// The synchronize root
- /// </summary>
- private static readonly object SyncRoot = new object();
-
- /// <summary>
- /// The instance of SettingFileService.
- /// </summary>
- private static volatile BackupSettingService instance;
-
- /// <summary>
- /// Prevents a default instance of the <see cref="BackupSettingService"/> class from being created.
- /// </summary>
- private BackupSettingService()
- {
- }
-
- /// <summary>
- /// Occurs when backup setting is created.
- /// </summary>
- public event EventHandler<SettingFileEventArgs> BackupSettingCreated;
-
- /// <summary>
- /// Occurs when backup setting is opened.
- /// </summary>
- public event EventHandler<SettingFileEventArgs> BackupSettingOpened;
-
- /// <summary>
- /// Occurs when backup setting is modified.
- /// </summary>
- public event EventHandler<SettingFileEventArgs> BackupSettingModified;
-
- /// <summary>
- /// Occurs when backup setting is saved.
- /// </summary>
- public event EventHandler<SettingFileEventArgs> BackupSettingSaved;
-
- /// <summary>
- /// Occurs when backup setting is closed.
- /// </summary>
- public event EventHandler<SettingFileEventArgs> BackupSettingClosed;
-
- /// <summary>
- /// Gets the instance.
- /// </summary>
- public static IBackupSettingService Instance
- {
- get
- {
- if (instance == null)
- {
- lock (SyncRoot)
- {
- if (instance == null)
- {
- instance = new BackupSettingService();
- }
- }
- }
-
- return instance;
- }
- }
-
- /// <summary>
- /// Gets the current setting.
- /// </summary>
- public IBackupSetting CurrentSetting { get; private set; }
-
- /// <summary>
- /// Creates the backup setting.
- /// </summary>
- /// <returns><c>true</c> if the new backup setting is created; otherwise, <c>false</c>.</returns>
- public bool CreateBackupSetting()
- {
- if ((this.CurrentSetting != null) && this.CurrentSetting.Modified)
- {
- MessageBoxResult confirmationResult = MessageBox.Show(
- Application.Current.MainWindow,
- Resources.Views_SaveConfirmationMessage,
- Resources.Views_ConfirmationDialogTitle,
- MessageBoxButton.YesNoCancel);
- if (confirmationResult == MessageBoxResult.Yes)
- {
- this.SaveCurrentBackupSetting();
- }
- else if (confirmationResult == MessageBoxResult.Cancel)
- {
- return false;
- }
- }
-
- if (this.CurrentSetting != null)
- {
- this.CloseCurrentBackupSetting();
- }
-
- var backupSetting = new BackupSetting { Modified = true };
- this.CurrentSetting = backupSetting;
- this.CurrentSetting.SettingModified += this.OnCurrentSettingModified;
-
- if (this.BackupSettingCreated != null)
- {
- this.BackupSettingCreated(this, new SettingFileEventArgs(this.CurrentSetting.SettingName));
- }
-
- return true;
- }
-
- /// <summary>
- /// Opens the backup setting.
- /// </summary>
- /// <param name="resultMessage">The result message.</param>
- /// <returns>
- /// <c>true</c> if backup setting is successfully loaded; otherwise, <c>false</c>.
- /// </returns>
- public bool OpenBackupSetting(out string resultMessage)
- {
- if ((this.CurrentSetting != null) && this.CurrentSetting.Modified)
- {
- MessageBoxResult confirmationResult = MessageBox.Show(
- Application.Current.MainWindow,
- Resources.Views_SaveConfirmationMessage,
- Resources.Views_ConfirmationDialogTitle,
- MessageBoxButton.YesNoCancel);
- if (confirmationResult == MessageBoxResult.Yes)
- {
- this.SaveCurrentBackupSetting();
- }
- else if (confirmationResult == MessageBoxResult.Cancel)
- {
- resultMessage = string.Empty;
- return false;
- }
- }
-
- string initialDirectory = AppDomain.CurrentDomain.BaseDirectory;
- if ((this.CurrentSetting != null) &&
- this.CurrentSetting.SettingFileName.IsValidFilePath())
- {
- initialDirectory = Path.GetDirectoryName(this.CurrentSetting.SettingFileName);
- this.CloseBackupSetting();
- }
-
- var openFileDialog = new OpenFileDialog
- {
- Title = Resources.Views_OpenFileDialogTitle,
- DefaultExt = ".xml",
- Filter = "Backup Setting File|*.xml",
- InitialDirectory = initialDirectory,
- Multiselect = false
- };
-
- if (openFileDialog.ShowDialog(Application.Current.MainWindow) != true)
- {
- resultMessage = string.Empty;
- return false;
- }
-
- var fileName = openFileDialog.FileName;
- try
- {
- Mouse.OverrideCursor = Cursors.Wait;
- return this.OpenBackupSetting(fileName, out resultMessage);
- }
- finally
- {
- Mouse.OverrideCursor = null;
- }
- }
-
- /// <summary>
- /// Closes the backup setting.
- /// </summary>
- public void CloseBackupSetting()
- {
- if (this.CurrentSetting == null)
- {
- return;
- }
-
- if (this.CurrentSetting.Modified)
- {
- MessageBoxResult confirmationResult = MessageBox.Show(
- Application.Current.MainWindow,
- Resources.Views_SaveConfirmationMessage,
- Resources.Views_ConfirmationDialogTitle,
- MessageBoxButton.YesNoCancel);
- if (confirmationResult == MessageBoxResult.Yes)
- {
- this.SaveCurrentBackupSetting();
- }
- else if (confirmationResult == MessageBoxResult.Cancel)
- {
- return;
- }
- }
-
- this.CloseCurrentBackupSetting();
- }
-
- /// <summary>
- /// Overwrites the currnt backup setting.
- /// </summary>
- /// <returns><c>true</c> if the backup setting is saved; otherwise, <c>false</c>.</returns>
- public bool OverWriteCurrntBackupSetting()
- {
- if (this.CurrentSetting == null)
- {
- return false;
- }
-
- if (string.IsNullOrEmpty(this.CurrentSetting.SettingFileName) ||
- (File.Exists(this.CurrentSetting.SettingFileName) == false))
- {
- var saveFileDialog = new SaveFileDialog
- {
- Title = Resources.Views_SaveFileDialogTitle,
- DefaultExt = ".xml",
- Filter = "Backup Setting File|*.xml"
- };
-
- if (saveFileDialog.ShowDialog(Application.Current.MainWindow) != true)
- {
- return false;
- }
-
- this.CurrentSetting.SettingFileName = saveFileDialog.FileName;
- }
-
- this.SaveCurrentBackupSetting();
- return true;
- }
-
- /// <summary>
- /// Saves the current backup setting as a new file.
- /// </summary>
- /// <returns><c>true</c> if the backup setting is saved; otherwise, <c>false</c>.</returns>
- public bool SaveCurrentBackupSettingAsNewFile()
- {
- if (this.CurrentSetting == null)
- {
- return false;
- }
-
- var saveFileDialog = new SaveFileDialog
- {
- Title = Resources.Views_SaveFileDialogTitle,
- DefaultExt = ".xml",
- Filter = "Backup Setting File|*.xml"
- };
-
- if (saveFileDialog.ShowDialog(Application.Current.MainWindow) != true)
- {
- return false;
- }
-
- this.CurrentSetting.SettingFileName = saveFileDialog.FileName;
-
- this.SaveCurrentBackupSetting();
- return true;
- }
-
- /// <summary>
- /// Opens the default backup setting.
- /// </summary>
- /// <param name="resultMessage">The result message.</param>
- /// <returns>
- /// <c>true</c> if succeeded, otherwise; <c>false</c>.
- /// </returns>
- public bool OpenDefaultBackupSetting(out string resultMessage)
- {
- return this.OpenBackupSetting(
- Properties.Settings.Default.DefaultSettingFileName,
- out resultMessage);
- }
-
- /// <summary>
- /// Creates the backup information.
- /// </summary>
- /// <param name="index">The index.</param>
- /// <returns>The created backup information.</returns>
- /// <exception cref="System.ArgumentOutOfRangeException"><paramref name="index"/></exception>
- public IBackupInfo CreateBackupInfo(int index)
- {
- if (index < 0)
- {
- throw new ArgumentOutOfRangeException("index");
- }
-
- var backupInfo = new BackupInfo();
- this.CurrentSetting.Insert(index, backupInfo);
- return backupInfo;
- }
-
- /// <summary>
- /// Copies the backup information.
- /// </summary>
- /// <param name="sourceBackupInfo">The source backup information.</param>
- /// <returns>A copied BackupInfo.</returns>
- /// <exception cref="System.ArgumentNullException"><paramref name="sourceBackupInfo"/></exception>
- public IBackupInfo CopyBackupInfo(IBackupInfo sourceBackupInfo)
- {
- sourceBackupInfo.ThrowsArgumentNullException("sourceBackupInfo");
-
- var backupInfo = new BackupInfo(sourceBackupInfo);
- return backupInfo;
- }
-
- /// <summary>
- /// Inserts the backup information.
- /// </summary>
- /// <param name="index">The index.</param>
- /// <param name="backupInfo">The backup information.</param>
- /// <exception cref="System.ArgumentOutOfRangeException"><paramref name="index"/></exception>
- /// <exception cref="System.ArgumentNullException"><paramref name="backupInfo"/></exception>
- public void InsertBackupInfo(int index, IBackupInfo backupInfo)
- {
- if (index > this.CurrentSetting.Count)
- {
- throw new ArgumentOutOfRangeException("index");
- }
-
- backupInfo.ThrowsArgumentNullException("backupInfo");
-
- this.CurrentSetting.Insert(index, backupInfo);
- }
-
- /// <summary>
- /// Removes the backup information.
- /// </summary>
- /// <param name="backupInfoId">The backup information identifier.</param>
- public void RemoveBackupInfo(Guid backupInfoId)
- {
- IBackupInfo removingBackupInfo =
- this.CurrentSetting.FirstOrDefault(backupInfoId);
- if (removingBackupInfo == null)
- {
- return;
- }
-
- this.CurrentSetting.Remove(removingBackupInfo);
- }
-
- /// <summary>
- /// Saves the backup setting.
- /// </summary>
- /// <param name="backupSetting">The backup setting.</param>
- private static void SaveBackupSetting(IBackupSetting backupSetting)
- {
- var xdoc = new XDocument { Declaration = new XDeclaration("1.0", "utf-8", "yes") };
- xdoc.Add(backupSetting.ToXml());
-
- xdoc.Save(backupSetting.SettingFileName, SaveOptions.None);
- }
-
- /// <summary>
- /// Opens the backup setting.
- /// </summary>
- /// <param name="fileName">Name of the file.</param>
- /// <param name="resultMessage">The result message.</param>
- /// <returns>
- /// <c>true</c> if succeeded; otherwise, <c>false</c>.
- /// </returns>
- private bool OpenBackupSetting(string fileName, out string resultMessage)
- {
- resultMessage = string.Empty;
-
- if (string.IsNullOrEmpty(fileName))
- {
- resultMessage = string.Format(
- Resources.BackupSetting_FailedToOpenSetting_EmptyFileNameFormat,
- fileName);
- return false;
- }
-
- XDocument xml = XDocument.Load(fileName, LoadOptions.None);
- XElement backupSettingElement = xml.Elements("BackupSetting").FirstOrDefault();
- if (backupSettingElement == null)
- {
- resultMessage = string.Format(
- Resources.BackupSetting_FailedToOpenSetting_NoBackupSettingElementFormat,
- fileName);
- return false;
- }
-
- XAttribute versionAttribute = backupSettingElement.Attributes().FirstOrDefault(p => p.Name == "Version");
- if (versionAttribute == null)
- {
- resultMessage = string.Format(
- Resources.BackupSetting_FailedToOpenSetting_NoVersionElementFormat,
- fileName);
- return false;
- }
-
- string[] versionTextFlagments = versionAttribute.Value.Split('.');
- if (versionTextFlagments.Length != 2)
- {
- resultMessage = string.Format(
- Resources.BackupSetting_FailedToOpenSetting_InvalidVersionFormat,
- fileName);
- return false;
- }
-
- int majorVersion;
- if (int.TryParse(versionTextFlagments[0], out majorVersion) == false)
- {
- resultMessage = string.Format(
- Resources.BackupSetting_FailedToOpenSetting_InvalidMajorVersionFormat,
- fileName);
- return false;
- }
-
- int minorVersion;
- if (int.TryParse(versionTextFlagments[1], out minorVersion) == false)
- {
- resultMessage = string.Format(
- Resources.BackupSetting_FailedToOpenSetting_InvalidMinorVersionFormat,
- fileName);
- return false;
- }
-
- XAttribute requiredToolVersionAttribute = backupSettingElement.Attributes().FirstOrDefault(p => p.Name == "RequiredToolVersion");
- if (requiredToolVersionAttribute == null)
- {
- resultMessage = string.Format(
- Resources.BackupSetting_FailedToOpenSetting_InvalidRequiredToolVersionFormat,
- fileName);
- return false;
- }
-
- if (majorVersion > SupportedMajorVersion)
- {
- string message = string.Format(
- Resources.BackupSetting_IncompatibleMajorVersionFormat,
- requiredToolVersionAttribute.Value);
- MessageBox.Show(
- Application.Current.MainWindow,
- message,
- Resources.Views_DefaultWindowTitle,
- MessageBoxButton.OK,
- MessageBoxImage.Error);
- resultMessage = message;
- return false;
- }
-
- if (minorVersion > SupportedMinorVersion)
- {
- string message = string.Format(
- Resources.BackupSetting_IncompatibleMinorVersionFormat,
- requiredToolVersionAttribute.Value);
- MessageBox.Show(
- Application.Current.MainWindow,
- message,
- Resources.Views_DefaultWindowTitle,
- MessageBoxButton.OK,
- MessageBoxImage.Warning);
- resultMessage = message + "\r\n";
- }
-
- BackupSetting backupSetting = ModelHelper.RestoreBackupSettingFromXml(backupSettingElement, fileName);
- this.CurrentSetting = backupSetting;
- this.CurrentSetting.SettingModified += this.OnCurrentSettingModified;
- if (this.BackupSettingOpened != null)
- {
- this.BackupSettingOpened(this, new SettingFileEventArgs(backupSetting.SettingFileName));
- }
-
- resultMessage += string.Format(Resources.BackupSetting_SettingOpenedFormat, fileName);
- return true;
- }
-
- /// <summary>
- /// Saves the current backup setting.
- /// </summary>
- private void SaveCurrentBackupSetting()
- {
- try
- {
- Mouse.OverrideCursor = Cursors.Wait;
-
- SaveBackupSetting(this.CurrentSetting);
-
- this.CurrentSetting.Modified = false;
- }
- finally
- {
- Mouse.OverrideCursor = null;
- }
-
- if (this.BackupSettingSaved != null)
- {
- this.BackupSettingSaved(this, new SettingFileEventArgs(this.CurrentSetting.SettingFileName));
- }
- }
-
- private void CloseCurrentBackupSetting()
- {
- UndoRedoService.Instance.ClearUndoRedoBuffer();
- string settingName = this.CurrentSetting.SettingFileName;
- this.CurrentSetting.SettingModified -= this.OnCurrentSettingModified;
- this.CurrentSetting = null;
-
- if (this.BackupSettingClosed != null)
- {
- this.BackupSettingClosed(this, new SettingFileEventArgs(settingName));
- }
- }
-
- /// <summary>
- /// Called when current setting is modified.
- /// </summary>
- /// <param name="sender">The sender.</param>
- /// <param name="eventArgs">The <see cref="EventArgs"/> instance containing the event data.</param>
- private void OnCurrentSettingModified(object sender, EventArgs eventArgs)
- {
- if (this.BackupSettingModified != null)
- {
- this.BackupSettingModified(this, new SettingFileEventArgs(this.CurrentSetting.SettingName));
- }
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="ClipboardService.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Linq;
-using System.Windows;
-using SimpleBackup.Core.Services;
-using SimpleBackup.Core.Utilities;
-
-namespace SimpleBackup.Services
-{
- /// <summary>
- /// Provides clip board access.
- /// </summary>
- public class ClipboardService : IClipboardService
- {
- private static readonly object SyncRoot = new object();
- private static volatile ClipboardService instance;
-
- /// <summary>
- /// Prevents a default instance of the <see cref="ClipboardService"/> class from being created.
- /// </summary>
- private ClipboardService()
- {
- }
-
- /// <summary>
- /// Gets the instance.
- /// </summary>
- public static IClipboardService Instance
- {
- get
- {
- if (instance == null)
- {
- lock (SyncRoot)
- {
- if (instance == null)
- {
- instance = new ClipboardService();
- }
- }
- }
-
- return instance;
- }
- }
-
- /// <summary>
- /// Sets the data object.
- /// </summary>
- /// <param name="dataObject">The data object.</param>
- /// <exception cref="ArgumentNullException">The data object is null.</exception>
- public void SetDataObject(IDataObject dataObject)
- {
- dataObject.ThrowsArgumentNullException("dataObject");
-
- Clipboard.SetDataObject(dataObject);
- }
-
- /// <summary>
- /// Gets the data.
- /// </summary>
- /// <typeparam name="T">The type.</typeparam>
- /// <param name="format">The format.</param>
- /// <returns>
- /// The data.
- /// </returns>
- /// <exception cref="ArgumentException">The format string is null or empty.</exception>
- public T GetData<T>(string format)
- {
- format.ThrowsArgumentExceptionIfNullOrEmpty("format");
-
- IDataObject dataObject = Clipboard.GetDataObject();
- if (dataObject != null)
- {
- if (dataObject.GetDataPresent(format))
- {
- try
- {
- return (T)dataObject.GetData(format);
- }
- catch
- {
- return default(T);
- }
- }
- }
-
- return default(T);
- }
-
- /// <summary>
- /// Gets a boolean value indicating whether the clipboard data contains data in specified format.
- /// </summary>
- /// <param name="format">The format.</param>
- /// <exception cref="ArgumentException">The format string is null or empty.</exception>
- /// <returns>True if the specified format is contained in the Clipboard.</returns>
- public bool DoesClipboardDataContain(string format)
- {
- format.ThrowsArgumentExceptionIfNullOrEmpty("format");
-
- IDataObject dataObject = Clipboard.GetDataObject();
- if (dataObject != null)
- {
- string[] formats = dataObject.GetFormats();
- return formats.Contains(format);
- }
-
- return false;
- }
-
- /// <summary>
- /// Clears the clipbord.
- /// </summary>
- public void ClearClipbord()
- {
- Clipboard.Clear();
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="ResourceService.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Resources;
-using System.Windows;
-
-namespace SimpleBackup.Services
-{
- /// <summary>
- /// Provides localized resources.
- /// </summary>
- public class ResourceService
- {
- /// <summary>
- /// The resource identifier property
- /// </summary>
- public static readonly DependencyProperty ResourceIdProperty = DependencyProperty.RegisterAttached(
- "ResourceId",
- typeof(string),
- typeof(ResourceService),
- new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.None, OnResourceIdChanged));
-
- /// <summary>
- /// The resource text property
- /// </summary>
- public static readonly DependencyProperty ResourceTextProperty = DependencyProperty.RegisterAttached(
- "ResourceText",
- typeof(string),
- typeof(ResourceService),
- new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.None));
-
- /// <summary>
- /// The inner resource manager
- /// </summary>
- private static readonly ResourceManager InnerResourceManager =
- new ResourceManager("SimpleBackup.Resources.Resources", typeof(ResourceService).Assembly);
-
- /// <summary>
- /// The synchronize root
- /// </summary>
- private static readonly object SyncRoot = new object();
-
- /// <summary>
- /// The instance of ResourceService.
- /// </summary>
- private static volatile ResourceService instance;
-
- /// <summary>
- /// Prevents a default instance of the <see cref="ResourceService"/> class from being created.
- /// </summary>
- private ResourceService()
- {
- }
-
- /// <summary>
- /// Gets the instance.
- /// </summary>
- public static ResourceService Instance
- {
- get
- {
- if (instance == null)
- {
- lock (SyncRoot)
- {
- if (instance == null)
- {
- instance = new ResourceService();
- }
- }
- }
-
- return instance;
- }
- }
-
- /// <summary>
- /// Sets the resource identifier.
- /// </summary>
- /// <param name="obj">The dependency object.</param>
- /// <param name="value">The value.</param>
- public static void SetResourceId(DependencyObject obj, string value)
- {
- obj.SetValue(ResourceIdProperty, value);
- }
-
- /// <summary>
- /// Gets the resource identifier.
- /// </summary>
- /// <param name="obj">The dependency object.</param>
- /// <returns>The resource ID.</returns>
- public static string GetResourceId(DependencyObject obj)
- {
- return (string)obj.GetValue(ResourceIdProperty);
- }
-
- /// <summary>
- /// Gets the resource text.
- /// </summary>
- /// <param name="obj">The object.</param>
- /// <returns>The resource text.</returns>
- public static string GetResourceText(DependencyObject obj)
- {
- return (string)obj.GetValue(ResourceTextProperty);
- }
-
- /// <summary>
- /// Called when [resource identifier changed].
- /// </summary>
- /// <param name="d">The dependency object.</param>
- /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
- private static void OnResourceIdChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- var newResourceId = (string)e.NewValue;
- string resourceText;
- if (TryGetResourceText(newResourceId, out resourceText))
- {
- d.SetValue(ResourceTextProperty, resourceText);
- }
- }
-
- /// <summary>
- /// Tries the get resource text.
- /// </summary>
- /// <param name="resourceId">The resource identifier.</param>
- /// <param name="resourceText">The resource text.</param>
- /// <returns>True if succeeded to get resource text.</returns>
- private static bool TryGetResourceText(string resourceId, out string resourceText)
- {
- resourceText = string.Empty;
-
- try
- {
- resourceText = InnerResourceManager.GetString(resourceId);
- }
- catch (ArgumentNullException)
- {
- //// Ignore exception.
- }
- catch (InvalidOperationException)
- {
- //// Ignore exception.
- }
- catch (MissingManifestResourceException)
- {
- //// Ignore exception.
- }
- catch (MissingSatelliteAssemblyException)
- {
- //// Ignore exception.
- }
-
- var succeeded = resourceText != null;
- resourceText = resourceText ?? string.Empty;
-
- return succeeded;
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="UndoRedoActionSet.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using SimpleBackup.Core.Utilities;
-
-namespace SimpleBackup.Services
-{
- /// <summary>
- /// Provides undo/redo function.
- /// </summary>
- public partial class UndoRedoService
- {
- /// <summary>
- /// Represents a pair of undo/redo actions and its context information.
- /// </summary>
- private class UndoRedoActionSet
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="UndoRedoActionSet"/> class.
- /// </summary>
- /// <param name="redoAction">The redo action.</param>
- /// <param name="undoAction">The undo action.</param>
- /// <param name="context">The context.</param>
- /// <exception cref="ArgumentNullException">The redoAction is null.</exception>
- /// <exception cref="ArgumentNullException">The undoAction is null.</exception>
- public UndoRedoActionSet(Action<object> redoAction, Action<object> undoAction, object context)
- {
- redoAction.ThrowsArgumentNullException("redoAction");
- undoAction.ThrowsArgumentNullException("undoAction");
-
- this.RedoAction = redoAction;
- this.UndoAction = undoAction;
- this.Context = context;
- }
-
- /// <summary>
- /// Gets the redo action.
- /// </summary>
- public Action<object> RedoAction { get; private set; }
-
- /// <summary>
- /// Gets the undo action.
- /// </summary>
- public Action<object> UndoAction { get; private set; }
-
- /// <summary>
- /// Gets the context.
- /// </summary>
- public object Context { get; private set; }
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="UndoRedoService.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Collections.Generic;
-using SimpleBackup.Core.Services;
-using SimpleBackup.Core.Utilities;
-
-namespace SimpleBackup.Services
-{
- /// <summary>
- /// Provides undo/redo function.
- /// </summary>
- public partial class UndoRedoService : IUndoRedoService
- {
- private static readonly object SyncRoot = new object();
- private static volatile UndoRedoService instance;
-
- private readonly Stack<UndoRedoActionSet> actionSetsForUndo = new Stack<UndoRedoActionSet>();
- private readonly Stack<UndoRedoActionSet> actionSetsForRedo = new Stack<UndoRedoActionSet>();
-
- /// <summary>
- /// Prevents a default instance of the <see cref="UndoRedoService"/> class from being created.
- /// </summary>
- private UndoRedoService()
- {
- }
-
- /// <summary>
- /// Gets the instance.
- /// </summary>
- public static IUndoRedoService Instance
- {
- get
- {
- if (instance == null)
- {
- lock (SyncRoot)
- {
- if (instance == null)
- {
- instance = new UndoRedoService();
- }
- }
- }
-
- return instance;
- }
- }
-
- /// <summary>
- /// Commits the specified redo action with related undo action and the context information.
- /// </summary>
- /// <param name="redoAction">The redo action.</param>
- /// <param name="undoAction">The undo action.</param>
- /// <param name="context">The context.</param>
- /// <exception cref="ArgumentNullException">The redoAction is null.</exception>
- /// <exception cref="ArgumentNullException">The undoAction is null.</exception>
- public void Commit(Action<object> redoAction, Action<object> undoAction, object context)
- {
- redoAction.ThrowsArgumentNullException("redoAction");
- undoAction.ThrowsArgumentNullException("undoAction");
-
- var undoRedoActionSet = new UndoRedoActionSet(redoAction, undoAction, context);
- this.actionSetsForUndo.Push(undoRedoActionSet);
- redoAction.Invoke(undoRedoActionSet.Context);
- }
-
- /// <summary>
- /// Executes undo action.
- /// </summary>
- public void Undo()
- {
- if (this.CanExecuteUndo() == false)
- {
- return;
- }
-
- UndoRedoActionSet undoRedoActionSet = this.actionSetsForUndo.Pop();
- undoRedoActionSet.UndoAction.Invoke(undoRedoActionSet.Context);
- this.actionSetsForRedo.Push(undoRedoActionSet);
- }
-
- /// <summary>
- /// Determines whether the undo action is executable.
- /// </summary>
- /// <returns>true if the undo action can be executable; otherwise, false.</returns>
- public bool CanExecuteUndo()
- {
- return this.actionSetsForUndo.Count != 0;
- }
-
- /// <summary>
- /// Executes redo action.
- /// </summary>
- public void Redo()
- {
- if (this.CanExecuteRedo() == false)
- {
- return;
- }
-
- UndoRedoActionSet undoRedoActionSet = this.actionSetsForRedo.Pop();
- undoRedoActionSet.RedoAction.Invoke(undoRedoActionSet.Context);
- this.actionSetsForUndo.Push(undoRedoActionSet);
- }
-
- /// <summary>
- /// Determines whether the redo action is executable.
- /// </summary>
- /// <returns>true if the redo action can be executable; otherwise, false.</returns>
- public bool CanExecuteRedo()
- {
- return this.actionSetsForRedo.Count != 0;
- }
-
- /// <summary>
- /// Clears the undo redo buffer.
- /// </summary>
- public void ClearUndoRedoBuffer()
- {
- this.actionSetsForUndo.Clear();
- this.actionSetsForRedo.Clear();
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="BackupInfoPasteInfo.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using SimpleBackup.Core.Utilities;
-
-namespace SimpleBackup.ViewModels
-{
- /// <summary>
- /// Paste information of BackupInfo.
- /// </summary>
- [Serializable]
- public class BackupInfoPasteInfo
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="BackupInfoPasteInfo"/> class.
- /// </summary>
- /// <param name="backupInfoBytes">The backup information bytes.</param>
- /// <param name="pasteType">Type of the paste.</param>
- /// <param name="sourceIndex">Index of the source backup information view model.</param>
- public BackupInfoPasteInfo(
- byte[] backupInfoBytes,
- PasteType pasteType,
- int sourceIndex)
- {
- backupInfoBytes.ThrowsArgumentNullException("backupInfoBytes");
-
- this.BackupInfoBytes = backupInfoBytes;
- this.PasteType = pasteType;
- this.SourceIndex = sourceIndex;
- }
-
- /// <summary>
- /// Gets the backup information bytes.
- /// </summary>
- public byte[] BackupInfoBytes { get; private set; }
-
- /// <summary>
- /// Gets the type of the paste.
- /// </summary>
- public PasteType PasteType { get; private set; }
-
- /// <summary>
- /// Gets the index of the source backup information view model.
- /// </summary>
- public int SourceIndex { get; private set; }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="BackupInfoViewModel.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.ComponentModel;
-using System.IO;
-using System.Text.RegularExpressions;
-using System.Windows.Forms;
-using System.Windows.Input;
-using SimpleBackup.Core.Models;
-using SimpleBackup.Core.Utilities;
-using SimpleBackup.Core.ViewModels;
-using SimpleBackup.Core.Views;
-using SimpleBackup.Models;
-using SimpleBackup.Services;
-using SimpleBackup.Views;
-
-namespace SimpleBackup.ViewModels
-{
- using SimpleBackup.Resources;
-
- /// <summary>
- /// Backup information view model.
- /// </summary>
- public class BackupInfoViewModel : PropertyChangeNotificationBase
- {
- private readonly IBackupInfo backupInfoModel;
-
- private readonly Action clearOutputMessageAction;
-
- private readonly Action<string> addOutputMessageAction;
-
- private bool innerHasSourcePathError;
-
- private bool innerHasDestinationFolderPathError;
-
- private bool innerIsSourceEditing;
-
- private string innerEditingSourcePath = string.Empty;
-
- private bool innerIsDestinationEditing;
-
- private string innerEditingDestinationPath = string.Empty;
-
- private bool innerIsCutReserved;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="BackupInfoViewModel"/> class.
- /// </summary>
- /// <param name="backupInfoModel">The backup information model.</param>
- /// <param name="clearOutputMessageAction">The clear output message action.</param>
- /// <param name="addOutputMessageAction">The add output message action.</param>
- public BackupInfoViewModel(
- IBackupInfo backupInfoModel,
- Action clearOutputMessageAction,
- Action<string> addOutputMessageAction)
- {
- backupInfoModel.ThrowsArgumentNullException("backupInfoModel");
- clearOutputMessageAction.ThrowsArgumentNullException("clearOutputMessageAction");
- addOutputMessageAction.ThrowsArgumentNullException("addOutputMessageAction");
-
- this.backupInfoModel = backupInfoModel;
- this.backupInfoModel.PropertyChanged += this.OnBackupInfoModelPropertyChanged;
- this.clearOutputMessageAction = clearOutputMessageAction;
- this.addOutputMessageAction = addOutputMessageAction;
-
- this.OpenSourceFileRelayCommand = new RelayCommand(this.ExecuteOpenSourceFile, this.CanExecuteOpenSourceFile);
- this.OpenSourceFolderRelayCommand = new RelayCommand(this.ExecuteOpenSourceFolder, this.CanExecuteOpenSourceFolder);
- this.SelectSourceRelayCommand = new RelayCommand(this.ExecuteSelectSource, this.CanExecuteSelectSource);
- this.OpenDestinationFolderRelayCommand = new RelayCommand(this.ExecuteOpenDestinationFolder, this.CanExecuteOpenDestinationFolder);
- this.SelectDestinationRelayCommand = new RelayCommand(this.ExecuteSelectDestination, this.CanExecuteSelectDestination);
- this.EditSourceRelayCommand = new RelayCommand(this.ExecuteEditSource, this.CanExecuteEditSource);
- this.EditDestinationRelayCommand = new RelayCommand(this.ExecuteEditDestination, this.CanExecuteEditDestination);
- this.SingleBackupRelayCommand = new RelayCommand(this.ExecuteSingleBackup, this.CanExecuteSingleBackup);
-
- this.UpdateErrorStatus();
- }
-
- /// <summary>
- /// Gets the open source file relay command.
- /// </summary>
- public RelayCommand OpenSourceFileRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the open source folder relay command.
- /// </summary>
- public RelayCommand OpenSourceFolderRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the select source relay command.
- /// </summary>
- public RelayCommand SelectSourceRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the open destination folder relay command.
- /// </summary>
- public RelayCommand OpenDestinationFolderRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the select destination relay command.
- /// </summary>
- public RelayCommand SelectDestinationRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the edit source relay command.
- /// </summary>
- public RelayCommand EditSourceRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the edit destination relay command.
- /// </summary>
- public RelayCommand EditDestinationRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the single backup with context menu relay command.
- /// </summary>
- public RelayCommand SingleBackupRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the backup information identifier.
- /// </summary>
- public Guid BackupInfoId
- {
- get
- {
- return this.backupInfoModel.Id;
- }
- }
-
- /// <summary>
- /// Gets the type of the source.
- /// </summary>
- public BackupSourceType SourceType
- {
- get
- {
- return this.backupInfoModel.BackupSourceType;
- }
- }
-
- /// <summary>
- /// Gets the state of the backup.
- /// </summary>
- public BackupState BackupState
- {
- get
- {
- return this.backupInfoModel.BackupState;
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether the backup is enabled.
- /// </summary>
- public bool IsEnabled
- {
- get
- {
- return this.backupInfoModel.IsEnabled;
- }
-
- set
- {
- if (this.backupInfoModel.IsEnabled != value)
- {
- this.backupInfoModel.IsEnabled = value;
- this.NotifyPropertyChanged("IsEnabled");
- }
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether the backup is zip archive.
- /// </summary>
- public bool IsZipArchive
- {
- get
- {
- return this.backupInfoModel.IsZipArchive;
- }
-
- set
- {
- if (this.backupInfoModel.IsZipArchive != value)
- {
- this.backupInfoModel.IsZipArchive = value;
- this.NotifyPropertyChanged("IsZipArchive");
- }
- }
- }
-
- /// <summary>
- /// Gets or sets the label.
- /// </summary>
- public string Label
- {
- get
- {
- return this.backupInfoModel.Label;
- }
-
- set
- {
- if (this.backupInfoModel.Label != value)
- {
- this.backupInfoModel.Label = value;
- this.NotifyPropertyChanged("Label");
- }
- }
- }
-
- /// <summary>
- /// Gets or sets the source path.
- /// </summary>
- public string SourcePath
- {
- get
- {
- return this.backupInfoModel.SourcePath;
- }
-
- set
- {
- if ((this.backupInfoModel.SourcePath != value) &&
- value.IsValidFileOrDirectoryPath())
- {
- this.backupInfoModel.SourcePath = value;
- this.UpdateErrorStatus();
- this.NotifyPropertyChanged("SourcePath");
- this.NotifyPropertyChanged("DisplaySourcePath");
- }
- }
- }
-
- /// <summary>
- /// Gets the display source path.
- /// </summary>
- public string DisplaySourcePath
- {
- get
- {
- return Helpers.CreateDisplayPathText(this.backupInfoModel.SourcePath);
- }
- }
-
- /// <summary>
- /// Gets or sets the editing source path.
- /// </summary>
- public string EditingSourcePath
- {
- get
- {
- return this.innerEditingSourcePath;
- }
-
- set
- {
- if (this.innerEditingSourcePath != value)
- {
- this.innerEditingSourcePath = value;
- this.NotifyPropertyChanged("EditingSourcePath");
- }
- }
- }
-
- /// <summary>
- /// Gets the source tool tip text.
- /// </summary>
- public string SourceToolTipText
- {
- get
- {
- Match match = Constants.EndPathSegmentRegex.Match(this.backupInfoModel.SourcePath);
- return match.Success ? match.Value : string.Empty;
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether this instance is source editing.
- /// </summary>
- public bool IsSourceEditing
- {
- get
- {
- return this.innerIsSourceEditing;
- }
-
- set
- {
- if (this.innerIsSourceEditing != value)
- {
- this.innerIsSourceEditing = value;
- this.NotifyPropertyChanged("IsSourceEditing");
- }
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether this instance has source path error.
- /// </summary>
- public bool HasSourcePathError
- {
- get
- {
- return this.innerHasSourcePathError;
- }
-
- private set
- {
- if (this.innerHasSourcePathError != value)
- {
- this.innerHasSourcePathError = value;
- this.NotifyPropertyChanged("HasSourcePathError");
- }
- }
- }
-
- /// <summary>
- /// Gets or sets the destination folder path.
- /// </summary>
- public string DestinationFolderPath
- {
- get
- {
- return this.backupInfoModel.DestinationFolderPath;
- }
-
- set
- {
- if ((this.backupInfoModel.DestinationFolderPath != value) &&
- value.IsValidFileOrDirectoryPath())
- {
- this.backupInfoModel.DestinationFolderPath = value;
- this.UpdateErrorStatus();
- this.NotifyPropertyChanged("DestinationFolderPath");
- this.NotifyPropertyChanged("DisplayDestinationFolderPath");
- }
- }
- }
-
- /// <summary>
- /// Gets the display destination folder path.
- /// </summary>
- public string DisplayDestinationFolderPath
- {
- get
- {
- return Helpers.CreateDisplayPathText(
- Regex.Replace(this.backupInfoModel.DestinationFolderPath, @"\\$", string.Empty));
- }
- }
-
- /// <summary>
- /// Gets or sets the editing destination path.
- /// </summary>
- public string EditingDestinationPath
- {
- get
- {
- return this.innerEditingDestinationPath;
- }
-
- set
- {
- if (this.innerEditingDestinationPath != value)
- {
- this.innerEditingDestinationPath = value;
- this.NotifyPropertyChanged("EditingDestinationPath");
- }
- }
- }
-
- /// <summary>
- /// Gets the destination tool tip text.
- /// </summary>
- public string DestinationToolTipText
- {
- get
- {
- string endSeparatorRemovedPath = Constants.EndPathSeparatorRegex.Replace(this.backupInfoModel.DestinationFolderPath, string.Empty);
- Match match = Constants.EndPathSegmentRegex.Match(endSeparatorRemovedPath);
- return match.Success ? match.Value : string.Empty;
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether this instance is destination editing.
- /// </summary>
- public bool IsDestinationEditing
- {
- get
- {
- return this.innerIsDestinationEditing;
- }
-
- set
- {
- if (this.innerIsDestinationEditing != value)
- {
- this.innerIsDestinationEditing = value;
- this.NotifyPropertyChanged("IsDestinationEditing");
- }
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether this instance has destination folder path error.
- /// </summary>
- public bool HasDestinationFolderPathError
- {
- get
- {
- return this.innerHasDestinationFolderPathError;
- }
-
- private set
- {
- if (this.innerHasDestinationFolderPathError != value)
- {
- this.innerHasDestinationFolderPathError = value;
- this.NotifyPropertyChanged("HasDestinationFolderPathError");
- }
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether this instance is editing.
- /// </summary>
- public bool IsEditing
- {
- get
- {
- return this.IsSourceEditing || this.IsDestinationEditing;
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether this instance is cut reserved.
- /// </summary>
- public bool IsCutReserved
- {
- get
- {
- return this.innerIsCutReserved;
- }
-
- set
- {
- if (this.innerIsCutReserved != value)
- {
- this.innerIsCutReserved = value;
- this.NotifyPropertyChanged("IsCutReserved");
- }
- }
- }
-
- /// <summary>
- /// Gets the backup information.
- /// </summary>
- /// <returns>The backup information.</returns>
- public IBackupInfo GetBackupInfo()
- {
- return this.backupInfoModel;
- }
-
- /// <summary>
- /// Executes the double click action.
- /// </summary>
- /// <param name="pathType">Type of the path.</param>
- public void ExecuteDoubleClickAction(BackupInfoPathType pathType)
- {
- switch (pathType)
- {
- case BackupInfoPathType.Source:
- if (this.SourcePath.IsValidFileOrDirectoryPath())
- {
- this.SingleBackup();
- }
- else
- {
- string extractedPath;
- this.SelectSource(
- Helpers.TryExtractValidFolderPath(this.SourcePath, out extractedPath)
- ? extractedPath
- : string.Empty);
- }
-
- break;
- case BackupInfoPathType.Destination:
- if (this.DestinationFolderPath.IsValidFileOrDirectoryPath())
- {
- this.ExecuteOpenDestinationFolder(null);
- }
- else
- {
- string extractedPath;
- this.SelectDestination(
- Helpers.TryExtractValidFolderPath(this.DestinationFolderPath, out extractedPath)
- ? extractedPath
- : string.Empty);
- }
-
- break;
- }
- }
-
- /// <summary>
- /// Executes single backup.
- /// </summary>
- public void SingleBackup()
- {
- try
- {
- Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
-
- this.clearOutputMessageAction();
- Helpers.UpdateWpfGui();
- this.addOutputMessageAction(Resources.Backup_ExecutingBackup);
- Helpers.UpdateWpfGui();
-
- ResultInfo resultInfo = BackupService.Instance.BackupSingleFile(this.BackupInfoId);
- this.addOutputMessageAction(string.Format("{0}: {1}", resultInfo.Category.Translate(), resultInfo.Description));
- }
- finally
- {
- Mouse.OverrideCursor = null;
- }
- }
-
- /// <summary>
- /// Commits the editing contents.
- /// </summary>
- public void CommitEditingContents()
- {
- if (this.IsSourceEditing)
- {
- // Path validation is executed in SourcePath setter.
- this.SourcePath = this.EditingSourcePath;
- this.EditingSourcePath = string.Empty;
- this.IsSourceEditing = false;
- }
-
- if (this.IsDestinationEditing)
- {
- // Path validation is executed in DestinationFolderPath setter.
- this.DestinationFolderPath = this.EditingDestinationPath;
- this.EditingDestinationPath = string.Empty;
- this.IsDestinationEditing = false;
- }
- }
-
- /// <summary>
- /// Resets the state of the backup.
- /// </summary>
- public void ResetBackupState()
- {
- this.backupInfoModel.BackupState = BackupState.Todo;
- this.UpdateErrorStatus();
- }
-
- private void OnBackupInfoModelPropertyChanged(
- object sender,
- PropertyChangedEventArgs propertyChangedEventArgs)
- {
- if (propertyChangedEventArgs.PropertyName == "BackupState")
- {
- this.NotifyPropertyChanged("BackupState");
- }
- }
-
- private void ExecuteOpenSourceFile(object obj)
- {
- if (this.CanExecuteOpenSourceFile(obj) == false)
- {
- return;
- }
-
- Helpers.OpenFile(this.SourcePath);
- }
-
- private bool CanExecuteOpenSourceFile(object obj)
- {
- return (BackupService.Instance.IsExecutingBackup == false) &&
- (this.backupInfoModel.BackupSourceType == BackupSourceType.File);
- }
-
- private void ExecuteOpenSourceFolder(object obj)
- {
- Helpers.OpenParentFolderAndSelect(this.SourcePath);
- }
-
- private bool CanExecuteOpenSourceFolder(object obj)
- {
- return BackupService.Instance.IsExecutingBackup == false;
- }
-
- private void ExecuteSelectSource(object obj)
- {
- this.SelectSource(string.Empty);
- }
-
- private void SelectSource(string initialDirectoryPath)
- {
- string newSourcePath = string.Empty;
-
- var fileFolderDialog = new FileFolderDialog();
- if ((string.IsNullOrEmpty(initialDirectoryPath) == false) && Directory.Exists(initialDirectoryPath))
- {
- fileFolderDialog.SelectedPath = initialDirectoryPath;
- }
- else
- {
- fileFolderDialog.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
- }
-
- if (fileFolderDialog.ShowDialog() == DialogResult.OK)
- {
- if (File.Exists(fileFolderDialog.SelectedPath))
- {
- this.backupInfoModel.BackupSourceType = BackupSourceType.File;
- newSourcePath = fileFolderDialog.SelectedPath;
- }
- else if (Directory.Exists(fileFolderDialog.SelectedPath))
- {
- this.backupInfoModel.BackupSourceType = BackupSourceType.Folder;
- newSourcePath = fileFolderDialog.SelectedPath;
- }
- }
-
- if (string.IsNullOrEmpty(newSourcePath) == false)
- {
- this.backupInfoModel.SourcePath = newSourcePath;
- this.NotifyPropertyChanged("SourceType");
- this.NotifyPropertyChanged("SourcePath");
- this.NotifyPropertyChanged("DisplaySourcePath");
- }
-
- this.UpdateErrorStatus();
- }
-
- private bool CanExecuteSelectSource(object obj)
- {
- return BackupService.Instance.IsExecutingBackup == false;
- }
-
- private void ExecuteOpenDestinationFolder(object obj)
- {
- IBackupInfo backupInfo = this.GetBackupInfo();
- if (((backupInfo.BackupSourceType == BackupSourceType.File) &&
- File.Exists(backupInfo.LatestSuccessfulBackupTargetName)) ||
- ((backupInfo.BackupSourceType == BackupSourceType.Folder) &&
- Directory.Exists(backupInfo.LatestSuccessfulBackupTargetName)))
- {
- Helpers.OpenParentFolderAndSelect(backupInfo.LatestSuccessfulBackupTargetName);
- }
- else
- {
- Helpers.OpenFolder(this.DestinationFolderPath);
- }
- }
-
- private bool CanExecuteOpenDestinationFolder(object obj)
- {
- return BackupSettingService.Instance.CurrentSetting != null;
- }
-
- private void ExecuteSelectDestination(object obj)
- {
- this.SelectDestination(string.Empty);
- }
-
- private void SelectDestination(string initialDirectoryPath)
- {
- var fileFolderDialog = new FileFolderDialog();
- if ((string.IsNullOrEmpty(initialDirectoryPath) == false) && Directory.Exists(initialDirectoryPath))
- {
- fileFolderDialog.SelectedPath = initialDirectoryPath;
- }
- else
- {
- fileFolderDialog.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
- }
-
- if (fileFolderDialog.ShowDialog() == DialogResult.OK)
- {
- string destinationPath =
- Directory.Exists(fileFolderDialog.SelectedPath)
- ? fileFolderDialog.SelectedPath
- : Path.GetDirectoryName(fileFolderDialog.SelectedPath);
- this.backupInfoModel.DestinationFolderPath = destinationPath;
- this.NotifyPropertyChanged("DestinationFolderPath");
- this.NotifyPropertyChanged("DisplayDestinationFolderPath");
- }
-
- this.UpdateErrorStatus();
- }
-
- private bool CanExecuteSelectDestination(object obj)
- {
- return BackupService.Instance.IsExecutingBackup == false;
- }
-
- private void ExecuteEditSource(object obj)
- {
- this.EditingSourcePath = this.SourcePath;
- this.IsSourceEditing = true;
- }
-
- private bool CanExecuteEditSource(object obj)
- {
- return BackupService.Instance.IsExecutingBackup == false;
- }
-
- private void ExecuteEditDestination(object obj)
- {
- this.EditingDestinationPath = this.DestinationFolderPath;
- this.IsDestinationEditing = true;
- }
-
- private bool CanExecuteEditDestination(object obj)
- {
- return BackupService.Instance.IsExecutingBackup == false;
- }
-
- private void ExecuteSingleBackup(object obj)
- {
- this.SingleBackup();
- }
-
- private bool CanExecuteSingleBackup(object obj)
- {
- return BackupService.Instance.IsExecutingBackup == false;
- }
-
- private void UpdateErrorStatus()
- {
- switch (this.backupInfoModel.BackupSourceType)
- {
- case BackupSourceType.File:
- this.HasSourcePathError = File.Exists(this.backupInfoModel.SourcePath) == false;
- break;
- case BackupSourceType.Folder:
- this.HasSourcePathError = Directory.Exists(this.backupInfoModel.SourcePath) == false;
- break;
- default:
- throw new InvalidOperationException("Unexpected backup source type.");
- }
-
- this.HasDestinationFolderPathError = Directory.Exists(this.backupInfoModel.DestinationFolderPath) == false;
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="DataGridColumnHeaderBaseViewModel.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using SimpleBackup.Core.Utilities;
-
-namespace SimpleBackup.ViewModels
-{
- public abstract class DataGridColumnHeaderBaseViewModel : PropertyChangeNotificationBase
- {
- private object innerHeader = new object();
-
- public object Header
- {
- get
- {
- return this.innerHeader;
- }
-
- set
- {
- if (this.innerHeader != value)
- {
- this.innerHeader = value;
- this.NotifyPropertyChanged("Header");
- }
- }
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="DestinationColumnHeaderViewModel.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SimpleBackup.ViewModels
-{
- public class DestinationColumnHeaderViewModel : DataGridColumnHeaderBaseViewModel
- {
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="EncodingInfoItemViewModel.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using SimpleBackup.Core.Utilities;
-
-namespace SimpleBackup.ViewModels
-{
- /// <summary>
- /// A view model for single encoding information item.
- /// </summary>
- public class EncodingInfoItemViewModel
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="EncodingInfoItemViewModel"/> class.
- /// </summary>
- /// <param name="encodingKeyName">Name of the encoding key.</param>
- /// <param name="encodingDisplayName">Display name of the encoding.</param>
- public EncodingInfoItemViewModel(string encodingKeyName, string encodingDisplayName)
- {
- encodingKeyName.ThrowsArgumentExceptionIfNullOrEmpty("encodingKeyName");
- encodingDisplayName.ThrowsArgumentExceptionIfNullOrEmpty("encodingDisplayName");
-
- this.EncodingKeyName = encodingKeyName;
- this.EncodingDisplayName = encodingDisplayName;
- }
-
- /// <summary>
- /// Gets the name of the encoding key.
- /// </summary>
- public string EncodingKeyName { get; private set; }
-
- /// <summary>
- /// Gets the display name of the encoding.
- /// </summary>
- public string EncodingDisplayName { get; private set; }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="IndexBackupInfoViewModelPair.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using SimpleBackup.Core.Utilities;
-
-namespace SimpleBackup.ViewModels
-{
- public class IndexBackupInfoViewModelPair
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="IndexBackupInfoViewModelPair"/> class.
- /// </summary>
- /// <param name="index">The index.</param>
- /// <param name="backupInfoViewModel">The backup information view model.</param>
- /// <exception cref="System.ArgumentOutOfRangeException">The provided index is out of the range.</exception>
- /// <exception cref="System.ArgumentNullException">The provided backupInfoViewModel is null.</exception>
- public IndexBackupInfoViewModelPair(int index, BackupInfoViewModel backupInfoViewModel)
- {
- if (index < 0)
- {
- throw new ArgumentOutOfRangeException("index");
- }
-
- backupInfoViewModel.ThrowsArgumentNullException("backupInfoViewModel");
-
- this.Index = index;
- this.BackupInfoViewModel = backupInfoViewModel;
- }
-
- /// <summary>
- /// Gets the index.
- /// </summary>
- public int Index { get; private set; }
-
- /// <summary>
- /// Gets the backup information view model.
- /// </summary>
- public BackupInfoViewModel BackupInfoViewModel { get; private set; }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="IsZipArchiveColumnHeaderViewModel.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SimpleBackup.ViewModels
-{
- public class IsZipArchiveColumnHeaderViewModel : DataGridColumnHeaderBaseViewModel
- {
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="LabelColumnHeaderViewModel.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SimpleBackup.ViewModels
-{
- public class LabelColumnHeaderViewModel : DataGridColumnHeaderBaseViewModel
- {
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="MainWindowViewModel.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Input;
-using SimpleBackup.Core.Models;
-using SimpleBackup.Core.Services;
-using SimpleBackup.Core.Utilities;
-using SimpleBackup.Core.ViewModels;
-using SimpleBackup.Core.Views;
-using SimpleBackup.Models;
-using SimpleBackup.Services;
-using SimpleBackup.Views;
-
-namespace SimpleBackup.ViewModels
-{
- /// <summary>
- /// The view model of the main window.
- /// </summary>
- public class MainWindowViewModel : PropertyChangeNotificationBase, IMainWindowViewModel
- {
- private readonly string defaultWindowTitleFormat = Resources.Resources.Views_DefaultWindowTitle;
- private readonly string windowTitleFormat = Resources.Resources.Views_WindowTitleFormat;
- private readonly List<EncodingInfoItemViewModel> innerZipEncodings = new List<EncodingInfoItemViewModel>();
- private string innerWindowTitle;
- private string innerOutputMessage;
- private EncodingInfoItemViewModel innerSelectedEncodingInfoItem;
- private CancellationTokenSource cancellationTokenSource;
- private BackupInfoViewModel innerSelectedBackupInfoViewModel;
- private int innerSelectedFirstCellItemIndex;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="MainWindowViewModel"/> class.
- /// </summary>
- public MainWindowViewModel()
- {
- this.CreateNewBackupSettingRelayCommand = new RelayCommand(this.ExecuteCreateNewBackupSetting, this.CanExecuteCreateNewBackupSetting);
- this.OpenBackupSettingRelayCommand = new RelayCommand(this.ExecuteOpenBackupSetting, this.CanExecuteOpenBackupSetting);
- this.SaveBackupSettingRelayCommand = new RelayCommand(this.ExecuteSaveBackupSetting, this.CanExecuteSaveBackupSetting);
- this.SaveAsBackupSettingRelayCommand = new RelayCommand(this.ExecuteSaveAsBackupSetting, this.CanExecuteSaveAsBackupSetting);
- this.CloseBackupSettingRelayCommand = new RelayCommand(this.ExecuteCloseBackupSetting, this.CanExecuteCloseBackupSetting);
- this.OpenCurrentSettingFileLocationRelayCommand = new RelayCommand(this.ExecuteOpenCurrentSettingFileLocation, this.CanExecuteOpenCurrentSettingFileLocation);
- this.ExitRelayCommand = new RelayCommand(this.ExecuteExit, this.CanExecuteExit);
-
- this.ShowHelpRelayCommand = new RelayCommand(this.ExecuteShowHelp);
- this.ShowVersionInformationRelayCommand = new RelayCommand(this.ExecuteShowVersionInformation);
-
- this.BackUpRelayCommand = new RelayCommand(this.ExecuteBackup, this.CanExecuteBackup);
- this.BackupCancelRelayCommand = new RelayCommand(this.ExecuteBackupCancel, this.CanExecuteBackupCancel);
- this.SingleBackupRelayCommand = new RelayCommand(this.ExecuteSingleBackup, this.CanExecuteSingleBackup);
- this.AddItemRelayCommand = new RelayCommand(this.ExecuteAddItem, this.CanExecuteAddItem);
- this.RemoveItemRelayCommand = new RelayCommand(this.ExecuteRemoveItem, this.CanExecuteRemoveItem);
- this.MoveUpItemRelayCommand = new RelayCommand(this.ExecuteMoveUpItem, this.CanExecuteMoveUpItem);
- this.MoveDownItemRelayCommand = new RelayCommand(this.ExecuteMoveDownItem, this.CanExecuteMoveDownItem);
- this.CopyRelayCommand = new RelayCommand(this.ExecuteCopy, this.CanExecuteCopy);
- this.CutRelayCommand = new RelayCommand(this.ExecuteCut, this.CanExecuteCut);
- this.PasteRelayCommand = new RelayCommand(this.ExecutePaste, this.CanExecutePaste);
- this.UndoRelayCommand = new RelayCommand(this.ExecuteUndo, this.CanExecuteUndo);
- this.RedoRelayCommand = new RelayCommand(this.ExecuteRedo, this.CanExecuteRedo);
- this.RefreshRelayCommand = new RelayCommand(this.ExecuteRefresh, this.CanExecuteRefresh);
- this.ClearOutputWindowRelayCommand = new RelayCommand(this.ExecuteClearOutputWindow, this.CanExecuteClearOutputWindow);
-
- this.WindowTitle = this.defaultWindowTitleFormat;
- this.BackupInfoViewModels = new ObservableCollection<BackupInfoViewModel>();
-
- this.IsZipArchiveColumnHeaderViewModel = new IsZipArchiveColumnHeaderViewModel { Header = "Zip" };
- this.LabelColumnHeaderViewModel = new LabelColumnHeaderViewModel { Header = Resources.Resources.Views_LabelColumnHeaderText };
- this.SourceColumnHeaderViewModel = new SourceColumnHeaderViewModel { Header = Resources.Resources.Views_BackupSourceColumnHeaderText };
- this.DestinationColumnHeaderViewModel = new DestinationColumnHeaderViewModel { Header = Resources.Resources.Views_BackupDestinationColumnHeaderText };
- this.ProgressViewModel = new ProgressViewModel();
-
- this.innerOutputMessage = string.Empty;
- this.SetupZipEncodingItems();
-
- BackupSettingService.Instance.BackupSettingOpened += this.OnBackupSettingOpened;
- BackupSettingService.Instance.BackupSettingModified += this.OnBackupSettingModified;
- BackupSettingService.Instance.BackupSettingSaved += this.OnBackupSettingSaved;
- BackupSettingService.Instance.BackupSettingClosed += this.OnBackupSettingClosed;
-
- BackupService.Instance.NofityFileBackupProgress += this.OnBackupServiceNofityFileBackupProgress;
-
- string resultMessage;
- if (BackupSettingService.Instance.OpenDefaultBackupSetting(out resultMessage))
- {
- foreach (BackupInfo backupInfo in BackupSettingService.Instance.CurrentSetting.BackupInfos)
- {
- var backupInfoViewModel = new BackupInfoViewModel(
- backupInfo,
- this.ClearOutputMessage,
- this.AddOutputMessage);
- this.BackupInfoViewModels.Add(backupInfoViewModel);
- }
- }
-
- if (string.IsNullOrEmpty(resultMessage) == false)
- {
- this.OutputMessage = resultMessage;
- }
- }
-
- /// <summary>
- /// Occurs when focusing on grid is required.
- /// </summary>
- public event EventHandler<EventArgs> FocusOnGrid;
-
- /// <summary>
- /// Occurs when focusing on grid row is required.
- /// </summary>
- public event EventHandler<FocusOnGridRowEventArgs> FocusOnGridRow;
-
- /// <summary>
- /// Gets the create new backup settings relay command.
- /// </summary>
- public RelayCommand CreateNewBackupSettingRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the open backup settings relay command.
- /// </summary>
- public RelayCommand OpenBackupSettingRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the save backup settings relay command.
- /// </summary>
- public RelayCommand SaveBackupSettingRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the save as backup settings relay command.
- /// </summary>
- public RelayCommand SaveAsBackupSettingRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the close backup settings relay command.
- /// </summary>
- public RelayCommand CloseBackupSettingRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the open current setting file location relay command.
- /// </summary>
- public RelayCommand OpenCurrentSettingFileLocationRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the exit relay command.
- /// </summary>
- public RelayCommand ExitRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the show help relay command.
- /// </summary>
- public RelayCommand ShowHelpRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the show version information relay command.
- /// </summary>
- public RelayCommand ShowVersionInformationRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the back up relay command.
- /// </summary>
- public RelayCommand BackUpRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the backup cancel relay command.
- /// </summary>
- public RelayCommand BackupCancelRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the single backup relay command.
- /// </summary>
- public RelayCommand SingleBackupRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the add item relay command.
- /// </summary>
- public RelayCommand AddItemRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the remove item relay command.
- /// </summary>
- public RelayCommand RemoveItemRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the move up item relay command.
- /// </summary>
- public RelayCommand MoveUpItemRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the move down item relay command.
- /// </summary>
- public RelayCommand MoveDownItemRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the copy relay command.
- /// </summary>
- public RelayCommand CopyRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the cut relay command.
- /// </summary>
- public RelayCommand CutRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the paste relay command.
- /// </summary>
- public RelayCommand PasteRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the undo relay command.
- /// </summary>
- public RelayCommand UndoRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the redo relay command.
- /// </summary>
- public RelayCommand RedoRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the refresh relay command.
- /// </summary>
- public RelayCommand RefreshRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the clear output window relay command.
- /// </summary>
- public RelayCommand ClearOutputWindowRelayCommand { get; private set; }
-
- /// <summary>
- /// Gets the backup information view models.
- /// </summary>
- public ObservableCollection<BackupInfoViewModel> BackupInfoViewModels { get; private set; }
-
- /// <summary>
- /// Gets the progress view model.
- /// </summary>
- public ProgressViewModel ProgressViewModel { get; private set; }
-
- /// <summary>
- /// Gets the is zip archive column header view model.
- /// </summary>
- public IsZipArchiveColumnHeaderViewModel IsZipArchiveColumnHeaderViewModel { get; private set; }
-
- /// <summary>
- /// Gets the label column header view model.
- /// </summary>
- public LabelColumnHeaderViewModel LabelColumnHeaderViewModel { get; private set; }
-
- /// <summary>
- /// Gets the source column header view model.
- /// </summary>
- public SourceColumnHeaderViewModel SourceColumnHeaderViewModel { get; private set; }
-
- /// <summary>
- /// Gets the destination column header view model.
- /// </summary>
- public DestinationColumnHeaderViewModel DestinationColumnHeaderViewModel { get; private set; }
-
- /// <summary>
- /// Gets or sets the window title.
- /// </summary>
- public string WindowTitle
- {
- get
- {
- return this.innerWindowTitle;
- }
-
- set
- {
- if (this.innerWindowTitle != value)
- {
- this.innerWindowTitle = value;
- this.NotifyPropertyChanged("WindowTitle");
- }
- }
- }
-
- /// <summary>
- /// Gets the zip encodings.
- /// </summary>
- public IEnumerable<EncodingInfoItemViewModel> ZipEncodings
- {
- get
- {
- return this.innerZipEncodings;
- }
- }
-
- /// <summary>
- /// Gets or sets the selected encoding information item.
- /// </summary>
- public EncodingInfoItemViewModel SelectedEncodingInfoItem
- {
- get
- {
- return this.innerSelectedEncodingInfoItem;
- }
-
- set
- {
- if (this.innerSelectedEncodingInfoItem != value)
- {
- this.innerSelectedEncodingInfoItem = value;
- SimpleBackup.Properties.Settings.Default.DefaultZipEncodingKeyText = value.EncodingKeyName;
- SimpleBackup.Properties.Settings.Default.Save();
- }
- }
- }
-
- /// <summary>
- /// Gets or sets the selected backup information view model.
- /// </summary>
- public BackupInfoViewModel SelectedBackupInfoViewModel
- {
- get
- {
- return this.innerSelectedBackupInfoViewModel;
- }
-
- set
- {
- if (this.innerSelectedBackupInfoViewModel != value)
- {
- this.innerSelectedBackupInfoViewModel = value;
- this.NotifyPropertyChanged("SelectedBackupInfoViewModel");
- }
- }
- }
-
- /// <summary>
- /// Gets or sets the output message.
- /// </summary>
- public string OutputMessage
- {
- get
- {
- return this.innerOutputMessage;
- }
-
- set
- {
- if (this.innerOutputMessage != value)
- {
- this.innerOutputMessage = value;
- this.NotifyPropertyChanged("OutputMessage");
- }
- }
- }
-
- /// <summary>
- /// Gets or sets the index of the selected first cell item.
- /// </summary>
- public int SelectedFirstCellItemIndex
- {
- get
- {
- return this.innerSelectedFirstCellItemIndex;
- }
-
- set
- {
- this.innerSelectedFirstCellItemIndex = value;
- this.CommitEditingContents();
- }
- }
-
- /// <summary>
- /// Gets or sets the selected first cell item.
- /// </summary>
- public BackupInfoViewModel SelectedFirstCellItem { get; set; }
-
- /// <summary>
- /// Called when ESC key is pressed.
- /// </summary>
- public void OnEscKeyPressed()
- {
- this.CancelCutOperation();
- this.CancelCellEditOperation();
- }
-
- /// <summary>
- /// Cancels the cut operation.
- /// </summary>
- private void CancelCutOperation()
- {
- var cutReservedBackupInfoViewModels = this.BackupInfoViewModels.Where(p => p.IsCutReserved).ToArray();
- foreach (BackupInfoViewModel infoViewModel in cutReservedBackupInfoViewModels)
- {
- infoViewModel.IsCutReserved = false;
- ClipboardService.Instance.ClearClipbord();
- }
- }
-
- /// <summary>
- /// Cancels the cell edit operation.
- /// </summary>
- private void CancelCellEditOperation()
- {
- var editingInfoViewModels = this.BackupInfoViewModels.Where(p => p.IsEditing).ToArray();
- foreach (BackupInfoViewModel infoViewModel in editingInfoViewModels)
- {
- infoViewModel.IsSourceEditing = false;
- infoViewModel.IsDestinationEditing = false;
- }
- }
-
- private void OnBackupSettingOpened(object sender, SettingFileEventArgs args)
- {
- this.WindowTitle = string.Format(CultureInfo.InvariantCulture, this.windowTitleFormat, args.SettingName);
- }
-
- private void OnBackupSettingModified(object sender, SettingFileEventArgs args)
- {
- this.UpdateWindowTitleAsModified(args.SettingName);
- }
-
- private void OnBackupSettingSaved(object sender, SettingFileEventArgs args)
- {
- this.WindowTitle = string.Format(CultureInfo.InvariantCulture, this.windowTitleFormat, args.SettingName);
- }
-
- private void OnBackupSettingClosed(object sender, SettingFileEventArgs args)
- {
- this.WindowTitle = this.defaultWindowTitleFormat;
- this.BackupInfoViewModels.Clear();
- }
-
- private void ExecuteCreateNewBackupSetting(object obj)
- {
- BackupSettingService.Instance.CreateBackupSetting();
- this.ExecuteAddItem(null);
- this.UpdateWindowTitleAsModified(BackupSettingService.Instance.CurrentSetting.SettingName);
- }
-
- private bool CanExecuteCreateNewBackupSetting(object obj)
- {
- return BackupService.Instance.IsExecutingBackup == false;
- }
-
- private void ExecuteBackup(object obj)
- {
- if (this.cancellationTokenSource != null)
- {
- this.cancellationTokenSource.Dispose();
- }
-
- this.cancellationTokenSource = new CancellationTokenSource();
- Action backupAction = () =>
- {
- try
- {
- Application.Current.Dispatcher.Invoke(
- () =>
- {
- this.OutputMessage = Resources.Resources.Backup_ExecutingBackup;
- Mouse.OverrideCursor = Cursors.Wait;
- });
-
- ResultInfo[] resultInfos;
- BackupService.Instance.BackupMultipulFiles(this.cancellationTokenSource.Token, out resultInfos);
- }
- finally
- {
- Application.Current.Dispatcher.Invoke(
- () =>
- {
- Mouse.OverrideCursor = null;
- });
- }
- };
- Action<Task> postBackupAction = previousTask =>
- {
- if (previousTask.Exception != null)
- {
- this.OutputMessage = this.OutputMessage + "\r\n" + previousTask.Exception.ToString();
- }
-
- if (this.FocusOnGrid != null)
- {
- Application.Current.Dispatcher.Invoke(
- () => this.FocusOnGrid(this, new EventArgs()));
- }
- };
-
- Task.Factory.StartNew(backupAction, this.cancellationTokenSource.Token)
- .ContinueWith(postBackupAction);
- }
-
- private bool CanExecuteBackup(object obj)
- {
- return (BackupSettingService.Instance.CurrentSetting != null) &&
- BackupService.Instance.IsReadyForBackup && (BackupService.Instance.IsExecutingBackup == false);
- }
-
- private void ExecuteBackupCancel(object obj)
- {
- if (this.cancellationTokenSource != null)
- {
- this.cancellationTokenSource.Cancel();
- }
- }
-
- private bool CanExecuteBackupCancel(object obj)
- {
- return BackupService.Instance.IsReadyForBackup && BackupService.Instance.IsExecutingBackup;
- }
-
- private void ExecuteOpenBackupSetting(object obj)
- {
- if (this.CanExecuteOpenBackupSetting(obj) == false)
- {
- return;
- }
-
- string resultMessage;
- if (BackupSettingService.Instance.OpenBackupSetting(out resultMessage))
- {
- foreach (IBackupInfo backupInfo in BackupSettingService.Instance.CurrentSetting.BackupInfos)
- {
- var backupInfoViewModel = new BackupInfoViewModel(
- backupInfo,
- this.ClearOutputMessage,
- this.AddOutputMessage);
- this.BackupInfoViewModels.Add(backupInfoViewModel);
- }
- }
-
- if (string.IsNullOrEmpty(resultMessage) == false)
- {
- this.OutputMessage = resultMessage;
- }
- }
-
- private bool CanExecuteOpenBackupSetting(object obj)
- {
- return BackupService.Instance.IsExecutingBackup == false;
- }
-
- private void ExecuteSaveBackupSetting(object obj)
- {
- BackupSettingService.Instance.OverWriteCurrntBackupSetting();
- }
-
- private bool CanExecuteSaveBackupSetting(object obj)
- {
- return (BackupSettingService.Instance.CurrentSetting != null) &&
- (BackupService.Instance.IsExecutingBackup == false);
- }
-
- private void ExecuteSaveAsBackupSetting(object obj)
- {
- BackupSettingService.Instance.SaveCurrentBackupSettingAsNewFile();
- }
-
- private bool CanExecuteSaveAsBackupSetting(object obj)
- {
- return (BackupSettingService.Instance.CurrentSetting != null) &&
- (BackupService.Instance.IsExecutingBackup == false);
- }
-
- private void ExecuteCloseBackupSetting(object obj)
- {
- BackupSettingService.Instance.CloseBackupSetting();
- }
-
- private bool CanExecuteCloseBackupSetting(object obj)
- {
- return (BackupSettingService.Instance.CurrentSetting != null) &&
- (BackupService.Instance.IsExecutingBackup == false);
- }
-
- private void ExecuteOpenCurrentSettingFileLocation(object obj)
- {
- Helpers.OpenParentFolderAndSelect(BackupSettingService.Instance.CurrentSetting.SettingFileName);
- }
-
- private bool CanExecuteOpenCurrentSettingFileLocation(object obj)
- {
- return (BackupSettingService.Instance.CurrentSetting != null) &&
- (BackupService.Instance.IsExecutingBackup == false);
- }
-
- private void ExecuteExit(object obj)
- {
- Application.Current.Shutdown(0);
- }
-
- private bool CanExecuteExit(object obj)
- {
- return BackupService.Instance.IsExecutingBackup == false;
- }
-
- private void ExecuteShowHelp(object obj)
- {
- string helpFilePath = string.Format(
- @"{0}\Documents\HelpDocument.pdf",
- Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
- Helpers.OpenFile(helpFilePath);
- }
-
- private void ExecuteShowVersionInformation(object obj)
- {
- var versionInformationWindow = new VersionInformationWindow
- {
- Owner = Application.Current.MainWindow,
- WindowStartupLocation =
- WindowStartupLocation.CenterOwner
- };
-
- versionInformationWindow.ShowDialog();
- }
-
- private void ExecuteSingleBackup(object obj)
- {
- if (this.SelectedFirstCellItem != null)
- {
- this.SelectedFirstCellItem.SingleBackup();
- }
- }
-
- private bool CanExecuteSingleBackup(object obj)
- {
- return BackupService.Instance.IsExecutingBackup == false;
- }
-
- private void ExecuteAddItem(object obj)
- {
- if (this.CanExecuteAddItem(obj) == false)
- {
- return;
- }
-
- int currentIndex = -1;
- if (this.SelectedBackupInfoViewModel != null)
- {
- currentIndex = this.BackupInfoViewModels.IndexOf(this.SelectedBackupInfoViewModel);
- }
-
- int targetIndex = (currentIndex != -1) ? currentIndex + 1 : this.BackupInfoViewModels.Count;
-
- var action = new Action<object>(
- context =>
- {
- var index = (int)context;
- var backupInfo = BackupSettingService.Instance.CreateBackupInfo(index);
- var backupInfoViewModel = new BackupInfoViewModel(
- backupInfo,
- this.ClearOutputMessage,
- this.AddOutputMessage);
- this.BackupInfoViewModels.Insert(index, backupInfoViewModel);
-
- if (this.FocusOnGridRow != null)
- {
- this.FocusOnGridRow(this, new FocusOnGridRowEventArgs(index));
- }
-
- this.SelectedBackupInfoViewModel = backupInfoViewModel;
- });
-
- var undoAction = new Action<object>(
- context =>
- {
- var index = (int)context;
- if (index < this.BackupInfoViewModels.Count)
- {
- var removingBackupInfoViewModel = this.BackupInfoViewModels[index];
- BackupSettingService.Instance.RemoveBackupInfo(removingBackupInfoViewModel.BackupInfoId);
- this.BackupInfoViewModels.Remove(removingBackupInfoViewModel);
-
- if (index < this.BackupInfoViewModels.Count)
- {
- if (this.FocusOnGridRow != null)
- {
- this.FocusOnGridRow(this, new FocusOnGridRowEventArgs(index));
- }
-
- this.SelectedBackupInfoViewModel = this.BackupInfoViewModels[index];
- }
- else if (this.BackupInfoViewModels.Count != 0)
- {
- if (this.FocusOnGridRow != null)
- {
- this.FocusOnGridRow(this, new FocusOnGridRowEventArgs(index - 1));
- }
-
- this.SelectedBackupInfoViewModel = this.BackupInfoViewModels[index - 1];
- }
- }
- });
-
- UndoRedoService.Instance.Commit(action, undoAction, targetIndex);
- }
-
- private bool CanExecuteAddItem(object obj)
- {
- return (BackupSettingService.Instance.CurrentSetting != null) &&
- (BackupService.Instance.IsExecutingBackup == false);
- }
-
- private void ExecuteRemoveItem(object obj)
- {
- if (this.CanExecuteRemoveItem(obj) == false)
- {
- return;
- }
-
- var targetIndexViewModelPair = new IndexBackupInfoViewModelPair(
- this.BackupInfoViewModels.IndexOf(this.SelectedBackupInfoViewModel),
- this.SelectedBackupInfoViewModel);
-
- this.RemoveItem(targetIndexViewModelPair);
- }
-
- private void RemoveItem(IndexBackupInfoViewModelPair targetIndexViewModelPair)
- {
- var action = new Action<object>(
- context =>
- {
- var indexViewModelPair = (IndexBackupInfoViewModelPair)context;
- if (indexViewModelPair.Index < this.BackupInfoViewModels.Count)
- {
- var removingBackupInfoViewModel = this.BackupInfoViewModels[indexViewModelPair.Index];
- BackupSettingService.Instance.RemoveBackupInfo(removingBackupInfoViewModel.BackupInfoId);
- this.BackupInfoViewModels.Remove(removingBackupInfoViewModel);
-
- if (indexViewModelPair.Index < this.BackupInfoViewModels.Count)
- {
- if (this.FocusOnGridRow != null)
- {
- this.FocusOnGridRow(this, new FocusOnGridRowEventArgs(indexViewModelPair.Index));
- }
-
- this.SelectedBackupInfoViewModel = this.BackupInfoViewModels[indexViewModelPair.Index];
- }
- else if (this.BackupInfoViewModels.Count != 0)
- {
- if (this.FocusOnGridRow != null)
- {
- this.FocusOnGridRow(this, new FocusOnGridRowEventArgs(indexViewModelPair.Index - 1));
- }
-
- this.SelectedBackupInfoViewModel = this.BackupInfoViewModels[indexViewModelPair.Index - 1];
- }
- }
- });
-
- var undoAction = new Action<object>(
- context =>
- {
- var indexViewModelPair = (IndexBackupInfoViewModelPair)context;
-
- BackupSettingService.Instance.InsertBackupInfo(
- indexViewModelPair.Index,
- indexViewModelPair.BackupInfoViewModel.GetBackupInfo());
- this.BackupInfoViewModels.Insert(
- indexViewModelPair.Index,
- indexViewModelPair.BackupInfoViewModel);
-
- if (this.FocusOnGridRow != null)
- {
- this.FocusOnGridRow(this, new FocusOnGridRowEventArgs(indexViewModelPair.Index));
- }
-
- this.SelectedBackupInfoViewModel = indexViewModelPair.BackupInfoViewModel;
- });
-
- UndoRedoService.Instance.Commit(action, undoAction, targetIndexViewModelPair);
- }
-
- private bool CanExecuteRemoveItem(object obj)
- {
- return (BackupSettingService.Instance.CurrentSetting != null) &&
- (BackupService.Instance.IsExecutingBackup == false) &&
- (this.SelectedBackupInfoViewModel != null);
- }
-
- private void ExecuteMoveUpItem(object obj)
- {
- if (this.CanExecuteMoveUpItem(obj) == false)
- {
- return;
- }
-
- var selectedIdIndexPair = new IdIndexPair(
- this.SelectedBackupInfoViewModel.BackupInfoId,
- this.BackupInfoViewModels.IndexOf(this.SelectedBackupInfoViewModel));
- var action = new Action<object>(context =>
- {
- var idIndexPair = (IdIndexPair)context;
- if (idIndexPair.Index > 0)
- {
- BackupSettingService.Instance.CurrentSetting.MoveItem(idIndexPair.Id, ItemMovingDirection.MoveUp);
- this.BackupInfoViewModels.Move(idIndexPair.Index, idIndexPair.Index - 1);
- }
- });
-
- var undoAction = new Action<object>(context =>
- {
- var idIndexPair = (IdIndexPair)context;
- var index = idIndexPair.Index - 1;
- if (index < this.BackupInfoViewModels.Count - 1)
- {
- BackupSettingService.Instance.CurrentSetting.MoveItem(idIndexPair.Id, ItemMovingDirection.MoveDown);
- this.BackupInfoViewModels.Move(index, index + 1);
- }
- });
-
- UndoRedoService.Instance.Commit(action, undoAction, selectedIdIndexPair);
- }
-
- private bool CanExecuteMoveUpItem(object obj)
- {
- return (BackupSettingService.Instance.CurrentSetting != null) &&
- (BackupService.Instance.IsExecutingBackup == false) &&
- (this.SelectedBackupInfoViewModel != null) &&
- this.BackupInfoViewModels.IndexOf(this.SelectedBackupInfoViewModel) > 0;
- }
-
- private void ExecuteMoveDownItem(object obj)
- {
- if (this.CanExecuteMoveDownItem(obj) == false)
- {
- return;
- }
-
- var selectedIdIndexPair = new IdIndexPair(
- this.SelectedBackupInfoViewModel.BackupInfoId,
- this.BackupInfoViewModels.IndexOf(this.SelectedBackupInfoViewModel));
- var action = new Action<object>(context =>
- {
- var idIndexPair = (IdIndexPair)context;
- if (idIndexPair.Index < this.BackupInfoViewModels.Count - 1)
- {
- BackupSettingService.Instance.CurrentSetting.MoveItem(idIndexPair.Id, ItemMovingDirection.MoveDown);
- this.BackupInfoViewModels.Move(idIndexPair.Index, idIndexPair.Index + 1);
- }
- });
-
- var undoAction = new Action<object>(context =>
- {
- var idIndexPair = (IdIndexPair)context;
- var index = idIndexPair.Index + 1;
- if (index > 0)
- {
- BackupSettingService.Instance.CurrentSetting.MoveItem(idIndexPair.Id, ItemMovingDirection.MoveUp);
- this.BackupInfoViewModels.Move(index, index - 1);
- }
- });
-
- UndoRedoService.Instance.Commit(action, undoAction, selectedIdIndexPair);
- }
-
- private bool CanExecuteMoveDownItem(object obj)
- {
- return (BackupSettingService.Instance.CurrentSetting != null) &&
- (BackupService.Instance.IsExecutingBackup == false) &&
- (this.SelectedBackupInfoViewModel != null) &&
- this.BackupInfoViewModels.IndexOf(this.SelectedBackupInfoViewModel) < this.BackupInfoViewModels.Count - 1;
- }
-
- private void ExecuteCopy(object obj)
- {
- if (this.CanExecuteCopy(obj))
- {
- IBackupInfo copiedBackupInfo = BackupSettingService.Instance.CopyBackupInfo(
- this.SelectedBackupInfoViewModel.GetBackupInfo());
- byte[] backupInfoBytes = copiedBackupInfo.ToBinary();
- var info = new BackupInfoPasteInfo(
- backupInfoBytes,
- PasteType.Copy,
- this.BackupInfoViewModels.IndexOf(this.SelectedBackupInfoViewModel));
- IDataObject dataObject = new DataObject();
- dataObject.SetData(Constants.BackupInfoClipboardFormat, info);
- dataObject.SetData(DataFormats.Text, copiedBackupInfo.ToText());
- ClipboardService.Instance.SetDataObject(dataObject);
- }
- }
-
- private bool CanExecuteCopy(object obj)
- {
- return this.SelectedBackupInfoViewModel != null;
- }
-
- private void ExecuteCut(object obj)
- {
- if (this.CanExecuteCut(obj))
- {
- IBackupInfo copiedBackupInfo = BackupSettingService.Instance.CopyBackupInfo(
- this.SelectedBackupInfoViewModel.GetBackupInfo());
- byte[] backupInfoBytes = copiedBackupInfo.ToBinary();
- var info = new BackupInfoPasteInfo(
- backupInfoBytes,
- PasteType.Cut,
- this.BackupInfoViewModels.IndexOf(this.SelectedBackupInfoViewModel));
- IDataObject dataObject = new DataObject();
- dataObject.SetData(Constants.BackupInfoClipboardFormat, info);
- ClipboardService.Instance.SetDataObject(dataObject);
- dataObject.SetData(DataFormats.Text, copiedBackupInfo.ToText());
- this.SelectedBackupInfoViewModel.IsCutReserved = true;
- }
- }
-
- private bool CanExecuteCut(object obj)
- {
- return this.SelectedBackupInfoViewModel != null;
- }
-
- private void ExecutePaste(object obj)
- {
- if (this.CanExecutePaste(obj))
- {
- if (ClipboardService.Instance.DoesClipboardDataContain(Constants.BackupInfoClipboardFormat))
- {
- var pasteInfo =
- ClipboardService.Instance.GetData<BackupInfoPasteInfo>(Constants.BackupInfoClipboardFormat);
- if (pasteInfo != null)
- {
- BackupInfo backupInfo = BackupInfo.FromBinary(
- pasteInfo.BackupInfoBytes,
- pasteInfo.PasteType == PasteType.Copy);
-
- if ((pasteInfo.PasteType == PasteType.Cut) &&
- (pasteInfo.SourceIndex < this.BackupInfoViewModels.Count))
- {
- BackupInfoViewModel source = this.BackupInfoViewModels[pasteInfo.SourceIndex];
- if (source.IsCutReserved)
- {
- var targetIndexViewModelPair = new IndexBackupInfoViewModelPair(
- pasteInfo.SourceIndex,
- source);
- this.RemoveItem(targetIndexViewModelPair);
- }
- }
-
- int targetIndex = this.GetTargetItemIndex();
- this.InsertBackupInfo(backupInfo, targetIndex);
- }
- }
- }
- }
-
- private bool CanExecutePaste(object obj)
- {
- var supportedClipboardFormats = new string[] { Constants.BackupInfoClipboardFormat };
-
- return supportedClipboardFormats.Any(p => ClipboardService.Instance.DoesClipboardDataContain(p));
- }
-
- private void InsertBackupInfo(BackupInfo backupInfo, int targetIndex)
- {
- if ((backupInfo == null) || (targetIndex < 0) || (targetIndex > this.BackupInfoViewModels.Count))
- {
- return;
- }
-
- var backupInfoViewModel = new BackupInfoViewModel(backupInfo, this.ClearOutputMessage, this.AddOutputMessage);
- var targetIndexViewModelPair = new IndexBackupInfoViewModelPair(
- targetIndex,
- backupInfoViewModel);
-
- var action = new Action<object>(
- context =>
- {
- // TODO: メソッド化
- var indexViewModelPair = (IndexBackupInfoViewModelPair)context;
- BackupSettingService.Instance.InsertBackupInfo(
- indexViewModelPair.Index,
- indexViewModelPair.BackupInfoViewModel.GetBackupInfo());
- this.BackupInfoViewModels.Insert(
- indexViewModelPair.Index,
- indexViewModelPair.BackupInfoViewModel);
- if (this.FocusOnGridRow != null)
- {
- this.FocusOnGridRow(this, new FocusOnGridRowEventArgs(indexViewModelPair.Index));
- }
-
- this.SelectedBackupInfoViewModel = indexViewModelPair.BackupInfoViewModel;
- });
- var undoAction = new Action<object>(
- context =>
- {
- // TODO: メソッド化
- var indexViewModelPair = (IndexBackupInfoViewModelPair)context;
- if (indexViewModelPair.Index < this.BackupInfoViewModels.Count)
- {
- var removingBackupInfoViewModel = this.BackupInfoViewModels[indexViewModelPair.Index];
- BackupSettingService.Instance.RemoveBackupInfo(removingBackupInfoViewModel.BackupInfoId);
- this.BackupInfoViewModels.Remove(removingBackupInfoViewModel);
-
- if (indexViewModelPair.Index < this.BackupInfoViewModels.Count)
- {
- if (this.FocusOnGridRow != null)
- {
- this.FocusOnGridRow(this, new FocusOnGridRowEventArgs(indexViewModelPair.Index));
- }
-
- this.SelectedBackupInfoViewModel = this.BackupInfoViewModels[indexViewModelPair.Index];
- }
- else if (this.BackupInfoViewModels.Count != 0)
- {
- if (this.FocusOnGridRow != null)
- {
- this.FocusOnGridRow(this, new FocusOnGridRowEventArgs(indexViewModelPair.Index - 1));
- }
-
- this.SelectedBackupInfoViewModel = this.BackupInfoViewModels[indexViewModelPair.Index - 1];
- }
- }
- });
-
- UndoRedoService.Instance.Commit(action, undoAction, targetIndexViewModelPair);
- }
-
- private void ExecuteUndo(object obj)
- {
- if (UndoRedoService.Instance.CanExecuteUndo())
- {
- UndoRedoService.Instance.Undo();
- }
- }
-
- private bool CanExecuteUndo(object obj)
- {
- return (BackupSettingService.Instance.CurrentSetting != null) &&
- UndoRedoService.Instance.CanExecuteUndo();
- }
-
- private void ExecuteRedo(object obj)
- {
- if (UndoRedoService.Instance.CanExecuteRedo())
- {
- UndoRedoService.Instance.Redo();
- }
- }
-
- private bool CanExecuteRedo(object obj)
- {
- return (BackupSettingService.Instance.CurrentSetting != null) &&
- UndoRedoService.Instance.CanExecuteRedo();
- }
-
- private void ExecuteRefresh(object obj)
- {
- this.ResetAllBackItemStates();
- this.RestProgressBar();
- }
-
- private bool CanExecuteRefresh(object obj)
- {
- return BackupService.Instance.IsExecutingBackup == false;
- }
-
- private void ExecuteClearOutputWindow(object obj)
- {
- this.OutputMessage = string.Empty;
- }
-
- private bool CanExecuteClearOutputWindow(object obj)
- {
- return BackupService.Instance.IsExecutingBackup == false;
- }
-
- private void OnBackupServiceNofityFileBackupProgress(object sender, FileBackupProgressEventArgs args)
- {
- this.ProgressViewModel.ProgressValue = args.ProgressValue;
- if (args.LatestResultInfo != null)
- {
- this.OutputMessage = this.OutputMessage + "\r\n"
- + string.Format(
- "{0}: {1}",
- args.LatestResultInfo.Category.Translate(),
- args.LatestResultInfo.Description);
- }
- }
-
- private void CommitEditingContents()
- {
- BackupInfoViewModel[] editingViewModels =
- this.BackupInfoViewModels.Where(p => p.IsEditing).ToArray();
-
- foreach (BackupInfoViewModel backupInfoViewModel in editingViewModels)
- {
- backupInfoViewModel.CommitEditingContents();
- }
- }
-
- private void UpdateWindowTitleAsModified(string backupSettingName)
- {
- this.WindowTitle = string.Format(
- CultureInfo.InvariantCulture,
- this.windowTitleFormat,
- backupSettingName + "*");
- }
-
- private void ResetAllBackItemStates()
- {
- foreach (BackupInfoViewModel backupInfoViewModel in this.BackupInfoViewModels)
- {
- backupInfoViewModel.ResetBackupState();
- }
- }
-
- private void RestProgressBar()
- {
- this.ProgressViewModel.ProgressValue = 0;
- }
-
- private void ClearOutputMessage()
- {
- this.OutputMessage = string.Empty;
- }
-
- private void AddOutputMessage(string additionalMessage)
- {
- this.OutputMessage = this.OutputMessage + (additionalMessage ?? string.Empty) + "\r\n";
- }
-
- private int GetTargetItemIndex()
- {
- int currentIndex = -1;
- if (this.SelectedBackupInfoViewModel != null)
- {
- currentIndex = this.BackupInfoViewModels.IndexOf(this.SelectedBackupInfoViewModel);
- }
- else
- {
- currentIndex = this.SelectedFirstCellItemIndex;
- }
-
- int targetIndex = (currentIndex != -1) ? currentIndex + 1 : this.BackupInfoViewModels.Count;
-
- return targetIndex;
- }
-
- private void SetupZipEncodingItems()
- {
- if (string.IsNullOrEmpty(SimpleBackup.Properties.Settings.Default.DefaultZipEncodingKeyText))
- {
- SimpleBackup.Properties.Settings.Default.DefaultZipEncodingKeyText = "utf-8";
- SimpleBackup.Properties.Settings.Default.Save();
- }
-
- this.innerZipEncodings.Add(new EncodingInfoItemViewModel("shift_jis", "Japanese (Shift-JIS)"));
- this.innerZipEncodings.Add(new EncodingInfoItemViewModel("utf-16", "Unicode"));
- this.innerZipEncodings.Add(new EncodingInfoItemViewModel("utf-8", "Unicode (UTF-8)"));
-
- EncodingInfoItemViewModel defaultEncodingItem =
- this.innerZipEncodings.FirstOrDefault(
- p =>
- string.Equals(
- p.EncodingKeyName,
- SimpleBackup.Properties.Settings.Default.DefaultZipEncodingKeyText,
- StringComparison.OrdinalIgnoreCase));
- if (defaultEncodingItem != null)
- {
- this.SelectedEncodingInfoItem = defaultEncodingItem;
- }
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="PasteType.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-namespace SimpleBackup.ViewModels
-{
- /// <summary>
- /// Paste operation type.
- /// </summary>
- public enum PasteType
- {
- /// <summary>
- /// The copy
- /// </summary>
- Copy,
-
- /// <summary>
- /// The cut
- /// </summary>
- Cut
- }
-}
\ No newline at end of file
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="ProgressViewModel.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SimpleBackup.ViewModels
-{
- using SimpleBackup.Core.Utilities;
-
- public class ProgressViewModel : PropertyChangeNotificationBase
- {
- private double progressValue;
-
- public double ProgressValue
- {
- get
- {
- return this.progressValue;
- }
-
- set
- {
- if (this.progressValue.Equals(value) == false)
- {
- this.progressValue = value;
- this.NotifyPropertyChanged("ProgressValue");
- }
- }
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="SourceColumnHeaderViewModel.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SimpleBackup.ViewModels
-{
- public class SourceColumnHeaderViewModel : DataGridColumnHeaderBaseViewModel
- {
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="BackupSourceTypeToImageConverter.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Diagnostics;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Media.Imaging;
-using SimpleBackup.Models;
-
-namespace SimpleBackup.Views
-{
- public class BackupSourceTypeToImageConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- Uri imageSourceUri;
- var backupState = (BackupSourceType)value;
- switch (backupState)
- {
- case BackupSourceType.File:
- imageSourceUri = new Uri("/Resources/Images/document_32xLG.png", UriKind.Relative);
- break;
- case BackupSourceType.Folder:
- imageSourceUri = new Uri("/Resources/Images/FileGroup_10135_32x.png", UriKind.Relative);
- break;
- default:
- imageSourceUri = new Uri("/Resources/Images/document_32xLG.png", UriKind.Relative);
- break;
- }
-
- var bitmapImage = new BitmapImage();
- bitmapImage.BeginInit();
- bitmapImage.UriSource = imageSourceUri;
- bitmapImage.EndInit();
-
- return new Image { Source = bitmapImage };
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- Debug.Assert(true, "ConvertBack is called.");
- return new object();
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="BackupStateToImageConverter.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Diagnostics;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Media.Imaging;
-using SimpleBackup.Core.Models;
-
-namespace SimpleBackup.Views
-{
- public class BackupStateToImageConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- Uri imageSourceUri;
- var backupState = (BackupState)value;
- switch (backupState)
- {
- case BackupState.Todo:
- imageSourceUri = new Uri("/Resources/Images/flag_16xLG.png", UriKind.Relative);
- break;
- case BackupState.InProgress:
- imageSourceUri = new Uri("/Resources/Images/Activity_16xLG.png", UriKind.Relative);
- break;
- case BackupState.Success:
- imageSourceUri = new Uri("/Resources/Images/StatusAnnotations_Complete_and_ok_32xLG_color.png", UriKind.Relative);
- break;
- case BackupState.Failed:
- imageSourceUri = new Uri("/Resources/Images/StatusAnnotations_Critical_32xLG_color.png", UriKind.Relative);
- break;
- case BackupState.Cancelled:
- imageSourceUri = new Uri("/Resources/Images/Warning.png", UriKind.Relative);
- break;
- case BackupState.Skipped:
- imageSourceUri = new Uri("/Resources/Images/Warning.png", UriKind.Relative);
- break;
- default:
- imageSourceUri = new Uri("/Resources/Images/Remove_16xLG.png", UriKind.Relative);
- break;
- }
-
- var bitmapImage = new BitmapImage();
- bitmapImage.BeginInit();
- bitmapImage.UriSource = imageSourceUri;
- bitmapImage.EndInit();
-
- return new Image { Source = bitmapImage };
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- Debug.Assert(true, "ConvertBack is called.");
- return new object();
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="ExDataGrid.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.Linq;
-using System.Windows;
-using System.Windows.Controls;
-using SimpleBackup.Core.Views;
-
-namespace SimpleBackup.Views
-{
- /// <summary>
- /// Ex data grid control.
- /// </summary>
- public class ExDataGrid : DataGrid
- {
- /// <summary>
- /// The selected first cell item index property key
- /// Read-Only Dependency Properties
- /// http://msdn.microsoft.com/en-us/library/ms754044(v=vs.110).aspx
- /// </summary>
- public static readonly DependencyPropertyKey SelectedFirstCellItemIndexPropertyKey =
- DependencyProperty.RegisterReadOnly(
- "SelectedFirstCellItemIndex",
- typeof(int),
- typeof(ExDataGrid),
- new PropertyMetadata(default(int)));
-
- /// <summary>
- /// The selected first cell item index property
- /// </summary>
- public static readonly DependencyProperty SelectedFirstCellItemIndexProperty =
- SelectedFirstCellItemIndexPropertyKey.DependencyProperty;
-
- /// <summary>
- /// The selected first cell item property key
- /// </summary>
- public static readonly DependencyPropertyKey SelectedFirstCellItemPropertyKey =
- DependencyProperty.RegisterReadOnly(
- "SelectedFirstCellItem",
- typeof(object),
- typeof(ExDataGrid),
- new PropertyMetadata(default(object)));
-
- /// <summary>
- /// The selected first cell item property
- /// </summary>
- public static readonly DependencyProperty SelectedFirstCellItemProperty =
- SelectedFirstCellItemPropertyKey.DependencyProperty;
-
- public ExDataGrid()
- {
- this.Loaded += (sender, args) =>
- {
- if (this.SelectedFirstCellItemChanged != null)
- {
- if (this.Items.Count != 0)
- {
- this.SelectedFirstCellItemChanged(
- this,
- new ExDataGridSelectedFirstCellItemChangedEventArgs(
- 0,
- this.Items[0]));
- }
- }
- };
- }
-
- public event EventHandler<ExDataGridSelectedFirstCellItemChangedEventArgs> SelectedFirstCellItemChanged;
-
- /// <summary>
- /// Gets the index of the selected first cell item.
- /// </summary>
- public int SelectedFirstCellItemIndex
- {
- get
- {
- return (int)this.GetValue(SelectedFirstCellItemIndexProperty);
- }
- }
-
- /// <summary>
- /// Gets the selected first cell item.
- /// </summary>
- public object SelectedFirstCellItem
- {
- get
- {
- return (object)this.GetValue(SelectedFirstCellItemProperty);
- }
- }
-
- protected override void OnSelectedCellsChanged(SelectedCellsChangedEventArgs e)
- {
- base.OnSelectedCellsChanged(e);
-
- int firstIndex = int.MaxValue;
- object firstIndexItem = null;
-
- DataGridCellInfo[] validCellInfos = this.SelectedCells.Where(p => p.IsValid).ToArray();
- foreach (DataGridCellInfo cellInfo in validCellInfos)
- {
- int index = this.Items.IndexOf(cellInfo.Item);
- if (index < firstIndex)
- {
- firstIndex = index;
- firstIndexItem = cellInfo.Item;
- }
- }
-
- if (this.SelectedFirstCellItemIndex != firstIndex)
- {
- this.SetValue(SelectedFirstCellItemIndexPropertyKey, firstIndex);
- this.SetValue(SelectedFirstCellItemPropertyKey, firstIndexItem);
-
- if (this.SelectedFirstCellItemChanged != null)
- {
- this.SelectedFirstCellItemChanged(
- this,
- new ExDataGridSelectedFirstCellItemChangedEventArgs(
- firstIndex,
- firstIndexItem));
- }
- }
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="ExDataGridSelectedFirstCellItemBehavior.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System.Windows;
-using System.Windows.Interactivity;
-using SimpleBackup.Core.Views;
-
-namespace SimpleBackup.Views
-{
- /// <summary>
- /// Behavior for ExDataGrid's SelectedFirstCellItemIndex and SelectedFirstCellItem read-only dependency properties.
- /// </summary>
- public class ExDataGridSelectedFirstCellItemBehavior : Behavior<ExDataGrid>
- {
- /// <summary>
- /// The selected first cell item index property.
- /// This wraps ExDataGrid's SelectedFirstCellItemIndex read-only dependency property.
- /// </summary>
- public static readonly DependencyProperty SelectedFirstCellItemIndexProperty =
- DependencyProperty.Register(
- "SelectedFirstCellItemIndex",
- typeof(int),
- typeof(ExDataGridSelectedFirstCellItemBehavior),
- new PropertyMetadata(default(int)));
-
- /// <summary>
- /// The selected first cell item property.
- /// This wraps ExDataGrid's SelectedFirstCellItem read-only dependency property.
- /// </summary>
- public static readonly DependencyProperty SelectedFirstCellItemProperty =
- DependencyProperty.Register(
- "SelectedFirstCellItem",
- typeof(object),
- typeof(ExDataGridSelectedFirstCellItemBehavior),
- new PropertyMetadata(default(object)));
-
- /// <summary>
- /// Gets or sets the index of the selected first cell item.
- /// </summary>
- public int SelectedFirstCellItemIndex
- {
- get { return (int)this.GetValue(SelectedFirstCellItemIndexProperty); }
- set { this.SetValue(SelectedFirstCellItemIndexProperty, value); }
- }
-
- /// <summary>
- /// Gets or sets the selected first cell item.
- /// </summary>
- public object SelectedFirstCellItem
- {
- get { return (object)this.GetValue(SelectedFirstCellItemProperty); }
- set { this.SetValue(SelectedFirstCellItemProperty, value); }
- }
-
- /// <summary>
- /// Called after the behavior is attached to an AssociatedObject.
- /// </summary>
- protected override void OnAttached()
- {
- base.OnAttached();
- this.AssociatedObject.SelectedFirstCellItemChanged += this.OnExDataGridSelectedFirstCellItemChanged;
- }
-
- /// <summary>
- /// Called when the behavior is being detached from its AssociatedObject, but before it has actually occurred.
- /// </summary>
- protected override void OnDetaching()
- {
- base.OnDetaching();
- this.AssociatedObject.SelectedFirstCellItemChanged -= this.OnExDataGridSelectedFirstCellItemChanged;
- }
-
- /// <summary>
- /// Called when ExDataGrid's SelectedFirstCellItemChanged event is published.
- /// </summary>
- /// <param name="sender">The sender.</param>
- /// <param name="e">The <see cref="ExDataGridSelectedFirstCellItemChangedEventArgs"/> instance containing the event data.</param>
- private void OnExDataGridSelectedFirstCellItemChanged(object sender, ExDataGridSelectedFirstCellItemChangedEventArgs e)
- {
- this.SelectedFirstCellItemIndex = e.SelectedFirstCellItemIndex;
- this.SelectedFirstCellItem = e.SelectedFirstCellItem;
- }
- }
-}
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="FileFolderDialog.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.IO;
-using System.Text;
-using System.Windows.Forms;
-
-namespace SimpleBackup.Views
-{
- /// <summary>
- /// File folder dialog.
- /// </summary>
- public class FileFolderDialog : CommonDialog
- {
- /// <summary>
- /// The inner open file dialog
- /// </summary>
- private readonly OpenFileDialog innerOpenFileDialog = new OpenFileDialog();
-
- /// <summary>
- /// Gets or sets the selected path.
- /// </summary>
- public string SelectedPath
- {
- get
- {
- if ((string.IsNullOrEmpty(this.innerOpenFileDialog.FileName) == false) &&
- (this.innerOpenFileDialog.FileName.EndsWith("Folder Selection.") || (File.Exists(this.innerOpenFileDialog.FileName) == false)) &&
- (Directory.Exists(this.innerOpenFileDialog.FileName) == false))
- {
- return Path.GetDirectoryName(this.innerOpenFileDialog.FileName);
- }
-
- return this.innerOpenFileDialog.FileName;
- }
-
- set
- {
- if (string.IsNullOrEmpty(value) == false)
- {
- this.innerOpenFileDialog.FileName = value;
- }
- }
- }
-
- /// <summary>
- /// Gets the selected paths as semi-colon seprated string.
- /// </summary>
- public string SelectedPaths
- {
- get
- {
- if ((this.innerOpenFileDialog.FileNames != null) && (this.innerOpenFileDialog.FileNames.Length > 1))
- {
- var sb = new StringBuilder();
- foreach (string fileName in this.innerOpenFileDialog.FileNames)
- {
- if (File.Exists(fileName))
- {
- sb.Append(fileName + ";");
- }
- }
-
- return sb.ToString();
- }
-
- return null;
- }
- }
-
- /// <summary>
- /// Runs a common dialog box with a default owner.
- /// </summary>
- /// <returns>
- /// <see cref="F:System.Windows.Forms.DialogResult.OK" /> if the user clicks OK in the dialog box; otherwise, <see cref="F:System.Windows.Forms.DialogResult.Cancel" />.
- /// </returns>
- /// <PermissionSet>
- /// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
- /// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
- /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
- /// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
- /// </PermissionSet>
- public new DialogResult ShowDialog()
- {
- return this.ShowDialog(null);
- }
-
- /// <summary>
- /// Runs a common dialog box with the specified owner.
- /// </summary>
- /// <param name="owner">Any object that implements <see cref="T:System.Windows.Forms.IWin32Window" /> that represents the top-level window that will own the modal dialog box.</param>
- /// <returns>
- /// <see cref="F:System.Windows.Forms.DialogResult.OK" /> if the user clicks OK in the dialog box; otherwise, <see cref="F:System.Windows.Forms.DialogResult.Cancel" />.
- /// </returns>
- public new DialogResult ShowDialog(IWin32Window owner)
- {
- this.innerOpenFileDialog.ValidateNames = false;
- this.innerOpenFileDialog.CheckFileExists = false;
- this.innerOpenFileDialog.CheckPathExists = true;
-
- // Set initial directory (used when dialog.FileName is set from outside)
- if (string.IsNullOrEmpty(this.innerOpenFileDialog.FileName) == false)
- {
- this.innerOpenFileDialog.InitialDirectory = Directory.Exists(this.innerOpenFileDialog.FileName)
- ? this.innerOpenFileDialog.FileName
- : Path.GetDirectoryName(this.innerOpenFileDialog.FileName);
- }
-
- // Always default to Folder Selection.
- this.innerOpenFileDialog.FileName = "Folder Selection.";
-
- return (owner == null)
- ? this.innerOpenFileDialog.ShowDialog()
- : this.innerOpenFileDialog.ShowDialog(owner);
- }
-
- /// <summary>
- /// When overridden in a derived class, resets the properties of a common dialog box to their default values.
- /// </summary>
- public override void Reset()
- {
- this.innerOpenFileDialog.Reset();
- }
-
- /// <summary>
- /// When overridden in a derived class, specifies a common dialog box.
- /// </summary>
- /// <param name="hwndOwner">A value that represents the window handle of the owner window for the common dialog box. </param>
- /// <returns>
- /// <c>true</c> if the dialog box was successfully run; otherwise, <c>false</c>.
- /// </returns>
- protected override bool RunDialog(IntPtr hwndOwner)
- {
- return true;
- }
- }
-}
+++ /dev/null
-<!--
-This file is part of Simple Backup.
-
-Simple Backup is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Simple Backup is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Foobar. If not, see <http://www.gnu.org/licenses/>.
--->
-<Window x:Class="SimpleBackup.Views.MainWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:services="clr-namespace:SimpleBackup.Services"
- xmlns:views="clr-namespace:SimpleBackup.Views"
- xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
- x:Name="RootWindow"
- Title="{Binding WindowTitle}" Height="400" Width="800" MinHeight="200" MinWidth="400"
- PreviewKeyDown="OnMainWindowPreviewKeyDown"
- Icon="/Resources/Images/ApplicationIcon.ico">
- <Window.Resources>
- <views:BackupStateToImageConverter x:Key="BackupStateToImageConverter"/>
- <views:BackupSourceTypeToImageConverter x:Key="BackupSourceTypeToImageConverter"/>
- <Style x:Key="ToolBarButtonStyle" TargetType="{x:Type Button}">
- <Setter Property="FocusVisualStyle">
- <Setter.Value>
- <Style>
- <Setter Property="Control.Template">
- <Setter.Value>
- <ControlTemplate>
- <Rectangle Margin="2" SnapsToDevicePixels="True" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </Setter.Value>
- </Setter>
- <Setter Property="Background" Value="#FFDDDDDD"/>
- <Setter Property="BorderBrush" Value="#FF707070"/>
- <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
- <Setter Property="BorderThickness" Value="1"/>
- <Setter Property="HorizontalContentAlignment" Value="Center"/>
- <Setter Property="VerticalContentAlignment" Value="Center"/>
- <Setter Property="Padding" Value="1"/>
- <Setter Property="Height" Value="20"/>
- <Setter Property="Width" Value="20"/>
- <Setter Property="ToolTipService.ShowOnDisabled" Value="True"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type Button}">
- <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
- <Grid>
- <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
- <Rectangle x:Name="disablingRectangle" Visibility="Collapsed">
- <Rectangle.Fill>
- <SolidColorBrush Color="White" Opacity="0.5"/>
- </Rectangle.Fill>
- </Rectangle>
- </Grid>
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsDefaulted" Value="True">
- <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
- </Trigger>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter Property="Background" TargetName="border" Value="#FFBEE6FD"/>
- <Setter Property="BorderBrush" TargetName="border" Value="#FF3C7FB1"/>
- </Trigger>
- <Trigger Property="IsPressed" Value="True">
- <Setter Property="Background" TargetName="border" Value="#FFC4E5F6"/>
- <Setter Property="BorderBrush" TargetName="border" Value="#FF2C628B"/>
- </Trigger>
- <Trigger Property="ToggleButton.IsChecked" Value="True">
- <Setter Property="Background" TargetName="border" Value="#FFBCDDEE"/>
- <Setter Property="BorderBrush" TargetName="border" Value="#FF245A83"/>
- </Trigger>
- <Trigger Property="IsEnabled" Value="False">
- <Setter Property="Background" TargetName="border" Value="#FFF4F4F4"/>
- <Setter Property="BorderBrush" TargetName="border" Value="#FFADB2B5"/>
- <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="#FF838383"/>
- <Setter Property="Visibility" TargetName="disablingRectangle" Value="Visible"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </Window.Resources>
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="20"/>
- <RowDefinition Height="3*" MinHeight="60"/>
- <RowDefinition Height="5"/>
- <RowDefinition Height="*" MinHeight="20"/>
- <RowDefinition Height="20"/>
- </Grid.RowDefinitions>
- <Menu Grid.Row="0">
- <MenuItem services:ResourceService.ResourceId="Views_MainMenu_File"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}">
- <MenuItem Command="{Binding CreateNewBackupSettingRelayCommand}"
- services:ResourceService.ResourceId="Views_MainMenu_New"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- <MenuItem Command="{Binding OpenBackupSettingRelayCommand}"
- services:ResourceService.ResourceId="Views_MainMenu_Open"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- <MenuItem Command="{Binding SaveBackupSettingRelayCommand}"
- services:ResourceService.ResourceId="Views_MainMenu_Save"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"
- InputGestureText="Ctrl+S"/>
- <MenuItem Command="{Binding SaveAsBackupSettingRelayCommand}"
- services:ResourceService.ResourceId="Views_MainMenu_SaveAs"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- <MenuItem Command="{Binding CloseBackupSettingRelayCommand}"
- services:ResourceService.ResourceId="Views_MainMenu_Close"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- <Separator/>
- <MenuItem Command="{Binding OpenCurrentSettingFileLocationRelayCommand}"
- services:ResourceService.ResourceId="Views_MainMenu_OpenCurrentSettingFileLocation"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- <Separator/>
- <MenuItem Command="{Binding ExitRelayCommand}"
- services:ResourceService.ResourceId="Views_MainMenu_Exit"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- </MenuItem>
- <MenuItem services:ResourceService.ResourceId="Views_MainMenu_Help"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}">
- <MenuItem Command="{Binding ShowHelpRelayCommand}"
- services:ResourceService.ResourceId="Views_MainMenu_ShowHelp"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- <Separator/>
- <MenuItem Command="{Binding ShowVersionInformationRelayCommand}"
- services:ResourceService.ResourceId="Views_MainMenu_ShowVersionInformation"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- </MenuItem>
- </Menu>
- <Grid Grid.Row="1">
- <Grid.RowDefinitions>
- <RowDefinition Height="23"/>
- <RowDefinition Height="*"/>
- </Grid.RowDefinitions>
- <StackPanel Orientation="Horizontal">
- <ToolBarTray>
- <ToolBar>
- <!-- Icon images are from VS203 Image Library http://www.microsoft.com/en-us/download/confirmation.aspx?id=35825 -->
- <Button Command="{Binding CreateNewBackupSettingRelayCommand}"
- services:ResourceService.ResourceId="Views_NewFileButtonToolTipText"
- ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"
- Style="{DynamicResource ToolBarButtonStyle}">
- <Image Source="/Resources/Images/NewFile_6276.png"/>
- </Button>
- <Button Command="{Binding OpenBackupSettingRelayCommand}"
- services:ResourceService.ResourceId="Views_OpenBackupSettingButtonToolTipText"
- ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"
- Style="{DynamicResource ToolBarButtonStyle}">
- <Image Source="/Resources/Images/Open_6529.png"/>
- </Button>
- <Button Command="{Binding SaveBackupSettingRelayCommand}"
- services:ResourceService.ResourceId="Views_SaveBackupSettingButtonToolTipText"
- ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"
- Style="{DynamicResource ToolBarButtonStyle}">
- <Image Source="/Resources/Images/save_16xLG.png"/>
- </Button>
- <Separator/>
- <Button Command="{Binding BackUpRelayCommand}"
- services:ResourceService.ResourceId="Views_MultipleBackupButtonToolTipText"
- ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"
- Style="{DynamicResource ToolBarButtonStyle}">
- <Image Source="/Resources/Images/arrow_all_run_16xLG.png"/>
- </Button>
- <Button Command="{Binding BackupCancelRelayCommand}"
- services:ResourceService.ResourceId="Views_CancelMultiBackupButtonToolTipText"
- ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"
- Style="{DynamicResource ToolBarButtonStyle}">
- <Image Source="/Resources/Images/action_Cancel_16xLG.png"/>
- </Button>
- <Separator/>
- <Button Command="{Binding SingleBackupRelayCommand}"
- services:ResourceService.ResourceId="Views_SingleBackupButtonToolTipText"
- ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"
- Style="{DynamicResource ToolBarButtonStyle}">
- <Image Source="/Resources/Images/arrow_run_16xLG.png"/>
- </Button>
- <Separator/>
- <Button Command="{Binding AddItemRelayCommand}"
- services:ResourceService.ResourceId="Views_AddButtonToolTipText"
- ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"
- Style="{DynamicResource ToolBarButtonStyle}">
- <Image Source="/Resources/Images/AddVariable_5541.png"/>
- </Button>
- <Button Command="{Binding RemoveItemRelayCommand}"
- services:ResourceService.ResourceId="Views_RemoveButtonToolTipText"
- ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"
- Style="{DynamicResource ToolBarButtonStyle}">
- <Image Source="/Resources/Images/Delete_black_32x32.png" Width="16" Height="16"/>
- </Button>
- <Separator/>
- <Button Command="{Binding MoveUpItemRelayCommand}"
- services:ResourceService.ResourceId="Views_MoveUpButtonToolTipText"
- ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"
- Style="{DynamicResource ToolBarButtonStyle}">
- <Image Source="/Resources/Images/arrow_Up_16xLG.png"/>
- </Button>
- <Button Command="{Binding MoveDownItemRelayCommand}"
- services:ResourceService.ResourceId="Views_MoveDownButtonToolTipText"
- ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"
- Style="{DynamicResource ToolBarButtonStyle}">
- <Image Source="/Resources/Images/arrow_Down_16xLG.png"/>
- </Button>
- <Separator/>
- <Button Command="{Binding CopyRelayCommand}"
- services:ResourceService.ResourceId="Views_CopyButtonToolTipText"
- ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"
- Style="{DynamicResource ToolBarButtonStyle}">
- <Image Source="/Resources/Images/Copy_6524.png"/>
- </Button>
- <Button Command="{Binding CutRelayCommand}"
- services:ResourceService.ResourceId="Views_CutButtonToolTipText"
- ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"
- Style="{DynamicResource ToolBarButtonStyle}">
- <Image Source="/Resources/Images/Cut_6523.png"/>
- </Button>
- <Button Command="{Binding PasteRelayCommand}"
- services:ResourceService.ResourceId="Views_PasteButtonToolTipText"
- ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"
- Style="{DynamicResource ToolBarButtonStyle}">
- <Image Source="/Resources/Images/Paste_6520.png"/>
- </Button>
- <Button Command="{Binding UndoRelayCommand}"
- services:ResourceService.ResourceId="Views_UndoButtonToolTipText"
- ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"
- Style="{DynamicResource ToolBarButtonStyle}">
- <Image Source="/Resources/Images/Arrow_UndoRevertRestore_16xLG.png"/>
- </Button>
- <Button Command="{Binding RedoRelayCommand}"
- services:ResourceService.ResourceId="Views_RedoButtonToolTipText"
- ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"
- Style="{DynamicResource ToolBarButtonStyle}">
- <Image Source="/Resources/Images/Arrow_RedoRetry_16xLG.png"/>
- </Button>
- <Separator/>
- <Button Command="{Binding RefreshRelayCommand}"
- services:ResourceService.ResourceId="Views_RefreshButtonToolTipText"
- ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"
- Style="{DynamicResource ToolBarButtonStyle}">
- <Image Source="/Resources/Images/refresh_16xLG.png"/>
- </Button>
- <Separator/>
- <TextBlock services:ResourceService.ResourceId="Views_ZipEncodingTitleText"
- Text="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- <ComboBox IsEditable="False" MinWidth="80" Margin="5,0,0,0"
- ItemsSource="{Binding ZipEncodings}" SelectionChanged="OnZipEncodingSelectionChanged"
- SelectedItem="{Binding SelectedEncodingInfoItem}"
- DisplayMemberPath="EncodingDisplayName"/>
- </ToolBar>
- </ToolBarTray>
- </StackPanel>
- <views:ExDataGrid x:Name="BackupInfoDataGrid"
- Grid.Row="1" ItemsSource="{Binding BackupInfoViewModels}" AlternatingRowBackground="AliceBlue" AlternationCount="2" AutoGenerateColumns="False"
- MouseDoubleClick="OnDataGridMouseDoubleClick"
- SelectedItem="{Binding SelectedBackupInfoViewModel, Mode=TwoWay}"
- SelectionMode="Extended"
- SelectionUnit="CellOrRowHeader"
- RowHeaderWidth="20">
- <views:ExDataGrid.Resources>
- <Style TargetType="{x:Type DataGridRow}">
- <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
- <Setter Property="SnapsToDevicePixels" Value="True"/>
- <Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
- <Setter Property="ValidationErrorTemplate">
- <Setter.Value>
- <ControlTemplate>
- <TextBlock Foreground="Red" Margin="2,0,0,0" Text="!" VerticalAlignment="Center"><Run Text="!"/></TextBlock>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type DataGridRow}">
- <Grid>
- <Border x:Name="DGR_Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
- <SelectiveScrollingGrid>
- <SelectiveScrollingGrid.ColumnDefinitions>
- <ColumnDefinition Width="Auto"/>
- <ColumnDefinition Width="*"/>
- </SelectiveScrollingGrid.ColumnDefinitions>
- <SelectiveScrollingGrid.RowDefinitions>
- <RowDefinition Height="*"/>
- <RowDefinition Height="Auto"/>
- </SelectiveScrollingGrid.RowDefinitions>
- <DataGridCellsPresenter Grid.Column="1" ItemsPanel="{TemplateBinding ItemsPanel}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
- <DataGridDetailsPresenter Grid.Column="1" Grid.Row="1" Visibility="{TemplateBinding DetailsVisibility}">
- <SelectiveScrollingGrid.SelectiveScrollingOrientation>
- <Binding Path="AreRowDetailsFrozen" RelativeSource="{RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type DataGrid}}">
- <Binding.ConverterParameter>
- <SelectiveScrollingOrientation>Vertical</SelectiveScrollingOrientation>
- </Binding.ConverterParameter>
- </Binding>
- </SelectiveScrollingGrid.SelectiveScrollingOrientation>
- </DataGridDetailsPresenter>
- <DataGridRowHeader Grid.RowSpan="2" SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical">
- <DataGridRowHeader.Visibility>
- <Binding Path="HeadersVisibility" RelativeSource="{RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type DataGrid}}">
- <Binding.ConverterParameter>
- <DataGridHeadersVisibility>Row</DataGridHeadersVisibility>
- </Binding.ConverterParameter>
- </Binding>
- </DataGridRowHeader.Visibility>
- </DataGridRowHeader>
- </SelectiveScrollingGrid>
- </Border>
- <Rectangle x:Name="CutReservingRectangle" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Fill="Transparent"
- Stroke="Coral" StrokeThickness="2" StrokeDashArray="2 2" Visibility="Collapsed"
- IsHitTestVisible="False"/>
- </Grid>
- <ControlTemplate.Triggers>
- <DataTrigger Binding="{Binding IsCutReserved}" Value="True">
- <Setter TargetName="CutReservingRectangle" Property="Visibility" Value="Visible"/>
- </DataTrigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- <Style.Triggers>
- <Trigger Property="IsNewItem" Value="True">
- <Setter Property="Margin" Value="{Binding NewItemMargin, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type DataGrid}}}"/>
- </Trigger>
- </Style.Triggers>
- </Style>
- </views:ExDataGrid.Resources>
- <!-- Using behaviours to bind to read-only properties in MVVM -->
- <!-- http://blog.magnusmontin.net/2014/01/30/wpf-using-behaviours-to-bind-to-readonly-properties-in-mvvm/ -->
- <i:Interaction.Behaviors>
- <views:ExDataGridSelectedFirstCellItemBehavior
- SelectedFirstCellItemIndex="{Binding SelectedFirstCellItemIndex, Mode=OneWayToSource}"
- SelectedFirstCellItem="{Binding SelectedFirstCellItem, Mode=OneWayToSource}"/>
- </i:Interaction.Behaviors>
- <DataGrid.Columns>
- <!-- Backup State Column -->
- <DataGridTemplateColumn>
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <ContentControl Width="16" Height="16" Content="{Binding BackupState, Mode=OneWay, Converter={StaticResource BackupStateToImageConverter}}"/>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <!-- IsEnabled Column -->
- <DataGridTemplateColumn>
- <DataGridTemplateColumn.HeaderTemplate>
- <DataTemplate>
- <Image Source="/Resources/Images/arrow_all_run_16xLG.png"/>
- </DataTemplate>
- </DataGridTemplateColumn.HeaderTemplate>
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <CheckBox IsChecked="{Binding IsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
- HorizontalAlignment="Center"
- PreviewKeyDown="OnCellContentPreviewKeyDown"/>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <!-- IsZipArchive Column -->
- <DataGridTemplateColumn>
- <DataGridTemplateColumn.Header>
- <ContentPresenter Content="{Binding DataContext.IsZipArchiveColumnHeaderViewModel,
- RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
- </DataGridTemplateColumn.Header>
- <DataGridTemplateColumn.HeaderTemplate>
- <DataTemplate>
- <TextBlock Text="{Binding Content.Header}"/>
- </DataTemplate>
- </DataGridTemplateColumn.HeaderTemplate>
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <CheckBox IsChecked="{Binding IsZipArchive, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
- HorizontalAlignment="Center"
- PreviewKeyDown="OnCellContentPreviewKeyDown"/>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <!-- Label Column -->
- <DataGridTemplateColumn>
- <!-- Binding of DataGrid Column Header -->
- <!-- http://social.technet.microsoft.com/wiki/contents/articles/22012.binding-of-datagrid-column-header.aspx -->
- <DataGridTemplateColumn.Header>
- <ContentPresenter Content="{Binding DataContext.LabelColumnHeaderViewModel,
- RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
- </DataGridTemplateColumn.Header>
- <DataGridTemplateColumn.HeaderTemplate>
- <DataTemplate>
- <TextBlock Text="{Binding Content.Header}"/>
- </DataTemplate>
- </DataGridTemplateColumn.HeaderTemplate>
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <TextBox Text="{Binding Label, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"
- PreviewKeyDown="OnCellContentPreviewKeyDown"/>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <!-- Backup Source Type Column -->
- <DataGridTemplateColumn>
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <ContentControl Width="16" Height="16" Content="{Binding SourceType, Mode=OneWay, Converter={StaticResource BackupSourceTypeToImageConverter}}"/>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <!-- SourcePath Column -->
- <DataGridTemplateColumn Width="300">
- <!-- Binding of DataGrid Column Header -->
- <!-- http://social.technet.microsoft.com/wiki/contents/articles/22012.binding-of-datagrid-column-header.aspx -->
- <DataGridTemplateColumn.Header>
- <ContentPresenter Content="{Binding DataContext.SourceColumnHeaderViewModel,
- RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
- </DataGridTemplateColumn.Header>
- <DataGridTemplateColumn.HeaderTemplate>
- <DataTemplate>
- <TextBlock Text="{Binding Content.Header}"/>
- </DataTemplate>
- </DataGridTemplateColumn.HeaderTemplate>
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <Grid>
- <TextBlock x:Name="SourceTextBlock" Text="{Binding DisplaySourcePath, Mode=OneWay}" ToolTip="{Binding SourceToolTipText}">
- <TextBlock.ContextMenu>
- <ContextMenu>
- <MenuItem Command="{Binding SingleBackupRelayCommand}"
- services:ResourceService.ResourceId="Views_ContextMenu_Backup"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- <Separator/>
- <MenuItem Command="{Binding OpenSourceFileRelayCommand}"
- services:ResourceService.ResourceId="Views_ContextMenu_OpenFile"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- <MenuItem Command="{Binding OpenSourceFolderRelayCommand}"
- services:ResourceService.ResourceId="Views_ContextMenu_OpenSourceFolder"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- <Separator/>
- <MenuItem Command="{Binding SelectSourceRelayCommand}"
- services:ResourceService.ResourceId="Views_ContextMenu_SelectSource"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- <MenuItem Command="{Binding EditSourceRelayCommand}"
- services:ResourceService.ResourceId="Views_ContextMenu_Edit"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- </ContextMenu>
- </TextBlock.ContextMenu>
- <TextBlock.Style>
- <Style TargetType="TextBlock">
- <Style.Triggers>
- <DataTrigger Binding="{Binding HasSourcePathError}" Value="true">
- <Setter Property="Foreground" Value="Red"/>
- </DataTrigger>
- </Style.Triggers>
- </Style>
- </TextBlock.Style>
- </TextBlock>
- <TextBox x:Name="SourceTextBox" Text="{Binding EditingSourcePath, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"
- Visibility="Collapsed" PreviewKeyDown="OnCellContentPreviewKeyDown"/>
- </Grid>
-
- <!-- DataTemplate.Triggers-->
- <!-- http://msdn.microsoft.com/ja-jp/library/system.windows.datatemplate.triggers%28v=vs.110%29.aspx -->
- <DataTemplate.Triggers>
- <DataTrigger Binding="{Binding IsSourceEditing}" Value="True">
- <Setter TargetName="SourceTextBlock" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="SourceTextBox" Property="Visibility" Value="Visible"/>
- </DataTrigger>
- </DataTemplate.Triggers>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <!-- DestinationFolderPath Column -->
- <DataGridTemplateColumn Width="300">
- <DataGridTemplateColumn.Header>
- <ContentPresenter Content="{Binding DataContext.DestinationColumnHeaderViewModel,
- RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
- </DataGridTemplateColumn.Header>
- <DataGridTemplateColumn.HeaderTemplate>
- <DataTemplate>
- <TextBlock Text="{Binding Content.Header}"/>
- </DataTemplate>
- </DataGridTemplateColumn.HeaderTemplate>
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <Grid>
- <TextBlock x:Name="DestinationTextBlock" Text="{Binding DisplayDestinationFolderPath, Mode=OneWay}" ToolTip="{Binding DestinationToolTipText}">
- <TextBlock.ContextMenu>
- <ContextMenu>
- <MenuItem Command="{Binding SingleBackupRelayCommand}"
- services:ResourceService.ResourceId="Views_ContextMenu_Backup"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- <Separator/>
- <MenuItem Command="{Binding OpenDestinationFolderRelayCommand}"
- services:ResourceService.ResourceId="Views_ContextMenu_OpenDestination"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- <Separator/>
- <MenuItem Command="{Binding SelectDestinationRelayCommand}"
- services:ResourceService.ResourceId="Views_ContextMenu_SelectDestination"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- <MenuItem Command="{Binding EditDestinationRelayCommand}"
- services:ResourceService.ResourceId="Views_ContextMenu_Edit"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- </ContextMenu>
- </TextBlock.ContextMenu>
- <TextBlock.Style>
- <Style TargetType="TextBlock">
- <Style.Triggers>
- <DataTrigger Binding="{Binding HasDestinationFolderPathError}" Value="true">
- <Setter Property="Foreground" Value="Red"/>
- </DataTrigger>
- </Style.Triggers>
- </Style>
- </TextBlock.Style>
- </TextBlock>
- <TextBox x:Name="DestinationTextBox" Text="{Binding EditingDestinationPath, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"
- Visibility="Collapsed" PreviewKeyDown="OnCellContentPreviewKeyDown"/>
- </Grid>
- <DataTemplate.Triggers>
- <DataTrigger Binding="{Binding IsDestinationEditing}" Value="True">
- <Setter TargetName="DestinationTextBlock" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="DestinationTextBox" Property="Visibility" Value="Visible"/>
- </DataTrigger>
- </DataTemplate.Triggers>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- </DataGrid.Columns>
- </views:ExDataGrid>
- </Grid>
- <GridSplitter Grid.Row="2" Height="5" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
- <ScrollViewer Grid.Row="3" HorizontalScrollBarVisibility="Auto">
- <TextBox IsReadOnly="True" Text="{Binding OutputMessage}">
- <TextBox.ContextMenu>
- <ContextMenu>
- <MenuItem Command="{Binding ClearOutputWindowRelayCommand}"
- services:ResourceService.ResourceId="Views_OutputWindowContextMenu_Clear"
- Header="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}"/>
- </ContextMenu>
- </TextBox.ContextMenu>
- </TextBox>
- </ScrollViewer>
- <ToolBar Grid.Row="4">
- <ProgressBar Width="100" Value="{Binding ProgressViewModel.ProgressValue}"/>
- </ToolBar>
- </Grid>
-</Window>
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="MainWindow.xaml.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-using System.ComponentModel;
-using System.Linq;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Controls.Primitives;
-using System.Windows.Input;
-using SimpleBackup.Core.Utilities;
-using SimpleBackup.Core.ViewModels;
-using SimpleBackup.Core.Views;
-using SimpleBackup.Services;
-using SimpleBackup.ViewModels;
-
-namespace SimpleBackup.Views
-{
- using Application = System.Windows.Application;
- using DataGrid = System.Windows.Controls.DataGrid;
- using DataGridCell = System.Windows.Controls.DataGridCell;
- using KeyEventArgs = System.Windows.Input.KeyEventArgs;
- using MessageBox = System.Windows.MessageBox;
- using TextBox = System.Windows.Controls.TextBox;
-
- /// <summary>
- /// Code-Behind of MainWindow.xaml.
- /// </summary>
- public partial class MainWindow : Window, IMainWindow
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="MainWindow"/> class.
- /// </summary>
- public MainWindow()
- {
- this.InitializeComponent();
-
- this.DataContextChanged += (sender, args) =>
- {
- var viewModel = this.DataContext as IMainWindowViewModel;
- if (viewModel != null)
- {
- viewModel.FocusOnGrid += this.OnFocusOnGridRequired;
- viewModel.FocusOnGridRow += this.OnFocusOnGridRowRequired;
- }
- else
- {
- throw new InvalidOperationException("The data context is not an IMainWindowViewModel object.");
- }
- };
-
- this.BackupInfoDataGrid.Loaded += (sender, args) =>
- {
- if (this.BackupInfoDataGrid.Items.Count != 0)
- {
- this.FocusOnGridRow(0);
- }
- };
- }
-
- /// <summary>
- /// Raises the Closing event.
- /// </summary>
- /// <param name="e">A <see cref="T:System.ComponentModel.CancelEventArgs" /> that contains the event data.</param>
- protected override void OnClosing(CancelEventArgs e)
- {
- if ((BackupSettingService.Instance.CurrentSetting != null) &&
- BackupSettingService.Instance.CurrentSetting.Modified)
- {
- MessageBoxResult confirmationResult = MessageBox.Show(
- Application.Current.MainWindow,
- SimpleBackup.Resources.Resources.Views_SaveConfirmationMessage,
- SimpleBackup.Resources.Resources.Views_ConfirmationDialogTitle,
- MessageBoxButton.YesNoCancel);
- if (confirmationResult == MessageBoxResult.Yes)
- {
- if (BackupSettingService.Instance.OverWriteCurrntBackupSetting() == false)
- {
- e.Cancel = true;
- }
- }
- else if (confirmationResult == MessageBoxResult.Cancel)
- {
- e.Cancel = true;
- }
- }
- }
-
- private void OnFocusOnGridRequired(object sender, EventArgs eventArgs)
- {
- this.BackupInfoDataGrid.Focus();
- }
-
- private void OnFocusOnGridRowRequired(object sender, FocusOnGridRowEventArgs args)
- {
- this.FocusOnGridRow(args.Index);
- }
-
- private void FocusOnGridRow(int index)
- {
- this.BackupInfoDataGrid.Focus();
- var dataGridRow = this.BackupInfoDataGrid.ItemContainerGenerator.ContainerFromIndex(index) as DataGridRow;
- if (dataGridRow != null)
- {
- dataGridRow.Focus();
- this.SelectBackupInfoDataGridItem(index);
-
- var dataGridCellsPanel = dataGridRow.GetVisualChild<DataGridCellsPanel>();
- if (dataGridCellsPanel != null)
- {
- if (dataGridCellsPanel.Children.Count != 0)
- {
- var dataGridCell = dataGridCellsPanel.Children[0] as DataGridCell;
- if (dataGridCell != null)
- {
- dataGridCell.Focus();
- }
- }
- }
- }
- }
-
- private void SelectBackupInfoDataGridItem(int index)
- {
- this.BackupInfoDataGrid.SelectedIndex = index;
- }
-
- private void OnDataGridMouseDoubleClick(object sender, MouseButtonEventArgs e)
- {
- var dataGrid = (DataGrid)sender;
- var currentItemviewModel = dataGrid.CurrentItem as BackupInfoViewModel;
- if (currentItemviewModel == null)
- {
- return;
- }
-
- DataGridCellInfo currentCellInfo = dataGrid.CurrentCell;
- var currentColumnHeaderContentPresenter = currentCellInfo.Column.Header as ContentPresenter;
- if (currentColumnHeaderContentPresenter != null)
- {
- var sourceColumnHeaderViewModel =
- currentColumnHeaderContentPresenter.Content as SourceColumnHeaderViewModel;
- if (sourceColumnHeaderViewModel != null)
- {
- currentItemviewModel.ExecuteDoubleClickAction(BackupInfoPathType.Source);
- }
- else
- {
- var destinationColumnHeaderViewModel =
- currentColumnHeaderContentPresenter.Content as DestinationColumnHeaderViewModel;
- if (destinationColumnHeaderViewModel != null)
- {
- currentItemviewModel.ExecuteDoubleClickAction(BackupInfoPathType.Destination);
- }
- }
- }
- }
-
- private void OnCellContentPreviewKeyDown(object sender, KeyEventArgs e)
- {
- Type sourceType = sender.GetType();
-
- var sourceDataGridCell = ((DependencyObject)sender).SearchUpParentWithSelf<DataGridCell>();
- if (sourceDataGridCell == null)
- {
- return;
- }
-
- var sourceDataGridRow = sourceDataGridCell.SearchUpParentWithSelf<DataGridRow>();
- if (sourceDataGridRow == null)
- {
- return;
- }
-
- var dataGrid = sourceDataGridRow.SearchUpParentWithSelf<DataGrid>();
- if (dataGrid == null)
- {
- return;
- }
-
- int sourceRowIndex = dataGrid.Items.IndexOf(sourceDataGridRow.Item);
- int targetRowIndex = -1;
- switch (e.Key)
- {
- case Key.Up:
- if (sourceRowIndex != 0)
- {
- targetRowIndex = sourceRowIndex - 1;
- }
-
- break;
- case Key.Down:
- if (sourceRowIndex < dataGrid.Items.Count - 1)
- {
- targetRowIndex = sourceRowIndex + 1;
- }
-
- break;
- case Key.PageUp:
- break;
- case Key.PageDown:
- break;
- }
-
- if (targetRowIndex < 0)
- {
- return;
- }
-
- var targetDataGridRow = dataGrid.ItemContainerGenerator.ContainerFromIndex(targetRowIndex) as DataGridRow;
- if (targetDataGridRow == null)
- {
- return;
- }
-
- var targetCellsPresenter = targetDataGridRow.GetVisualChild<DataGridCellsPresenter>();
- if (targetCellsPresenter == null)
- {
- return;
- }
-
- var targetDataGridCell =
- (DataGridCell)targetCellsPresenter.ItemContainerGenerator.ContainerFromIndex(sourceDataGridCell.Column.DisplayIndex);
- if (targetDataGridCell == null)
- {
- return;
- }
-
- var targetElement = targetDataGridCell.GetVisualChild(sourceType) as UIElement;
- if (targetElement == null)
- {
- return;
- }
-
- sourceDataGridRow.IsSelected = false;
- targetDataGridRow.IsSelected = true;
- targetElement.Focus();
-
- e.Handled = true;
- }
-
- private void OnMainWindowPreviewKeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.F2)
- {
- this.StartEditCurrentCell();
- e.Handled = true;
- }
- else if (e.Key == Key.Escape)
- {
- var viewModel = this.DataContext as IMainWindowViewModel;
- if (viewModel != null)
- {
- viewModel.OnEscKeyPressed();
- }
-
- e.Handled = true;
- }
- else if ((Keyboard.Modifiers & ModifierKeys.Control) > 0)
- {
- if (e.Key == Key.S)
- {
- var viewModel = this.DataContext as IMainWindowViewModel;
- if (viewModel != null)
- {
- if (viewModel.SaveBackupSettingRelayCommand.CanExecute(this))
- {
- viewModel.SaveBackupSettingRelayCommand.Execute(this);
- e.Handled = true;
- }
- }
- }
- }
- }
-
- private void StartEditCurrentCell()
- {
- var currentItemviewModel = this.BackupInfoDataGrid.CurrentItem as BackupInfoViewModel;
- if (currentItemviewModel == null)
- {
- return;
- }
-
- DataGridCellInfo currentCellInfo = this.BackupInfoDataGrid.CurrentCell;
- var currentColumnHeaderContentPresenter = currentCellInfo.Column.Header as ContentPresenter;
- if (currentColumnHeaderContentPresenter != null)
- {
- if (currentColumnHeaderContentPresenter.Content is SourceColumnHeaderViewModel)
- {
- currentItemviewModel.EditSourceRelayCommand.Execute(null);
- this.FocusOnTextBoxInSelectedDataGridCell();
- }
- else if (currentColumnHeaderContentPresenter.Content is DestinationColumnHeaderViewModel)
- {
- currentItemviewModel.EditDestinationRelayCommand.Execute(null);
- this.FocusOnTextBoxInSelectedDataGridCell();
- }
- else if (currentColumnHeaderContentPresenter.Content is LabelColumnHeaderViewModel)
- {
- this.FocusOnTextBoxInSelectedDataGridCell();
- }
- }
- }
-
- private void FocusOnTextBoxInSelectedDataGridCell()
- {
- DataGridCellInfo cellInfo = this.BackupInfoDataGrid.SelectedCells.FirstOrDefault();
- var cellContentPresenter = cellInfo.Column.GetCellContent(cellInfo.Item) as ContentPresenter;
- if (cellContentPresenter != null)
- {
- var textBox = cellContentPresenter.GetVisualChild<TextBox>();
- if (textBox != null)
- {
- textBox.Focus();
- textBox.Select(textBox.Text.Length, 0);
- }
- }
- }
-
- private void OnZipEncodingSelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- // Move focus setting from the ComboBox by setting focus to the main window.
- this.Focus();
- }
- }
-}
+++ /dev/null
-<!--
-This file is part of Simple Backup.
-
-Simple Backup is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Simple Backup is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Foobar. If not, see <http://www.gnu.org/licenses/>.
--->
-<Window x:Class="SimpleBackup.Views.VersionInformationWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:services="clr-namespace:SimpleBackup.Services"
- Height="200" Width="350" ResizeMode="NoResize"
- Icon="/Resources/Images/ApplicationIcon.ico"
- services:ResourceService.ResourceId="Views_VersionWindowTitle"
- Title="{Binding RelativeSource={RelativeSource Self}, Path=(services:ResourceService.ResourceText)}">
- <Window.Resources>
- <Style x:Key="VersionInfoTextBoxStyle" TargetType="{x:Type TextBox}">
- <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
- <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
- <Setter Property="BorderThickness" Value="1"/>
- <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
- <Setter Property="HorizontalContentAlignment" Value="Left"/>
- <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
- <Setter Property="AllowDrop" Value="True"/>
- <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
- <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type TextBox}">
- <ScrollViewer x:Name="PART_ContentHost" Focusable="False" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- <Style.Triggers>
- <MultiTrigger>
- <MultiTrigger.Conditions>
- <Condition Property="IsInactiveSelectionHighlightEnabled" Value="True"/>
- <Condition Property="IsSelectionActive" Value="False"/>
- </MultiTrigger.Conditions>
- <Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}"/>
- </MultiTrigger>
- </Style.Triggers>
- </Style>
- </Window.Resources>
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto"/>
- <RowDefinition/>
- </Grid.RowDefinitions>
- <TextBox Grid.Row="0" x:Name="VersionInfoTextBox" IsReadOnly="True" Style="{DynamicResource VersionInfoTextBoxStyle}" Margin="5,15,5,10" TextWrapping="Wrap"/>
- <ScrollViewer Grid.Row="1" Margin="5">
- <TextBox x:Name="CopyrightTextBox" IsReadOnly="True" Style="{DynamicResource VersionInfoTextBoxStyle}" TextWrapping="Wrap"/>
- </ScrollViewer>
- </Grid>
-</Window>
+++ /dev/null
-//-----------------------------------------------------------------------
-// <copyright file="VersionInformationWindow.xaml.cs" company="Takayoshi Matsuyama">
-// Copyright (c) Takayoshi Matsuyama. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-// This file is part of Simple Backup.
-//
-// Simple Backup is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Simple Backup is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
-
-using System.Reflection;
-using System.Windows;
-
-namespace SimpleBackup.Views
-{
- /// <summary>
- /// Code-Behind of VersionInformationWindow.xaml.
- /// </summary>
- public partial class VersionInformationWindow : Window
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="VersionInformationWindow"/> class.
- /// </summary>
- public VersionInformationWindow()
- {
- this.InitializeComponent();
-
- this.VersionInfoTextBox.Text = string.Format(
- "{0} Ver.{1}\r\n{2}",
- SimpleBackup.Resources.Resources.Views_CopyrightApplicationName,
- Assembly.GetExecutingAssembly().GetName().Version,
- SimpleBackup.Resources.Resources.Version_Copyright);
- this.CopyrightTextBox.Text = SimpleBackup.Resources.Resources.Version_CopyrightDescription;
- }
- }
-}