Example #1
0
 private void BtnYes_Click(object sender, EventArgs e)
 {
     try
     {
         string strVideoName = tbVideoName.Text;
         string strPathValue = tbPathValue.Text;
         if (string.IsNullOrEmpty(strVideoName) || string.IsNullOrEmpty(strPathValue))
         {
             throw new Exception("请正确输入视频名称或视频网址");
         }
         if (!Directory.Exists(Application.StartupPath + @"\manageVideoIni\"))
         {
             Directory.CreateDirectory(Application.StartupPath + @"\manageVideoIni\");
         }
         string   iniPath = Application.StartupPath + @"\manageVideoIni\" + strVideoName + ".ini";
         INIClass ini     = new INIClass(iniPath);
         if (ini.ExistINIFile())
         {
             throw new Exception("该文件已存在,请更换视频名称");
         }
         ini.IniWriteValue("MyVideoMsg", "VideoName", strVideoName);
         ini.IniWriteValue("MyVideoMsg", "VideoPath", strPathValue);
         DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         Log.Error("[" + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "][" + System.Reflection.MethodBase.GetCurrentMethod().Name + "] err" + ex);
         MessageBox.Show(ex.Message);
     }
 }
Example #2
0
        private string GetVideoAddrByInitfilepath(string initFilePath)
        {
            string   strRes           = "";
            INIClass gasCardReaderIni = new INIClass(initFilePath);

            strRes = gasCardReaderIni.IniReadValue("MyService", "VideoAddr");
            return(strRes);
        }
Example #3
0
        private void initFrom()
        {
            try
            {
                lbAD.Text = Global.ConfigInfoList[Global.ConfigInfo.YeMeiMsg];
                string initFilePath = Global.ConfigInfoList[Global.ConfigInfo.InitAddr];

                if (string.IsNullOrEmpty(initFilePath))
                {
                    return;
                }
                string fullpath          = Application.StartupPath + "\\" + initFilePath.Substring(initFilePath.IndexOf("File"));
                string tempstr           = Path.GetFileNameWithoutExtension(initFilePath);
                string filenameExtension = tempstr.Substring(tempstr.IndexOf('.') + 1);
                initFilePath = fullpath.Substring(0, fullpath.LastIndexOf(".")) + ".temp";
                TreeNode tn = new TreeNode();
                //取出文件拓展名
                //string filenameExtension = Path.GetFileNameWithoutExtension(initFilePath).Substring(initFilePath.IndexOf('.') + 1);
                CommonData.FileType fileType = GetFileType(filenameExtension);
                switch (fileType)
                {
                case CommonData.FileType.Pdf:
                {
                    //pdfControl.DisplayPDFFile(filepath);
                    pdfFoxControl.DisplayPDFFile(initFilePath);
                    MyPanel.Controls.Clear();
                    MyPanel.Controls.Add(pdfFoxControl);
                    IsPicOrTxt(false);
                }
                break;

                case CommonData.FileType.Video:
                {
                    //INIClass ini = new INIClass(fullPath + ".temp");
                    INIClass ini        = new INIClass(initFilePath);
                    string   videoValue = ini.IniReadValue("MyVideoMsg", "VideoPath");
                    if (!string.IsNullOrEmpty(videoValue))
                    {
                        //webBrowserControl.SetVideoValue(videoValue);
                        MyPanel.Controls.Clear();
                        MyPanel.Controls.Add(webBrowserControl);
                        IsPicOrTxt(false);
                    }
                    else
                    {
                        throw new Exception("视频地址为空");
                    }
                }
                break;

                case CommonData.FileType.TXT:
                {
                    //txtControl.DisplayTxt(fullPath + ".temp");
                    txtControl.DisplayTxt(initFilePath);
                    MyPanel.Controls.Clear();
                    MyPanel.Controls.Add(txtControl);
                    IsPicOrTxt(false);
                }
                break;

                case CommonData.FileType.Image:
                {
                    picControl.SetPicPath(initFilePath);
                    MyPanel.Controls.Clear();
                    MyPanel.Controls.Add(picControl);
                    IsPicOrTxt(true);
                }
                break;

                case CommonData.FileType.PCB:
                {
                    pcbControl.ShowPcb(initFilePath);
                    MyPanel.Controls.Clear();
                    MyPanel.Controls.Add(pcbControl);
                    IsPicOrTxt(false);
                }
                break;
                }
            }
            catch (Exception ex)
            {
                Log.Error("[" + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "][" + System.Reflection.MethodBase.GetCurrentMethod().Name + "] err" + ex);
                MessageBox.Show(ex.Message);
            }
        }
Example #4
0
        private void Tv_AfterSelect(object sender, TreeViewEventArgs e)
        {
            try
            {
                //HideBox();
                TreeNode            tn       = e.Node;
                CommonData.FileType filetype = new CommonData.FileType();
                if (tn.Tag == null)
                {
                    return;
                }
                filetype = (CommonData.FileType)tn.Tag;
                string filepath = tn.Name;
                if (filetype != CommonData.FileType.Folder && filetype != CommonData.FileType.None)
                {
                    string name     = tn.Text;
                    string fullPath = Global.SysFilePath + "\\" + tn.FullPath;
                    webBrowserControl.ClearVideo();
                    switch (filetype)
                    {
                    case CommonData.FileType.Pdf:
                    {
                        //pdfControl.DisplayPDFFile(filepath);
                        pdfFoxControl.DisplayPDFFile(filepath);
                        MyPanel.Controls.Clear();
                        MyPanel.Controls.Add(pdfFoxControl);
                        IsPicOrTxt(false);
                    }
                    break;

                    case CommonData.FileType.Video:
                    {
                        //INIClass ini = new INIClass(fullPath + ".temp");
                        INIClass ini        = new INIClass(filepath);
                        string   videoValue = ini.IniReadValue("MyVideoMsg", "VideoPath");
                        if (!string.IsNullOrEmpty(videoValue))
                        {
                            webBrowserControl.SetVideoValue(videoValue);
                            MyPanel.Controls.Clear();
                            MyPanel.Controls.Add(webBrowserControl);
                            IsPicOrTxt(false);
                        }
                        else
                        {
                            throw new Exception("视频地址为空");
                        }
                    }
                    break;

                    case CommonData.FileType.TXT:
                    {
                        //txtControl.DisplayTxt(fullPath + ".temp");
                        txtControl.DisplayTxt(filepath);
                        MyPanel.Controls.Clear();
                        MyPanel.Controls.Add(txtControl);
                        IsPicOrTxt(false);
                    }
                    break;

                    case CommonData.FileType.Image:
                    {
                        picControl.SetPicPath(filepath);
                        MyPanel.Controls.Clear();
                        MyPanel.Controls.Add(picControl);
                        IsPicOrTxt(true);
                    }
                    break;

                    case CommonData.FileType.PCB:
                    {
                        pcbControl.ShowPcb(filepath);
                        MyPanel.Controls.Clear();
                        MyPanel.Controls.Add(pcbControl);
                        IsPicOrTxt(false);
                    }
                    break;

                    case CommonData.FileType.Web:
                    {
                        INIClass ini = new INIClass(filepath);
                        string   url = ini.IniReadValue("MyWebMsg", "URL");
                        webControl.DisplayWeb(url);
                        MyPanel.Controls.Clear();
                        MyPanel.Controls.Add(webControl);
                        IsPicOrTxt(false);
                    }
                    break;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("[" + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "][" + System.Reflection.MethodBase.GetCurrentMethod().Name + "] err" + ex);
                MessageBox.Show(ex.Message);
            }
        }