예제 #1
0
 public void Task()
 {
     // NSInvalidArgumentException -[MonoTouchFixtures_Foundation_UrlProtocolTest_CustomProtocol task]: unrecognized selector sent to instance 0x7ff4c910
     using (var p = new CustomProtocol()) {
         Assert.Null(p.Task, "Task");
     }
 }
예제 #2
0
        private void Login()
        {
            string UserName = this.UserNametextBox.Text.Trim();
            string PassWord = this.passwordBox.Password.Trim();

            GlobalData.UserName = UserName;
            GlobalData.Password = PassWord;
            bool flag = GlobalData.Connectflag && !Connection.isConnected;

            if (flag)
            {
                Connection.Start();
            }
            CustomProtocol proto = new CustomProtocol();

            proto.AddString("EA1");
            proto.AddString(UserName);
            proto.AddString(PassWord);
            Connection.Send(proto);
            base.Dispatcher.Invoke(delegate
            {
                this.remember_check.IsEnabled = true;
            });
            base.Dispatcher.Invoke(delegate
            {
                this.automatic_check.IsEnabled = true;
            });
        }
예제 #3
0
        static private bool registerCustomProtocol()
        {
            string binaryFilePath    = Process.GetCurrentProcess().MainModule.FileName;
            string defaultIconString = String.Format("\"{0}\", 0", binaryFilePath);
            string commandString     = String.Format("\"{0}\" \"%1\"", binaryFilePath);

            const string   ProtocolDescription   = "Merge Request Helper for GitLab link protocol";
            CustomProtocol protocol              = new CustomProtocol(Constants.CustomProtocolName);
            Dictionary <string, string> commands = new Dictionary <string, string> {
                { "open", commandString }
            };

            try
            {
                protocol.RegisterInRegistry(ProtocolDescription, commands, defaultIconString);
            }
            catch (UnauthorizedAccessException ex)
            {
                MessageBox.Show("Operation failed. Run mrHelper as Administrator to register or unregister Custom Protocol.",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ExceptionHandlers.Handle("Cannot register custom protocol", ex);
                return(false);
            }
            return(true);
        }
예제 #4
0
        private void Exitbutton_Click(object sender, RoutedEventArgs e)
        {
            this.UserNametextBox.IsEnabled = true;
            this.passwordBox.IsEnabled     = true;
            this.UserNametextBox.Clear();
            this.passwordBox.Clear();
            this.UserNametextBox.Focus();
            XMLHelper.UsersDeleter("UsersFile");
            bool rejisterflag = GlobalData.Rejisterflag;

            if (rejisterflag)
            {
                CustomProtocol proto = new CustomProtocol();
                proto.AddString("EE1");
                proto.AddString(GlobalData.UserName);
                Connection.Send(proto);
            }
            this.remember_check.IsChecked  = new bool?(false);
            this.remember_check.IsEnabled  = true;
            GlobalData.Rememberflag        = false;
            this.automatic_check.IsChecked = new bool?(false);
            this.automatic_check.IsEnabled = true;
            GlobalData.Automaticflag       = "0";
            GlobalData.Rejisterflag        = false;
            bool flag = RejisterPage.username != null;

            if (flag)
            {
                RejisterPage.username();
            }
        }
예제 #5
0
파일: RecordPage.cs 프로젝트: HubWhale/Bike
        private void onlinedataLoad(ProtocolBase proto)
        {
            CustomProtocol protocol = (CustomProtocol)proto;
            int            tnum     = protocol.GetInt(this.start, ref this.start);
            bool           flag     = tnum > 0;

            if (flag)
            {
                for (int i = 0; i < tnum; i++)
                {
                    string     temp = GlobalData.UserName;
                    RidingData dr   = new RidingData();
                    dr.ID        = (this.num + 1 + i).ToString();
                    dr.Name      = temp;
                    dr.TrackName = protocol.GetString(this.start, ref this.start);
                    dr.Time1     = protocol.GetString(this.start, ref this.start);
                    dr.Time2     = protocol.GetString(this.start, ref this.start);
                    dr.Distance  = protocol.GetString(this.start, ref this.start);
                    dr.Velocity  = protocol.GetString(this.start, ref this.start);
                    base.Dispatcher.Invoke(delegate
                    {
                        this.ObservableObj.Add(dr);
                    });
                }
            }
        }
예제 #6
0
        public Resolver GetResolver(CustomProtocol msg)
        {
            foreach (Resolver resolver in resolvers)
            {
                if (resolver.Support(msg))
                {
                    return(resolver);
                }
            }

            throw (new ArgumentException($"cannot find resolver, message type: {msg.Type}"));
        }
예제 #7
0
파일: RecordPage.cs 프로젝트: HubWhale/Bike
        private void RecordDelete_Click(object sender, RoutedEventArgs e)
        {
            sender = this.listView.SelectedItem;
            RidingData temp = sender as RidingData;
            bool       flag = temp == null;

            if (!flag)
            {
                bool flag2 = MessageBox.Show(MultiLanguage.Warn24, MultiLanguage.Warn22, MessageBoxButton.YesNo) != MessageBoxResult.Yes;
                if (!flag2)
                {
                    GlobalData.RecordName = temp.Name;
                    GlobalData.RecordData = XMLHelper.RecordReader(temp.Name, 5);
                    string FileName    = XMLHelper.RecordReader(temp.Name, 3);
                    string NowFileName = Environment.CurrentDirectory + "\\" + FileName + ".xml";
                    bool   flag3       = GlobalData.RecordData != null;
                    if (flag3)
                    {
                        XMLHelper.RecordDeleter(GlobalData.RecordName);
                        bool flag4 = File.Exists(NowFileName);
                        if (flag4)
                        {
                            File.Delete(NowFileName);
                        }
                        this.ObservableObj.Clear();
                        this.dataLoad();
                        bool recordflag = GlobalData.Recordflag;
                        if (recordflag)
                        {
                            this.start = 11;
                            this.onlinedataLoad(GlobalData.proto);
                        }
                    }
                    else
                    {
                        int            id    = Convert.ToInt32(temp.ID) - this.num;
                        CustomProtocol proto = new CustomProtocol();
                        proto.AddString("EF1");
                        proto.AddInt(id);
                        Connection.Send(proto);
                        this.deleteID = temp.ID;
                    }
                }
            }
        }
예제 #8
0
파일: RecordPage.cs 프로젝트: HubWhale/Bike
        public void LoginReturn(ProtocolBase proto)
        {
            GlobalData.proto = proto;
            CustomProtocol protocol = (CustomProtocol)proto;
            string         str      = protocol.GetString(this.start, ref this.start);
            int            ret      = protocol.GetInt(this.start, ref this.start);
            int            num      = ret;

            if (num != 0)
            {
                MessageBox.Show(MultiLanguage.Warn26, MultiLanguage.Warn22);
            }
            else
            {
                this.onlinedataLoad(protocol);
                MessageBox.Show(MultiLanguage.Hint7, MultiLanguage.Warn);
                GlobalData.Recordflag = true;
            }
        }
예제 #9
0
파일: RecordPage.cs 프로젝트: HubWhale/Bike
        //internal TabControl tabControl;

        //internal ListView listView;

        //internal TextBlock textBlock;

        //private bool _contentLoaded;

        public RecordPage()
        {
            this.InitializeComponent();
            this.ObservableObj = new ObservableCollection <RidingData>();
            this.dataLoad();
            this.languageInit();
            bool rejisterflag = GlobalData.Rejisterflag;

            if (rejisterflag)
            {
                string         UserName = GlobalData.UserName;
                CustomProtocol proto    = new CustomProtocol();
                proto.AddString("EC1");
                proto.AddString(UserName);
                Connection.Send(proto);
            }
            Connection.record  += new Connection.RegisterW(this.LoginReturn);
            Connection.recordD += new Connection.RegisterW(this.LoginReturnD);
        }
예제 #10
0
        private void RegisterReturn(ProtocolBase proto)
        {
            CustomProtocol protocol = (CustomProtocol)proto;
            int            start    = 0;
            string         str      = protocol.GetString(start, ref start);
            int            ret      = protocol.GetInt(start, ref start);
            int            num      = ret;

            if (num != 0)
            {
                MessageBox.Show(MultiLanguage.Hint21, MultiLanguage.Warn);
            }
            else
            {
                MessageBox.Show(MultiLanguage.Hint20, MultiLanguage.Warn);
                base.Dispatcher.Invoke(delegate
                {
                    base.Close();
                });
            }
        }
예제 #11
0
파일: RecordPage.cs 프로젝트: HubWhale/Bike
        public void LoginReturnD(ProtocolBase proto)
        {
            CustomProtocol protocol = (CustomProtocol)proto;
            string         str      = protocol.GetString(this.start, ref this.start);
            int            ret      = protocol.GetInt(this.start, ref this.start);
            int            num      = ret;

            if (num != 0)
            {
                MessageBox.Show(MultiLanguage.Warn27, MultiLanguage.Warn22);
            }
            else
            {
                this.onlinedataLoad(protocol);
                MessageBox.Show(MultiLanguage.Hint8, MultiLanguage.Warn);
                CustomProtocol proto2 = new CustomProtocol();
                proto2.AddString("EC1");
                proto2.AddString(GlobalData.UserName);
                Connection.Send(proto2);
                this.DeleteData(this.deleteID);
            }
        }
예제 #12
0
 public bool Support(CustomProtocol msg)
 {
     return(supportMessageType == msg.Type);
 }
예제 #13
0
 public void Resolve(IChannelHandlerContext ctx, CustomProtocol msg)
 {
     //Log.Info($"收到来自{msg.Id}的聊天 >>> {msg.Content}");
     Model.ReceiveText = msg.Content;
 }
예제 #14
0
        private void Registerbutton_Click(object sender, RoutedEventArgs e)
        {
            string UserName      = this.UserNametextBox.Text.Trim();
            string PassWord      = this.passwordBox.Password.Trim();
            string PassWordagain = this.passwordagainBox.Password.Trim();
            string E_mail        = this.E_mailBox.Text.Trim();
            string Telephone     = this.TelephoneBox.Text.Trim();
            string Height        = this.HeightBox.Text.Trim();
            string Weight        = this.WeightBox.Text.Trim();
            string regex         = "^[\\u4E00-\\u9FA5a-zA-Z0-9_]+$";
            string regex2        = "^[a-zA-Z0-9_]+$";
            string regexE        = "^(\\w)+(\\.\\w+)*@(\\w)+((\\.\\w{2,3}){1,3})$";
            string regexT        = "^[0-9]+$";
            string regexH        = "^([0-9]{3})$";
            string regexW        = "^([0-9]{2,3})$";
            bool   flag          = string.IsNullOrWhiteSpace(UserName);

            if (flag)
            {
                MessageBox.Show(MultiLanguage.Hint1);
            }
            else
            {
                bool flag2 = !Regex.IsMatch(UserName, regex);
                if (flag2)
                {
                    MessageBox.Show(MultiLanguage.Hint2, MultiLanguage.Warn);
                    this.UserNametextBox.Clear();
                    this.UserNametextBox.Focus();
                }
                else
                {
                    bool flag3 = string.IsNullOrWhiteSpace(PassWord);
                    if (flag3)
                    {
                        MessageBox.Show(MultiLanguage.Hint9);
                    }
                    else
                    {
                        bool flag4 = !Regex.IsMatch(PassWord, regex2);
                        if (flag4)
                        {
                            MessageBox.Show(MultiLanguage.Hint10, MultiLanguage.Warn);
                            this.passwordBox.Clear();
                            this.passwordagainBox.Clear();
                            this.passwordBox.Focus();
                        }
                        else
                        {
                            bool flag5 = !PassWord.Equals(PassWordagain);
                            if (flag5)
                            {
                                MessageBox.Show(MultiLanguage.Hint11, MultiLanguage.Warn);
                                this.passwordBox.Clear();
                                this.passwordagainBox.Clear();
                                this.passwordBox.Focus();
                            }
                            else
                            {
                                bool flag6 = string.IsNullOrWhiteSpace(E_mail);
                                if (flag6)
                                {
                                    MessageBox.Show(MultiLanguage.Hint12);
                                }
                                else
                                {
                                    bool flag7 = !Regex.IsMatch(E_mail, regexE);
                                    if (flag7)
                                    {
                                        MessageBox.Show(MultiLanguage.Hint13, MultiLanguage.Warn);
                                        this.E_mailBox.Clear();
                                        this.E_mailBox.Focus();
                                    }
                                    else
                                    {
                                        bool flag8 = string.IsNullOrWhiteSpace(Telephone);
                                        if (flag8)
                                        {
                                            MessageBox.Show(MultiLanguage.Hint24);
                                        }
                                        else
                                        {
                                            bool flag9 = !Regex.IsMatch(Telephone, regexT);
                                            if (flag9)
                                            {
                                                MessageBox.Show(MultiLanguage.Hint25, MultiLanguage.Warn);
                                                this.TelephoneBox.Clear();
                                                this.TelephoneBox.Focus();
                                            }
                                            else
                                            {
                                                bool flag10 = this.SexBox.SelectedItem == null;
                                                if (flag10)
                                                {
                                                    MessageBox.Show(MultiLanguage.Hint14);
                                                }
                                                else
                                                {
                                                    string Sex    = this.SexBox.SelectedItem.ToString();
                                                    bool   flag11 = this.NationalityBox.SelectedItem == null;
                                                    if (flag11)
                                                    {
                                                        MessageBox.Show(MultiLanguage.Hint23);
                                                    }
                                                    else
                                                    {
                                                        string Nationality = this.NationalityBox.SelectedItem.ToString();
                                                        bool   flag12      = string.IsNullOrWhiteSpace(Height);
                                                        if (flag12)
                                                        {
                                                            MessageBox.Show(MultiLanguage.Hint15);
                                                        }
                                                        else
                                                        {
                                                            bool flag13 = !Regex.IsMatch(Height, regexH);
                                                            if (flag13)
                                                            {
                                                                MessageBox.Show(MultiLanguage.Hint16, MultiLanguage.Warn);
                                                                this.HeightBox.Clear();
                                                                this.HeightBox.Focus();
                                                            }
                                                            else
                                                            {
                                                                bool flag14 = string.IsNullOrWhiteSpace(Weight);
                                                                if (flag14)
                                                                {
                                                                    MessageBox.Show(MultiLanguage.Hint17);
                                                                }
                                                                else
                                                                {
                                                                    bool flag15 = !Regex.IsMatch(Weight, regexW);
                                                                    if (flag15)
                                                                    {
                                                                        MessageBox.Show(MultiLanguage.Hint18, MultiLanguage.Warn);
                                                                        this.WeightBox.Clear();
                                                                        this.WeightBox.Focus();
                                                                    }
                                                                    else
                                                                    {
                                                                        bool flag16 = this.SizeBox.SelectedItem == null;
                                                                        if (flag16)
                                                                        {
                                                                            MessageBox.Show(MultiLanguage.Hint19);
                                                                        }
                                                                        else
                                                                        {
                                                                            string Size   = this.SizeBox.SelectedItem.ToString();
                                                                            string size   = Size.Substring(0, Size.Length - 1);
                                                                            bool   flag17 = Sex == "男" && Sex == "male";
                                                                            string sex;
                                                                            if (flag17)
                                                                            {
                                                                                sex = "1";
                                                                            }
                                                                            else
                                                                            {
                                                                                sex = "0";
                                                                            }
                                                                            CustomProtocol proto = new CustomProtocol();
                                                                            proto.AddString("EB1");
                                                                            proto.AddString(UserName);
                                                                            proto.AddString(PassWord);
                                                                            proto.AddString(E_mail);
                                                                            proto.AddString(Telephone);
                                                                            proto.AddString(sex);
                                                                            proto.AddString(Nationality);
                                                                            proto.AddString(Height);
                                                                            proto.AddString(Weight);
                                                                            proto.AddString(size);
                                                                            Connection.Send(proto);
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #15
0
        public void LoginReturn(ProtocolBase proto)
        {
            CustomProtocol protocol = (CustomProtocol)proto;
            int            start    = 0;
            string         str      = protocol.GetString(start, ref start);
            int            ret      = protocol.GetInt(start, ref start);
            int            num      = ret;

            if (num != 0)
            {
                if (num != 2)
                {
                    MessageBox.Show(MultiLanguage.Warn28, MultiLanguage.Warn_t);
                    base.Dispatcher.Invoke(delegate
                    {
                        this.UserNametextBox.IsEnabled = true;
                    });
                    base.Dispatcher.Invoke(delegate
                    {
                        this.passwordBox.IsEnabled = true;
                    });
                    base.Dispatcher.Invoke(delegate
                    {
                        this.remember_check.IsEnabled = true;
                    });
                    base.Dispatcher.Invoke(delegate
                    {
                        this.automatic_check.IsEnabled = true;
                    });
                    base.Dispatcher.Invoke(delegate
                    {
                        this.UserNametextBox.Clear();
                    });
                    base.Dispatcher.Invoke(delegate
                    {
                        this.passwordBox.Clear();
                    });
                    base.Dispatcher.Invoke(delegate
                    {
                        this.UserNametextBox.Focus();
                    });
                    base.Dispatcher.Invoke(delegate
                    {
                        this.remember_check.IsChecked = new bool?(false);
                    });
                    base.Dispatcher.Invoke(delegate
                    {
                        this.automatic_check.IsChecked = new bool?(false);
                    });
                    GlobalData.Rejisterflag = false;
                }
                else
                {
                    MessageBox.Show(MultiLanguage.Warn29, MultiLanguage.Warn_t);
                    base.Dispatcher.Invoke(delegate
                    {
                        this.UserNametextBox.IsEnabled = true;
                    });
                    base.Dispatcher.Invoke(delegate
                    {
                        this.passwordBox.IsEnabled = true;
                    });
                    base.Dispatcher.Invoke(delegate
                    {
                        this.remember_check.IsEnabled = true;
                    });
                    base.Dispatcher.Invoke(delegate
                    {
                        this.automatic_check.IsEnabled = true;
                    });
                    base.Dispatcher.Invoke(delegate
                    {
                        this.UserNametextBox.Clear();
                    });
                    base.Dispatcher.Invoke(delegate
                    {
                        this.passwordBox.Clear();
                    });
                    base.Dispatcher.Invoke(delegate
                    {
                        this.UserNametextBox.Focus();
                    });
                    base.Dispatcher.Invoke(delegate
                    {
                        this.remember_check.IsChecked = new bool?(false);
                    });
                    base.Dispatcher.Invoke(delegate
                    {
                        this.automatic_check.IsChecked = new bool?(false);
                    });
                    GlobalData.Rejisterflag = false;
                }
            }
            else
            {
                MessageBox.Show(MultiLanguage.Hint22, MultiLanguage.Warn);
                base.Dispatcher.Invoke(delegate
                {
                    this.UserNametextBox.IsEnabled = false;
                });
                base.Dispatcher.Invoke(delegate
                {
                    this.passwordBox.IsEnabled = false;
                });
                base.Dispatcher.Invoke(delegate
                {
                    this.remember_check.IsEnabled = false;
                });
                base.Dispatcher.Invoke(delegate
                {
                    this.automatic_check.IsEnabled = false;
                });
                GlobalData.Rejisterflag = true;
                XMLHelper.UsersWriter("UsersFile");
                bool flag = RejisterPage.username != null;
                if (flag)
                {
                    RejisterPage.username();
                }
            }
        }
예제 #16
0
 public void Send(object parameter)
 {
     socket.SendMessage(CustomProtocol.Msg(CustomProtocol.Heartbeat().Id, InputText));
 }