Esempio n. 1
0
        public void Print()
        {
            string tmp = string.Empty;

            string[] tmpArray;
            string   port = this.txtHotPort.Text.Trim();

            for (int i = 0; i < config.Commands.Count; i++)
            {
                WindowFormDelegate.SetMainThreadHint(this.lbPrintHint, string.Format("正执行第{0}条命令", i));
                //Thread.Sleep(500);
                tmp = config.Commands[i];
                if (tmp.IndexOf("|") != -1)
                {
                    tmpArray = tmp.Trim().Split('|');
                    if (tmpArray.Length > 0)
                    {
                        tmp = string.Empty;
                        for (int j = 0; j < tmpArray.Length; j++)
                        {
                            tmp += (char)Convert.ToInt32(tmpArray[j]);
                        }
                    }
                }
                if (port.StartsWith("lpt"))
                {
                    helper.Write(tmp);
                }
                else
                {
                    helper2.Write(tmp);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 返回主界面
        /// </summary>
        public static void GoPanel(Control panel)
        {
            try
            {
                if (MainForm != null)
                {
                    MainForm.AutoScroll = true;
                    if (GlobalTools.fullScreenSeatSelectorForm != null)
                    {
                        Form frm = GlobalTools.fullScreenSeatSelectorForm;
                        GlobalTools.fullScreenSeatSelectorForm = null;
                        frm.Close();
                    }
                    Control parent = MainForm;
                    if (parent.Controls.Count > 0)
                    {
                        MainPanel oldPanel = parent.Controls[0] as MainPanel;
                        if (oldPanel != null)
                        {
                            oldPanel.StopAdTimer();
                        }
                        parent.Controls.Clear();
                    }
#if DEBUG
                    Console.WriteLine("GoPanel开始隐藏小键盘");
#endif
                    HideAllKeyBoard();

                    WindowFormDelegate.AddControlTo(parent, panel);
                    //parent.Controls.Add(panel);
                    if (panel is MainPanel)
                    {
                        StopUnOperationCounter();
                    }
                    else if (panel is OperationTimeParentPanel)
                    {
                        StopUnOperationCounter();

                        InitUnOperationControl(parent.Controls[0]);
                    }
                    else
                    {
                        ResetUnOperationTime();
                        StopUnOperationCounter();
                        StartUnOperationCounter();
                        InitUnOperationControl(parent.Controls[0]);
                    }
                }
            }
            catch (Exception ex)
            {
                GlobalTools.Log(ex);
                MessageBox.Show("切换界面出现异常:" + ex.ToString());
            }
        }
Esempio n. 3
0
        private void InitSeat(List <SeatObject> lists)
        {
            if (lists == null || lists.Count == 0)
            {
                return;
            }
            SeatList = lists;
            //75, 78 height=29
            int x        = 0;
            int y        = 0;
            int lineOneY = lists[0].YPoint;

#if DEBUG
            Console.WriteLine("第一行" + lists[0].XPoint + "-" + lists[0].YPoint);
#endif

            int  picWid    = 25;
            int  picHeight = 25;
            Font font      = new Font("方正兰亭纤黑简体", 9, FontStyle.Bold);
            for (int i = 0; i < lists.Count; i++)
            {
                Label lb = new Label();
                lb.Name      = lists[i].SeatId;
                lb.BackColor = Color.Transparent;
                lb.Text      = lists[i].SeatNo.ToString();
                lb.AutoSize  = false;
                if (lists[i].LockState == "0")
                {
                    lb.BackColor = emptyColor;
                }
                else
                {
                    lb.BackColor = selledColor;
                }
                lb.ForeColor = Color.White;
                lb.Font      = font;
                // lb.autos
                lb.Width     = picWid;
                lb.Height    = picHeight;
                lb.TextAlign = ContentAlignment.MiddleCenter;
                lb.Tag       = lists[i];
                //this.panelContent.Controls.Add(lb);
                lb.Location = new Point(x + lists[i].XPoint, y + lists[i].YPoint - lineOneY);
                lb.Click   += new EventHandler(lb_Click);
                //  WindowFormDelegate.AddControlTo(this.panelContent,lb);
                WindowFormDelegate.AddControlTo(this.panelSeat, lb);
            }
        }
Esempio n. 4
0
        private void setHint(string msg)
        {
            WindowFormDelegate.SetMainThreadHint(this.lbHint, msg);

            /*
             * if (lbHint.InvokeRequired)
             * {
             *  SetMainThreadHintDelegate msgCallback = new SetMainThreadHintDelegate(setHint);
             *  lbHint.Invoke(msgCallback, new object[] { msg });
             * }
             * else
             * {
             *  lbHint.Text = msg;
             * }
             */
        }
 private void PrintTask2()
 {
     while (this.counter < this.stopCounter)
     {
         StringBuilder msg = new StringBuilder();
         int           i   = HotPrinterImporter.PrintLine(this.txtPrintContent.Text.Trim(), msg);
         if (i == 0)
         {
             counter++;
         }
         WindowFormDelegate.SetMainThreadHint(this.lbHotHint, "正在打印:" + counter.ToString() + "行!");
         System.Threading.Thread.Sleep(this.threadSleepTime * 1000);
         if (this.counter == this.stopCounter)
         {
             WindowFormDelegate.SetMainThreadHint(this.lbHotHint, "打印完成:" + counter.ToString() + "行!");
             break;
         }
     }
 }
Esempio n. 6
0
        private void InitMovies(DateTime dt)
        {
            SystemConfig       config = FT.Commons.Cache.StaticCacheManager.GetConfig <SystemConfig>();
            List <MovieObject> all    = HiPiaoCache.GetHotMovie(config.Province, config.City);

            List <MovieObject> lists = HiPiaoCache.GetDayMovie(config.City, config.CinemaId, dt, all);

            if (lists == null || lists.Count == 0)
            {
                //274, 42
                //745, 374
                PictureBox pic = new PictureBox();
                pic.BackgroundImage = Properties.Resources.BuyTick_No_Plan;
                pic.Width           = 745;
                pic.Height          = 374;
                pic.Location        = new Point(274, 42);
                this.panelContent.Controls.Clear();
                //this.panelContent.Controls.Add(pic);
                WindowFormDelegate.AddControlTo(this.panelContent, pic);
                //this.picShowNoPlanHint.Visible = true;
            }

            else if (lists != null && lists.Count > 0)
            {
                this.panelContent.Controls.Clear();
                int x         = 100;
                int y         = 0;
                int col       = 0;
                int row       = 0;
                int linecount = 6;
                for (int i = 0; i < lists.Count; i++)
                {
                    PictureBox pc = new PictureBox();
                    pc.Width  = picWid;
                    pc.Height = picHeight;
                    pc.Tag    = lists[i];
                    if (lists[i].AdImagePath.Length > 0)
                    {
                        pc.Image = Image.FromFile(lists[i].AdImagePath);
                    }
                    pc.Location = new Point(x + (i % linecount) * (picWid + colSep), y + (i / linecount) * (picHeight + rowSep));
                    Label lb = new Label();
                    lb.Tag      = lists[i];
                    lb.AutoSize = false;
                    lb.Width    = picWid;
                    //lb.BackColor = Color.Red;
                    lb.Height    = 28;
                    lb.Location  = new Point(pc.Location.X, pc.Location.Y + picHeight);
                    lb.ForeColor = Color.FromArgb(69, 68, 68);
                    lb.TextAlign = ContentAlignment.MiddleCenter;
                    lb.Font      = new Font("方正兰亭纤黑简体", 18, FontStyle.Bold);
                    //string name = "很长的测试电影名字如果爱琴海岛上没有海盗";
                    string name = lists[i].Name;
                    if (name.Length > 6)
                    {
                        lb.Text = name.Substring(0, 6);
                    }
                    else
                    {
                        lb.Text = name;
                    }
                    lb.MouseHover += new EventHandler(lb_MouseHover);

                    pc.Click      += new EventHandler(pc_Click);
                    pc.MouseHover += new EventHandler(lb_MouseHover);
                    WindowFormDelegate.AddControlTo(this.panelContent, pc);
                    WindowFormDelegate.AddControlTo(this.panelContent, lb);
                    //this.panelContent.Controls.Add(pc);
                    //this.panelContent.Controls.Add(lb);
                }
            }
        }
Esempio n. 7
0
 void kmy_keyPressStringEvent(string info)
 {
     WindowFormDelegate.AddMainThreadHintText(this.txtKeyResult, ";" + info);
 }
        private void SetMoviePlan(MoviePlanObject plan)
        {
            this.moviePlan = plan;
            for (int i = this.panelContent.Controls.Count - 1; i >= 0; i--)
            {
                Control ctr = this.panelContent.Controls[i];
                if (ctr.Name == "picNoPlanHint")
                {
                    WindowFormDelegate.RemoveControlFrom(this.panelContent, ctr);
                }
                else if (ctr is RoomPlanShowPanel)
                {
                    //
                    //this.panelContent.Controls.Remove(ctr);
                    WindowFormDelegate.RemoveControlFrom(this.panelContent, ctr);
                }
                //this.picNoPlanHint.Visible = false;
            }
            if (plan == null)
            {
                // 274, 257
                PictureBox pic = new PictureBox();
                pic.Name            = "picNoPlanHint";
                pic.BackgroundImage = Properties.Resources.BuyTick_No_Plan;
                pic.Width           = 745;
                pic.Height          = 374;
                pic.Location        = new Point(274, 257);
                //this.panelContent.Controls.Clear();
                WindowFormDelegate.AddControlTo(this.panelContent, pic);
                // this.panelContent.Controls.Add(pic);
                //this..Visible = true;
                return;
            }
            if (movie.OtherName.Length > 0)
            {
                this.lbOtherName.Visible = false;
            }
            else
            {
                this.lbOtherName.Visible = true;
                if (plan.Type.Length > 0)
                {
                    this.lbOtherName.Text = movie.OtherName + "(" + plan.Type + ")";
                }
            }
            this.lbLanguage.Text      = string.Format("语言:{0}", plan.Language);
            this.lbLanguage.ForeColor = Color.FromArgb(85, 85, 85);
            List <RoomPlanObject> lists = plan.RoomPlans;

            if (lists != null && lists.Count > 0)
            {
                //this.panelContent.Controls.Clear();
                int  x            = 57;
                int  y            = 274;
                int  linecount    = 5;
                int  picWid       = 195;
                int  picHeight    = 88;
                int  colSep       = 14;
                int  rowSep       = 14;
                int  controlCount = 0;
                bool isToday      = this.planDt.Day == System.DateTime.Now.Day;
                int  hourNow      = System.DateTime.Now.Hour;
                int  minuteNow    = System.DateTime.Now.Minute + 5;

                for (int i = 0; i < lists.Count; i++)
                {
                    try
                    {
                        string   tttt   = lists[i].Playtime;
                        string[] times  = tttt.Split(':');
                        int      hour   = Convert.ToInt32(times[0]);
                        int      minute = Convert.ToInt32(times[1]);
                        if (isToday && (hour == hourNow && minute < minuteNow))
                        {
                            continue;
                        }
                    }
                    catch (Exception ex)
                    {
                        GlobalTools.Log(ex);
                    }
                    RoomPlanShowPanel pc = new RoomPlanShowPanel(lists[i]);
                    pc.AutoScaleMode = AutoScaleMode.None;
                    pc.Width         = picWid;
                    pc.Height        = picHeight;
                    pc.Tag           = lists[i];
                    pc.Location      = new Point(x + (controlCount % linecount) * (picWid + colSep), y + (controlCount / linecount) * (picHeight + rowSep));
                    pc.Click        += new EventHandler(pc_Click);

                    //this.panelContent.Controls.Add(pc);
                    WindowFormDelegate.AddControlTo(this.panelContent, pc);
                    controlCount++;
                }
            }
        }
Esempio n. 9
0
 private void setHint(string msg)
 {
     WindowFormDelegate.SetMainThreadHint(this.lbPrintHint, msg);
 }
Esempio n. 10
0
 private void SetReadHint(string msg)
 {
     WindowFormDelegate.SetMainThreadHint(this.lbPrintHint, this.lbPrintHint.Text += msg);
 }
Esempio n. 11
0
        private void BeginMonitor()
        {
            int    sec = Convert.ToInt32(this.txtTimerSecond.Text.Trim());
            int    MonitorLineCount = Convert.ToInt32(this.txtMonitorLine.Text.Trim());
            int    days             = Convert.ToInt32(this.txtLogDays.Text.Trim());
            string monitorPath      = this.txtMonitorPath.Text.Trim();

            while (true)
            {
                try
                {
                    DateTime      begin      = System.DateTime.Now;
                    string        path       = string.Empty;
                    string        bakRestart = string.Empty;
                    string        bakNormal  = string.Empty;
                    string        date       = System.DateTime.Now.ToString("yyyyMMdd");
                    DirectoryInfo dir;
                    if (monitorPath.Length > 0)
                    {
                        dir = new DirectoryInfo(monitorPath);
                    }
                    else
                    {
                        dir = new DirectoryInfo(Application.StartupPath);
                    }
                    FileInfo[] files    = dir.GetFiles();
                    FileInfo   fileTemp = null;
                    string     olddate  = System.DateTime.Now.AddDays(-days).ToString("yyyyMMdd");
                    for (int i = 0; i < files.Length; i++)
                    {
                        fileTemp = files[i];
                        if (fileTemp.Name.StartsWith(olddate))
                        {
                            fileTemp.Delete();
                        }
                    }
                    if (this.txtMonitorPath.Text.Trim().Length > 0)
                    {
                        path       = this.txtMonitorPath.Text.Trim() + "\\" + date + ".txt";
                        bakRestart = this.txtMonitorPath.Text.Trim() + "\\" + date + "-" + System.DateTime.Now.ToString("HHmmss") + "-restart.txt";
                        bakNormal  = this.txtMonitorPath.Text.Trim() + "\\" + date + "-" + System.DateTime.Now.ToString("HHmmss") + "-normal.txt";
                    }
                    else
                    {
                        path       = date + ".txt";
                        bakRestart = date + "-" + System.DateTime.Now.ToString("HHmmss") + "-restart.txt";
                        bakNormal  = date + "-" + System.DateTime.Now.ToString("HHmmss") + "-normal.txt";
                    }

                    FileInfo file = new FileInfo(path);
                    if (file.Exists)
                    {
                        int  counter   = 0;
                        bool findError = false;
                        using (FileStream file_s =
                                   //new FileStream(path, FileMode.Open);
                                   File.Open(path, FileMode.Open, FileAccess.Read))
                        {
                            using (StreamReader sr = new StreamReader(file_s))
                            //using (StreamReader sr = new StreamReader(path))
                            {
                                String line;


                                // Read and display lines from the file until the end of
                                // the file is reached.
                                while ((line = sr.ReadLine()) != null)
                                {
                                    counter++;
                                    WindowFormDelegate.SetMainThreadHint(lbHint, string.Format(HintFormatter, counter, date));
                                    WindowFormDelegate.SetMainThreadHint(lbLogContent, string.Format(HintContentFormatter, line));

                                    if (counter <= LineCounter)
                                    {
                                        continue;
                                    }
                                    else
                                    {
                                        if (line.IndexOf(ErrorString) != -1)
                                        {
                                            findError        = true;
                                            this.LineCounter = counter;
                                            break;
                                        }
                                    }
                                }
                                // while(sr.EndOfStream
                            }

                            if (findError)
                            {
                                FT.Commons.Tools.WindowServicesHelper.ForceStop(XServerName);
                                try
                                {
                                    file.CopyTo(bakRestart);
                                    file.Delete();
                                    this.LineCounter = 0;
                                }
                                catch (Exception ex)
                                {
                                    log.Info(bakRestart);
                                    log.Info(ex);
                                    //MessageBoxHelper.Show(ex.ToString());
                                }
                                System.Threading.Thread.Sleep(2000);
                                FT.Commons.Tools.WindowServicesHelper.ForceStart(XServerName);
                            }
                            else if (counter > MonitorLineCount)
                            {
                                try
                                {
                                    file.CopyTo(bakNormal);
                                    file.Delete();
                                    this.LineCounter = 0;
                                }
                                catch (Exception ex)
                                {
                                    log.Info(bakNormal);
                                    log.Info(ex);
                                    //MessageBoxHelper.Show(ex.ToString());
                                }
                            }
                        }
                    }

                    DateTime end = System.DateTime.Now;
                    TimeSpan ts  = end.Subtract(begin);
                    WindowFormDelegate.SetMainThreadHint(lbUseTimes, ts.TotalMilliseconds.ToString());

                    System.Threading.Thread.Sleep(sec);
                }
                catch (Exception ex)
                {
                    log.Info("大循环异常:" + ex);
                }
            }
        }