示例#1
0
        /// <summary>
        /// HRV读取用Timer
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnTimerHRV(object sender, EventArgs e)
        {
            try
            {
                hd.GetHRV();

                if (isGameStart)
                {
                    ArrayList tmpHRVArr = hd.HRVArr;
                    ArrayList tmpEPArr  = hd.EPArr;
                    ArrayList tmpIBIArr = hd.IBIArr;
                    ArrayList tmpPPGArr = hd.PPGArr;

                    for (int i = 0; i < tmpHRVArr.Count; i++)
                    {
                        HRVData.Add(tmpHRVArr[i]);
                        if (HRVData.Count == 1)
                        {
                            startTime = DateTime.Now;
                        }

                        for (int ep = 0; ep < tmpEPArr.Count; ep++)
                        {
                            OnAnimationForEP((Single)tmpEPArr[ep]);
                            EPData.Add(tmpEPArr[ep]);
                        }
                    }
                }

                ArrayList tempHRVArr = hd.HRVArr;
                for (int hrv = 0; hrv < tempHRVArr.Count; hrv++)
                {
                    String cmd = "<invoke name=\"setHrv\" returntype=\"xml\"><arguments><number>" +
                                 (Single)tempHRVArr[hrv] + "</number></arguments></invoke>";
                    shockwave.CallFunction(cmd);
                }

                ArrayList tempEPArr = hd.EPArr;
                for (int ep = 0; ep < tempEPArr.Count; ep++)
                {
                    //OnAnimationForEP((Single)tempEPArr[ep]);
                    Console.WriteLine(tempEPArr[ep]);
                    String cmd = "<invoke name=\"writeEp\" returntype=\"xml\"><arguments><number>" +
                                 (Single)tempEPArr[ep] + "</number></arguments></invoke>";
                    shockwave.CallFunction(cmd);
                }
            }
            catch (Exception ex)
            {
            }
        }
        /// <summary>
        /// Call flash inside methods in a thread safe way.
        /// </summary>
        /// <param name="req"></param>
        /// <param name="flash"></param>
        public void CallFunction(string req)
        {
            if (flash == null)
            {
                return;
            }

            if (flash.InvokeRequired)
            {
                flash.Invoke(new MethodInvoker(delegate { flash.CallFunction(req); }));
                return;
            }
            flash.CallFunction(req);
        }
        /// <summary>
        /// Call flash inside methods in a thread safe way.
        /// </summary>
        /// <param name="req"></param>
        /// <param name="flash"></param>
        public static void CallFunction(string req, AxShockwaveFlashObjects.AxShockwaveFlash flashobj2 = null)
        {
            if (flashobj2 == null)
            {
                return;
            }

            if (flashobj2.InvokeRequired)
            {
                flashobj2.Invoke(new MethodInvoker(delegate { flashobj2.CallFunction(req); }));
                return;
            }
            flashobj2.CallFunction(req);
        }
示例#4
0
        /// <summary>
        /// 开始播放课程
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnPlayCourse(object sender, RoutedEventArgs e)
        {
            TreeViewItem tvi = (TreeViewItem)sender;
            Hashtable    tmp = (Hashtable)tvi.Tag;

            host.Dispose();
            shockwave.Dispose();
            host       = new System.Windows.Forms.Integration.WindowsFormsHost();
            shockwave  = new AxShockwaveFlashObjects.AxShockwaveFlash();
            host.Child = shockwave;
            //this.playerPanel.Children.Add(host);

            // 设置 .swf 文件相对路径
            string swfPath = System.Environment.CurrentDirectory;

            swfPath             += "\\Course\\" + tmp["mid"] + "-" + tmp["cid"] + ".swf";
            shockwave.Movie      = swfPath;
            shockwave.FlashCall += new AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEventHandler(FromFlashCall);
            shockwave.CallFunction("<invoke name=\"c2flash\" returntype=\"xml\"><arguments><number>50</number></arguments></invoke>");
            // this.changeVolume.Value = 50;
            shockwave.Loop = false;
            //this.changeVolume.ValueChanged += changeVolume_ValueChanged;
            cdb.OnUpCourseLook(tmp);

            //           MessageBox.Show("开始。。。");
        }
示例#5
0
        private object CallFunction(string name, params object[] args)
        {
            StringBuilder     builder  = new StringBuilder();
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.OmitXmlDeclaration = true;
            using (XmlWriter writer = XmlWriter.Create(builder, settings))
            {
                writer.WriteStartElement("invoke");
                writer.WriteAttributeString("name", name);
                writer.WriteAttributeString("returnType", "xml");
                writer.WriteStartElement("arguments");
                foreach (object arg in args)
                {
                    WriteXmlValue(arg, writer);
                }
                writer.WriteFullEndElement();
                writer.WriteFullEndElement();
            }
            string request = builder.ToString();
            string result  = axShockwaveFlash.CallFunction(request);

            using (XmlReader reader = XmlReader.Create(new StringReader(result)))
            {
                reader.Read();
                return(ReadXmlValue(reader));
            }
        }
示例#6
0
        private string callFlashString(AxShockwaveFlashObjects.AxShockwaveFlash flash,
                                       string method, params object[] vals)
        {
            string response = string.Empty;

            StringBuilder sb = new StringBuilder();

            try
            {
                foreach (var param in vals)
                {
                    sb.AppendFormat("<string>{0}</string>", param);
                }

                _log.DebugFormat("Calling method: {0}[{1}]", method, sb.ToString());
                lock (_lock)
                {
                    response = flash.CallFunction(string.Format(METHODSTRING, method, sb.ToString()));
                }
                if (response != "<undefined/>") //void
                {
                    _log.DebugFormat("Response from method: {0}[{1}] = {2}", method, sb.ToString(), response);
                }
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Error Calling method {0} [{1}] on flash {2}. {3}",
                                 method, sb, flash.Name, ex.ToString());
            }
            return(response);
        }
示例#7
0
        /// <summary>
        /// 开始播放
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StartPlay_Click(object sender, RoutedEventArgs e)
        {
            if (playPath != "" || !String.IsNullOrEmpty(playPath))
            {
                host       = new System.Windows.Forms.Integration.WindowsFormsHost();
                shockwave  = new AxShockwaveFlashObjects.AxShockwaveFlash();
                host.Child = shockwave;
                this.playerPanel.Children.Add(host);

                // 设置 .swf 文件相对路径
                shockwave.Movie      = playPath;
                shockwave.FlashCall += new AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEventHandler(FromFlashCall);
                shockwave.Loop       = false;
                this.ScaleListTreeView.IsEnabled = false;

                String cmd = "<invoke name=\"c2flash\" returntype=\"xml\"><arguments><string>";
                if (UserInfoStatic.UserSex == "男")
                {
                    cmd += "men";
                }
                else
                {
                    cmd += "women";
                }

                cmd += "</string></arguments></invoke>";

                shockwave.CallFunction(cmd);
                shockwave.Play();
                host.Unloaded += OnRemoveFlash;
                ///隐藏量表列表
                if (this.ScaleListGrid.Visibility == System.Windows.Visibility.Hidden)
                {
                    double left = this.Margin.Left - 80;
                    this.Margin = new Thickness(left, 0, 0, 0);
                    this.ScaleListGrid.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    double left = this.Margin.Left + 80;
                    this.Margin = new Thickness(left, 0, 0, 0);
                    this.ScaleListGrid.Visibility = System.Windows.Visibility.Hidden;
                }
            }
        }
示例#8
0
        private string callFlashEmpty(AxShockwaveFlashObjects.AxShockwaveFlash flash,
                                      string method)
        {
            string response = string.Empty;

            try
            {
                _log.DebugFormat("Calling method: {0}", method);
                lock (_lock)
                {
                    response = flash.CallFunction(string.Format(METHODEMPTY, method));
                }
                if (response != "<undefined/>") //void
                {
                    _log.DebugFormat("Response from method: {0} = {1}", method, response);
                }
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Error Calling method {0} on flash {1}. {2}",
                                 method, flash.Name, ex.ToString());
            }
            return(response);
        }
 private void changeVolume_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
 {
     System.Diagnostics.Debug.Write("Slider值:" + e.NewValue + "\n");
     shockwave.CallFunction("<invoke name=\"c2flash\" returntype=\"xml\"><arguments><number>" + e.NewValue + "</number></arguments></invoke>");
 }
示例#10
0
 public void CallFunction(string request)
 {
     flash.CallFunction(request);
 }
        /// <summary>
        /// 读取HRV的Timer
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnTimerHRV(Object sender, EventArgs e)
        {
            try
            {
                hd.GetHRV();

                if (isGameStart)
                {
                    ArrayList tmpHRVArr = hd.HRVArr;
                    ArrayList tmpEPArr  = hd.EPArr;
                    ArrayList tmpIBIArr = hd.IBIArr;
                    ArrayList tmpPPGArr = hd.PPGArr;

                    for (int i = 0; i < tmpHRVArr.Count; i++)
                    {
                        HRVData.Add(tmpHRVArr[i]);
                        if (HRVData.Count == 1)
                        {
                            startTime = DateTime.Now;
                        }
                        OnChartPaint(HRVData);
                        for (int ep = 0; ep < tmpEPArr.Count; ep++)
                        {
                            EPData.Add(tmpEPArr[ep]);
                            OnAnimationForEP((Single)tmpEPArr[ep]);
                        }
                    }
                }

                ArrayList tempEPArr = hd.EPArr;
                for (int ep = 0; ep < tempEPArr.Count; ep++)
                {
                    double EPValue = (Single)tempEPArr[ep];
                    for (int i = 0; i < 15; i++)
                    {
                        if (EPValue > EPRange[i, 0] && EPValue <= EPRange[i, 1])
                        {
                            String cmd = "<invoke name=\"ep\" returntype=\"xml\"><arguments><number>" + (i + 1);
                            cmd += "</number></arguments></invoke>";
                            shockwave.CallFunction(cmd);
                        }
                    }
                }


                //开始判断是否是伪信号
                if (!hrvPromptFlg)
                {
                    if (!IsSpurious(HRVData))
                    {
                        HRVPrompt.Visibility = System.Windows.Visibility.Visible;


                        //hrvp = new HRVPrompt();
                        //hrvp.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                        //hrvp.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
                        //hrvp.Margin = new Thickness(0,0, 0, 0);
                        //hrvp.Width = 274;
                        //this.mainWindow.Children.Add(hrvp);
                        hrvPromptFlg = true;
                        System.Diagnostics.Debug.Write("MainWindow中成员个数:" + this.mainWindow.Children.Count + "\n");
                    }
                }
                else
                {
                    if (IsSpurious(HRVData))
                    {
                        //System.Diagnostics.Debug.Write("删除提示框\n");
                        //this.mainWindow.Children.Remove(hrvp);
                        //System.Diagnostics.Debug.Write("MainWindow中成员个数:" + this.mainWindow.Children.Count + "\n");
                        //hrvp = null;
                        HRVPrompt.Visibility = System.Windows.Visibility.Hidden;
                        hrvPromptFlg         = false;
                        this.UpdateLayout();
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        /// <summary>
        /// 开始训练
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void viewGrid_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                if (Convert.ToInt32(tInfo["tid"]) == 20 || Convert.ToInt32(tInfo["tid"]) == 21 || Convert.ToInt32(tInfo["tid"]) == 22 || Convert.ToInt32(tInfo["tid"]) == 23 || Convert.ToInt32(tInfo["tid"]) == 24 || Convert.ToInt32(tInfo["tid"]) == 25)
                {
                    HRVPrompt.Visibility           = System.Windows.Visibility.Hidden;
                    HrvChartGrid2.Visibility       = System.Windows.Visibility.Hidden;
                    xietiaoView.Visibility         = System.Windows.Visibility.Hidden;
                    PlayerView.Margin              = new Thickness(0, 0, 0, 57);
                    PlayerView.VerticalAlignment   = System.Windows.VerticalAlignment.Bottom;
                    PlayerView.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                    PlayerView.Height              = 589;
                    TrainDesensitization des = new TrainDesensitization();

                    this.PlayerView.Children.Add(des);
                }
                else if (Convert.ToInt32(tInfo["tid"]) == 1 || Convert.ToInt32(tInfo["tid"]) == 2 || Convert.ToInt32(tInfo["tid"]) == 3 || Convert.ToInt32(tInfo["tid"]) == 4 || Convert.ToInt32(tInfo["tid"]) == 5 || Convert.ToInt32(tInfo["tid"]) == 6)
                {
                    enabledDevice();
                    HrvChartGrid2.Visibility       = System.Windows.Visibility.Visible;
                    xietiaoView.Visibility         = System.Windows.Visibility.Visible;
                    PlayerView.Margin              = new Thickness(0, 0, 0, 97);
                    PlayerView.VerticalAlignment   = System.Windows.VerticalAlignment.Bottom;
                    PlayerView.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                    PlayerView.Height              = 549;
                    host       = new System.Windows.Forms.Integration.WindowsFormsHost();
                    shockwave  = new AxShockwaveFlashObjects.AxShockwaveFlash();
                    host.Child = shockwave;

                    this.PlayerView.Children.Add(host);

                    // 设置 .swf 文件相对路径
                    string swfPath = System.Environment.CurrentDirectory;
                    swfPath             += @"\Train\" + tInfo["tid"].ToString() + "\\play.swf";
                    shockwave.Movie      = swfPath;
                    shockwave.FlashCall += new AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEventHandler(FromFlashCall);
                    String cmd = "<invoke name=\"c2flash\" returntype=\"xml\"><arguments><object>";
                    cmd += "<property id=\"Level\"><number>" + tInfo["gateOpen"] + "</number></property>";
                    cmd += "<property id=\"O\"><number>" + UserInfoStatic.O + "</number></property>";
                    cmd += "<property id=\"R\"><number>" + UserInfoStatic.R + "</number></property>";
                    cmd += "<property id=\"T\"><number>" + UserInfoStatic.T + "</number></property>";
                    cmd += "<property id=\"E\"><number>" + UserInfoStatic.E + "</number></property>";
                    cmd += "<property id=\"W\"><number>" + UserInfoStatic.W + "</number></property>";
                    cmd += "</object></arguments></invoke>";

                    shockwave.CallFunction(cmd);
                    shockwave.Play();
                }
                //else if (Convert.ToInt32(tInfo["tid"]) == 30 || Convert.ToInt32(tInfo["tid"]) == 31 || Convert.ToInt32(tInfo["tid"]) == 32 )
                //{

                //    enabledDevice();
                //    HrvChartGrid2.Visibility = System.Windows.Visibility.Visible;
                //    xietiaoView.Visibility = System.Windows.Visibility.Visible;
                //    PlayerView.Margin = new Thickness(0, 0, 0, 97);
                //    PlayerView.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
                //    PlayerView.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                //    PlayerView.Height = 549;
                //    host = new System.Windows.Forms.Integration.WindowsFormsHost();
                //    shockwave = new AxShockwaveFlashObjects.AxShockwaveFlash();
                //    host.Child = shockwave;

                //    this.PlayerView.Children.Add(host);

                //    // 设置 .swf 文件相对路径
                //    string swfPath = System.Environment.CurrentDirectory;
                //    swfPath += @"\Train\" + tInfo["tid"].ToString() + "\\play.swf";
                //    shockwave.Movie = swfPath;
                //    shockwave.FlashCall += new AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEventHandler(FromFlashCall);
                //    String cmd = "<invoke name=\"c2flash\" returntype=\"xml\"><arguments><object>";
                //    cmd += "<property id=\"Level\"><number>" + tInfo["gateOpen"] + "</number></property>";
                //    cmd += "<property id=\"O\"><number>" + UserInfoStatic.O + "</number></property>";
                //    cmd += "<property id=\"R\"><number>" + UserInfoStatic.R + "</number></property>";
                //    cmd += "<property id=\"T\"><number>" + UserInfoStatic.T + "</number></property>";
                //    cmd += "<property id=\"E\"><number>" + UserInfoStatic.E + "</number></property>";
                //    cmd += "<property id=\"W\"><number>" + UserInfoStatic.W + "</number></property>";
                //    cmd += "</object></arguments></invoke>";

                //    shockwave.CallFunction(cmd);
                //    shockwave.Play();
                //}
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Write("载入flash时出错:" + ex.Message + "\n");
            }
        }