Пример #1
0
        private void btn_Base64_Decode_Click(object sender, EventArgs e)
        {
            var codeText = rtxt_Base64_Orginal.Text;

            if (string.IsNullOrWhiteSpace(codeText))
            {
                WinFormHelper.ShowWarning("请输入要解码的文本!");
                return;
            }
            try
            {
                rtxt_Base64_Handled.Text = Base64Helper.UnBase64String(codeText);
            }
            catch (Exception ex)
            {
                WinFormHelper.ShowError(ex);
            }
        }
Пример #2
0
        private void ShowTextArea(string text)
        {
            txtTranslation.Rtf = text;

            if (Height == _height[1])
            {
                Region   = Region.FromHrgn(WinFormHelper.CreateRoundRectRgn(0, 0, Width = _width[0], Height = _height[0], 10, 10));
                Location = new Point(Location.X - (Width - _width[1]), Location.Y);
            }

            Activate();
            txtWord.Focus();
            txtWord.SelectAll();
            txtTranslation.Focus();
            Opacity = 1;
            UpdateStyles();
            //txtTranslation.ForceRefresh();
        }
Пример #3
0
        public static void ChangePanel(Form frm, Control panel)
        {
            if (frm != null && panel != null)
            {
                FT.Commons.Win32.WindowFormDelegate.RemoveAllControlFrom(frm);


                frm.MaximizeBox     = true;
                frm.MinimizeBox     = true;
                frm.FormBorderStyle = FormBorderStyle.Sizable;
                frm.StartPosition   = FormStartPosition.Manual;
                frm.WindowState     = FormWindowState.Normal;
                frm.Parent          = null;
                // MessageBox.Show("1-现有窗体宽度为Width:" + frm.Width.ToString() + ":Height:" + frm.Height.ToString());
                frm.MaximumSize = new Size(panel.Width, panel.Height);
                frm.MinimumSize = new Size(panel.Width, panel.Height);
                frm.Width       = panel.Width;
                frm.Height      = panel.Height;
                //frm.WindowState = FormWindowState.Maximized;
                //System.Threading.Thread.Sleep(1000);

                //frm.
                // MessageBox.Show("2-现有窗体宽度为Width:" + frm.Width.ToString() + ":Height:" + frm.Height.ToString());
                // frm.Size = new Size(panel.Width, panel.Height);

                // frm.BackColor = Color.Red;
                panel.Dock = DockStyle.Fill;
                //frm.StartPosition = FormStartPosition.CenterScreen;

                WinFormHelper.CenterForm(frm);
                FT.Commons.Win32.WindowFormDelegate.AddControlTo(frm, panel);

                frm.FormBorderStyle = FormBorderStyle.None;
                frm.Invalidate();
                // frm.ResumeLayout(true);
                // frm.PerformLayout();
                //MessageBox.Show("3-现有窗体宽度为Width:" + frm.Width.ToString() + ":Height:" + frm.Height.ToString());

                //frm.Controls.Add(panel);
            }
        }
Пример #4
0
        private void MessageForm_Paint(object sender, PaintEventArgs e)
        {
            WinFormHelper.PaintFirstRound(sender, e);
            // WinFormHelper.PainYellowBorder(sender, e);

            /*
             * ControlPaint.DrawBorder(e.Graphics,
             *                     this.ClientRectangle,
             *                     Color.LightSeaGreen,//7f9db9
             *                     1,
             *                     ButtonBorderStyle.Solid,
             *                     Color.LightSeaGreen,
             *                     1,
             *                     ButtonBorderStyle.Solid,
             *                     Color.LightSeaGreen,
             *                     1,
             *                     ButtonBorderStyle.Solid,
             *                     Color.LightSeaGreen,
             *                     1,
             *                     ButtonBorderStyle.Solid);
             * */
        }
Пример #5
0
        void pic_Image_Click(object sender, EventArgs e)
        {
            if (processImage == null)
            {
                return;
            }
            PictureBox pic    = sender as PictureBox;
            PictureBox picAdd = new PictureBox();

            picAdd.Width    = pic.Width;
            picAdd.Height   = pic.Height;
            picAdd.Image    = pic.BackgroundImage.Clone() as Image;
            picAdd.SizeMode = PictureBoxSizeMode.StretchImage;
            picAdd.Location = new Point((this.panelContent.Width - pic.Width) / 2, (this.panelContent.Height - pic.Height) / 2);
            picAdd.Click   += new EventHandler(picAdd_Click);
            WinFormHelper.DropMove(picAdd);
            picAdd.MouseMove += new MouseEventHandler(picAdd_MouseMove);
            this.panelContent.Controls.Add(picAdd);
            this.currentPic = picAdd;

            //throw new NotImplementedException();
        }
        /// <summary>
        /// 平台 设备控制命令,终端应答
        /// </summary>
        private static void T808_0x8600AndT808_0x0600_Process()
        {
            T808_0x0600 body = new T808_0x0600();

            body.setTerminalID(simNum);
            T808_MessageHeader mh = new T808_MessageHeader();

            // 获取终端对应的sim卡号
            mh.setSimNum(simNum);
            var cm = new CommonMessage <T808_0x0600>(body.getMessageID(), mh, body);

            try
            {
                var porto    = new T808_0x0600_Process <T808_0x0600>();
                var sendByte = porto.PackData(cm, key);
                WinFormHelper.ShowInfo(txtInfo, $"向服务器发送电子围栏设置应答消息:{ToolHelper.ByteConvertToHex(sendByte)}");
            }
            catch (Exception ex)
            {
                WinFormHelper.ShowInfo(txtInfo, $"电子围栏设置应答消息发送过程出现异常:{ex.Message},关闭连接!");
                EndConn();
            }
        }
 public void Start()
 {
     if (!isConnection)
     {
         throw new Exception("socket未连接");
     }
     T808_0x0011_Process();
     Task.Run(() =>
     {
         while (true)
         {
             if (clientSocket.Connected)
             {
                 Receive();
             }
             else
             {
                 WinFormHelper.ShowInfo(txtInfo, "服务器连接已断开");
                 break;
             }
         }
     });
 }
Пример #8
0
 private void btnBase64Bmp_ToBmp_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(rtxtBase64BmpStr.Text))
     {
         rtxtBase64BmpStr.Focus();
     }
     else
     {
         try
         {
             if (picBoxBase64Bmp.Image != null)
             {
                 picBoxBase64Bmp.Image.Dispose();
                 picBoxBase64Bmp.Image = null;
             }
             picBoxBase64Bmp.Image = Base64Helper.Base64ToImg(rtxtBase64BmpStr.Text.Replace("data:image/png;base64,", ""));
         }
         catch (Exception ex)
         {
             WinFormHelper.ShowError(ex);
         }
     }
 }
        /// <summary>
        /// 钥匙接触电子锁自动上报,0x0702上报日志,和0x0701参数相同,发送的内容也相同
        /// </summary>
        /// <param name="pinNum">操作员ping码</param>
        /// <param name="password">操作员密码</param>
        /// <param name="lockNum">锁号/封铅号</param>
        /// <param name="jzdw">基站定位</param>
        /// <param name="altitude">高度</param>
        /// <param name="speed">速度</param>
        /// <param name="direction">方向</param>
        public static void T808_0x0701_Process(string pinNum, string password, string lockNum, string jzdw, int altitude, int speed, int direction)
        {
            T808_0x0701 body = new T808_0x0701();

            body.setTerminalID(simNum);
            T808_MessageHeader mh = new T808_MessageHeader();

            // 获取终端对应的sim卡号
            mh.setSimNum(simNum);
            var cm = new CommonMessage <T808_0x0701>(body.getMessageID(), mh, body);

            try
            {
                var porto    = new T808_0x0701_Process <T808_0x0701>();
                var sendByte = porto.PackData(cm, key, pinNum, password, lockNum, jzdw, altitude, speed, direction);
                clientSocket.Send(sendByte);
                WinFormHelper.ShowInfo(txtInfo, $"钥匙接触电子锁上传消息:{ToolHelper.ByteConvertToHex(sendByte)}");
            }
            catch (Exception ex)
            {
                WinFormHelper.ShowInfo(txtInfo, $"钥匙接触电子锁消息发送过程出现异常:{ex.Message},关闭连接!");
                EndConn();
            }
        }
Пример #10
0
        /// <summary>
        /// 终端位置信息汇报,心跳
        /// </summary>
        /// <param name="voltage">电压</param>
        /// <param name="status">状态32位</param>
        /// <param name="version">版本</param>
        /// <param name="jzdw">基站定位</param>
        /// <param name="altitude">高度</param>
        /// <param name="speed">速度</param>
        /// <param name="direction">方向</param>
        public static void T808_0x0200_Process(string voltage, string status, string version, string jzdw, int altitude, int speed, int direction)
        {
            T808_0x0200 body = new T808_0x0200();

            body.setTerminalID(simNum);
            T808_MessageHeader mh = new T808_MessageHeader();

            // 获取终端对应的sim卡号
            mh.setSimNum(simNum);
            var cm = new CommonMessage <T808_0x0200>(body.getMessageID(), mh, body);

            try
            {
                var porto    = new T808_0x0200_Process <T808_0x0200>();
                var sendByte = porto.PackData(cm, key, voltage, status, version, jzdw, altitude, speed, direction);
                clientSocket.Send(sendByte);
                WinFormHelper.ShowInfo(txtInfo, $"向服务器发送位置消息:{ToolHelper.ByteConvertToHex(sendByte)}");
            }
            catch (Exception ex)
            {
                WinFormHelper.ShowInfo(txtInfo, $"发送位置消息过程出现异常:{ex.Message},关闭连接!");
                EndConn();
            }
        }
Пример #11
0
        /// <summary>
        /// 平台设置终端参数,终端应答
        /// </summary>
        public static void T808_0x8103AndT808_0x0103_Process()
        {
            T808_0x0103 body = new T808_0x0103();

            body.setTerminalID(simNum);
            T808_MessageHeader mh = new T808_MessageHeader();

            // 获取终端对应的sim卡号
            mh.setSimNum(simNum);
            var cm = new CommonMessage <T808_0x0103>(body.getMessageID(), mh, body);

            try
            {
                var porto    = new T808_0x0103_Process <T808_0x0103>();
                var sendByte = porto.PackData(cm, key);
                clientSocket.Send(sendByte);
                WinFormHelper.ShowInfo(txtInfo, $"向服务器发送设置终端参数回复消息:{ToolHelper.ByteConvertToHex(sendByte)}");
            }
            catch (Exception ex)
            {
                WinFormHelper.ShowInfo(txtInfo, $"设置终端参数回复消息发送过程出现异常:{ex.Message},关闭连接!");
                EndConn();
            }
        }
Пример #12
0
        private void Form1Load(object sender, EventArgs e)
        {
            // create loggers
            _loggerRef = Reference <ILogger> .Create(new TextBoxLogger(txtMainLog));

            // create client factory and client
            _clientFactory = new CoreClientFactory(_loggerRef);
            _clientFactory.SetEnv(BuildConst.BuildEnv);
            _clientFactory.SetApplication(Assembly.GetExecutingAssembly());
            _client = _clientFactory.Create();
            // - form title
            WinFormHelper.SetAppFormTitle(this, EnvHelper.EnvName(BuildEnv));
            // setup the AlertRule view
            _alertRuleViewHelper = new AlertRuleViewHelper();
            _alertRuleDataHelper = new AlertRuleDataHelper();
            _alertRuleFilters    = new ComboxBoxFilterGroup(
                panelAlertRule, _alertRuleViewHelper, AlertRuleSelectionChanged);
            _alertRuleSelecter = new AlertRuleSelecter(
                _alertRuleFilters, _alertRuleViewHelper, _alertRuleDataHelper);
            _alertRuleView = new ListViewManager <AlertRule>(
                _loggerRef.Target, lvAlertRule, _alertRuleViewHelper,
                _alertRuleSelecter, _alertRuleFilters, new AlertRuleSorter(), _alertRuleDataHelper);

            ICoreCache alertRuleCache = _client.CreateCache(
                update => _alertRuleView.UpdateData(new ViewChangeNotification <AlertRule>
            {
                Change  = update.Change,
                OldData =
                    (AlertRule)update.OldItem?.Data,
                NewData =
                    (AlertRule)update.NewItem?.Data
            }), SynchronizationContext.Current);

            alertRuleCache.SubscribeNoWait <AlertRule>(Expr.ALL, null, null);
            // setup the AlertSignal view
            _alertSignalViewHelper = new AlertSignalViewHelper();
            _alertSignalDataHelper = new AlertSignalDataHelper();
            _alertSignalFilters    = new ComboxBoxFilterGroup(
                panelAlertSignal, _alertSignalViewHelper, AlertSignalSelectionChanged);
            _alertSignalSelecter = new AlertSignalSelecter(
                _alertSignalFilters, _alertSignalViewHelper, _alertSignalDataHelper);
            _alertSignalView = new ListViewManager <AlertSignal>(
                _loggerRef.Target, lvAlertSignal, _alertSignalViewHelper,
                _alertSignalSelecter, _alertSignalFilters, new AlertSignalSorter(), _alertSignalDataHelper);
            ICoreCache alertSignalCache = _client.CreateCache(
                update => _alertSignalView.UpdateData(new ViewChangeNotification <AlertSignal>
            {
                Change  = update.Change,
                OldData =
                    (AlertSignal)update.OldItem?.Data,
                NewData =
                    (AlertSignal)update.NewItem?.Data
            }), SynchronizationContext.Current);

            alertSignalCache.SubscribeNoWait <AlertSignal>(Expr.ALL, null, null);
            // setup the LogEvent view
            _logEventViewHelper = new LogEventViewHelper();
            _logEventDataHelper = new LogEventDataHelper();
            _logEventFilters    = new ComboxBoxFilterGroup(
                panelLogEvent, _logEventViewHelper, LogEventSelectionChanged);
            _logEventSelecter = new LogEventSelecter(
                _logEventFilters, _logEventViewHelper, _logEventDataHelper);
            _logEventView = new ListViewManager <DebugLogEvent>(
                _loggerRef.Target, lvLogEvent, _logEventViewHelper,
                _logEventSelecter, _logEventFilters, new LogEventSorter(), _logEventDataHelper);
            ICoreCache logEventCache = _client.CreateCache(
                update => _logEventView.UpdateData(new ViewChangeNotification <DebugLogEvent>
            {
                Change  = update.Change,
                OldData =
                    (DebugLogEvent)update.OldItem?.Data,
                NewData =
                    (DebugLogEvent)update.NewItem?.Data
            }), SynchronizationContext.Current);

            logEventCache.SubscribeNoWait <DebugLogEvent>(Expr.ALL, null, null);
            // init controls
            // server 0
            _serverAddress[0] = txtServer0Address;
            _ping[0]          = chkServer0Ping;
            _lastChecked[0]   = txtServer0LastChecked;
            _lastReplied[0]   = txtServer0LastReplied;
            _serverStatus[0]  = txtServer0Status;
            _serverReason[0]  = txtServer0OtherInfo;
            // server 1
            _serverAddress[1] = txtServer1Address;
            _ping[1]          = chkServer1Ping;
            _lastChecked[1]   = txtServer1LastChecked;
            _lastReplied[1]   = txtServer1LastReplied;
            _serverStatus[1]  = txtServer1Status;
            _serverReason[1]  = txtServer1OtherInfo;
            // server 2
            _serverAddress[2] = txtServer2Address;
            _ping[2]          = chkServer2Ping;
            _lastChecked[2]   = txtServer2LastChecked;
            _lastReplied[2]   = txtServer2LastReplied;
            _serverStatus[2]  = txtServer2Status;
            _serverReason[2]  = txtServer2OtherInfo;
            // server 3
            _serverAddress[3] = txtServer3Address;
            _ping[3]          = chkServer3Ping;
            _lastChecked[3]   = txtServer3LastChecked;
            _lastReplied[3]   = txtServer3LastReplied;
            _serverStatus[3]  = txtServer3Status;
            _serverReason[3]  = txtServer3OtherInfo;
            // server 4
            _serverAddress[4] = txtServer4Address;
            _ping[4]          = chkServer4Ping;
            _lastChecked[4]   = txtServer4LastChecked;
            _lastReplied[4]   = txtServer4LastReplied;
            _serverStatus[4]  = txtServer4Status;
            _serverReason[4]  = txtServer4OtherInfo;
            // server 5
            _serverAddress[5] = txtServer5Address;
            _ping[5]          = chkServer5Ping;
            _lastChecked[5]   = txtServer5LastChecked;
            _lastReplied[5]   = txtServer5LastReplied;
            _serverStatus[5]  = txtServer5Status;
            _serverReason[5]  = txtServer5OtherInfo;
            for (int i = 0; i < NServers; i++)
            {
                _lastChecked[i].BackColor  = Color.FromKnownColor(KnownColor.Window);
                _lastReplied[i].BackColor  = Color.FromKnownColor(KnownColor.Window);
                _serverStatus[i].BackColor = Color.FromKnownColor(KnownColor.Window);
                _serverReason[i].BackColor = Color.FromKnownColor(KnownColor.Window);
            }
        }
Пример #13
0
 private void pictureBox1_Click(object sender, EventArgs e)
 {
     WinFormHelper.GotoUrl("http://salplachta.net/AdvancedLogViewer/Donate.aspx");
 }
Пример #14
0
 private void forumLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     WinFormHelper.GotoUrl("https://github.com/Scarfsail/AdvancedLogViewer/issues");
 }
Пример #15
0
 private void SecondRoundNotifyForm_Paint(object sender, PaintEventArgs e)
 {
     // WinFormHelper.PaintSecondRound(this);
     WinFormHelper.PaintSecondRound(sender, e);
     //WinFormHelper.PainSecondBorder(sender, e);
 }
Пример #16
0
 private void ConfirmForm_Paint(object sender, PaintEventArgs e)
 {
     WinFormHelper.PainYellowBorder(sender, e);
 }
Пример #17
0
 private void regeExHelpLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     WinFormHelper.GotoUrl("http://regexlib.com/CheatSheet.aspx");
 }
Пример #18
0
 private void YellowNotifyUserPanel_Paint(object sender, PaintEventArgs e)
 {
     WinFormHelper.PaintFirstRound(sender, e);
     //  WinFormHelper.PainYellowBorder(sender, e);
 }
Пример #19
0
 private void BaseOneLineMessageForm_Paint(object sender, PaintEventArgs e)
 {
     //WinFormHelper.PaintRound(sender);
     WinFormHelper.PainYellowBorder(sender, e);
 }
Пример #20
0
        public UserPayCheckPanel(List <TicketPrintObject> tickets, MovieObject movie, MoviePlanObject moviePlan, RoomPlanObject roomPlan, DateTime dt)
        {
            InitializeComponent();
            this.SetSepartor(false);

            this.lists     = tickets;
            this.movieInfo = movie;
            this.moviePlan = moviePlan;
            this.roomPlan  = roomPlan;
            this.dt        = dt;
            if (tickets != null)
            {
                TicketPrintObject ticket = tickets[0];
                this.picAdImage.Image = movieInfo.AdImage;
                //ticket.MovieName = "假如真的是爱情有天意的话";
                if (ticket.MovieName.Length > 9)
                {
                    this.lbMovieName.Text     = ticket.MovieName.Substring(0, 9) + "\n" + ticket.MovieName.Substring(9);
                    this.lbMovieInfo.Location = new Point(this.lbMovieName.Location.X, this.lbMovieName.Location.Y + this.lbMovieName.Height + 2);
                }
                else
                {
                    this.lbMovieName.Text = ticket.MovieName;
                }
                this.lbMovieInfo.Text = string.Format(this.lbMovieInfo.Text, moviePlan.Type, moviePlan.Language, movieInfo.TotalMinutes);
                //DateTime  playDate=Convert.ToDateTime(ticket.PlayDate);
                // DateTime playDate = movie.PlayTime;
                DateTime playDate = dt;
                this.lbDate.Text = playDate.ToString("MM月dd日") + " " + DateTimeHelper.GetChineseXq(playDate);
                WinFormHelper.LocationAfter(this.lbDate, this.lbDateHint);

                this.lbTime.Text = ticket.PlayTime;
                WinFormHelper.LocationAfter(this.lbDateHint, this.lbTime);
                WinFormHelper.LocationAfter(this.lbTime, this.lbTimeHint);

                this.lbRoom.Text = ticket.RoomName;
                WinFormHelper.LocationAfter(this.lbTimeHint, this.lbRoom);

                //this.lbRoom.Location = new Point(this.lbTimeHint.Location.X + this.lbTimeHint.Width, this.lbTimeHint.Location.Y);

                int    num  = 6;
                string seat = string.Empty;
                for (int i = 0; i < lists.Count; i++)
                {
                    if (i != 0 && i % num == 0)
                    {
                        // seat += "\n座位:"
                        seat += "\n          ";
                    }
                    seat += lists[i].Seat + " ";
                }
                this.lbSeats.Text       = string.Format(this.lbSeats.Text, seat);
                this.lbTicketPrice.Text = ticket.Price.ToString();
                WinFormHelper.LocationAfter(this.lbTicketPrice, this.lbTicketPriceHint);
                this.lbTicketCount.Text = this.lists.Count.ToString();
                WinFormHelper.LocationAfter(this.lbTicketPriceHint, this.lbTicketCount);
                WinFormHelper.LocationAfter(this.lbTicketCount, this.lbTicketCountHint);
                this.lbTicketTotalPrice.Text = (ticket.Price * this.lists.Count).ToString();
                WinFormHelper.LocationAfter(this.lbTicketTotalPrice, this.lbTicketTotalPriceHint);
            }
            this.SetOperationTime(30);
        }
Пример #21
0
 static void form_Paint(object sender, PaintEventArgs e)
 {
     WinFormHelper.PaintRound(sender);
 }
Пример #22
0
 private void forumLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     WinFormHelper.GotoUrl("http://forum.salplachta.net");
 }
Пример #23
0
 private void webLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     WinFormHelper.GotoUrl("http://" + ((LinkLabel)sender).Text);
 }
Пример #24
0
 private void ctxItemStartup_Click(object sender, EventArgs e)
 {
     ctxItemStartup.Checked = WinFormHelper.CreateShortcut(_startupPathName, !ctxItemStartup.Checked);
 }
Пример #25
0
        private void Form1_Load(object sender, EventArgs e)
        {
            _MainLog    = new TextBoxLogger(txtLog);
            _WorkerALog = new TextBoxLogger(txtWorkerALog);
            _WorkerBLog = new TextBoxLogger(txtWorkerBLog);
            _ManagerLog = new TextBoxLogger(txtManagerLog);
            _ClientRef  = Reference <ICoreClient> .Create(new CoreClientFactory(_MainLog).Create());

            // init controls
            txtWorkerComputer.Text = Environment.MachineName;
            txtWorkerInstance.Text = "A";
            // - form title
            WinFormHelper.SetAppFormTitle(this, BuildConst.BuildEnv);

            cbMarketName.Items.Add(CurveConst.QR_EOD);
            cbMarketName.Items.Add(CurveConst.NAB_EOD);
            cbMarketName.SelectedIndex = 0;

            cbCounterParty.Items.Add("14859,Woolworths");
            cbCounterParty.Items.Add("13142,Barclays");
            cbCounterParty.SelectedIndex = 0;


            // setup the request progress view
            _ProgressViewHelper = new ProgressViewHelper();
            _ProgressDataHelper = new ProgressDataHelper();
            _ProgressFilters    = new ComboxBoxFilterGroup(
                panelProgress, _ProgressViewHelper, new EventHandler(ProgressSelectionChanged));
            _ProgressSelecter = new ProgressSelecter(
                _ProgressFilters, _ProgressViewHelper, _ProgressDataHelper);
            _ProgressView = new ListViewManager <ProgressObj>(
                _MainLog, lvProgress, _ProgressViewHelper,
                _ProgressSelecter, _ProgressFilters, new ProgressSorter(), _ProgressDataHelper);

            _ClientRef.Target.SubscribeNoWait <PortfolioValuationRequest>(Expr.ALL, ProgressCallback, null);
            _ClientRef.Target.SubscribeNoWait <TradeValuationRequest>(Expr.ALL, ProgressCallback, null);
            _ClientRef.Target.SubscribeNoWait <OrdinaryCurveGenRequest>(Expr.ALL, ProgressCallback, null);
            _ClientRef.Target.SubscribeNoWait <StressedCurveGenRequest>(Expr.ALL, ProgressCallback, null);
            _ClientRef.Target.SubscribeNoWait <UnassignedWorkflowRequest>(Expr.ALL, ProgressCallback, null);
            _ClientRef.Target.SubscribeNoWait <AssignedWorkflowRequest>(Expr.ALL, ProgressCallback, null);
            _ClientRef.Target.SubscribeNoWait <HandlerResponse>(Expr.ALL, ProgressCallback, null);
            _ClientRef.Target.SubscribeNoWait <WorkerResponse>(Expr.ALL, ProgressCallback, null);
            _ClientRef.Target.SubscribeNoWait <ManagerResponse>(Expr.ALL, ProgressCallback, null);

            // setup the worker availability view
            _AvailabilityViewHelper = new AvailabilityViewHelper();
            _AvailabilityDataHelper = new AvailabilityDataHelper();
            _AvailabilityFilters    = new ComboxBoxFilterGroup(
                panelAvailability, _AvailabilityViewHelper, new EventHandler(AvailabilitySelectionChanged));
            _AvailabilitySelecter = new AvailabilitySelecter(
                _AvailabilityFilters, _AvailabilityViewHelper, _AvailabilityDataHelper);
            _AvailabilityView = new ListViewManager <WorkerAvailability>(
                _MainLog, lvAvailability, _AvailabilityViewHelper,
                _AvailabilitySelecter, _AvailabilityFilters, new AvailabilitySorter(), _AvailabilityDataHelper);

            ICoreCache _AvailabilityCache = _ClientRef.Target.CreateCache(
                delegate(CacheChangeData update)
            {
                _AvailabilityView.UpdateData(new ViewChangeNotification <WorkerAvailability>()
                {
                    Change  = update.Change,
                    OldData = (update.OldItem != null) ? (WorkerAvailability)update.OldItem.Data : null,
                    NewData = (update.NewItem != null) ? (WorkerAvailability)update.NewItem.Data : null
                });
            }, WindowsFormsSynchronizationContext.Current);

            _AvailabilityCache.SubscribeNoWait <WorkerAvailability>(Expr.ALL, null, null);
        }
Пример #26
0
        private void btnSymmetricEncryption_Dencrypt_Click(object sender, EventArgs e)
        {
            var orginal = rtxtSymmetricEncryptionOrginal.Text;

            if (string.IsNullOrWhiteSpace(orginal))
            {
                rtxtSymmetricEncryptionOrginal.Focus();
                return;
            }
            var key = txtSymmetricEncryptionKey.Text;

            if (string.IsNullOrWhiteSpace(key))
            {
                txtSymmetricEncryptionKey.Focus();
                return;
            }
            try
            {
                switch (Convert.ToInt32(cmbSymmetricEncryptionEncryptMethod.SelectedValue))
                {
                case 1:     // AES128
                    rtxtSymmetricEncryptionHandled.Text = SecurityHelper.AES_128.Decrypt(orginal, key);
                    break;

                case 2:     // AES256
                    if (key.Length != 32)
                    {
                        rtxtSymmetricEncryptionHandled.Text = "密钥必须为32位!";
                        break;
                    }
                    rtxtSymmetricEncryptionHandled.Text = SecurityHelper.AES_256.Decrypt(orginal, key);
                    break;

                case 3:     // DES
                    if (key.Length != 8)
                    {
                        rtxtSymmetricEncryptionHandled.Text = "密钥必须为8位!";
                        break;
                    }
                    rtxtSymmetricEncryptionHandled.Text = SecurityHelper.DES.Decrypt(orginal, key);
                    break;

                case 4:     // RC4
                    using (SecurityHelper.RC4Crypt crypter = new SecurityHelper.RC4Crypt(key))
                    {
                        rtxtSymmetricEncryptionHandled.Text = crypter.Decrypt(orginal);
                    }
                    break;

                case 5:     // Rabbit
                    break;

                case 6:     // TripleDES
                    rtxtSymmetricEncryptionHandled.Text = SecurityHelper.TripleDES.Decrypt(orginal, key);
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                WinFormHelper.ShowError(ex);
            }
        }
Пример #27
0
 //how to avoid twinkle
 private void PaintGrid(int rowCount, int columnCount)
 {
     WinFormHelper.DrawGrid(this.pnlGame, rowCount, columnCount);
 }
Пример #28
0
        private void btnImgCutterStart_Click(object sender, EventArgs e)
        {
            var selectedPath = txtImgCutterImgSelectPath.Text.Trim();
            var savePath     = txtImgCutterImgSavePath.Text.Trim();

            if (string.IsNullOrWhiteSpace(selectedPath))
            {
                WinFormHelper.ShowError("请选定需处理图片所在的文件夹!");
                return;
            }
            if (string.IsNullOrWhiteSpace(savePath))
            {
                WinFormHelper.ShowError("请选定处理后图片所保存的文件夹!");
                return;
            }
            if (ImgCutter_ImgPathList.Count <= 0)
            {
                BindImgCutterListView();
            }
            if (ImgCutter_ImgPathList.Count <= 0)
            {
                WinFormHelper.ShowError("指定的文件夹内无图片!");
                return;
            }



            if ((selectedPath == savePath && MessageBox.Show(this, "保存图片的路径与来源一致,图片将被覆盖!请确认继续", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) || savePath != selectedPath)
            {
                var cutWidthStr  = txtImgCutterImgWidth.Text.Trim();
                var cutHeightStr = txtImgCutterImgHeight.Text.Trim();

                int cutWidth = 0, cutHeight = 0;

                if (rbImgCutterSolidBoth.Checked)
                {
                    if (string.IsNullOrEmpty(cutHeightStr) || string.IsNullOrEmpty(cutWidthStr))
                    {
                        WinFormHelper.ShowError("请指定图片的宽高!");
                        return;
                    }
                    cutHeight = Convert.ToInt32(cutHeightStr);
                    cutWidth  = Convert.ToInt32(cutWidthStr);
                }
                else if (rbImgCutterSolidWidth.Checked)
                {
                    if (string.IsNullOrEmpty(cutWidthStr))
                    {
                        WinFormHelper.ShowError("请指定图片的宽度!");
                        return;
                    }

                    cutHeight = 0;
                    cutWidth  = Convert.ToInt32(cutWidthStr);
                }
                else if (rbImgCutterSolidHeight.Checked)
                {
                    if (string.IsNullOrEmpty(cutHeightStr))
                    {
                        WinFormHelper.ShowError("请指定图片的高度!");
                        return;
                    }
                    cutHeight = Convert.ToInt32(cutHeightStr);
                    cutWidth  = 0;
                }
                else
                {
                    return;
                }

                if (ckbImgCutterImgWatermark.Checked && string.IsNullOrEmpty(ImgCutter_WatermarkTextOrImgPath))
                {
                    WinFormHelper.ShowError("请指定水印图片!");
                    txtImgCutterImgWatermarkPath.Focus();
                    return;
                }
                else if (ckbImgCutterTxtWatermark.Checked && string.IsNullOrEmpty(ImgCutter_WatermarkTextOrImgPath))
                {
                    WinFormHelper.ShowError("请输入水印文字!");
                    txtImgCutterTxtWatermark.Focus();
                    return;
                }
                else
                {
                    imgCutter = new ImgCutter(ImgCutter_ImgPathList, cutWidth, cutHeight, ImgCutter_RootPath, savePath, ImgCutter_IsUseWaterMark, ImgCutter_WatermarkTypeEnum, ImgCutter_WatermarkPosition, ImgCutter_WatermarkTextOrImgPath);
                }

                if (imgCutter != null)
                {
                    imgCutter.TaskProgress.ProgressChanged += ImgCutter_StatusProgressEvent;
                    imgCutter.CutProgress.ProgressChanged  += ImgCutter_ProgressEvent;
                    imgCutter.Action();
                }
            }
        }
Пример #29
0
        private void btnPortScanerStart_Click(object sender, EventArgs e)
        {
            ipStateList.Clear();
            ipStateBindingList.Clear();
            rtxtPortScanerStatus.Clear();
            lstbPortScanerStatus.DataSource = ipStateBindingList;
            ipStateBindingList.Add("IP地址              " + "    端口       " + "  端口状态 " + "             服务");
            btnPortScanerStop.Enabled  = true;
            btnPortScanerStart.Enabled = false;



            if (cbPortScanerSingleIp.Checked)
            {
                txtPortScanerIpEnd.Text = txtPortScanerIpStart.Text;
            }
            if (cbPortScanerSinglePort.Checked)
            {
                txtPortScanerPortEnd.Text = txtPortScanerPortStart.Text;
            }

            if (IpHelper.IsIp(txtPortScanerIpEnd.Text) && IpHelper.IsIp(txtPortScanerIpStart.Text))//匹配正确IP
            {
                try
                {
                    if (IpHelper.IpToInt64(txtPortScanerIpStart.Text) <= IpHelper.IpToInt64(txtPortScanerIpEnd.Text))
                    {
                        if (string.IsNullOrEmpty(txtPortScanerPortStart.Text) || string.IsNullOrEmpty(txtPortScanerPortEnd.Text))
                        {
                            WinFormHelper.ShowError("请输入端口号!");
                        }
                        else
                        {
                            ipStart   = IpHelper.IpToInt64(txtPortScanerIpStart.Text);
                            ipEnd     = IpHelper.IpToInt64(txtPortScanerIpEnd.Text);
                            portStart = Int32.Parse(txtPortScanerPortStart.Text);
                            portEnd   = Int32.Parse(txtPortScanerPortEnd.Text);

                            if (portEnd < portStart)
                            {
                                WinFormHelper.ShowError("请填写正确端口范围");
                                return;
                            }

                            var progress = ((ipEnd + 1 - ipStart) * (portEnd + 1 - portStart));
                            if (progress > int.MaxValue)
                            {
                                WinFormHelper.ShowError("Ip地址范围过大");
                                return;
                            }
                            pgbPortScanerProgress.Minimum = 0;
                            pgbPortScanerProgress.Maximum = (int)progress;
                            pgbPortScanerProgress.Value   = 0;

                            System.Diagnostics.Debug.WriteLine("[Form主线程]ThreadId:{0}", System.Threading.Thread.CurrentThread.ManagedThreadId);
                            portScaner = new PortScaner(txtPortScanerIpStart.Text, txtPortScanerIpEnd.Text, portStart, portEnd, tbPortScanerTimeOut.Value, Convert.ToInt32(txtPortScanerTaskNum.Text));
                            if (portScaner != null)
                            {
                                portScaner.TaskProgress.ProgressChanged += PortScanerStatusProgressEvent;
                                portScaner.ScanProgress.ProgressChanged += PortScanerIpListProgressEvent;

                                portScaner.Action();
                            }
                        }
                    }
                    else
                    {
                        WinFormHelper.ShowError("请输入有效的IP地址范围");
                        return;
                    }
                }
                catch (Exception ex)
                {
                }
            }
            else
            {
                WinFormHelper.ShowError("请输入有效的IP地址");
                return;
            }
        }
Пример #30
0
        public static string GetDisplayValue(ColumnTypes columnType, object value)
        {
            string val = string.Empty;;

            if (value == null)
            {
                return(string.Empty);
            }
            switch (columnType)
            {
            case ColumnTypes.Integer:
                val = string.Format("{0}", Math.Round(Conversion.ToDouble(value.ToString().Replace(",", string.Empty)), 0));
                break;

            case ColumnTypes.Amount:
                if (Configuration.UseRoundedValue)
                {
                    val = string.Format("{0}", Math.Round(Conversion.ToDouble(value.ToString().Replace(",", string.Empty)), 0));
                    val = WinFormHelper.GetFormattedNumber(val, ThousandSeparaterTypes.Nepali);
                }
                else
                {
                    val = string.Format("{0}", Math.Round(Conversion.ToDouble(value.ToString().Replace(",", string.Empty)), 2));
                    val = WinFormHelper.GetFormattedNumber(val, ThousandSeparaterTypes.Nepali, 2);
                }
                break;

            case ColumnTypes.AmountRound2:
                val = string.Format("{0}", Math.Round(Conversion.ToDouble(value.ToString().Replace(",", string.Empty)), 2));
                val = WinFormHelper.GetFormattedNumber(val, ThousandSeparaterTypes.Nepali, 2);
                break;

            case ColumnTypes.AmountRound:
                val = string.Format("{0}", Math.Round(Conversion.ToDouble(value.ToString().Replace(",", string.Empty)), 0));
                val = WinFormHelper.GetFormattedNumber(val, ThousandSeparaterTypes.Nepali);
                break;

            case ColumnTypes.EnglishDate:
                if (Validation.IsValidGregorianDate(value.ToString(), Configuration.DB_DATE_FORMAT))
                {
                    val = Bsoft.Data.Validation.GetGregorianDate(value.ToString(), Configuration.DB_DATE_FORMAT).ToString(Configuration.DISPLAY_DATE_FORMAT).ToString();
                }
                break;

            case ColumnTypes.EnglishDateTime:
                val = ((DateTime)value).ToString(Configuration.DATETIME_FORMAT);
                break;

            case ColumnTypes.NepaliDate:
                val = value.ToString();
                if (val.Length == 8)
                {
                    val = val.Substring(0, 4) + "/" + val.Substring(4, 2) + "/" + val.Substring(6, 2);
                }

                break;

            default:
                throw new Exception(string.Format("Invalid DB type used for the column."));    // {0}.", _dbColumnName));
                //throw new Exception(string.Format("Invalid DB type used for the column {0}.", _dbColumnName));
            }

            return(val);
        }