aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/SideChains/MaterialDesignInXamlToolkit-master/MaterialDesignThemes.Wpf/Transitions/TransitionEffectKind.cs
blob: 60b5721ba152b031e6549e58675a1f38390c7620 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
namespace MaterialDesignThemes.Wpf.Transitions
{
    public enum TransitionEffectKind
    {
        None,        
        ExpandIn,
        FadeIn,
        SlideInFromLeft,
        SlideInFromTop,
        SlideInFromRight,
        SlideInFromBottom
    }
}
eral.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core;
using Tango.Core.Components;
using Tango.PPC.Common.Application;
using Tango.PPC.Common.Connection;
using Tango.Settings;

namespace Tango.PPC.Common.HotSpot
{
    /// <summary>
    /// Represents the default hot spot provider.
    /// </summary>
    /// <seealso cref="Tango.Core.ExtendedObject" />
    /// <seealso cref="Tango.PPC.Common.HotSpot.IHotSpotProvider" />
    public class DefaultHotSpotProvider : ExtendedObject, IHotSpotProvider
    {
        private IMachineProvider _machineProvider;

        private bool _isEnabled;
        /// <summary>
        /// Gets a value indicating whether the hot spot network is active.
        /// </summary>
        public bool IsEnabled
        {
            get { return _isEnabled; }
            private set { _isEnabled = value; RaisePropertyChangedAuto(); }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultHotSpotProvider"/> class.
        /// </summary>
        /// <param name="applicationManager">The application manager.</param>
        /// <param name="machineProvider">The machine provider.</param>
        public DefaultHotSpotProvider(IPPCApplicationManager applicationManager, IMachineProvider machineProvider)
        {
            _machineProvider = machineProvider;
            applicationManager.ApplicationReady += ApplicationManager_ApplicationReady;
        }

        /// <summary>
        /// Handles the ApplicationReady event of the ApplicationManager.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void ApplicationManager_ApplicationReady(object sender, EventArgs e)
        {
            Task.Factory.StartNew(async () =>
            {
                var settings = SettingsManager.Default.GetOrCreate<PPCSettings>();

                if (settings.EnableHotSpot)
                {
                    try
                    {
                        await EnableHotSpot(settings.HotSpotPassword);
                    }
                    catch (Exception ex)
                    {
                        LogManager.Log(ex, "Error starting on application startup.");
                    }
                }
            });
        }

        /// <summary>
        /// Enables the hot spot.
        /// </summary>
        /// <param name="password">The password.</param>
        /// <returns></returns>
        public async Task EnableHotSpot(string password)
        {
            if (!IsEnabled)
            {
                try
                {
                    CmdCommand command = new CmdCommand("netsh", $"wlan set hostednetwork mode=allow ssid={"Tango-" + _machineProvider.Machine.SerialNumber} key={password}");
                    await command.Run();

                    command = new CmdCommand("netsh", "wlan start hosted network");
                    await command.Run();

                    IsEnabled = true;
                }
                catch (Exception ex)
                {
                    LogManager.Log(ex, "Error activating hot spot.");
                    throw;
                }
            }
        }

        /// <summary>
        /// Disables the hot spot.
        /// </summary>
        /// <returns></returns>
        public async Task DisableHotSpot()
        {
            if (IsEnabled)
            {
                try
                {
                    CmdCommand command = new CmdCommand("netsh", "wlan stop hosted network");
                    await command.Run();
                    IsEnabled = false;
                }
                catch (Exception ex)
                {
                    LogManager.Log(ex, "Error deactivating hot spot.");
                    throw;
                }
            }
        }
    }
}