public static void LoadScripts(DataTable dataTable) { try { int x = 0; foreach (DataRow row in dataTable.Rows) { if (row.ItemArray.Length == 2) { string title = row[0].ToString(); string body = row[1].ToString(); string[] lines = body.Split('\n'); Script script = new Script(title, lines, body); editItems[x].Header = (x + 1) + " " + script.title; executeItems[x].Header = (x + 1) + " " + script.title; scripts[x] = script; } x++; } } catch (Exception e) { LogCtrl.Error("Couldn't load Scripts."); LogCtrl.Error(e.ToString()); } }
public void ReadFinish() { if (!EventExtension.InvokeGracefully(callBack)) { LogCtrl.Error(" callBack Is Null "); } }
/// <summary> /// 提取配置属性 /// </summary> /// <returns>The prototype.</returns> /// <param name="prototypeID">Prototype I.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> public T GetPrototype(int prototypeID) { T basePrototype = null; Type refType = typeof(T); Dictionary <int, T> table = GetPrototypeTable(); if (table != null) { if (table.TryGetValue(prototypeID, out basePrototype)) { if (basePrototype == null) { return(null); } return(basePrototype); } else { #if UNITY_EDITOR LogCtrl.Error("此表中没有此ID GetPrototype = " + refType.Name + " prototypeID = " + prototypeID); #else LogCtrl.Warn("此表中没有此ID GetPrototype = " + refType.Name + " prototypeID = " + prototypeID); #endif } } return(null); }
// 设置当前游戏状态; public bool SetActiveState(Int32 stateId, object param = null) { // 别闹; if (_currentState != null && _currentState.GetStateID() == stateId) { return(false); } GameState nextState = null; if (!_stateMap.TryGetValue(stateId, out nextState)) { // 如果找不到新状态,就别切换了; LogCtrl.Error("切换游戏错误: 要切换的状态不存在 : " + stateId); return(false); } bool tryLeaveState = _currentState == null ? true : _currentState.TryLeaveState(nextState); bool tryEnterState = nextState.TryEnterState(_currentState); // 尝试离开或进入失败,则意味着,当前条件下,不允许切换(至于具体为什么,请查阅详细代码); if (!tryLeaveState || !tryEnterState) { return(false); } if (_currentState != null) { _currentState.LeaveState(nextState); } _preState = _currentState; _currentState = nextState; _currentState.EnterState(_preState, param); return(true); }
public void InitialTask(int type, int maxCount = 6) { if (mapTasks.ContainsKey(type)) { LogCtrl.Error("Call GetFreeType Function GetType. Error : " + type); return; } mapTasks.Add(type, CreateTaskData(type, maxCount)); }
public static void Shutter(int id, bool open) { foreach (BeamerCtrl b in beamers) { if (b.id == id) { b.Shutter(open); return; } } LogCtrl.Error("Beamer " + id + " doesn't exist."); }
private static void SetBackup() { isMain = false; if (!server.Init()) { LogCtrl.Error("Can't set to Backup."); } else { server.Start(); LogCtrl.Status("Set to Backup Mode."); } }
public void Start() { try { udpThread = new Thread(StartReceive); udpThread.Start(); } catch (Exception e) { LogCtrl.Error("Couldn't start Go Listener thread!"); LogCtrl.Error(e.Message); udpThread.Abort(); } }
private void StartReceive() { try { while (!_shouldStop) { data = client.Receive(ref sender); string[] message = Encoding.ASCII.GetString(data, 0, data.Length).Split(' '); if (message.Length == 2) { int cueNr; if (int.TryParse(message[1], out cueNr)) { switch (message[0]) { case "GO": Application.Current.Dispatcher.Invoke(new Action(() => { GoCtrl.Go(cueNr); })); break; case "BACK": Application.Current.Dispatcher.Invoke(new Action(() => { GoCtrl.GoBack(); })); break; } } } } } catch (SocketException se) { if (se.SocketErrorCode == SocketError.TimedOut) { Start(); } else { Application.Current.Dispatcher.Invoke(new Action(() => { LogCtrl.Error("Backup listener thread crashed!"); LogCtrl.Error(se.Message); })); } } }
public static void SetSettingsFromTable(DataTable dt) { foreach (DataRow row in dt.Rows) { bool b; if (Boolean.TryParse(row[0].ToString(), out b)) { Core.win.saveTriggerCheckbox.IsChecked = b; } else { LogCtrl.Error("Couldn't read Save Trigger settings!"); } } }
public bool Init() { try { client = new UdpClient(ipep); client.Client.ReceiveTimeout = 5000; } catch (Exception e) { LogCtrl.Error("Couldn't create Backup Listener thread!"); LogCtrl.Error(e.Message); return(false); } return(true); }
private Dictionary <int, T> GetPrototypeTable() { Type refType = typeof(T); if (dicAllTableData.ContainsKey(refType)) { return(dicAllTableData[refType]); } else { LogCtrl.Error("没有" + refType.Name + "表"); } return(null); }
public static void ExecuteScript(int nr) { if (scripts[nr - 1] != null) { LogCtrl.Status("Execute Script " + nr + ": " + scripts[nr - 1].title); foreach (Cue cue in scripts[nr - 1].cues) { GoCtrl.ExecuteCueSend(cue); } } else { LogCtrl.Error("Script doesn't exist."); } }
public static void Play(int[] seqCue) { LogCtrl.Status("Start: Sequence " + seqCue[0] + " Cue " + seqCue[1]); if (!Auto.MoveSequenceToCue(seqCue[0], seqCue[1])) { LogCtrl.Error("PB Error: " + Auto.GetLastError().ToString()); } Thread.Sleep(2); if (!Auto.SetSequenceTransportMode(seqCue[0], "Play")) { LogCtrl.Error("PB Error: " + Auto.GetLastError().ToString()); } }
public static void Close() { if (outputDevice != null && outputDevice.IsOpen) { try { outputDevice.Close(); LogCtrl.Status("Close MIDI Out: " + outputDevice.Name); } catch (Exception e) { LogCtrl.Error(e.Message); DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Error", "Coudn't close " + outputDevice.Name); } } }
public static void Close() { if (inputDevice != null && inputDevice.IsOpen) { try { inputDevice.StopReceiving(); inputDevice.Close(); LogCtrl.Status("Close MIDI In: " + inputDevice.Name); } catch (Exception e) { LogCtrl.Error(e.Message); DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Error", "Coudn't close " + inputDevice.Name); } } }
public static void Open(OutputDevice device) { Close(); try { outputDevice = device; outputDevice.Open(); Properties.Settings.Default.midiOutputDeviceName = outputDevice.Name; Properties.Settings.Default.Save(); LogCtrl.Status("Open MIDI Out: " + outputDevice.Name); } catch (Exception e) { LogCtrl.Error(e.Message); DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Error", "Coudn't open " + outputDevice.Name); } }
public void LoadData(XmlNode data) { PrototypeId = XmlUtil.GetAttribute <int>(data, "id"); if (PrototypeId < 0) { LogCtrl.Error("ID 为 " + PrototypeId + ",表出错了 。 表名:" + GetType()); } Name = XmlUtil.GetAttribute <string>(data, "name"); Icon = XmlUtil.GetAttribute <string>(data, "icon"); BackIcon1 = XmlUtil.GetAttribute <string>(data, "backIcon1"); BackIcon2 = XmlUtil.GetAttribute <string>(data, "backIcon2"); Desc = XmlUtil.GetAttribute <string>(data, "desc"); Quality = XmlUtil.GetAttribute <int>(data, "quality"); // Texture = XmlUtil.GetAttribute <Texture>(data, "texture"); OnLoadData(data); }
public static bool Open(InputDevice device) { try { inputDevice = device; inputDevice.Open(); inputDevice.StartReceiving(null, true); inputDevice.ControlChange += InputDevice_ControlChange; LogCtrl.Status("Connect: " + inputDevice.Name); return(true); } catch { LogCtrl.Error("Coudn't connect to " + inputDevice.Name); return(false); } }
public static bool Write(bool overwrite) { string filename; if (overwrite && path != null) { filename = path; } else { Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.Filter = "CC Files (*.cc)|*.cc"; bool?result = dlg.ShowDialog(); if (result == false) { return(false); } filename = dlg.FileName; } string p = Path.ChangeExtension(filename, ".cc"); using (DataSet dataSet = new DataSet("Cuelist")) { dataSet.Tables.Add(GetSettingsTable()); dataSet.Tables.Add(CuelistCtrl.GetCueTable()); dataSet.Tables.Add(ScriptlistCtrl.GetScriptTable()); dataSet.Tables.Add(BeamerlistCtrl.GetBeamerTable()); dataSet.Tables.Add(MidiController.GetMidiMapTable()); try { dataSet.WriteXml(p); } catch (Exception e) { LogCtrl.Error(e.Message); DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Error", "Couldn't write file!"); return(false); } } SetPath(p); CuelistCtrl.saved = true; RecentFilesCtrl.Add(p); LogCtrl.Status("Saved file: " + p); return(true); }
public static void ExecuteCmd(PbCmd cmd) { cmd.method.Invoke(null, cmd.args); if (Auto.GetLastError() != AutoError.None) { LogCtrl.Error("PB Error: " + Auto.GetLastError().ToString()); } if (cmd.args.Length > 0) { LogCtrl.Status("PB: " + cmd.method.Name + "," + string.Join(",", cmd.args)); } else { LogCtrl.Status("PB: " + cmd.method.Name); } }
public static void Close() { RequestStop(); if (inputDevice != null && inputDevice.IsOpen) { try { Auto2.UnInitialize(); inputDevice.StopReceiving(); inputDevice.Close(); LogCtrl.Status("Close MIDI In: " + inputDevice.Name); } catch (Exception e) { LogCtrl.Error(e.Message); } } }
public static void SendMSC(MscCommand mscCommand) { if (outputDevice != null && outputDevice.IsOpen && !MidiInputCtrl.mscMute) { try { outputDevice.SendSysEx(mscCommand.byteMessage); LogCtrl.Status("Send: " + mscCommand.message); } catch (Exception e) { LogCtrl.Error("Couldn't send MSC command!"); LogCtrl.Error(e.ToString()); } } else { LogCtrl.Warning("Send: " + mscCommand.message); } }
private void ReadDataConfig <T>(string path) where T : BasePrototype { listTableInfos.Add(typeof(T)); ResourceManager.LoadAsync(dataPath + "Castle/Castle", obj => { if (obj != null) { TextAsset textAsset = obj as TextAsset; byte[] b = textAsset.bytes; string content = System.Text.UTF8Encoding.UTF8.GetString(b).Trim(); PrototypeManager <T> .Instance.LoadData(content); } else { LogCtrl.Error(" 读取文件失败, Path : " + path + " Type : " + typeof(T)); } listTableInfos.Remove(typeof(T)); CheckIsFinish(); }); }
public static void Open(InputDevice device) { Close(); try { inputDevice = device; inputDevice.Open(); inputDevice.StartReceiving(null, true); inputDevice.SysEx += InputDevice_SysEx; inputDevice.NoteOn += InputDevice_NoteOn; Properties.Settings.Default.midiInputDeviceName = inputDevice.Name; Properties.Settings.Default.Save(); LogCtrl.Status("Open MIDI In: " + inputDevice.Name); } catch (Exception e) { LogCtrl.Error(e.Message); DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Error", "Coudn't open " + inputDevice.Name); } }
private void SendMethod(string ip, string message) { using (UdpClient udpClient = new UdpClient(ip, UDPPORT)) { try { Byte[] inputToBeSent = new Byte[256]; inputToBeSent = Encoding.ASCII.GetBytes(message.ToCharArray()); IPEndPoint remoteIpEndPoint = new IPEndPoint(IPAddress.Parse(ip), UDPPORT); udpClient.Send(inputToBeSent, inputToBeSent.Length); udpClient.Close(); } catch { Application.Current.Dispatcher.Invoke(new Action(() => { LogCtrl.Error("Error connection to Backup CueController!"); })); } } }
public static void ExecuteCmdArg(PbCmdArg cmdArg, float val) { try { int length = cmdArg.cmd.args.GetLength(0); object[] args = new object[length]; Array.Copy(cmdArg.cmd.args, args, length); Type type = args[cmdArg.argNr].GetType(); args[cmdArg.argNr] = Convert.ChangeType(val, type); cmdArg.cmd.method.Invoke(null, args); if (Auto.GetLastError() != AutoError.None) { LogCtrl.Error(Auto.GetLastError().ToString()); } } catch (Exception e) { LogCtrl.Error(e.Message); } }
public static void LoadBeamers(DataTable table) { try { beamers.Clear(); foreach (DataRow row in table.Rows) { int id = int.Parse(row[0].ToString()); string ip = row[1].ToString(); beamers.Add(new BeamerCtrl(id, ip)); } beamers.Sort((x, y) => x.id.CompareTo(y.id)); RefreshBeamerMenus(); } catch (Exception e) { LogCtrl.Error("Couldn't load beamers."); LogCtrl.Error(e.ToString()); } }
public static void SendNote(MidiNote note) { if (outputDevice != null && outputDevice.IsOpen && !MidiInputCtrl.noteMute) { try { Pitch pitch = (Pitch)note.pitch; outputDevice.SendNoteOn(Channel.Channel1, pitch, 127); outputDevice.SendNoteOn(Channel.Channel1, pitch, 0); LogCtrl.Status("Send: " + note.note + " (" + note.pitch + ")"); } catch (Exception e) { LogCtrl.Error("Couldn't send MIDI note!"); LogCtrl.Error(e.ToString()); } } else { LogCtrl.Warning("Send: " + note.note + " (" + note.pitch + ")"); } }
private static void InputDevice_SysEx(SysExMessage msg) { Application.Current.Dispatcher.Invoke(new Action(() => { MscCommand mscCommand = MscCommand.getMscCommand(msg.Data); if (mscCommand != null) { if (!mscMute) { for (int i = 0; i < CuelistCtrl.cues.Count; ++i) { Cue cue = CuelistCtrl.cues[i]; if (cue.trigger != null && cue.trigger.type == TriggerType.MSC && MscCommand.Compare(mscCommand, cue.trigger.mscCmd)) { if (Core.win.saveTriggerCheckbox.IsChecked && Core.win.cueTable.SelectedIndex != i) { LogCtrl.Error("In: " + mscCommand.message); } else { LogCtrl.Success("In: " + mscCommand.message); GoCtrl.Go(i); } return; } } LogCtrl.Status("In: " + mscCommand.message); } else { LogCtrl.Warning("In: " + mscCommand.message); } } })); }