public NewLikesProcessor(
     MainStorage mainStorage,
     MainPool mainPool)
 {
     _storage = mainStorage;
     _pool    = mainPool;
 }
Exemple #2
0
 public SuggestPrinter(
     MainStorage mainStorage,
     MainContext mainContext)
 {
     _storage = mainStorage;
     _context = mainContext;
 }
Exemple #3
0
 public InterestsContext(
     MainPool pool,
     MainStorage storage)
 {
     _pool    = pool;
     _storage = storage.Interests;
 }
Exemple #4
0
 public RecommendPrinter(
     MainStorage mainStorage,
     MainContext mainContext)
 {
     _storage = mainStorage;
     _context = mainContext;
 }
 public AccountPrinter(
     MainStorage mainStorage,
     MainContext mainContext)
 {
     _storage = mainStorage;
     _context = mainContext;
 }
Exemple #6
0
 public void Init(
     MainStorage mainStorage,
     List <GroupKey> keys,
     bool order)
 {
     _storage = mainStorage;
     _keys    = keys;
     _order   = order;
 }
 public EditAccountProcessor(
     MainStorage mainStorage,
     MainPool mainPool,
     Validator validator)
 {
     _storage   = mainStorage;
     _validator = validator;
     _pool      = mainPool;
 }
Exemple #8
0
 public NewAccountProcessor(
     Validator validator,
     MainPool mainPool,
     MainStorage mainStorage)
 {
     _validator = validator;
     _storage   = mainStorage;
     _pool      = mainPool;
 }
 public FilterProcessor(
     MainStorage mainStorage,
     MainContext mainContext,
     MainPool mainPool,
     AccountPrinter accountPrinter,
     MessageProcessor processor
     )
 {
     _pool      = mainPool;
     _storage   = mainStorage;
     _context   = mainContext;
     _printer   = accountPrinter;
     _processor = processor;
 }
 public RecommendProcessor(
     MainStorage mainStorage,
     MainContext mainContext,
     MainPool mainPool,
     RecommendPrinter printer,
     MessageProcessor processor
     )
 {
     _context   = mainContext;
     _storage   = mainStorage;
     _pool      = mainPool;
     _printer   = printer;
     _processor = processor;
 }
Exemple #11
0
        public static Buff CreatingBuff(string name, string tech, int value, int countdown)
        {
            ulong stId   = MainStorage.GetValueOf("LatestBuffId");
            ulong Id     = (ulong)Convert.ToInt32(stId) + 1;
            var   result = from i in buffs
                           where i.ID == Id
                           select i;
            var buf = result.FirstOrDefault();

            if (buf == null)
            {
                buf = CreateBuff(Id, name, tech, value, countdown);
            }
            return(buf);
        }
Exemple #12
0
        private unsafe static void Main()
        {
            // Values
            int[] MouseAccelParams = new int[3] { 0, 0, 0 };
            GCHandle PArray = GCHandle.Alloc(MouseAccelParams, GCHandleType.Pinned);
            IntPtr Pointer = PArray.AddrOfPinnedObject();

            // Store the current Windows mouse pointer settings, such as speed and acceleration status
            if (!SystemParametersInfo(SPI_GETMOUSE, 0, Pointer, 0))
                MessageBox.Show("SPI_GETMOUSE failed!", "MiniSynapse - ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

            // Log into Razer Synapse by using the last login data
            MainStorage I1 = Singleton<MainStorage>.Instance;
            I1.Initialize(Storage_Project.Emily);
            if (I1.TryLastLogin() != LoginStatus.Success)
            {
                // Something went wrong and we were unable to login
                MessageBox.Show("Cannot configure your Razer devices - you need to login through Razer Synapse first.");
                PArray.Free();

                return;
            }

            // Enumerate all the installed Razer Synapse 2.x devices
            RzDeviceManager RazerDM = new RzDeviceManager();
            RazerDM.Enumerate();

            // Initialize the settings loader
            CommonConfigLoader I2 = Singleton<CommonConfigLoader>.Instance;
            I2.StartConfig();

            // Apply the Razer Synapse settings to the device
            foreach (RzDevice RazerDevice in RazerDM.ActiveDevices.ToArray())
            {
                RazerDevice.RefreshData();
                I2.DeviceAdded(RazerDevice.VID, RazerDevice.PID);
                Console.WriteLine("Configured device: " + I2.FindDevice(RazerDevice.PID).Name);
            }

            // Restore the mouse settings back, since Synapse 2.10+ seem to reset them
            if (!SystemParametersInfo(SPI_SETMOUSE, 0, Pointer, SPIF.SPIF_SENDCHANGE))
                MessageBox.Show("SPI_SETMOUSE failed!", "MiniSynapse - ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

            // Free the GCHandle since we don't need it anymore
            PArray.Free();

            return;
        }
Exemple #13
0
        private static Buff CreateBuff(ulong id, string name, string tech, int value, int countdown)
        {
            var newBuff = new Buff()
            {
                ID        = id,
                Name      = name,
                Tech      = tech,
                Value     = value,
                Countdown = countdown
            };

            buffs.Add(newBuff);
            MainStorage.ChangeData("LatestBuffId", id);
            SaveBuffs();
            return(newBuff);
        }
Exemple #14
0
        public static Item CreatingItem(string name, string type, bool active, int value, string rarity,
                                        int countdown, string description)
        {
            ulong stId   = MainStorage.GetValueOf("LatestItemId");
            ulong Id     = (ulong)Convert.ToInt32(stId) + 1;
            var   result = from i in items
                           where i.ID == Id
                           select i;
            var item = result.FirstOrDefault();

            name = name.Replace("-", " ");
            if (item == null)
            {
                item = CreateItem(Id, name, type, active, value, rarity, countdown, description);
            }
            return(item);
        }
        private Task Action(RemoveTokenOptions options)
        {
            MainStorage storage = Storage.Read();

            if (storage.VKTokens.Count() >= options.Index)
            {
                storage.VKTokens.RemoveAt(options.Index);
                Storage.Write(storage);

                Console.WriteLine($"Токен с индексом {options.Index} был удален из хранилища");
            }
            else
            {
                Console.WriteLine("Такой токен не существует");
            }

            return(Task.CompletedTask);
        }
Exemple #16
0
        private static Quiz CreateQuiz(ulong id, string type, string imageUrl, string fullImage, string diff, string correct)
        {
            var newQuiz = new Quiz()
            {
                ID          = id,
                Type        = type,
                Difficulty  = diff,
                URL         = imageUrl,
                RightAnswer = correct,
                FullImage   = fullImage,
                Drop        = new List <Item>(),
                Hints       = new List <string>()
            };

            quizzes.Add(newQuiz);
            MainStorage.ChangeData("LatestQuizId", id);
            SaveQuizzes();
            return(newQuiz);
        }
Exemple #17
0
        public static Quiz CreatingQuiz(string type, string imageUrl, string fullImage, string diff, string correct)
        {
            ulong stId = MainStorage.GetValueOf("LatestQuizId");

            ulong Id     = (ulong)Convert.ToInt32(stId) + 1;
            var   result = from i in quizzes
                           where i.ID == Id
                           select i;
            var quiz = result.FirstOrDefault();

            if (quiz == null)
            {
                if (fullImage.Equals("x") || fullImage.Equals("X"))
                {
                    fullImage = "";
                }
                quiz = CreateQuiz(Id, type, imageUrl, fullImage, diff, correct);
            }
            return(quiz);
        }
Exemple #18
0
 public AccountsController(
     GroupPreprocessor groupsPreprocessor,
     NewAccountProcessor newAccountProcessor,
     EditAccountProcessor editAccountProcessor,
     NewLikesProcessor newLikesProcessor,
     FilterProcessor filterProcessor,
     GroupProcessor groupProcessor,
     RecommendProcessor recommendProcessor,
     SuggestProcessor suggestProcessor,
     MainStorage mainStorage)
 {
     _groupsPreprocessor   = groupsPreprocessor;
     _newAccountProcessor  = newAccountProcessor;
     _editAccountProcessor = editAccountProcessor;
     _newLikesProcessor    = newLikesProcessor;
     _filterProcessor      = filterProcessor;
     _groupProcessor       = groupProcessor;
     _recommendProcessor   = recommendProcessor;
     _suggestProcessor     = suggestProcessor;
     _storage = mainStorage;
 }
Exemple #19
0
        private static Item CreateItem(ulong id, string name, string type, bool active, int value, string rarity,
                                       int countdown, string description)
        {
            var newItem = new Item()
            {
                ID          = id,
                Name        = name,
                Type        = type,
                Active      = active,
                Value       = value,
                Rarity      = rarity,
                Buffs       = new List <Buff>(),
                Debuffs     = new List <Debuff>(),
                Description = description,
                Countdown   = countdown
            };

            items.Add(newItem);
            MainStorage.ChangeData("LatestItemId", id);
            SaveItems();
            return(newItem);
        }
Exemple #20
0
 public void Clear()
 {
     _storage = null;
     _keys    = null;
     _order   = false;
 }
Exemple #21
0
 public MainContext(MainPool pool, MainStorage storage)
 {
     Interests  = new InterestsContext(pool, storage);
     FirstNames = new FirstNameContext(storage);
     LastNames  = new LastNameContext(storage);
 }
Exemple #22
0
 public DomainParser(
     MainStorage mainStorage
     )
 {
     _storage = mainStorage;
 }
        public MessageProcessor(
            MainContext mainContext,
            MainStorage mainStorage,
            DomainParser parser,
            MainPool mainPool,
            GroupPreprocessor groupPreprocessor,
            NewAccountProcessor newAccountProcessor,
            EditAccountProcessor editAccountProcessor,
            NewLikesProcessor newLikesProcessor,
            DataLoader dataLoader)
        {
            _context           = mainContext;
            _storage           = mainStorage;
            _parser            = parser;
            _pool              = mainPool;
            _groupPreprocessor = groupPreprocessor;

            var newAccountObservable = newAccountProcessor
                                       .DataReceived;

            var editAccountObservable = editAccountProcessor
                                        .DataReceived;

            var newLikesObservable = newLikesProcessor
                                     .DataReceived;


            _likeWorker = new SingleThreadWorker <LikeEvent>(ProcessLike, "Like thread started");
            _loadWorker = new SingleThreadWorker <LoadEvent>(LoadAccount, "Import thread started");
            _postWorker = new SingleThreadWorker <PostEvent>(PostProcess, "Post thread started");

            _importGcSubscription = dataLoader
                                    .CallGc
                                    .Subscribe(_ => {
                _loadWorker.Enqueue(LoadEvent.GC);
            });

            _likeLoadedSubscription = dataLoader
                                      .LikeLoaded
                                      .Subscribe(
                x => _likeWorker.Enqueue(new LikeEvent(x, true)),
                _ => {},
                () => _likeWorker.Enqueue(LikeEvent.EndEvent)
                );

            _dataLoaderSubscription = dataLoader
                                      .AccountLoaded
                                      .Subscribe(
                item => { _loadWorker.Enqueue(new LoadEvent(item)); },
                _ => {},
                () => { _loadWorker.Enqueue(LoadEvent.EndEvent); });

            _newAccountProcessorSubscription = newAccountObservable
                                               .Subscribe(x => { _postWorker.Enqueue(PostEvent.Add(x)); });

            _editAccountProcessorSubscription = editAccountObservable
                                                .Subscribe(x => { _postWorker.Enqueue(PostEvent.Edit(x)); });

            _newLikesProcessorSubscription = newLikesObservable
                                             .Subscribe(NewLikes);

            var updateObservable = newAccountObservable
                                   .Select(_ => Interlocked.Increment(ref _editQuery))
                                   .Merge(editAccountObservable.Select(_ => Interlocked.Increment(ref _editQuery)))
                                   .Merge(newLikesObservable.Select(_ => Interlocked.Increment(ref _editQuery)));

            _secondPhaseEndSubscription = updateObservable
                                          .Throttle(TimeSpan.FromMilliseconds(2000))
                                          .Subscribe(_ =>
            {
                _postWorker.Enqueue(PostEvent.End());
                _likeWorker.Enqueue(LikeEvent.EndEvent);
            });
        }
Exemple #24
0
 public GroupPrinter(MainStorage storage, MainContext context)
 {
     _storage = storage;
     _context = context;
 }
Exemple #25
0
 public LastNameContext(MainStorage storage)
 {
     _storage = storage.LastNames;
 }
Exemple #26
0
 static void Main(string[] args)
 {
     #region Hide program from taskbar
     IntPtr current = Process.GetCurrentProcess().MainWindowHandle;
     EnableMenuItem(GetSystemMenu(current, false), SC_CLOSE, MF_GRAYED);
     IntPtr shellWin = GetShellWindow();
     SetParent(current, shellWin);
     #endregion
     if (File.Exists(AssemblyLocation(true) + "\\RzSynapse.exe"))
     {
         MainStorage mainApp = Singleton <MainStorage> .Instance;
         mainApp.Initialize(Storage_Project.Emily);
         if (!mainApp.TryLastLogin())
         {
             MessageBox.Show("Please login on Razer Synapse first.");
         }
         else
         {
             RzDeviceManager dManager = new RzDeviceManager();
             dManager.Enumerate();
             CommonConfigLoader configLoader = Singleton <CommonConfigLoader> .Instance;
             configLoader.StartConfig();
             RzDevice[] allDevices = dManager.ActiveDevices.ToArray();
             foreach (RzDevice rzDevice in allDevices)
             {
                 rzDevice.RefreshData();
                 configLoader.DeviceAdded(rzDevice.VID, rzDevice.PID);
                 //PluginDevice pluginDevice = configLoader.FindDevice(rzDevice.PID);
                 //Console.WriteLine("Loaded: " + pluginDevice.Name);
             }
         }
     }
     else
     {
         DialogResult result = DialogResult.None;
         if (args.Length < 1)
         {
             if (Directory.Exists(defaultDirectory))
             {
                 result = MessageBox.Show("The program is not in the Synapse folder. Automatically move it?", "Synapse Was Not Found", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
             }
             else
             {
                 MessageBox.Show("The program is not in the Synapse folder, and we can't find the directory. You probably installed it somewhere else. Please manually move the program to the root of the Razer Synapse directory.");
                 return;
             }
         }
         if (result == DialogResult.Yes || args.Length > 0)
         {
             WindowsPrincipal pricipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
             bool             hasAdministrativeRight = pricipal.IsInRole(WindowsBuiltInRole.Administrator);
             if (!hasAdministrativeRight)
             {
                 string           fileName    = Assembly.GetExecutingAssembly().Location;
                 ProcessStartInfo processInfo = new ProcessStartInfo
                 {
                     Verb      = "runas",
                     Arguments = "-true",
                     FileName  = fileName
                 };
                 try
                 {
                     Process.Start(processInfo);
                 }
                 catch
                 {
                     //Thrown if cancelled.
                     MessageBox.Show("The program needs admin to move the file to your program files.");
                     MessageBox.Show("The program will now exit.");
                     return;
                 }
                 return;
             }
             else
             {
                 string path = defaultDirectory + "\\" + Path.GetFileName(AssemblyLocation(false));
                 File.Copy(AssemblyLocation(false), path, true);
                 Process.Start(path);
                 result = MessageBox.Show("Run program at computer startup? Please disable Synapse from running at startup if yes.", "Add Startup Shortcut", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                 if (result == DialogResult.Yes)
                 {
                     AddShortcut("CleanSynapse", @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup");
                 }
                 MessageBox.Show("Completed installation.");
                 return;
             }
         }
         if (result == DialogResult.No)
         {
             MessageBox.Show("The program will now exit.");
             return;
         }
     }
 }
Exemple #27
0
 public Set()
 {
     StorageInstance = JsonStorage.GetInstance();
     MainStorage     = StorageInstance.Read();
 }
        public GroupPreprocessor(
            MainContext mainContext,
            MainStorage mainStorage,
            MainPool mainPool)
        {
            _context = mainContext;
            _storage = mainStorage;
            _pool    = mainPool;

            _worker = new SingleThreadWorker <Request>(r => {
                if (r.PostEnded)
                {
                    CompressImpl();
                    DataConfig.GroupUpdates = false;
                    return;
                }

                if (r.ImportEnded)
                {
                    LoadEndedImpl();
                    return;
                }

                if (r.IsLoad)
                {
                    AddImpl(r.Dto, true);
                    return;
                }

                DataConfig.GroupUpdates = true;

                if (r.IsAdd)
                {
                    AddImpl(r.Dto, false);
                }
                else
                {
                    UpdateImpl(r.Dto);
                }
            }, "Group thread started");

            for (int i = 1; i < 32; i++)
            {
                GroupKey keys = (GroupKey)i;

                int initialCapacity = 1;
                if (keys.HasFlag(GroupKey.Sex))
                {
                    initialCapacity *= 2;
                }

                if (keys.HasFlag(GroupKey.Status))
                {
                    initialCapacity *= 3;
                }

                if (keys.HasFlag(GroupKey.City))
                {
                    initialCapacity *= 700;
                }

                if (keys.HasFlag(GroupKey.Country))
                {
                    initialCapacity *= 100;
                }

                if (keys.HasFlag(GroupKey.Interest))
                {
                    initialCapacity *= 160;
                }

                initialCapacity = Math.Min(initialCapacity, DataConfig.MaxId);

                _data[keys] = new SortedSet <GroupBucket>(GroupBucketComparer.Default);
            }
        }
 public FirstNameContext(
     MainStorage storage)
 {
     _storage = storage.Names;
 }