private void button_pptopen_Click(object sender, EventArgs e)
        {
            string         filepath = "";
            OpenFileDialog op       = new OpenFileDialog();

            op.Title = "请选择教学资源文件";
            //op.Filter = "All Files(*.*)|*.*|ppt Files(*.ppt)|*.ppt|word 2007 Files(*.doc)|*.doc|excel 2007 Files(*.xls)|*.xls|word Files(*.docx)|*.docx|excel Files(*.xlsx)|*.xlsx";
            op.Filter = "ppt Files(*.ppt,*.pptx)|*.ppt;*.pptx";
            //op.Filter = "ppt Files(*.ppt,*.pptx)|*.ppt;*.pptx|Image Files(*.jpg,*.jpeg,*.bmp,*.png,*.gif)|*.jpg;*.jpeg;*.bmp;*.png;*.gif";

            if (op.ShowDialog() == DialogResult.OK)
            {
                filepath = op.FileName;
                string dir       = filepath.Substring(0, filepath.LastIndexOf("\\"));
                string fname     = op.SafeFileName;
                string extension = Path.GetExtension(op.FileName);
            }
            else
            {
                return;
            }


            if (myppt == null)
            {
                myppt = new MyPPT();
                myppt.PPTOpen(filepath);
            }
            else
            {
                myppt.PPTClose();
                myppt.PPTOpen(filepath);
            }
        }
 private void button_pptclose_Click(object sender, EventArgs e)
 {
     if (myppt != null)
     {
         myppt.PPTClose();
         myppt = null;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 异步拷贝到本地sourcefile目录下
        /// </summary>
        public void AsnycCopy()
        {
            DriveInfo[] drives = DriveInfo.GetDrives();
            string      hd     = sourcePath.Substring(0, 1);
            string      hdtype = "";

            foreach (DriveInfo dri in drives)
            {
                string _name = dri.Name.Substring(0, 1);
                if (_name == hd)
                {
                    hdtype = dri.DriveType.ToString();
                    break;
                }
            }
            string dir      = Application.StartupPath + "\\sourcefile\\";
            string filename = sourceFilename;

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            string pathSrc = sourcePath + "\\" + sourceFilename;
            string ext     = Path.GetExtension(pathSrc);

            //if (ext == ".ppt" || ext == ".pptx" || ext == ".doc" || ext == ".docx" || ext == ".jpg" || ext == ".jpeg" || ext == ".bmp" || ext == ".png" || ext == ".gif")
            //{
            //    FileOper.CopyFile(pathSrc, dir + filename, true);
            //}
            EService.selectFile(sourceFilename, pathSrc, false);

            if (filename.IndexOf("ppt") > 0 || filename.IndexOf("PPT") > 0)
            {
                bExporting = true;
                MyPPT.exportImg(sourcePath + "\\" + sourceFilename);


                bExporting = false;
            }
        }
Exemplo n.º 4
0
        private void ReadFilePath(string diskPath, int field, bool bNotify = false)
        {
            currentdir = diskPath;
            if (diskPath.LastIndexOf("\\") == diskPath.Length - 1)
            {
                diskPath = diskPath.Substring(0, diskPath.Length - 1);
            }
            ArrayList autoAddedFileList = new ArrayList();
            ArrayList al = Disk.MergrObj(diskPath.Replace("\r\n", ""));

            btnList = new ArrayList();
            if (field == 1)
            {
                Button backBtn = CreateBackBtn();
                btnList.Add(backBtn);
            }

            bool bAutoSync = false;

            string[]  szType    = { "ppt", "pptx", "doc", "docx", "pdf", "mp3", "wma", "wmv", "mp4", "swf" };
            ArrayList filelist0 = Disk.getFilelist(diskPath.Replace("\r\n", ""), szType);

            if (filelist0.Count <= 5)
            {
                bAutoSync = true;
            }
            else
            {
                Httpd.pushFilelistTips("U盘课件文件超过5个!\r\n请手动选择课件文件,并使用鼠标\"右键\"选择\"添加到如e小助手\"");
            }
            bAutoSync = false;

            for (int k = 0; k < al.Count; k++)
            {
                string value = al[k].ToString();
                Button btn   = new Button();
                btn.Size      = new System.Drawing.Size(70, 70);
                btn.BackColor = System.Drawing.Color.FromArgb(255, 255, 255);
                btn.FlatStyle = FlatStyle.Flat;
                btn.FlatAppearance.BorderColor        = System.Drawing.Color.FromArgb(153, 209, 255);
                btn.FlatAppearance.BorderSize         = 0;
                btn.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(204, 232, 255);
                btn.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(229, 243, 255);
                btn.TextAlign  = ContentAlignment.BottomCenter;
                btn.MouseMove += new System.Windows.Forms.MouseEventHandler(btn_MouseMove);
                btn.MouseDown += new System.Windows.Forms.MouseEventHandler(btn_MouseDown);
                btn.AllowDrop  = true;
                if (value.Split('|')[0].ToString() == "0")
                {
                    btn.BackgroundImage = global::RueHelper.Properties.Resources.wenjianjia;
                    btn.Name            = "0|" + diskPath + "|" + value.Split('|')[2].ToString();
                }
                else
                {
                    string filename = value.Split('|')[2].ToString();
                    string extName  = filename.Substring(filename.LastIndexOf(".") + 1, (filename.Length - filename.LastIndexOf(".") - 1));
                    btn.BackgroundImage = FileICON(extName);//load
                    if (btn.BackgroundImage == null)
                    {
                        continue;
                    }
                    btn.Name = "1|" + diskPath + "|" + value.Split('|')[2].ToString();

                    if (filename.StartsWith("~$"))
                    {
                        continue;
                    }

                    if (field == 0 && bAutoSync)
                    {
                        //仅仅在插上U盘时自动加载
                        string _filepath = diskPath + "\\" + filename;
                        autoAddedFileList.Add(_filepath);
                        continue;
                    }
                }
                this.label6.Text = diskPath + "\\" + value.Split('|')[2].ToString();
                btn.Text         = value.Split('|')[1].ToString();
                string tooltipStr = value.Split('|')[2].ToString() + "\r\n类型:" + value.Split('|')[3].ToString() + "\r\n修改日期:" + value.Split('|')[5].ToString() + "\r\n大小:" + value.Split('|')[4].ToString() + "";
                this.toolTip1.SetToolTip(btn, tooltipStr);
                addButtonlist_Left(btn);
            }

            try
            {
                for (int i = 0; i < autoAddedFileList.Count; i++)
                {
                    string _path = (string)autoAddedFileList.ToArray()[i];
                    string _name = Path.GetFileName(_path);
                    EService.selectFile(_name, _path);
                    this.AddFile(_path, false);
                }
            }catch (Exception e1) {
                ;//
            }

            Thread thread = new Thread(delegate()
            {
                if (autoAddedFileList.Count == 0)
                {
                    return;
                }

                bExporting = true;

                try
                {
                    string title = Global.getSchoolname() + " - " + Global.getClassname() + "";
                    if (bNotify)
                    {
                        if (fNotify == null)
                        {
                            fNotify = new FormNotify(title, "\r\n 课件导入中,请稍后!", 30);
                        }
                        this.Invoke(new System.EventHandler(this.showForm), new object[] { fNotify, null });
                        fNotify.InvokeUpdate(title, "\r\n 课件导入中,请稍后!");
                    }

                    for (int i = 0; i < autoAddedFileList.Count; i++)
                    {
                        string filepathSrc = (string)autoAddedFileList.ToArray()[i];
                        Log.Info("copy ppt......0:" + filepathSrc);
                        string _fname = Path.GetFileName(filepathSrc);
                        if (_fname.IndexOf("ppt") > 0 || _fname.IndexOf("PPT") > 0)
                        {
                            Log.Info("copy ppt......3");
                            MyPPT.exportImg(filepathSrc);
                            Log.Info("copy ppt......4");
                        }
                        Log.Info("copy ppt......5");
                    }
                    bExporting = false;
                    if (bNotify && fNotify != null)
                    {
                        fNotify.InvokeUpdate(title, "\r\n 课件导入完毕!");
                        Thread.Sleep(5000);
                        fNotify.InvokeClose();
                        fNotify = null;
                    }
                }catch (Exception e1) {
                    Log.Error("Err!!! " + e1.Message);
                    bExporting = false;
                    try
                    {
                        if (fNotify != null)
                        {
                            fNotify.InvokeClose();
                            fNotify = null;
                        }
                    }
                    catch (Exception e2)
                    {
                        Log.Error("Err!!! " + e2.Message);
                    }
                }
            });

            thread.Start();

            RefreshControls();
        }
Exemplo n.º 5
0
        private void Exit()
        {
            try
            {
                MyPPT.clearImg();
            }
            catch (Exception e) { Log.Error(e.Message); }

            isExit = true;
            //2016-04-09
            Log.Info("From1.exit now...");
            try
            {
                if (m_db != null)
                {
                    m_db.Close();
                    m_db = null;
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            this.timer_lessonOff.Enabled = false;
            this.ShowInTaskbar           = false;
            this.notifyIcon1.Visible     = false;

            try
            {
                Process p = Process.GetCurrentProcess();
                if (p != null)
                {
                    Log.Info("From1 KillProcess now. pid=" + p.Id);
                    Thread.Sleep(1000);
                    p.Kill();
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (m_Host != null)
                {
                    m_Host.Close();
                    m_Host = null;
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (m_HttpdComet != null)
                {
                    m_HttpdComet.stop();
                    m_HttpdComet = null;
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (thread_comet != null)
                {
                    thread_comet.Abort();
                    thread_comet.Interrupt();
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (thread_Manage != null)
                {
                    thread_Manage.Abort();
                    thread_Manage.Interrupt();
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (thread_DeviceStatusCheck != null)
                {
                    thread_DeviceStatusCheck.Abort();
                    thread_DeviceStatusCheck.Interrupt();
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (fNotify != null)
                {
                    fNotify.Close();
                    fNotify = null;
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (f12 != null)
                {
                    f12.Close();
                    f12 = null;
                }
                Application.Exit();
            }
            catch (Exception e) { Log.Error(e.Message); }


            Log.Info("From1 exit over.");
        }