本文整理汇总了C#中DeviceState类的典型用法代码示例。如果您正苦于以下问题:C# DeviceState类的具体用法?C# DeviceState怎么用?C# DeviceState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeviceState类属于命名空间,在下文中一共展示了DeviceState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnumerateDevices
/// <summary>
/// Generates a collection of audio endpoint devices that meet the specified criteria.
/// </summary>
/// <param name="dataFlow">The data-flow direction for the endpoint device.</param>
/// <param name="stateMask">The state or states of the endpoints that are to be included in the collection.</param>
/// <returns><see cref="MMDeviceCollection"/> which contains the enumerated devices.</returns>
public static MMDeviceCollection EnumerateDevices(DataFlow dataFlow, DeviceState stateMask)
{
using (var enumerator = new MMDeviceEnumerator())
{
return enumerator.EnumAudioEndpoints(dataFlow, stateMask);
}
}
示例2: EnumAudioEndpoints
/// <summary>
/// Generates a collection of audio endpoint devices that meet the specified criteria.
/// </summary>
/// <param name="dataFlow">The data-flow direction for the endpoint device.</param>
/// <param name="stateMask">The state or states of the endpoints that are to be included in the collection.</param>
/// <returns><see cref="MMDeviceCollection"/> which contains the enumerated devices.</returns>
public MMDeviceCollection EnumAudioEndpoints(DataFlow dataFlow, DeviceState stateMask)
{
IntPtr pcollection;
CoreAudioAPIException.Try(EnumAudioEndpointsNative(dataFlow, stateMask, out pcollection), InterfaceName,
"EnumAudioEndpoints");
return new MMDeviceCollection(pcollection);
}
示例3: EnumAudioEndpointsNative
public unsafe int EnumAudioEndpointsNative(DataFlow dataFlow, DeviceState stateMask, out IntPtr collection)
{
IntPtr pcollection;
int result = InteropCalls.CallI(_basePtr, unchecked(dataFlow), unchecked(stateMask), &pcollection, ((void**)(*(void**)_basePtr))[3]);
collection = pcollection;
return result;
}
示例4: GetByState
public IHttpActionResult GetByState(Guid companyId, DeviceState state)
{
IReadOnlyCollection<Device> devices;
if (state == DeviceState.Pending)
{
devices = DeviceRepository.GetPending(companyId);
}
else if (state == DeviceState.Approved)
{
devices = DeviceRepository.GetApproved(companyId);
}
else if (state == DeviceState.Declined)
{
devices = DeviceRepository.GetDeclined(companyId);
}
else if (state == DeviceState.Blocked)
{
devices = DeviceRepository.GetBlocked(companyId);
}
else
{
throw new NotImplementedException(String.Format("There is no implementation for DeviceState '{0}'", state));
}
var model = devices.Select(x => DeviceModel.From(x));
return Ok(model);
}
示例5: AudioDeviceLister
public AudioDeviceLister(DeviceState state)
{
_state = state;
AudioController.DeviceAdded += AudioControllerOnDeviceAdded;
AudioController.DeviceRemoved += AudioControllerOnDeviceRemoved;
AudioController.DeviceStateChanged += AudioControllerOnDeviceStateChanged;
}
示例6: HardDrive
public HardDrive(RenderWindow window, VirtualMachine virtualMachine, XElement config)
{
vm = virtualMachine;
state = DeviceState.None;
var errorMsg = "";
try
{
errorMsg = "Bad Port";
devPort = short.Parse(Util.ElementValue(config, "Port", null));
errorMsg = "Bad FileName";
var fileName = Util.ElementValue(config, "FileName", null);
if (fileName == null)
throw new Exception();
errorMsg = string.Format("Failed to open '{0}'", fileName);
diskImage = new FileStream(fileName, FileMode.Open);
sectorCount = (ushort)(new FileInfo(fileName).Length / BytesPerSector);
}
catch (Exception e)
{
throw new Exception(string.Format("HardDrive: {0}", errorMsg), e);
}
}
示例7: Device
/// <summary>
/// Creates a device with the specific serial number
/// </summary>
/// <param name="serialNo">The serial number of the device as a String</param>
/// <param name="model">The model of the device</param>
/// <param name="productName">The product name of the device</param>
/// <param name="state">The state of the device</param>
internal Device(string serialNo, string model, string productName, string name, DeviceState state)
{
mSerialNumber = serialNo;
mProductName = productName;
mModel = model;
mConnectionStatus = state;
mName = name;
}
示例8: Open
public override Boolean Open(int Instance = 0)
{
if (base.Open(Instance))
{
m_State = DeviceState.Reserved;
}
return State == DeviceState.Reserved;
}
示例9: From
public static DeviceStateRequest From(DeviceState state, DateTime changeDate, string comment)
{
return new DeviceStateRequest()
{
State = state,
ChangeDate = changeDate,
Comment = comment
};
}
示例10: ApplyState
public virtual void ApplyState(DeviceState state)
{
// Shouldn't change any of these post creation
state.Name = mState.Name;
state.DisplayName = mState.DisplayName;
state.Archetype = mState.Archetype;
if (!state.Type.Equals(mState.Type))
throw new InvalidOperationException(string.Format("Type {0} of source state does not match type {1} of target state", state.Type, mState.Type));
}
示例11: From
public static StateModel From(DeviceState state, DateTime changeDate, string macAddress, string comment)
{
return new StateModel()
{
State = state.ToString(),
ChangeDate = changeDate,
MacAddress = macAddress,
Comment = comment
};
}
示例12: Close
public override Boolean Close()
{
if (IsActive)
{
Unplug(0);
m_State = DeviceState.Disconnected;
}
return base.Close();
}
示例13: DeviceBase
protected DeviceBase(DeviceState state, DeviceCreationInfo creationInfo)
{
mState = state;
mState.Name = creationInfo.Configuration.name;
try
{
mState.DisplayName = creationInfo.Configuration.displayName;
}
catch (RuntimeBinderException) { } // Optional
mState.Type = GetType().ToString();
}
示例14: DirectXOutputDevice
public DirectXOutputDevice(Controller controller)
{
_controller = controller;
_deviceState = DeviceState.Stopped;
_streamWriteProcDelegate = OutputStreamWriteProc;
_silence = new Silence();
_deviceNo = GetDeviceNo();
BASSInit flags = BASSInit.BASS_DEVICE_DEFAULT;
// Because all deviceinfo is saved in a static dictionary,
// we need to determine the latency only once.
if (!_deviceInfos.ContainsKey(_deviceNo))
flags |= BASSInit.BASS_DEVICE_LATENCY;
bool result = Bass.BASS_Init(
_deviceNo,
44100, //Only relevant for -> pre-XP (VxD drivers)
flags,
IntPtr.Zero);
BASSError? bassInitErrorCode = result ? null : new BASSError?(Bass.BASS_ErrorGetCode());
// If the GetDeviceNo() method returned BassConstants.BassDefaultDevice, we must request the actual device number
// of the choosen default device
_deviceNo = Bass.BASS_GetDevice();
if (bassInitErrorCode.HasValue)
{
if (bassInitErrorCode.Value == BASSError.BASS_ERROR_ALREADY)
{
if (!Bass.BASS_SetDevice(_deviceNo))
throw new BassLibraryException("BASS_SetDevice");
bassInitErrorCode = null;
}
}
if (bassInitErrorCode.HasValue)
throw new BassLibraryException("BASS_Init", bassInitErrorCode.Value);
CollectDeviceInfo(_deviceNo);
int ms = Convert.ToInt32(Controller.GetSettings().DirectSoundBufferSize.TotalMilliseconds);
if (!Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_BUFFER, ms))
throw new BassLibraryException("BASS_SetConfig");
// Enable update thread while the output device is active
if (!Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, ms / 4))
throw new BassLibraryException("BASS_SetConfig");
}
示例15: ApplyState
public override void ApplyState(DeviceState state)
{
base.ApplyState(state);
var newState = (ComputerState)state;
var currentState = (ComputerState)mState;
if (newState.Power != currentState.Power)
SetPower(newState.Power);
if (newState.MonitorPower != currentState.MonitorPower)
SetMonitorPower(newState.MonitorPower);
}