private void moveToWithStructureToolStripMenuItem_Click(object sender, EventArgs e) { try { FolderBrowserDialog dlg = new FolderBrowserDialog(); dlg.SelectedPath = txtPath.Text; dlg.ShowNewFolderButton = true; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { for (int i = 0; i < data.SelectedRows.Count; i++) { try { clData cur = (clData)data.SelectedRows[i].Tag; string movePath = dlg.SelectedPath + "\\" + cur.fileInfo.FullName.Substring(txtPath.Text.Length); Directory.CreateDirectory(FileFunc.GetDirOfFullName(movePath)); cur.fileInfo.MoveTo(movePath); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } catch (Exception ex) { GenFunc.LogAdd(ex); } }
private void encodeToolStripMenuItem_Click(object sender, EventArgs e) { try { if (data.SelectedRows.Count == 0) { if (data.SelectedCells.Count == 1) { clData cur = (clData)data.SelectedCells[0].OwningRow.DataBoundItem; cur.AskEncoding(); } } else { for (int i = 0; i < data.SelectedRows.Count; i++) { clData cur = (clData)data.SelectedRows[i].DataBoundItem; cur.AskEncoding(); } } } catch (Exception ex) { GenFunc.LogAdd(ex); } }
private void getFilesInDir(clParam p, DirectoryInfo curDir) { try { if (backWorkFindFiles.CancellationPending) return; FileInfo[] files = curDir.GetFiles(); for (int i = 0; i < files.Length; i++) { if (isGoodExtension(p, files[i])) { backWorkFindFiles.ReportProgress(2, new clData(files[i])); } } if (cntDirectory++ > 50) { cntDirectory = 0; backWorkFindFiles.ReportProgress(1, curDir.FullName.Substring(p.pathLength)); } DirectoryInfo[] childDirectories = curDir.GetDirectories(); for (int i = 0; i < childDirectories.Length; i++) { getFilesInDir(p, childDirectories[i]); } } catch (Exception ex) { GenFunc.LogAdd(ex); } }
private void backWorkGetData_DoWork(object sender, DoWorkEventArgs e) { bool hadData = false; while (!isClosing) { try { if (LstGetInfo.Count > 0) { clData cur = LstGetInfo[0]; LstGetInfo.RemoveAt(0); cur.updateInfo(); isDirty = true; hadData = true; VideoTotalSize += cur.SizeMb; backWorkGetData.ReportProgress(0); } else { if (hadData) { hadData = false; backWorkGetData.ReportProgress(0); } System.Threading.Thread.Sleep(500); } } catch (Exception ex) { GenFunc.LogAdd(ex); } } }
private void backWorkFindFiles_ProgressChanged(object sender, ProgressChangedEventArgs e) { try { switch (e.ProgressPercentage) { case 0: if (e.UserState.GetType().Name == "String") { MessageBox.Show(e.UserState.ToString()); return; } break; case 1: lblScanStatus.Text = "Scanning: " + e.UserState.ToString(); break; case 2: clData item = (clData)e.UserState; bindingData.Add(item); LstGetInfo.Add(item); lblVideoFound.Text = bindingData.Count.ToString(); break; default: break; } } catch (Exception ex) { GenFunc.LogAdd(ex); } }
/// <summary> /// /// </summary> public RichTextBoxEx() : base() { //加载contextMenuTrip的子项---消息显示的清楚和 ToolStripItem tsItem; this.ContextMenuStrip = this.usedContextMenuStrip; //---添加清楚消息的功能 tsItem = GenFunc.AddContextMenu("清除", this.usedContextMenuStrip.Items, new EventHandler(this.buttonClear_Click)); this.ContextMenuStrip.Width = 64; }
static void Main() { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmMain()); } catch (Exception ex) { GenFunc.LogAdd(ex); MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } }
internal bool updateInfo() { try { if (fileInfo == null || fileInfo.Exists == false || fileInfo.DirectoryName.Contains(@":\$RECYCLE.BIN\")) { return(false); } DateTime start = DateTime.Now; var ffProbe = new NReco.VideoInfo.FFProbe(); var videoInfo = ffProbe.GetMediaInfo(fileInfo.FullName); durationMs = videoInfo.Duration.TotalMilliseconds; Duration = string.Format("{0}:{1}:{2}", videoInfo.Duration.Hours, videoInfo.Duration.Minutes, videoInfo.Duration.Seconds); if (Duration.StartsWith("0:")) { Duration = Duration.Substring(2); } SizeByte = fileInfo.Length; SizeMb = (int)(fileInfo.Length / (1024 * 1024.0)); Bitrate = Math.Round((SizeByte / 1024.0) / (durationMs / 1000.0)); string formatVideo = ""; string formatAudio = ""; for (int i = 0; i < videoInfo.Streams.Length; i++) { if (videoInfo.Streams[i].CodecType == "video") { formatVideo += videoInfo.Streams[i].CodecName + " "; } else { formatAudio += videoInfo.Streams[i].CodecName + " "; } } Format = formatVideo + formatAudio.Trim(); Status = EnEncoding.HasInfo; //GenFunc.LogAddInfo(this,"updateInfo", "Time: " + Math.Round((DateTime.Now - start).TotalMilliseconds) + " [ms]"); return(true); } catch (Exception ex) { GenFunc.LogAdd(ex); Status = EnEncoding.Error; } return(false); }
private void playBackupToolStripMenuItem_Click(object sender, EventArgs e) { try { for (int i = 0; i < data.SelectedCells.Count; i++) { clData cur = (clData)data.SelectedCells[i].OwningRow.DataBoundItem; Process.Start(cur.pathBackup); } } catch (Exception ex) { GenFunc.LogAdd(ex); } }
private bool isGoodExtension(clParam p, FileInfo fileInfo) { try { for (int i = 0; i < p.extensionArr.Length; i++) { if (fileInfo.Extension == p.extensionArr[i]) return true; } return false; } catch (Exception ex) { GenFunc.LogAdd(ex); return false; } }
internal void EncodeVideo() { Status = EnEncoding.Processing; frmMain.isDirty = true; string originalPath = fileInfo.FullName; string newName = fileInfo.FullName.Replace(fileInfo.Extension, ".mp4"); System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(pathBackup)); fileInfo.MoveTo(pathBackup); fileInfo = new System.IO.FileInfo(newName); try { var ffMpeg = new FFMpegConverter(); ConvertSettings c = new ConvertSettings(); //c.VideoCodec = "libx264"; //c.CustomOutputArgs = "-crf 23"; //ffMpeg.ConvertMedia(cur.fileInfo.FullName, null, newName + "23", "MP4", c); //c.CustomOutputArgs = "-crf 1"; //ffMpeg.ConvertMedia(cur.fileInfo.FullName, null, newName + "1", "MP4", c); c.VideoCodec = "libx265"; c.CustomOutputArgs = "-crf 28"; EncodingLog = new StringBuilder(); ffMpeg.FFMpegProcessPriority = System.Diagnostics.ProcessPriorityClass.BelowNormal; ffMpeg.LogReceived += FfMpeg_LogReceived; ffMpeg.ConvertMedia(fileInfo.FullName, null, newName, "MP4", c); string s = EncodingLog.ToString(); updateInfo(); Status = EnEncoding.Encoded; } catch (Exception ex) { GenFunc.LogAdd(ex); FileFunc.TryDelete(newName); fileInfo = new System.IO.FileInfo(pathBackup); fileInfo.MoveTo(originalPath); updateInfo(); Status = EnEncoding.Error; } frmMain.isDirty = true; }
IEnumerator ShowBling(Transform tr, Vector3 pos) { tr.gameObject.SetActive(true); tr.localScale = new Vector3(0, 0, 0); tr.localRotation = Quaternion.Euler(20, 0, 0); if (_rank > 3) { tr.Find("Cup").gameObject.SetActive(false); } else { tr.Find("Medal").gameObject.SetActive(false); MeshRenderer R = tr.Find("Cup").GetComponent <MeshRenderer>(); Material[] M = R.sharedMaterials; if (_rank == 1) { M[0] = (Material)Resources.Load("Prefabs/Materials/Gold"); } if (_rank == 2) { M[0] = (Material)Resources.Load("Prefabs/Materials/Silver"); } if (_rank == 3) { M[0] = (Material)Resources.Load("Prefabs/Materials/Bronze"); } R.sharedMaterials = M; } tr.GetComponentInChildren <Text>().text = GenFunc.OrdinalIndicator(_rank); for (int t = 0; t < 90; t++) { tr.localScale += new Vector3(0.16f, 0.16f, 0.16f); tr.Rotate(tr.parent.up, 5, Space.World); yield return(new WaitForSeconds(0.02f)); } for (int t = 0; t < 2000; t++) { tr.Rotate(tr.parent.up, 5, Space.World); yield return(new WaitForSeconds(0.02f)); } //07811713204 yield break; }
private void backWorkFindFiles_DoWork(object sender, DoWorkEventArgs e) { try { clParam p = (clParam)e.Argument; DirectoryInfo curDir = new DirectoryInfo(p.path); if (!curDir.Exists) { backWorkFindFiles.ReportProgress(0, "Folder doen't exists"); return; } getFilesInDir(p, curDir); } catch (Exception ex) { GenFunc.LogAdd(ex); } }
IEnumerator ShowHiScores() { int _startRank = _rank < 11 ? 1 : _rank - 4; float pos = trPanel.rect.min.y; float ScrHght = trPanel.rect.height; int ScrWdth = Screen.width; float ScoreHght = ScrHght / 11; yield return(new WaitForSecondsRealtime(2)); for (int n = 9; n >= 0; n--) { int r = n + _startRank; GameObject goHiScore = (GameObject)GameObject.Instantiate(HiScorePrefab, trPanel); RectTransform tr = goHiScore.GetComponent <RectTransform>(); tr.anchorMin = new Vector3(0.5f, 0); tr.anchorMax = new Vector3(0.5f, 0); tr.anchoredPosition = Vector2.zero; tr.localPosition = new Vector3(pos, pos, 0); tr.localScale = Vector3.one; tr.sizeDelta = new Vector2(0, ScoreHght); tr.Find("txtRank").GetComponent <Text>().text = r.ToString(); if (r <= L.Count) { tr.Find("txtName").GetComponent <Text>().text = L[r - 1].Name; tr.Find("txtTime").GetComponent <Text>().text = GenFunc.HMS(L[r - 1].SegTime * Road.Instance.Segments.Count); } if (r != _rank) { tr.Find("ipName").gameObject.SetActive(false); } else { _myTransform = tr; InputField ip = tr.Find("ipName").GetComponent <InputField>(); ip.onEndEdit.AddListener(delegate { NameOnEndEdit(ip.text); }); StartCoroutine(ShowBling(_trTrophy, tr.localPosition)); } pos += ScoreHght; yield return(new WaitForSecondsRealtime(0.3f)); } yield break; }
public void Update() { if (Paused) { return; } if (!Started) { return; } if (txtTimer == null) { txtTimer = GameObject.Find("txtTimer").GetComponent <Text>(); } foreach (Racer r in Racers) { r.GetProgrss(); } float TotalTime = Time.time - StartTime; txtTimer.text = GenFunc.HMS(TotalTime); }
private void moveToToolStripMenuItem_Click(object sender, EventArgs e) { try { FolderBrowserDialog dlg = new FolderBrowserDialog(); dlg.SelectedPath = txtPath.Text; dlg.ShowNewFolderButton = true; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { for (int i = 0; i < data.SelectedRows.Count; i++) { clData cur = (clData)data.SelectedRows[i].Tag; cur.fileInfo.MoveTo(dlg.SelectedPath + "\\" + cur.fileInfo.Name); } } } catch (Exception ex) { GenFunc.LogAdd(ex); } }
private void txtPath_TextChanged(object sender, EventArgs e) { try { if (Directory.Exists(txtPath.Text)) { txtPath.BackColor = Color.LightGreen; butStart.Enabled = true; } else { txtPath.BackColor = Color.Pink; butStart.Enabled = false; } } catch (Exception ex) { GenFunc.LogAdd(ex); txtPath.BackColor = Color.Pink; butStart.Enabled = false; } }
private void butStart_Click(object sender, EventArgs e) { try { if (!txtPath.Text.EndsWith("\\")) { txtPath.Text += "\\"; } if (!txtBackFolder.Text.EndsWith("\\")) { txtBackFolder.Text += "\\"; } if (butStart.Text == "Start") { bindingData.Clear(); VideoTotalSize = 0; clParam p = new clParam(); p.path = txtPath.Text; p.extension = txtExtension.Text; p.BackupPath = txtBackFolder.Text; clData.param = p; backWorkFindFiles.RunWorkerAsync(p); butStart.Text = "Cancel"; } else { backWorkFindFiles.CancelAsync(); } } catch (Exception ex) { GenFunc.LogAdd(ex); } }
private void OnSegmentEnter() { if (Progrss < 20 && PrevProgrss > RoadSegCount - 20) { Lap++; if (!isMachine) { float LapTime = Time.time - LapStartTime; _Race.LapStats.Add(new LapStat { stFr = LapStartFrame, finFr = Recrdng.Current.FrameCount - 1, time = LapTime }); if (Game.current.BestLap == null || LapTime < Game.current.BestLap) { int LapScore = RoadSegCount / 50; Race.Current.LapRecBonus += LapScore; StringBuilder s = new StringBuilder("New Lap Record\n$"); s.Append(LapScore.ToString()); Main.Instance.PopupMsg(s.ToString(), Color.green); Game.current.BestLap = LapTime; SaveLoadModel.SaveSavedGames(); } if (Main.Instance.Ghost) { GhostController gc = (GhostController)DrivingPlayManager.Current.GhostCarManager.VehicleController; gc.Frame = 0; } LapStartTime = Time.time; LapStartFrame = Recrdng.Current.FrameCount; } } TotProgrss = Progrss + (Lap - 1) * RoadSegCount; //keeping the AI cars close to the player if (isMachine) { foreach (Racer pr in PlayerOpposition) { if (_hogBonusTime == 0 && pr.TotProgrss > TotProgrss + 20 || pr.TotProgrss < TotProgrss - 301) //Player is too far ahead or really far behind { JumpTo(pr); } if (pr.TotProgrss < TotProgrss - 10) //AICar is a bit ahead of the player slow down { _vehicleController.motorForce = _defaultMotorForce * 0.4f; } else { _vehicleController.motorForce = _defaultMotorForce; } } } else { if (txtLap == null) { txtLap = GameObject.Find("txtLap").GetComponent <Text>(); } float LapTime = Time.time - LapStartTime; if (LapTime > 10) { txtLap.text = GenFunc.HMS(LapTime); } if (Lap == Race.Current.Laps + 1) { Race.Current.Finish(); } if (TotProgrss > RoadSegCount * Race.Current.Laps - 100 && ChFlag == false) { Transform trStart = GameObject.Find("StartingLine").transform; foreach (ParticleSystem ps in trStart.GetComponentsInChildren <ParticleSystem>()) { ps.Play(); } Race.Current.ShowChequeredFlag(true); CamSelector.Instance.SelectCam("Simple"); ChFlag = true; } } }
void ShowBestLap() { _bestLap = Race.Current.LapStats.OrderBy(ls => ls.time).First(); transform.Find("txtBestLapTime").GetComponent <Text>().text = GenFunc.HMS(_bestLap.time); }
public FunctionalGen(GenFunc <T> func) { _func = func; }