Пример #1
0
    public Sonic4Ep1()
    {
        Sonic4Ep1.pInstance = this;

        AppMain.storePath = System.IO.Directory.GetCurrentDirectory();

        var config = XmlStorage.Load();

        if (config == null)
        {
            config = new Sonic4Save();
        }

        var backup = gs.backup.SSave.CreateInstance();

        backup.SetSave(config);

        XmlStorage.Save(config, false, false);

        this.graphics = new GraphicsDeviceManager((Game)this);
        this.graphics.PreferredBackBufferWidth       = 480 * 3;
        this.graphics.PreferredBackBufferHeight      = 288 * 3;
        this.graphics.SupportedOrientations          = DisplayOrientation.LandscapeLeft;
        this.graphics.PreparingDeviceSettings       += new EventHandler <PreparingDeviceSettingsEventArgs>(this.graphics_PreparingDeviceSettings);
        this.graphics.SynchronizeWithVerticalRetrace = true;
        this.graphics.IsFullScreen = false;
        this.IsMouseVisible        = true;
        this.Content.RootDirectory = "Content";
        this.TargetElapsedTime     = TimeSpan.FromSeconds(1d / 60);


        this.Activated   += new EventHandler <EventArgs>(OnActivated);
        this.Deactivated += new EventHandler <EventArgs>(OnDeactivated);
    }
Пример #2
0
        public PluginViewModel(IPlugin plugin)
        {
            this._plugin = plugin;
            var protocalSetting = plugin.GetProtocalSetting();

            Title                   = protocalSetting.Title;
            Description             = protocalSetting.Description;
            _log                    = TinyIoCContainer.Current.Resolve <ILogDog>();
            PluginKVViewModels      = new ObservableCollection <PluginKVViewModel>();
            PluginMonitorViewModels = new ObservableCollection <PluginMonitorViewModel>();

            _xmlPluginKvSgsStorage = new XmlStorage <PluginKvSgs>(PathHelper.Combine(MessageToken.CONFIG_FOLDER, MessageToken.SETTINGCONFIG_FOLDER));
            _xmlPluginKvSgsStorage.Load();
            _pluginKvSgs = _xmlPluginKvSgsStorage.Storage;
            var pluginKvs      = protocalSetting.PluginKVs;
            var pluginMonitors = protocalSetting.PluginMonitors;

            foreach (var item in pluginKvs)
            {
                if (_pluginKvSgs.PluginKvSgList != null && _pluginKvSgs.PluginKvSgList.Exists(p => p.Key == item.Key))
                {
                    item.Value = _pluginKvSgs.PluginKvSgList.FirstOrDefault(p => p.Key == item.Key).Value;
                }
                var kvm = new PluginKVViewModel(item);
                PluginKVViewModels.Add(kvm);
                kvm.PropertyChanged += Kvm_PropertyChanged;
            }
            foreach (var item in plugin.GetProtocalSetting().PluginMonitors)
            {
                PluginMonitorViewModels.Add(new PluginMonitorViewModel(item));
            }
            SelectedPluginMonitorVm = PluginMonitorViewModels.FirstOrDefault();
        }
Пример #3
0
        public void PageRegistr(bool b)
        {
            if (b)
            {
                _password     = _dateMas[1];
                _name         = _dateMas[2];
                _mail         = _dateMas[3];
                _createTime   = _dateMas[4] + " " + _dateMas[5];
                _modifiedTime = _dateMas[7] + " " + _dateMas[8];
                var storage = new XmlStorage("UserBase.xml");
                var users   = storage.Load();
                users.Add(new User()
                {
                    Login = _login, Name = _name, Password = _password, Mail = _mail, CreatedAt = _createTime, ModifiedAt = _modifiedTime
                });
                storage.Save(users);


                Console.WriteLine($"Система:  Данные пользователя при регистрации  {_data}  (Пользователь добавлен)");
                string otvet         = "0";
                byte[] otvetRegistra = Encoding.Unicode.GetBytes(otvet);
                _stream.Write(otvetRegistra, 0, otvetRegistra.Length);
            }
            else
            {
                Console.WriteLine($"Система:\tДанные пользователя при регистрации  {_data}  (Уже существует)");
                string otvet         = "1";
                byte[] otvetRegistra = Encoding.Unicode.GetBytes(otvet);
                _stream.Write(otvetRegistra, 0, otvetRegistra.Length);
            }
        }
Пример #4
0
        /// <summary>
        /// 传入项目所在目录名称
        /// </summary>
        /// <param name="projectFolderName"></param>
        public App(string projectFolderName) : this()
        {
            if (string.IsNullOrWhiteSpace(projectFolderName))
            {
                throw new ArgumentException("请输入Templates下的工程文件夹名称。");
            }
            var projectMetaFile = $"{string.Format(TemplatesFolder, projectFolderName)}project.xml";
            //生成项目文件示例
            var projectFile = AppHelper.GetFileFullName(projectMetaFile);

            //DebugConsole.Error(projectFile);
            Project = XmlStorage.Load <ProjectMeta>(projectFile);
            //Debug.Green(p1.ToJsonByJc());
            Project.TemplatesRootDirectory = $"~/Templates/{projectFolderName}/";
            RootTemplateFullPath           = FileHelper.GetFullPath(Project.TemplatesRootDirectory);
            var subs = FileHelper.GetSubFolderNames(RootTemplateFullPath).ToList(); //子模板目录

            if (subs.Count == 0)
            {
                log.Error("子模板不存在,无法生成项目。");
            }
            Models = new List <ModelMeta>();
            foreach (var sub in subs)
            {
                Models.Add(new ModelMeta(sub, Project));
            }
        }
Пример #5
0
 public GeneralSettingViewModel()
 {
     _xmlPluginKvSgsStorage = new XmlStorage <PluginKvSgs>(PathHelper.Combine(MessageToken.CONFIG_FOLDER, MessageToken.GENERAL_SETTING));
     _xmlPluginKvSgsStorage.Load();
     _pluginKvSgs        = _xmlPluginKvSgsStorage.Storage;
     GeneralKvViewModels = new ObservableCollection <PluginKVViewModel>
     {
         new PluginKVViewModel(
             new PluginKV()
         {
             Key    = MessageToken.SAVELOGDAYS,
             Value  = "15",
             KvType = KvType.Int,
         })
     };
     foreach (var kvvm in GeneralKvViewModels)
     {
         var kv = _pluginKvSgs.PluginKvSgList.Find(o => o.Key == kvvm.Key);
         if (kv != null)
         {
             kvvm.Value = kv.Value;
         }
         else
         {
             _pluginKvSgs.PluginKvSgList.Add(new PluginKvSg()
             {
                 Key = kvvm.Key, Value = kvvm.Value
             });
         }
         kvvm.PropertyChanged += Kvvm_PropertyChanged;
     }
 }
Пример #6
0
    private static void DmCmnBackupLoad()
    {
        var instance = SSave.CreateInstance();
        var save     = XmlStorage.Load();

        if (save != null)
        {
            instance.SetSave(save);
        }
    }
Пример #7
0
        public DatabaseViewModel(MetroDialog dialog)
        {
            _databaseStorage = new XmlStorage <DatabaseSg>(
                PathHelper.Combine(MessageToken.CONFIG_FOLDER, MessageToken.DATABASEXML));
            _databaseStorage.Load();

            DatabaseSg = _databaseStorage.Storage;

            ConnectCommand = new RelayCommand(Connect);

            _dialog = dialog;
        }
Пример #8
0
        public void PageChat()
        {
            byte[] smsByteLenght = new byte[Buffersize];
            _stream.Read(smsByteLenght, 0, smsByteLenght.Length);
            string smsLenght = Encoding.Unicode.GetString(smsByteLenght);

            int smsBuffLenght = int.Parse(smsLenght);

            byte[] smsByte = new byte[smsBuffLenght];

            _stream.Write(_wait1, 0, _wait1.Length);

            _stream.Read(smsByte, 0, smsByte.Length);
            var sms = Encoding.Unicode.GetString(smsByte);

            _smsMas = sms.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            var time = _smsMas[0];

            _countMes = _smsMas.Last();
            var smsLine = "";

            for (int i = 1; i < _smsMas.Length; i++)
            {
                smsLine += _smsMas[i];
                smsLine += " ";
            }
            Console.WriteLine($"{_login}:  {smsLine}    {time}");
            var storage = new XmlStorage("UserBase.xml");
            var users   = storage.Load();

            _user.Message += $"{Environment.NewLine}  {time}    {smsLine.Remove(smsLine.Length - 2, 1)}";
            //user.Count = int.Parse(countMes);
            var c = _user.Count + int.Parse(_countMes);

            _user.Count = c;
            users.Add(_user);
            storage.Save(users);
            List <User> listUser = new List <User>();

            foreach (var item in users)
            {
                if (item.Login == _login)
                {
                    listUser.Add(item);
                }
            }
            var a = listUser[0];

            users.Remove(a);
            storage.Save(users);
        }
Пример #9
0
        public bool YesNoRegistr()
        {
            _dateMas     = _data.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            _login       = _dateMas[0];
            _loginSearch = true;
            var storage = new XmlStorage("UserBase.xml");
            var users   = storage.Load();

            foreach (var item in users)
            {
                if (item.Login == _login)
                {
                    _loginSearch = false;
                }
            }
            return(_loginSearch);
        }
Пример #10
0
 public static void Load()
 {
     XmlStorage ps = new XmlStorage ();
     ps.Load (Path.Combine (Defines.DATA_DIR, Defines.THEMES_FILE));
     ps.Get (ref themes);
 }
Пример #11
0
        public void Load(string file)
        {
            XmlStorage ps = new XmlStorage ();
            List <VideoProjectElement> videos = new List <VideoProjectElement> ();
            List <SlideShowProjectElement> slides = new List <SlideShowProjectElement> ();
            List <ButtonProjectElement> bts = new List <ButtonProjectElement> ();

            Logger.Debug ("Project.Load. Loading project {0}", file);
            ps.Load (file);

            Clear ();

            ps.Get <ProjectDetails> ("details", ref details);
            ps.Get <List <ButtonProjectElement>> ("buttons", ref bts);
            ps.Get <List <VideoProjectElement>> ("videos", ref videos);
            ps.Get <List <SlideShowProjectElement>> ("slides", ref slides);

            details.Filename = file; // After the details have been loaded

            foreach (Video video in videos)
                elements.Add (video);

            foreach (SlideShow slide in slides)
                elements.Add (slide);

            foreach (Button button in bts)
                buttons.Add (button);

            Logger.Debug ("Project.Load. Loaded {0} - {1} elements", Details.Filename, elements.Count);
        }
Пример #12
0
        public void PageRemimdPas(bool b)
        {
            var storage = new XmlStorage("UserBase.xml");
            var users   = storage.Load();


            #region Прием названия кнопки которая нажата в "Remind"
            //stream.Write(wait1, 0, wait1.Length);
            byte[] methodTypeByteLenght = new byte[Buffersize];
            _stream.Read(methodTypeByteLenght, 0, methodTypeByteLenght.Length);
            string methodTypeLenght     = Encoding.Unicode.GetString(methodTypeByteLenght);
            int    methodTypeBuffLenght = int.Parse(methodTypeLenght);
            byte[] methodTypeByte       = new byte[methodTypeBuffLenght];
            _stream.Write(_wait1, 0, _wait1.Length);

            _stream.Read(methodTypeByte, 0, methodTypeByte.Length);
            var methodType = Encoding.Unicode.GetString(methodTypeByte);
            //stream.Write(wait1, 0, wait1.Length);

            #endregion

            if (methodType == "btOK_Click")
            {
                if (b)
                {
                    int random = _rnd.Next(10000, 99999);

                    foreach (var item in users)
                    {
                        if (item.Login == _login)
                        {
                            _mail = item.Mail;
                        }
                    }
                    string otvet         = "0";
                    byte[] otvetRegistra = Encoding.Unicode.GetBytes(otvet);
                    _stream.Write(otvetRegistra, 0, otvetRegistra.Length);
                    Console.WriteLine($"Система:  Такой логин для восстановления есть");
                    _stream.Read(_wait1, 0, _wait1.Length);

                    string userMail           = _mail + " " + random;
                    byte[] userMailByte       = Encoding.Unicode.GetBytes(userMail);
                    string userMailLenght     = userMailByte.Length.ToString();
                    byte[] userMailLenghtByte = Encoding.Unicode.GetBytes(userMailLenght);
                    _stream.Write(userMailLenghtByte, 0, userMailLenghtByte.Length);
                    _stream.Read(_wait1, 0, _wait1.Length);
                    _stream.Write(userMailByte, 0, userMailByte.Length);

                    MailAddress from     = new MailAddress("*****@*****.**");
                    MailAddress to       = new MailAddress(_mail);
                    MailMessage mailSend = new MailMessage(from, to);
                    mailSend.Body       = "<h2>Код для восстановления пароля </h2>" + random;
                    mailSend.IsBodyHtml = true;

                    SmtpClient smtp = new SmtpClient("smtp.mail.ru", 25);
                    smtp.Credentials = new NetworkCredential("*****@*****.**", "45626336rustam");
                    smtp.EnableSsl   = true;
                    smtp.Send(mailSend);
                }
                else
                {
                    Console.WriteLine($"Система:\tТакого логина для восстановления нет");
                    string otvet         = "1";
                    byte[] otvetRegistra = Encoding.Unicode.GetBytes(otvet);
                    _stream.Write(otvetRegistra, 0, otvetRegistra.Length);
                }
            }
            if (methodType == "btChangePas_Click")
            {
                #region Прием пароля для изменения
                byte[] pasByteLenght = new byte[Buffersize];
                _stream.Read(pasByteLenght, 0, pasByteLenght.Length);
                string pasLenght     = Encoding.Unicode.GetString(pasByteLenght);
                int    pasBuffLenght = int.Parse(pasLenght);
                byte[] pasByte       = new byte[pasBuffLenght];
                _stream.Write(_wait1, 0, _wait1.Length);
                _stream.Read(pasByte, 0, pasByte.Length);
                var pas_time = Encoding.Unicode.GetString(pasByte);
                var pasTime  = pas_time.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                #endregion

                User p = users.First(x => x.Login == _login);
                p.Password   = pasTime[0];
                p.ModifiedAt = pasTime[1] + " " + pasTime[2];
                users.Add(p);
                storage.Save(users);
                List <User> listUser = new List <User>();

                foreach (var item in users)
                {
                    if (item.Login == _login)
                    {
                        listUser.Add(item);
                    }
                }
                var a = listUser[0];
                users.Remove(a);
                storage.Save(users);
            }
        }
Пример #13
0
        public void PageAdmin()
        {
            #region Прием названия кнопки которая нажата в "Admin"
            byte[] methodTypeByteLenght = new byte[Buffersize];
            _stream.Read(methodTypeByteLenght, 0, methodTypeByteLenght.Length);
            string methodTypeLenght     = Encoding.Unicode.GetString(methodTypeByteLenght);
            int    methodTypeBuffLenght = int.Parse(methodTypeLenght);
            byte[] methodTypeByte       = new byte[methodTypeBuffLenght];

            _stream.Write(_wait1, 0, _wait1.Length);

            _stream.Read(methodTypeByte, 0, methodTypeByte.Length);
            var methodType = Encoding.Unicode.GetString(methodTypeByte);
            #endregion

            var storage = new XmlStorage("UserBase.xml");
            var users   = storage.Load();
            int count   = users.Count() - 1;

            if (methodType == "ButtonLoadUsers")
            {
                byte[] countByte       = Encoding.Unicode.GetBytes(count.ToString());
                string countLenght     = countByte.Length.ToString();
                byte[] countLenghtByte = Encoding.Unicode.GetBytes(countLenght);
                _stream.Write(countLenghtByte, 0, countLenghtByte.Length);
                _stream.Read(_wait1, 0, _wait1.Length);
                _stream.Write(countByte, 0, countByte.Length);


                foreach (var item in users)
                {
                    if (item.Login != "admin")
                    {
                        byte[] lognameByte   = Encoding.Unicode.GetBytes(item.Login + " " + item.Name + " " + item.Password + " " + item.Count.ToString() + " " + item.CreatedAt + " " + item.ModifiedAt);
                        byte[] lognameLenght = Encoding.Unicode.GetBytes(lognameByte.Length.ToString());
                        _stream.Write(lognameLenght, 0, lognameLenght.Length);
                        _stream.Read(_wait1, 0, _wait1.Length);
                        _stream.Write(lognameByte, 0, lognameByte.Length);


                        if (item.Message != null)
                        {
                            string otvet         = "0";
                            byte[] otvetRegistra = Encoding.Unicode.GetBytes(otvet);
                            _stream.Write(otvetRegistra, 0, otvetRegistra.Length);

                            _stream.Read(_wait1, 0, _wait1.Length);

                            byte[] messageByte       = Encoding.Unicode.GetBytes(item.Message);
                            byte[] messageByteLenght = Encoding.Unicode.GetBytes(messageByte.Length.ToString());
                            _stream.Write(messageByteLenght, 0, messageByteLenght.Length);
                            _stream.Read(_wait1, 0, _wait1.Length);
                            _stream.Write(messageByte, 0, messageByte.Length);
                        }
                        else
                        {
                            string otvet         = "1";
                            byte[] otvetRegistra = Encoding.Unicode.GetBytes(otvet);
                            _stream.Write(otvetRegistra, 0, otvetRegistra.Length);
                        }
                    }
                }
            }
            if (methodType == "ButtonDelete")
            {
                #region Получаем логин пользователя которого нужно удалить из базы
                byte[] selectedByteLenght = new byte[Buffersize];
                _stream.Read(selectedByteLenght, 0, selectedByteLenght.Length);
                string selectedLenght     = Encoding.Unicode.GetString(selectedByteLenght);
                int    selectedBuffLenght = int.Parse(selectedLenght);
                byte[] selectedByte       = new byte[selectedBuffLenght];

                _stream.Write(_wait1, 0, _wait1.Length);

                _stream.Read(selectedByte, 0, selectedByte.Length);
                var selectedLogin = Encoding.Unicode.GetString(selectedByte);
                #endregion

                User p = users.First(x => x.Login == selectedLogin);
                users.Remove(p);
                storage.Save(users);
            }
        }
Пример #14
0
        public void PageMain(bool b)
        {
            var storage = new XmlStorage("UserBase.xml");
            var users   = storage.Load();


            #region Проверяем хешированный пароль
            bool hashpass = false;
            foreach (var item in users)
            {
                if (_login == item.Login)
                {
                    if (item.Login == "admin" && item.Password == _password)
                    {
                        hashpass = true;
                    }
                    else
                    {
                        if (_password == null)
                        {
                            throw new ArgumentNullException("b");
                        }
                        var    passhash        = GetMd5Hash(_password);
                        byte[] passHashbBytes1 = Encoding.UTF8.GetBytes(passhash);
                        if (item.Password != null)
                        {
                            byte[] passHashbBytes2 = Encoding.UTF8.GetBytes(item.Password);

                            hashpass = ByteArrayCompare(passHashbBytes1, passHashbBytes2);
                        }
                    }
                }
            }
            #endregion

            bool checkUser = false;
            if (b)
            {
                foreach (var item in users)
                {
                    if (_login == item.Login && hashpass)
                    {
                        checkUser = true;
                        _user     = item;
                    }
                }
                if (checkUser)
                {
                    string otvet         = "0";
                    byte[] otvetRegistra = Encoding.Unicode.GetBytes(otvet);
                    _stream.Write(otvetRegistra, 0, otvetRegistra.Length);
                    Console.WriteLine($"Система:  Вы вошли: {_login}");
                }
                else
                {
                    Console.WriteLine($"Система:\tДанные введены неверно");
                    string otvet         = "1";
                    byte[] otvetRegistra = Encoding.Unicode.GetBytes(otvet);
                    _stream.Write(otvetRegistra, 0, otvetRegistra.Length);
                }
            }
            else
            {
                Console.WriteLine($"Система:\tДанные введены неверно");
                string otvet         = "1";
                byte[] otvetRegistra = Encoding.Unicode.GetBytes(otvet);
                _stream.Write(otvetRegistra, 0, otvetRegistra.Length);
            }
        }
Пример #15
0
        public void Read()
        {
            if (File.Exists (filename) == false)
                return;

            XmlStorage ps = new XmlStorage ();
            XmlNode root;
            ps.Load (filename);

            if ((ps.xml_document.ChildNodes.Count > 0) == false)
                return;

            root = ps.xml_document.ChildNodes [1];

            RecentFile item = new RecentFile ();
            foreach (XmlNode node in root.ChildNodes)
            {
                XmlSerializer serializer = new XmlSerializer (typeof (RecentFile));
                StringReader reader = new StringReader (node.OuterXml);
                item = (RecentFile) serializer.Deserialize (reader);
                reader.Close ();
                items.Add (item);
            }
        }