Exemplo n.º 1
0
        public static async Task <CommandModelBase> ImportCommandFromFile()
        {
            string fileName = ChannelSession.Services.FileService.ShowOpenFileDialog(string.Format("Mix It Up Command (*{0})|*{0},*{1}|All files (*.*)|*.*", MixItUpCommandFileExtension, MixItUpOldCommandFileExtension));

            if (!string.IsNullOrEmpty(fileName))
            {
                if (Path.GetExtension(fileName).Equals(MixItUpOldCommandFileExtension))
                {
#pragma warning disable CS0612 // Type or member is obsolete
                    MixItUp.Base.Commands.CommandBase command = await FileSerializerHelper.DeserializeFromFile <MixItUp.Base.Commands.CommandBase>(fileName);

                    ActionGroupCommandModel actionGroup = new ActionGroupCommandModel(command.Name, false);
                    foreach (MixItUp.Base.Actions.ActionBase action in command.Actions)
                    {
                        actionGroup.Actions.AddRange(ActionModelBase.UpgradeAction(action));
                    }
                    return(actionGroup);

#pragma warning restore CS0612 // Type or member is obsolete
                }
                else
                {
                    return(await FileSerializerHelper.DeserializeFromFile <CommandModelBase>(fileName));
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        public static async Task <T> ImportCommandFromFile <T>(string filePath) where T : CommandModelBase
        {
            if (!string.IsNullOrEmpty(filePath))
            {
                if (Path.GetExtension(filePath).Equals(MixItUpOldCommandFileExtension))
                {
#pragma warning disable CS0612 // Type or member is obsolete
                    MixItUp.Base.Commands.CommandBase command = await FileSerializerHelper.DeserializeFromFile <MixItUp.Base.Commands.CommandBase>(filePath);

                    ActionGroupCommandModel actionGroup = new ActionGroupCommandModel(command.Name, false);
                    foreach (MixItUp.Base.Actions.ActionBase action in command.Actions)
                    {
                        actionGroup.Actions.AddRange(ActionModelBase.UpgradeAction(action));
                    }
                    return(actionGroup as T);

#pragma warning restore CS0612 // Type or member is obsolete
                }
                else
                {
                    return(await FileSerializerHelper.DeserializeFromFile <T>(filePath));
                }
            }
            return(null);
        }
        private void CommandButtons_EditClicked(object sender, RoutedEventArgs e)
        {
            ActionGroupCommandModel command = ((CommandListingButtonsControl)sender).GetCommandFromCommandButtons <ActionGroupCommandModel>();

            if (command != null)
            {
                CommandEditorWindow window = CommandEditorWindow.GetCommandEditorWindow(command);
                window.CommandSaved += Window_CommandSaved;
                window.ForceShow();
            }
        }
 private async void CommandButtons_DeleteClicked(object sender, RoutedEventArgs e)
 {
     await this.Window.RunAsyncOperation(async() =>
     {
         ActionGroupCommandModel command = ((CommandListingButtonsControl)sender).GetCommandFromCommandButtons <ActionGroupCommandModel>();
         if (command != null)
         {
             ChannelSession.Services.Command.ActionGroupCommands.Remove(command);
             ChannelSession.Settings.RemoveCommand(command);
             this.viewModel.RemoveCommand(command);
             await ChannelSession.SaveSettings();
         }
     });
 }
 public ActionGroupCommandEditorWindowViewModel(ActionGroupCommandModel existingCommand)
     : base(existingCommand)
 {
     this.RunOneRandomly = existingCommand.RunOneRandomly;
 }