///
/// Nanotec Nanolib example
/// Copyright (C) Nanotec GmbH & Co. KG - All Rights Reserved
///
/// This product includes software developed by the
/// Nanotec GmbH & Co. KG (http://www.nanotec.com/).
///
/// The Nanolib interface headers and the examples source code provided are 
/// licensed under the Creative Commons Attribution 4.0 Internaltional License. 
/// To view a copy of this license, 
/// visit https://creativecommons.org/licenses/by/4.0/ or send a letter to 
/// Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
///
/// The parts of the library provided in binary format are licensed under 
/// the Creative Commons Attribution-NoDerivatives 4.0 International License. 
/// To view a copy of this license, 
/// visit http://creativecommons.org/licenses/by-nd/4.0/ or send a letter to 
/// Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
///
/// 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. 
///
/// <file_name>DataTransferCallbackExample.cs</file_name>
///
/// <summary>Definition of data transfer callback class</summary>
///
/// <date>29-10-2024</date>
///
/// <author>Michael Milbradt<author>
///

using Nlc;

namespace NanolibExample
{
    /// <summary>
    /// Implementation class of NlcDataTransferCallback, handling the data transfer callback
    /// </summary>
    public class DataTransferCallbackExample : NlcDataTransferCallback
    {
        /// <summary>
        /// Gets called during data transfer
        /// </summary>
        /// <param name="info">state of data transfer</param>
        /// <param name="data">progress of data transfer (0-100)</param>
        /// <returns>returns ResultVoid with error if error occurred</returns>
        public override ResultVoid callback(DataTransferInfo info, int data)
        {
            switch (info)
            {
                case DataTransferInfo.Init:
                    // do nothing
                    break;
                case DataTransferInfo.FileOpen:
                    Console.WriteLine("Transfer started ...");
                    break;
                case DataTransferInfo.Finished:
                    Console.WriteLine("Transfer finished ...");
                    break;
                case DataTransferInfo.Progress:
                    if ((data & 1) == 0) // data holds transfer progress
                    {
                        Console.Write(".");
                    }
                    break;
                case DataTransferInfo.Reboot:
                    Console.WriteLine("Rebooting ...");
                    break;
            }

            return new ResultVoid();
        }
    }
}
