Exemplo n.º 1
0
        private void OpenFromByName(string formName)
        {
            try
            {
                Form frmOpen = UiUtility.GetFromByName(formName);
                if (frmOpen == null)
                {
                    return;
                }

                bool   isFound   = false;
                Form[] openForms = this.MdiChildren;
                if (openForms.Length == 0)
                {
                    //No open form
                    //frmOpen.MdiParent = this;
                    //frmOpen.Show();

                    if (this.bgwProcessInform.IsBusy)
                    {
                        this.bgwProcessInform.CancelAsync();
                    }
                    else
                    {
                        this.bgwProcessInform.RunWorkerAsync(frmOpen);
                    }
                }
                else
                {
                    foreach (Form frm in openForms)
                    {
                        if (frmOpen.Name == frm.Name)
                        {
                            isFound = true;
                            frm.Activate();
                            break;
                        }
                    }

                    if (!isFound)
                    {
                        //frmOpen.MdiParent = this;
                        //frmOpen.Show();
                        if (this.bgwProcessInform.IsBusy)
                        {
                            this.bgwProcessInform.CancelAsync();
                        }
                        else
                        {
                            this.bgwProcessInform.RunWorkerAsync(frmOpen);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
Exemplo n.º 2
0
        /*
         * private void InitializeAutoCheckVersion()
         * {
         *  if (UiUtility.IsAutoCheckVersion)
         *  {
         *      TimerCallback timerDelegate = new TimerCallback(this.ProcessRoutine);
         *      AutoResetEvent autoEvent = new AutoResetEvent(false);
         *
         *      if (this.processTimer == null)
         *      {
         *          System.TimeSpan chkTime = System.TimeSpan.Parse(UiUtility.CheckVersionTime);
         *          this.processTimer = new System.Threading.Timer(timerDelegate, autoEvent, chkTime, chkTime); //every 3 min
         *      }
         *      else
         *      {
         *          this.processTimer.Change(15000, 180000);
         *      }
         *  }
         * }
         *
         * private void ProcessRoutine(object data)
         * {
         *  FindFuncLoc();
         * }
         *
         * private void FindFuncLoc()
         * {
         *  if (InvokeRequired)
         *  {
         *      this.Invoke(new MethodInvoker(delegate
         *      {
         *          bool isClearGrid = false;
         *          Version curVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
         *          Version newVersion = UiUtility.CheckVersion(false, out isClearGrid);//this.CheckVersion();
         *          //newVersion = new Version("1.0.3.0");
         *
         *          if (curVersion.CompareTo(newVersion) != 0 && this.notifyIcon != null)
         *          {
         *              this.notifyIcon.ShowBalloon("FGTrack Detected New Version", "Please logoff and login again.", NotifyIconEx.NotifyInfoFlags.Info, 5);
         *          }
         *      }));
         *
         *      return;
         *
         *  }
         * }
         * */

        #endregion "Auto Check Update Version"

        #region "Application Idle"

        //void applicationIdle_Started(object sender, EventArgs e)
        //{
        //    this.isCleared = false;
        //    UpdateTimeDisplays(normalColour);
        //}

        //void applicationIdle_TickAsync(object sender, TickEventArgs e)
        //{
        //    BeginInvoke(new MethodInvoker(
        //        delegate() {
        //            applicationIdle_Tick(sender, e);

        //        })
        //        );
        //}

        //void applicationIdle_Tick(object sender, TickEventArgs e)
        //{
        //    ////this.barStaticItem2.Caption = string.Format("Remaining: {0}", base.AppIdle.TimeRemaining.ToString());
        //    lblReminding.Text = string.Format("Remaining: {0}", base.AppIdle.TimeRemaining.ToString());
        //    if (e.IsWarnPeriod)
        //    {
        //        UpdateTimeDisplays(warnColour);
        //    }
        //    else
        //    {
        //        UpdateTimeDisplays(normalColour);
        //    }

        //}

        //void applicationIdle_Stopped(object sender, EventArgs e)
        //{
        //    UpdateTimeDisplays(normalColour);
        //    //lblActivity.Text = string.Empty;
        //}

        //void applicationIdle_Activity(object sender, ActivityEventArgs e)
        //{
        //    //lblActivity.Text = e.Message.ToString();
        //    UpdateTimeDisplays(normalColour);
        //}

        //void applicationIdle_WarnAsync(object sender, EventArgs e)
        //{
        //    Console.Beep();
        //}

        //void applicationIdle_IdleAsync(object sender, EventArgs e)
        //{
        //    BeginInvoke(new MethodInvoker(
        //        delegate() { applicationIdle_Idle(sender, e); })
        //        );
        //}

        //void applicationIdle_Idle(object sender, EventArgs e)
        //{
        //    UiUtility.IsLogOut = true;
        //    this.Close();

        //    //this.UserID = string.Empty;

        //    //if (this.MdiChildren.Length > 0)
        //    //{
        //    //    foreach (Form openningForm in this.MdiChildren)
        //    //    {
        //    //        openningForm.Close();
        //    //    }

        //    //    this.Close();
        //    //}
        //    //else
        //    //{
        //    //    this.Close();
        //    //}
        //}

        //void UpdateTimeDisplays(Color remainingForeColor)
        //{
        //    lblReminding.Appearance.ForeColor = remainingForeColor;
        //    lblReminding.Text = string.Format("Remaining: {0}", base.AppIdle.TimeRemaining.ToString());
        //    //this.barStaticItem2.Appearance.ForeColor = remainingForeColor;
        //    //this.barStaticItem2.Caption = string.Format("Remaining: {0}", base.AppIdle.TimeRemaining.ToString());
        //}

        #endregion "Application Idle"


        public void OpenJobOrderForm()
        {
            try
            {
                HTN.BITS.UIL.PLASESS.Transaction.frmJobOrder frmOpen = UiUtility.GetFromByName("Transaction.frmJobOrder") as HTN.BITS.UIL.PLASESS.Transaction.frmJobOrder;
                if (frmOpen == null)
                {
                    return;
                }

                bool   isFound   = false;
                Form[] openForms = this.MdiChildren;
                foreach (Form frm in openForms)
                {
                    if (frmOpen.Name == frm.Name)
                    {
                        isFound = true;
                        frmOpen = frm as HTN.BITS.UIL.PLASESS.Transaction.frmJobOrder;
                        frmOpen.Activate();
                        break;
                    }
                }

                if (!isFound)
                {
                    if (frmOpen.Tag != null)
                    {
                        frmOpen.WindowState = this.SetFormWindowsState(frmOpen.Tag.ToString());
                    }

                    frmOpen.MdiParent = this;
                    frmOpen.Show();
                    this.Activate();
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Error OpenJobOrderForm", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }