private void RunLuaScript(object sender, EventArgs e) { if (FileManager.currentFileId < 0) { return; } //check if files are saved bool unsavedFiles = false; for (int i = 0; i < FileManager.isFileNotSaved.Length; i++) { if (FileManager.isFileNotSaved[i]) { unsavedFiles = true; break; } } if (unsavedFiles) { MessageBoxResult res = CustomMessageBox.ShowYesNoCancel( "There are unsaved files, do you want to save all files?", "Unsaved Files", "Yes", "No", "Cancel", MessageBoxImage.Exclamation ); if (res == MessageBoxResult.Yes) { string writePath = LHregistry.GetFile(FileManager.currentFileId); textEditor.Save(writePath); UnChangedFile(Listbox); } if (res == MessageBoxResult.Cancel) { return; } } //load and run lua script Communicator.load(FileManager.files[FileManager.currentFileId]); Communicator.start(); //start monitoring Startwindow sw = new Startwindow(); sw.Show(); LuaFileView.Items.Refresh(); return; }
public static void DistributeData() { StreamReader sr = new StreamReader(dataStream); while (Active) { //dataStream.EndRead(readres); //dataStream.Read(buf, 0, 1023); string s = sr.ReadToEnd(); ushort[] shortbuf = new ushort[512]; for (int i = 0; i < 512; i++) { shortbuf[i] = BitConverter.ToUInt16(buf, (i * 2) % 1023); } if (Enumerable.Contains <ushort>(shortbuf, 65535)) { //still shit to do ushort[] dat = CommunicatorHelper.SubArray <ushort>(shortbuf, 0, 7); DataPacket pack = ProcessData(dat); charsread += 14; if (pack != null) { Debug.WriteLine("detected a new message" + pack.val.ToString()); if (Startwindow.inst != null) { Random rand = new Random(); Startwindow.addNodeToGraph(pack.id, 2 + (pack.val * 2)); } } } else { } for (int i = 0; i < 1024; i++) { } //readres = dataStream.BeginRead(buf, 0, 1024, null, null); //Thread.Sleep(10); //errorstream } }
// [0-4] Fingers // [5-7] Acceleration // [8-10] Rotation public Startwindow() { inst = this; InitializeComponent(); ProgramIcon.Source = ImageSourceFromBitmap(LeHandUI.Properties.Resources.BTIconNew); //REDUNDANT LISTS FOR TEST VALUES, TO BE REMOVED IN NEXT IMPLEMENTATION PinkList.AddRange(new ChartValues <double>(new double[] { 5, 7, 4, 6 })); RingvingerList.AddRange(new ChartValues <double>(new double[] { 8, 6, 7, 5 })); MiddelvingerList.AddRange(new ChartValues <double>(new double[] { 3, 8, 5, 6 })); WijsvingerList.AddRange(new ChartValues <double>(new double[] { 0, 6, 8, 5 })); DuimList.AddRange(new ChartValues <double>(new double[] { 5, 4, 7, 5 })); AccXList.AddRange(new ChartValues <double>(new double[] { 2, 5, 6, 6 })); AccYList.AddRange(new ChartValues <double>(new double[] { 0, 2, 8, 4 })); AccZList.AddRange(new ChartValues <double>(new double[] { 5, 3, 5, 4 })); RotXList.AddRange(new ChartValues <double>(new double[] { 0, 0, 2, 4 })); RotYList.AddRange(new ChartValues <double>(new double[] { 1, 2, 7, 3 })); RotZList.AddRange(new ChartValues <double>(new double[] { 3, 0, 0, 0 })); #region AccelerationGraph AccelerationGraph.Series = new SeriesCollection { new LineSeries { Title = "X", Values = AccXList, //new ChartValues<double> {4, 6, 5, 2, 7} PointGeometry = DefaultGeometries.Diamond, PointGeometrySize = defaultGeometrySize, LineSmoothness = defaultSmoothness, StrokeThickness = defaultStrokeThicc, Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(52, 172, 188)), Fill = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 52, 172, 188)) //Completely transparent but if you want you can enable it }, new LineSeries { Title = "Y", Values = AccYList, PointGeometry = DefaultGeometries.Circle, PointGeometrySize = defaultGeometrySize, LineSmoothness = defaultSmoothness, StrokeThickness = defaultStrokeThicc, Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 19, 120)), //#E11378 Fill = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 255, 19, 120)) // same here, just insert 120 into the alpha channel }, new LineSeries { Title = "Z", Values = AccZList, PointGeometry = DefaultGeometries.Square, PointGeometrySize = defaultGeometrySize, LineSmoothness = defaultSmoothness, StrokeThickness = defaultStrokeThicc, Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 217, 89)), //#FFD959 Fill = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 255, 217, 89)) } }; AccelerationGraph.AxisX.Add(new Axis { Title = "Refreshes", Labels = null }); AccelerationGraph.AxisY.Add(new Axis { Title = "Value", LabelFormatter = null }); AccelerationGraph.DisableAnimations = true; AccelerationGraph.ToolTip = null; AccelerationGraph.Hoverable = false; AccelerationGraph.DataClick += CartesianChart1OnDataClick; #endregion #region RotationGraph RotationGraph.Series = new SeriesCollection { new LineSeries { Title = "X", Values = RotXList, PointGeometry = DefaultGeometries.Triangle, PointGeometrySize = defaultGeometrySize, LineSmoothness = defaultSmoothness, StrokeThickness = defaultStrokeThicc, Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(52, 172, 188)), Fill = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 52, 172, 188)) //Completely transparent but if you want you can enable it }, new LineSeries { Title = "Y", Values = RotYList, PointGeometry = DefaultGeometries.Diamond, PointGeometrySize = defaultGeometrySize, LineSmoothness = defaultSmoothness, StrokeThickness = defaultStrokeThicc, Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 19, 120)), //#E11378 Fill = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 255, 19, 120)) // same here, just insert 120 into the alpha channel }, new LineSeries { Title = "Z", Values = RotZList, PointGeometry = DefaultGeometries.Circle, PointGeometrySize = defaultGeometrySize, LineSmoothness = defaultSmoothness, StrokeThickness = defaultStrokeThicc, Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 217, 89)), //#FFD959 Fill = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 255, 217, 89)) } }; RotationGraph.AxisX.Add(new Axis { Title = "Refreshes", Labels = null }); RotationGraph.AxisY.Add(new Axis { Title = "Value", LabelFormatter = null }); RotationGraph.DisableAnimations = true; RotationGraph.ToolTip = null; RotationGraph.Hoverable = false; RotationGraph.DataClick += CartesianChart1OnDataClick; #endregion #region HandGraph HandGraph.Series = new SeriesCollection { new LineSeries { Title = "Duim", Values = DuimList, PointGeometry = DefaultGeometries.Square, PointGeometrySize = defaultGeometrySize, LineSmoothness = defaultSmoothness, StrokeThickness = defaultStrokeThicc, Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(52, 172, 188)), Fill = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 52, 172, 188)) //Completely transparent but if you want you can enable it }, new LineSeries { Title = "Wijsvinger", Values = WijsvingerList, PointGeometry = DefaultGeometries.Square, PointGeometrySize = defaultGeometrySize, LineSmoothness = defaultSmoothness, StrokeThickness = defaultStrokeThicc, Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 19, 120)), //#E11378 Fill = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 255, 19, 120)) // same here, just insert 120 into the alpha channel }, new LineSeries { Title = "Middelvinger", Values = MiddelvingerList, PointGeometry = DefaultGeometries.Square, PointGeometrySize = defaultGeometrySize, LineSmoothness = defaultSmoothness, StrokeThickness = defaultStrokeThicc, Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 217, 89)), //#FFD959 Fill = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 255, 217, 89)) }, new LineSeries { Title = "Ringvinger", Values = RingvingerList, PointGeometry = DefaultGeometries.Square, PointGeometrySize = defaultGeometrySize, LineSmoothness = defaultSmoothness, StrokeThickness = defaultStrokeThicc, Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(242, 242, 242)), Fill = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 242, 242, 242)) }, new LineSeries { Title = "Pink", Values = PinkList, PointGeometry = DefaultGeometries.Square, PointGeometrySize = defaultGeometrySize, LineSmoothness = defaultSmoothness, StrokeThickness = defaultStrokeThicc, Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(35, 143, 35)), //#238F23 Fill = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 35, 143, 35)) } }; HandGraph.AxisX.Add(new Axis { Title = "Refreshes", Labels = null }); HandGraph.AxisY.Add(new Axis { Title = "Value", LabelFormatter = null }); HandGraph.DisableAnimations = true; HandGraph.ToolTip = null; HandGraph.Hoverable = false; #endregion }