コード例 #1
0
ファイル: BanSystem.cs プロジェクト: vsrz/desbot_vsrz
 /// <summary>
 /// Add operation to pending queue
 /// </summary>
 /// <param name="op">The operation to execute</param>
 static void AddOperation(PendingOperation op)
 {
     lock (State.GlobalSync)
     {
         pending.Add(op);
         RefreshFromIrc();
     }
 }
コード例 #2
0
ファイル: BassEngine.cs プロジェクト: jasine/KinectExplorer
 /// <summary>
 /// 播放当前音频
 /// </summary>
 public void Play()
 {
     //Debug.WriteLine("已调用BassEngine.Play()");
     if (CanPlay)
     {
         PlayCurrentStream();
         IsPlaying = true;
         CanPause = true;
         CanPlay = false;
         CanStop = true;
         pendingOperation = PendingOperation.None;
     }
     else
     {
         pendingOperation = PendingOperation.Play;
     }
 }
コード例 #3
0
ファイル: BassEngine.cs プロジェクト: jasine/KinectExplorer
        /// <summary>
        /// 停止当前音频,并释放资源
        /// </summary>
        public void Stop()
        {
            //Debug.WriteLine("已调用BassEngine.Stop()");

            if (canStop)
            {
                ChannelPosition = TimeSpan.Zero;
                if (ActiveStreamHandle != 0)
                {
                    Un4seen.Bass.Bass.BASS_ChannelStop(ActiveStreamHandle);
                    Un4seen.Bass.Bass.BASS_ChannelSetPosition(ActiveStreamHandle, ChannelPosition.TotalSeconds);
                    //Debug.WriteLine("已调用BASS_ChannelStop()");
                }
                IsPlaying = false;
                CanStop = false;
                CanPlay = false;
                CanPause = false;
            }

            FreeCurrentStream();
            pendingOperation = PendingOperation.None;
        }
コード例 #4
0
ファイル: BassEngine.cs プロジェクト: jasine/KinectExplorer
        /// <summary>
        /// 打开网络地址
        /// </summary>
        /// <param name="url">URL地址</param>
        public void OpenUrlAsync(string url)
        {
            openningFile = url;
            //Debug.WriteLine("已调用BassEngine.OpenUrlAsync()");

            Stop();
            pendingOperation = PendingOperation.None;

            onlineFileWorker = new Thread(new ThreadStart(() =>
                {
                    int handle = Un4seen.Bass.Bass.BASS_StreamCreateURL(url, 0, Un4seen.Bass.BASSFlag.BASS_DEFAULT, null, IntPtr.Zero);

                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            if (handle != 0)
                            {
                                if (openningFile == url)		//该文件为正在打开的文件
                                {
                                    ActiveStreamHandle = handle;
                                    ChannelLength = TimeSpan.FromSeconds(Un4seen.Bass.Bass.BASS_ChannelBytes2Seconds(ActiveStreamHandle, Un4seen.Bass.Bass.BASS_ChannelGetLength(ActiveStreamHandle, 0)));
                                    Un4seen.Bass.BASS_CHANNELINFO info = new Un4seen.Bass.BASS_CHANNELINFO();
                                    Un4seen.Bass.Bass.BASS_ChannelGetInfo(ActiveStreamHandle, info);
                                    sampleFrequency = info.freq;

                                    int syncHandle = Un4seen.Bass.Bass.BASS_ChannelSetSync(ActiveStreamHandle,
                                         Un4seen.Bass.BASSSync.BASS_SYNC_END,
                                         0,
                                         endTrackSyncProc,
                                         IntPtr.Zero);

                                    if (syncHandle == 0)
                                        throw new ArgumentException("Error establishing End Sync on file stream.", "path");

                                    CanPlay = true;
                                    RaiseOpenSucceededEvent();

                                    switch (pendingOperation)
                                    {
                                        case PendingOperation.None:
                                            break;
                                        case PendingOperation.Play:
                                            Play();
                                            break;
                                        case PendingOperation.Pause:
                                            Pause();
                                            break;
                                        default:
                                            break;
                                    }
                                }
                                else		//该文件不是正在打开的文件(即文件已过时,可能的原因是UI线程较忙,调用onlineFileWorker.Abort()时BeginInvoke的内容已提交,但还未执行)
                                {
                                    if (!Un4seen.Bass.Bass.BASS_StreamFree(handle))
                                    {
                                        Debug.WriteLine("BASS_StreamFree失败:" + Un4seen.Bass.Bass.BASS_ErrorGetCode());
                                    }
                                    //Debug.WriteLine("已调用BASS_StreamFree()");
                                }
                            }
                            else
                            {
                                Debug.WriteLine(Un4seen.Bass.Bass.BASS_ErrorGetCode());
                                RaiseOpenFailedEvent();
                            }
                        }));
                    onlineFileWorker = null;
                }));
            onlineFileWorker.IsBackground = true;
            onlineFileWorker.Start();
        }
コード例 #5
0
ファイル: BassEngine.cs プロジェクト: jasine/KinectExplorer
 /// <summary>
 /// 暂停当前音频
 /// </summary>
 public void Pause()
 {
     //Debug.WriteLine("已调用BassEngine.Pause()");
     if (IsPlaying && CanPause)
     {
         Un4seen.Bass.Bass.BASS_ChannelPause(ActiveStreamHandle);
         IsPlaying = false;
         CanPlay = true;
         CanPause = false;
         pendingOperation = PendingOperation.None;
     }
     else
     {
         pendingOperation = PendingOperation.Pause;
     }
 }
コード例 #6
0
		/// <summary>
		/// Closes/Hides the progress window.
		/// </summary>
		private void CloseProgressWindow() {
			Gtk.Application.Invoke (delegate {
				m_windowProgressInfo.Hide ();
				m_pendingOperation = PendingOperation.NOTHING;
			});
		}
コード例 #7
0
ファイル: BassEngine.cs プロジェクト: jasine/KinectExplorer
        /// <summary>
        /// 打开文件
        /// </summary>
        /// <param name="filename">文件名</param>
        public void OpenFile(string filename)
        {
            openningFile = filename;
            //Debug.WriteLine("已调用BassEngine.OpenFile()");
            Stop();
            pendingOperation = PendingOperation.None;

            int handle = Un4seen.Bass.Bass.BASS_StreamCreateFile(filename, 0, 0, Un4seen.Bass.BASSFlag.BASS_DEFAULT);

            if (handle != 0)
            {
                ActiveStreamHandle = handle;
                ChannelLength = TimeSpan.FromSeconds(Un4seen.Bass.Bass.BASS_ChannelBytes2Seconds(ActiveStreamHandle, Un4seen.Bass.Bass.BASS_ChannelGetLength(ActiveStreamHandle, 0)));
                Un4seen.Bass.BASS_CHANNELINFO info = new Un4seen.Bass.BASS_CHANNELINFO();
                Un4seen.Bass.Bass.BASS_ChannelGetInfo(ActiveStreamHandle, info);
                sampleFrequency = info.freq;

                int syncHandle = Un4seen.Bass.Bass.BASS_ChannelSetSync(ActiveStreamHandle,
                     Un4seen.Bass.BASSSync.BASS_SYNC_END,
                     0,
                     endTrackSyncProc,
                     IntPtr.Zero);

                if (syncHandle == 0)
                    throw new ArgumentException("Error establishing End Sync on file stream.", "path");

                CanPlay = true;
                RaiseOpenSucceededEvent();

                switch (pendingOperation)
                {
                    case PendingOperation.None:
                        break;
                    case PendingOperation.Play:
                        Play();
                        break;
                    case PendingOperation.Pause:
                        Pause();
                        break;
                    default:
                        break;
                }
            }
            else
            {
                RaiseOpenFailedEvent();
            }
        }
コード例 #8
0
		/// <summary>
		/// Opens the progress window and sets the current pending operation.
		/// </summary>
		/// <returns><c>true</c>, if progress window was opened, <c>false</c>, if there already is an operation pending.</returns>
		/// <param name="thisOperation">This operation.</param>
		private bool OpenProgressWindow(PendingOperation thisOperation) {
			// do not start another operation when there is already one
			if (m_pendingOperation != PendingOperation.NOTHING)
				return false;


			m_pendingOperation = thisOperation;

			m_windowProgressInfo.Show ();
			return true;
		}
コード例 #9
0
		private void PreviewButtonClicked() {
			if(this.m_pendingOperation != PendingOperation.NOTHING)
				return;
			this.m_pendingOperation = PendingOperation.GENERATE_PREVIEW;
			m_windowProgressInfo.Show();

			// read settings while handling errors
			Settings settings = new Settings ();
			try {
				// read all required information to class/struct, so that off-gtk-thread computation is possible
				settings = new Settings ();
				ReadGui (settings);

				// quickly decide whether these inputs can be used for a run
				IsSettingsValid (settings);

			} catch(Exception e) {
				SetErrorMessage (e.Message);
				CloseProgressWindow ();
				return;
			}

			m_previewSettings = settings;


			Thread compuationThread = new Thread(() => ComputationThreadSafe(settings));
			compuationThread.Start();

		}
コード例 #10
0
ファイル: FindSensorsDialog.cs プロジェクト: fparaggio/atmo
 private void sensorSetupLine_SensorSet(int obj)
 {
     if (_pendingOperation == PendingOperation.None) {
         if (DialogResult.OK == MessageBox.Show("Make sure only one unassigned sensor is connected.", "Verify", MessageBoxButtons.OKCancel)) {
             _device.SetSensorId(-1, obj);
         }
         _pendingOperation = PendingOperation.Add;
         _pendingSensorIndex = obj;
         addRemWorker.RunWorkerAsync();
     }
 }
コード例 #11
0
ファイル: FindSensorsDialog.cs プロジェクト: fparaggio/atmo
 private void sensorSetupLine_SensorRemove(int obj)
 {
     if (_pendingOperation == PendingOperation.None) {
         if (DialogResult.Yes == MessageBox.Show("Are you sure you wish to remove this sensor?", "Confirm", MessageBoxButtons.YesNoCancel)) {
             _device.SetSensorId(obj, -1);
         }
         _pendingOperation = PendingOperation.Rem;
         _pendingSensorIndex = obj;
         addRemWorker.RunWorkerAsync();
     }
 }
コード例 #12
0
ファイル: FindSensorsDialog.cs プロジェクト: fparaggio/atmo
        private void addRemWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            ISensor sensor = _device.GetSensor(_pendingSensorIndex);

            MessageBoxIcon resultIcon;
            string resultTitle;
            string resultMessage = "Operation";
            bool sensorIsDesiredToBeFound = true;

            if (_pendingOperation == PendingOperation.Add) {
                resultMessage = "Sensor assignment";
            }
            else if (_pendingOperation == PendingOperation.Rem) {
                resultMessage = "Sensor removal";
                sensorIsDesiredToBeFound = false;
            }

            Thread.Sleep(500); // wait for the sensor to be active

            var sensorFound = null != sensor && sensor.IsValid;

            if (sensorFound == sensorIsDesiredToBeFound) {
                resultTitle = "Success";
                resultMessage += " successful";
                resultIcon = MessageBoxIcon.Information;
            }
            else {
                resultTitle = "Failure";
                resultMessage += " failed";
                resultIcon = MessageBoxIcon.Error;
            }

            _pendingOperation = PendingOperation.None;
            MessageBox.Show(this, resultTitle, resultMessage, MessageBoxButtons.OK, resultIcon);
        }