private void listTracks_ItemCheck(object sender, ItemCheckEventArgs e) { m_Tracks[e.Index].Visible = e.NewValue == CheckState.Checked; // Fire tracks change notification TracksChanged?.Invoke(this, null); }
private void listTracks_DragDrop(object sender, DragEventArgs e) { // Get drop index var point = listTracks.PointToClient(new Point(e.X, e.Y)); var index = listTracks.InsertionMark.NearestIndex(point); // Get the list of items to drop var items = e.Data.GetData(typeof(ListViewItem[])) as ListViewItem[]; // decide on move order items = (index > items[0].Index) ? items : items.Reverse().ToArray(); // Fire before change notification BeforeChange?.Invoke(this, null); foreach (var item in items) { // Remove from list listTracks.Items.Remove(item); m_Tracks.Remove(item.Tag as TrackInfo); // Insert in new position listTracks.Items.Insert(index, item); m_Tracks.Insert(index, item.Tag as TrackInfo); } // Fire tracks change notification TracksChanged?.Invoke(this, null); }
private void listTracks_AfterLabelEdit(object sender, LabelEditEventArgs e) { // Check if label has text if (!string.IsNullOrWhiteSpace(e.Label)) { // Fire before change notification BeforeChange?.Invoke(this, null); // Assign edited value back to track ((TrackInfo)listTracks.Items[e.Item].Tag).Name = e.Label; // Fire tracks change notification TracksChanged?.Invoke(this, null); } }
public void OnTracksChanged(TrackGroupArray p0, TrackSelectionArray p1) { var trackGroupArray = new TrackGroup[p0.Length]; for (var i = 0; i < p0.Length; i++) { trackGroupArray[i] = p0.Get(i); } var trackSelectionArray = new ITrackSelection[p1.Length]; for (var i = 0; i < p1.Length; i++) { trackSelectionArray[i] = p1.Get(i); } TracksChanged?.Invoke(trackGroupArray, trackSelectionArray); }
private void UpdateTrack(object o, RawTransponderDataEventArgs args) { tracks.Clear(); foreach (var data in args.TransponderData) { var track = ReadTrackData(data); tracks.Add(track); } if (count >= 1 && count <= 27) { tracks.Add(ReadTrackData("NIC666;" + 20000 + ";" + (10050 - 2 * count) + ";" + 5000 + ";20181004123456789")); } if (count >= -10) { tracks.Add(ReadTrackData("CHR112;" + (30000 + 2 * count) + ";" + (20000 + 2 * count) + ";" + 10000 + ";20181004123456789")); } if (count >= 10 && count <= 30) { tracks.Add(ReadTrackData("MOR007;" + 30000 + ";" + (25200 - 10 * count) + ";" + 10000 + ";20181004123456789")); } if (count > 30) { tracks.Add(ReadTrackData("MOR007;" + (30000 - 10 * (count - 30)) + ";" + (24900 + (count - 30) * 5) + ";" + 10000 + ";20181004123456789")); } count = count + 1; if (tracks.Count != 0) { TracksChanged?.Invoke(this, new TracksChangedEventArgs(tracks)); } }
public static void EventLoop() { while (true) { IntPtr ptr = mpv_wait_event(Handle, -1); mpv_event evt = (mpv_event)Marshal.PtrToStructure(ptr, typeof(mpv_event)); if (WindowHandle == IntPtr.Zero) { WindowHandle = FindWindowEx(MainForm.Hwnd, IntPtr.Zero, "mpv", null); } // Debug.WriteLine(evt.event_id.ToString()); try { switch (evt.event_id) { case mpv_event_id.MPV_EVENT_SHUTDOWN: if (App.DebugMode) { Trace.WriteLine("before Shutdown.Invoke"); } Shutdown?.Invoke(); if (App.DebugMode) { Trace.WriteLine("after Shutdown.Invoke"); } WriteHistory(null); ShutdownAutoResetEvent.Set(); return; case mpv_event_id.MPV_EVENT_LOG_MESSAGE: LogMessage?.Invoke(); break; case mpv_event_id.MPV_EVENT_GET_PROPERTY_REPLY: GetPropertyReply?.Invoke(); break; case mpv_event_id.MPV_EVENT_SET_PROPERTY_REPLY: SetPropertyReply?.Invoke(); break; case mpv_event_id.MPV_EVENT_COMMAND_REPLY: CommandReply?.Invoke(); break; case mpv_event_id.MPV_EVENT_START_FILE: StartFile?.Invoke(); break; case mpv_event_id.MPV_EVENT_END_FILE: var end_fileData = (mpv_event_end_file)Marshal.PtrToStructure(evt.data, typeof(mpv_event_end_file)); EndFileEventMode reason = (EndFileEventMode)end_fileData.reason; EndFile?.Invoke(reason); break; case mpv_event_id.MPV_EVENT_FILE_LOADED: HideLogo(); FileLoaded?.Invoke(); WriteHistory(get_property_string("path")); break; case mpv_event_id.MPV_EVENT_TRACKS_CHANGED: TracksChanged?.Invoke(); break; case mpv_event_id.MPV_EVENT_TRACK_SWITCHED: TrackSwitched?.Invoke(); break; case mpv_event_id.MPV_EVENT_IDLE: Idle?.Invoke(); if (get_property_int("playlist-count") == 0) { ShowLogo(); } break; case mpv_event_id.MPV_EVENT_PAUSE: Pause?.Invoke(); break; case mpv_event_id.MPV_EVENT_UNPAUSE: Unpause?.Invoke(); break; case mpv_event_id.MPV_EVENT_TICK: Tick?.Invoke(); break; case mpv_event_id.MPV_EVENT_SCRIPT_INPUT_DISPATCH: ScriptInputDispatch?.Invoke(); break; case mpv_event_id.MPV_EVENT_CLIENT_MESSAGE: var client_messageData = (mpv_event_client_message)Marshal.PtrToStructure(evt.data, typeof(mpv_event_client_message)); string[] args = NativeUtf8StrArray2ManagedStrArray(client_messageData.args, client_messageData.num_args); if (args.Length > 1 && args[0] == "mpv.net") { Command.Execute(args[1], args.Skip(2).ToArray()); } else if (args.Length > 0) { ClientMessage?.Invoke(args); } break; case mpv_event_id.MPV_EVENT_VIDEO_RECONFIG: VideoReconfig?.Invoke(); break; case mpv_event_id.MPV_EVENT_AUDIO_RECONFIG: AudioReconfig?.Invoke(); break; case mpv_event_id.MPV_EVENT_METADATA_UPDATE: MetadataUpdate?.Invoke(); break; case mpv_event_id.MPV_EVENT_SEEK: Seek?.Invoke(); break; case mpv_event_id.MPV_EVENT_PROPERTY_CHANGE: var propData = (mpv_event_property)Marshal.PtrToStructure(evt.data, typeof(mpv_event_property)); if (propData.format == mpv_format.MPV_FORMAT_FLAG) { foreach (var i in BoolPropChangeActions) { if (i.Key == propData.name) { i.Value.Invoke(Marshal.PtrToStructure <int>(propData.data) == 1); } } } if (propData.format == mpv_format.MPV_FORMAT_STRING) { foreach (var i in StringPropChangeActions) { if (i.Key == propData.name) { i.Value.Invoke(StringFromNativeUtf8(Marshal.PtrToStructure <IntPtr>(propData.data))); } } } if (propData.format == mpv_format.MPV_FORMAT_INT64) { foreach (var i in IntPropChangeActions) { if (i.Key == propData.name) { i.Value.Invoke(Marshal.PtrToStructure <int>(propData.data)); } } } break; case mpv_event_id.MPV_EVENT_PLAYBACK_RESTART: PlaybackRestart?.Invoke(); string path = get_property_string("path"); if (LastPlaybackRestartFile != path) { Size vidSize = new Size(get_property_int("dwidth"), get_property_int("dheight")); if (vidSize.Width == 0 || vidSize.Height == 0) { vidSize = new Size(1, 1); } if (VideoSize != vidSize) { VideoSize = vidSize; VideoSizeChanged?.Invoke(); } VideoSizeAutoResetEvent.Set(); Task.Run(new Action(() => ReadMetaData())); LastPlaybackRestartFile = path; } break; case mpv_event_id.MPV_EVENT_CHAPTER_CHANGE: ChapterChange?.Invoke(); break; case mpv_event_id.MPV_EVENT_QUEUE_OVERFLOW: QueueOverflow?.Invoke(); break; case mpv_event_id.MPV_EVENT_HOOK: Hook?.Invoke(); break; } } catch (Exception ex) { Msg.ShowException(ex); } } }
public static void EventLoop() { while (true) { IntPtr ptr = mpv_wait_event(MpvHandle, -1); mpv_event evt = (mpv_event)Marshal.PtrToStructure(ptr, typeof(mpv_event)); if (MpvWindowHandle == IntPtr.Zero) { MpvWindowHandle = FindWindowEx(MainForm.Hwnd, IntPtr.Zero, "mpv", null); } //Debug.WriteLine(evt.event_id.ToString()); switch (evt.event_id) { case mpv_event_id.MPV_EVENT_SHUTDOWN: Shutdown?.Invoke(); AutoResetEvent.Set(); return; case mpv_event_id.MPV_EVENT_LOG_MESSAGE: LogMessage?.Invoke(); break; case mpv_event_id.MPV_EVENT_GET_PROPERTY_REPLY: GetPropertyReply?.Invoke(); break; case mpv_event_id.MPV_EVENT_SET_PROPERTY_REPLY: SetPropertyReply?.Invoke(); break; case mpv_event_id.MPV_EVENT_COMMAND_REPLY: CommandReply?.Invoke(); break; case mpv_event_id.MPV_EVENT_START_FILE: StartFile?.Invoke(); break; case mpv_event_id.MPV_EVENT_END_FILE: var end_fileData = (mpv_event_end_file)Marshal.PtrToStructure(evt.data, typeof(mpv_event_end_file)); EndFile?.Invoke((EndFileEventMode)end_fileData.reason); break; case mpv_event_id.MPV_EVENT_FILE_LOADED: FileLoaded?.Invoke(); LoadFolder(); break; case mpv_event_id.MPV_EVENT_TRACKS_CHANGED: TracksChanged?.Invoke(); break; case mpv_event_id.MPV_EVENT_TRACK_SWITCHED: TrackSwitched?.Invoke(); break; case mpv_event_id.MPV_EVENT_IDLE: Idle?.Invoke(); break; case mpv_event_id.MPV_EVENT_PAUSE: Pause?.Invoke(); break; case mpv_event_id.MPV_EVENT_UNPAUSE: Unpause?.Invoke(); break; case mpv_event_id.MPV_EVENT_TICK: Tick?.Invoke(); break; case mpv_event_id.MPV_EVENT_SCRIPT_INPUT_DISPATCH: ScriptInputDispatch?.Invoke(); break; case mpv_event_id.MPV_EVENT_CLIENT_MESSAGE: if (ClientMessage != null) { try { var client_messageData = (mpv_event_client_message)Marshal.PtrToStructure(evt.data, typeof(mpv_event_client_message)); string[] args = NativeUtf8StrArray2ManagedStrArray(client_messageData.args, client_messageData.num_args); if (args != null && args.Length > 1 && args[0] == "mpv.net") { bool found = false; foreach (var i in mpvnet.Command.Commands) { if (args[1] == i.Name) { found = true; i.Action.Invoke(args.Skip(2).ToArray()); } } if (!found) { List <string> names = mpvnet.Command.Commands.Select((item) => item.Name).ToList(); names.Sort(); MainForm.Instance.ShowMsgBox($"No command '{args[1]}' found. Available commands are:\n\n{string.Join("\n", names)}\n\nHow to bind these commands can be seen in the default input bindings and menu definition located at:\n\nhttps://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt", MessageBoxIcon.Error); } } ClientMessage?.Invoke(args); } catch (Exception ex) { MainForm.Instance.ShowMsgBox(ex.GetType().Name + "\n\n" + ex.ToString(), MessageBoxIcon.Error); } } break; case mpv_event_id.MPV_EVENT_VIDEO_RECONFIG: VideoReconfig?.Invoke(); break; case mpv_event_id.MPV_EVENT_AUDIO_RECONFIG: AudioReconfig?.Invoke(); break; case mpv_event_id.MPV_EVENT_METADATA_UPDATE: MetadataUpdate?.Invoke(); break; case mpv_event_id.MPV_EVENT_SEEK: Seek?.Invoke(); break; case mpv_event_id.MPV_EVENT_PROPERTY_CHANGE: var event_propertyData = (mpv_event_property)Marshal.PtrToStructure(evt.data, typeof(mpv_event_property)); if (event_propertyData.format == mpv_format.MPV_FORMAT_FLAG) { foreach (var i in BoolPropChangeActions) { if (i.Key == event_propertyData.name) { i.Value.Invoke(Marshal.PtrToStructure <int>(event_propertyData.data) == 1); } } } break; case mpv_event_id.MPV_EVENT_PLAYBACK_RESTART: PlaybackRestart?.Invoke(); Size s = new Size(get_property_int("dwidth"), get_property_int("dheight")); if (VideoSize != s && s != Size.Empty) { VideoSize = s; VideoSizeChanged?.Invoke(); } break; case mpv_event_id.MPV_EVENT_CHAPTER_CHANGE: ChapterChange?.Invoke(); break; case mpv_event_id.MPV_EVENT_QUEUE_OVERFLOW: QueueOverflow?.Invoke(); break; case mpv_event_id.MPV_EVENT_HOOK: Hook?.Invoke(); break; } } }