Пример #1
0
        protected void RebootTarget(TargetFileType filetype)
	{
            if (IsConnected()/*m_telnet.IsOpenConnection()*/)
            {
                if (filetype == TargetFileType.HMI)
                {
                    if (MessageBox.Show("Sure you want to reboot hmi board?", "Reboot", MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        return;
                    }
                    m_atc.ReceivedEventHandle = ReceivedRebootHandle;
                    m_atc.SendReboot("HMI");
                }
                else if (filetype == TargetFileType.CORE)
                {
                    if (MessageBox.Show("Sure you want to reboot core board?", "Reboot", MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        return;
                    }
                    m_atc.ReceivedEventHandle = ReceivedRebootHandle;
                    m_atc.SendReboot("CORE");
                }
                else
                {
                    MessageBox.Show("Unknown file type!");
                }
            }
            else
            {
                MessageBox.Show("Please connect!");
            }	
	}
Пример #2
0
 protected void CloseApplication(TargetFileType tgtFileType)
 {
     switch (tgtFileType)
     {
     case TargetFileType.ACCESS:
         // find orphaned property dialog
         string pjtname = null;
         foreach (VBProject vbp in AccApp.VBE.VBProjects)
         {
             pjtname = vbp.Name;
             break;
         }
         var hwnd = FindWindowA(null, pjtname + " - Project Properties");
         // Jpn support
         if (hwnd == IntPtr.Zero)
         {
             hwnd = FindWindowA(null, pjtname + " - プロジェクト プロパティ");
         }
         // find cancel button
         var hbtn = FindWindowExA(hwnd, IntPtr.Zero, null, "Cancel");
         // Jpn support
         if (hbtn == IntPtr.Zero)
         {
             hbtn = FindWindowExA(hwnd, IntPtr.Zero, null, "キャンセル");
         }
         if (hbtn != IntPtr.Zero)
         {
             SendMessage(hbtn, BM_CLICK, IntPtr.Zero, null);
         }
         if (AccApp != null)
         {
             AccApp.Quit(Access.AcQuitOption.acQuitSaveNone);
         }
         if (AccApp != null)
         {
             Marshal.ReleaseComObject(AccApp);
         }
         GC.Collect();
         GC.WaitForPendingFinalizers();
         GC.Collect();
         GC.WaitForPendingFinalizers();
         break;
     }
 }
Пример #3
0
        /// <summary>
        /// Set up FileDialog for required file type
        /// </summary>
        /// <param name="targetFileType"></param>
        /// <param name="dialog"></param>
        private void SetUpDialog(TargetFileType targetFileType, FileDialog dialog)
        {
            switch (targetFileType)
            {
            case TargetFileType.PDF:
            {
                dialog.Filter     = @"PDF file(*.pdf)|*.pdf";
                dialog.DefaultExt = "pdf";
            } break;

            case TargetFileType.DOC_DOCX:
            {
                dialog.Filter     = @"DOC file(*.doc)|*.doc|DOCX file(*.docx)|*.docx";
                dialog.DefaultExt = "doc";
            } break;
            }
            dialog.AddExtension     = true;
            dialog.InitialDirectory = Environment.CurrentDirectory;
        }
Пример #4
0
        /// <summary>
        /// Show OpenFIleDialog
        /// </summary>
        /// <param name="targetType">required files type</param>
        /// <returns>true, if dialog closed with true (user press on OK button)</returns>
        public bool OpenFileDialog(TargetFileType targetType)
        {
            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                SetUpDialog(targetType, openFileDialog);

                if (openFileDialog.ShowDialog() == true)
                {
                    FilePath = openFileDialog.FileName;
                    return(true);
                }
                return(false);
            }
            catch (Exception e)
            {
                throw new Exception("Не удалось запустить диалог для открытия файла.\n Системное описание ошибки" + e.Message);
            }
        }
Пример #5
0
        /// <summary>
        /// Show SaveFileDialog
        /// </summary>
        /// <param name="targetType">required files type</param>
        /// <returns>true, if dialog closed with true (user press on OK button)</returns>
        public bool SaveFileDialog(TargetFileType targetType)
        {
            try
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                SetUpDialog(targetType, saveFileDialog);

                saveFileDialog.CreatePrompt    = true;
                saveFileDialog.OverwritePrompt = true;

                if (saveFileDialog.ShowDialog() == true)
                {
                    FilePath = saveFileDialog.FileName;
                    return(true);
                }
                return(false);
            }
            catch (Exception e)
            {
                throw new Exception("Не удалось запустить диалог для сохранения файла.\n Системное описание ошибки" + e.Message);
            }
        }
Пример #6
0
 public FileSelectionEventValue(IEnumerable <string> paths, TargetFileType targetFileType)
 {
     this.Paths          = paths;
     this.TargetFileType = targetFileType;
 }
Пример #7
0
        protected void OpenApplication(string tgtFile, TargetFileType tgtFileType, string pwd = "")
        {
            switch (tgtFileType)
            {
            case TargetFileType.ACCESS:
                try
                {
                    AccApp = new Access.Application();
                    //AccApp.Visible = false;
                    AccApp.OpenCurrentDatabase(tgtFile, true, pwd);
                    //AccApp.Visible = false;
                    CommandBarControl ctrl = AccApp.VBE.CommandBars[1].FindControl(Id: 2578, Recursive: true);
                    Console.WriteLine(ctrl.Caption);
                    ctrl.Execute();
                    //find password dialog
                    string pjtname = null;
                    foreach (VBProject vbp in AccApp.VBE.VBProjects)
                    {
                        pjtname = vbp.Name;
                        break;
                    }
                    var hwnd = FindWindowA(null, pjtname + " Password");
                    // Jpn support
                    if (hwnd == IntPtr.Zero)
                    {
                        hwnd = FindWindowA(null, pjtname + " パスワード");
                    }
                    if (hwnd == IntPtr.Zero)
                    {
                        return;
                    }
                    //find password textbox
                    var hpwd = FindWindowExA(hwnd, IntPtr.Zero, "Edit", null);
                    // input password
                    SendMessage(hpwd, WM_SETTEXT, IntPtr.Zero, pwd);
                    // find OK button
                    var hbtn = FindWindowExA(hwnd, IntPtr.Zero, null, "OK");
                    if (hbtn != IntPtr.Zero)
                    {
                        SendMessage(hbtn, BM_CLICK, IntPtr.Zero, null);
                    }
                    System.Threading.Thread.Sleep(500);
                    // find "properties" dialog
                    hwnd = FindWindowA(null, pjtname + " - Project Properties");
                    // Jpn support
                    if (hwnd == IntPtr.Zero)
                    {
                        hwnd = FindWindowA(null, pjtname + " - プロジェクト プロパティ");
                    }
                    if (hwnd == IntPtr.Zero)
                    {
                        return;
                    }
                    // find OK button(2nd)
                    hbtn = FindWindowExA(hwnd, IntPtr.Zero, null, "OK");
                    // Jpn support
                    if (hbtn != IntPtr.Zero)
                    {
                        SendMessage(hbtn, BM_CLICK, IntPtr.Zero, null);
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteExceptionLog(ex);
                }
                break;

            case TargetFileType.EXCEL:
                // TODO
                break;
            }
        }