123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using System;
- using System.Windows.Input;
- namespace FastReport.Design
- {
- public partial class WpfDesignerControl
- {
- /// <summary>
- /// Represents a designer command.
- /// </summary>
- public class DesignerCommand : ICommand
- {
- internal FastReport.Design.DesignerCommand InnerCommand { get; }
- private bool lastEnabledState;
- /// <inheritdoc/>
- public event EventHandler CanExecuteChanged;
- /// <inheritdoc/>
- public bool CanExecute(object parameter) => InnerCommand.Enabled;
- /// <inheritdoc/>
- public void Execute(object parameter) => InnerCommand.Invoke();
- private void Designer_UIStateChanged(object sender, EventArgs e)
- {
- bool newEnabledState = InnerCommand.Enabled;
- if (newEnabledState != lastEnabledState)
- {
- lastEnabledState = newEnabledState;
- CanExecuteChanged?.Invoke(this, EventArgs.Empty);
- }
- }
- internal DesignerCommand(WpfDesignerControl designer, Design.DesignerCommand innerCommand)
- {
- InnerCommand = innerCommand;
- designer.UIStateChanged += Designer_UIStateChanged;
- }
- }
- /// <summary>
- /// Represents a designer "Open" command.
- /// </summary>
- public class OpenCommand : DesignerCommand
- {
- /// <summary>
- /// Loads a specified report file.
- /// </summary>
- /// <param name="fileName">File to load.</param>
- /// <param name="silent">true to suppress message dialog if load is failed.</param>
- public void LoadFile(string fileName, bool silent = false) => (InnerCommand as Design.OpenCommand).LoadFile(fileName, silent);
- internal OpenCommand(WpfDesignerControl designer, Design.OpenCommand innerCommand) : base(designer, innerCommand) { }
- }
- /// <summary>
- /// Represents a designer "Recent Files" command.
- /// </summary>
- public class RecentFilesCommand : DesignerCommand
- {
- /// <summary>
- /// Returns true if the file specified is a cloud file.
- /// </summary>
- /// <param name="fileName">File name to check.</param>
- /// <returns>true if file is a cloud file.</returns>
- public bool IsCloudFile(string fileName) => (InnerCommand as Design.RecentFilesCommand).IsCloudFile(fileName);
- /// <summary>
- /// Opens a recent file with specified name either from local PC or from cloud.
- /// </summary>
- /// <param name="fileName">File name to open.</param>
- public void LoadFile(string fileName) => (InnerCommand as Design.RecentFilesCommand).LoadFile(fileName);
- internal RecentFilesCommand(WpfDesignerControl designer, Design.RecentFilesCommand innerCommand) : base(designer, innerCommand) { }
- }
- }
- }
|