Exemplo n.º 1
0
 public void BytesAsHexStringWith3NumbersAndSplitter()
 {
     Assert.AreEqual(
         StringsFunctions.BytesAsHexString(new byte[] { 1, 13, 255 }, ","),
         "01,0D,FF"
         );
 }
Exemplo n.º 2
0
        private void InitTrayIcon()
        {
            // Create Tray icon
            //AppData.notifyIcon = new TaskbarIcon();
            AppData.notifyIcon = (TaskbarIcon)FindResource("NotifyIcon");
            if (AppData.notifyIcon == null)
            {
                throw new ArgumentNullException("Resource: NotifyIcon");
            }

            AppData.notifyIcon.TrayRightMouseUp += AppData.MenuOpen;
            AppData.notifyIcon.ToolTipText       = StringsFunctions.ResourceString("resVersion");

            // Icons.
            AppData.imageSources[0] = ImageFunctions.GetIconFromResource("init");
            AppData.imageSources[1] = ImageFunctions.GetIconFromResource("enabled");
            AppData.imageSources[2] = ImageFunctions.GetIconFromResource("disabled");
            AppData.imageSources[3] = ImageFunctions.GetIconFromResource("notset");

            // Set INIT icon
            this.Dispatcher.Invoke(() =>
            {
                AppData.notifyIcon.IconSource = AppData.imageSources[0];
            });

            // Show Welcome Note
            AppData.notifyIcon.ShowBalloonTip(
                StringsFunctions.ResourceString("resWelcome"),
                StringsFunctions.ResourceString("resVersion"),
                BalloonIcon.Info
                );

            // AdHock
            new RegistryMonitorCore().LoadDataFromRegistry(false);
        }
Exemplo n.º 3
0
 public void BytesAsHexStringWith7NumbersAndSplitter()
 {
     Assert.AreEqual(
         StringsFunctions.BytesAsHexString(new byte[] { 0, 4, 1, 13, 255, 254, 88 }, "-"),
         "00-04-01-0D-FF-FE-58"
         );
 }
        /// <summary>
        ///     Run GpUpdate.EXE and wait in new Thread when process will be completed
        /// </summary>
        /// <param name="o"></param>
        private void CmdGPupdateProc(object o)
        {
            GPUpdate = new ProcessesFunctions().Run(AppConsts.CMD_GPUPDATE, AppConsts.CMD_GPUPDATE_PARAMS);

            if (GPUpdate != null)
            {
                new Task(() =>
                {
                    AppData.notifyIcon.CloseBalloon();
                    AppData.notifyIcon.ShowBalloonTip(StringsFunctions.ResourceString("resGPUPdateStart"), StringsFunctions.ResourceString("resVersion"), BalloonIcon.Info);
                }
                         ).Start();

                new Task(() =>
                {
                    GPUpdate.WaitForExit();
                    AppData.notifyIcon.CloseBalloon();
                    AppData.notifyIcon.ShowBalloonTip(StringsFunctions.ResourceString("resGPUPdateDone"), StringsFunctions.ResourceString("resVersion"), BalloonIcon.Info);
                    GPUpdate = null;
                }
                         ).Start();
            }
            else
            {
                new Task(() =>
                {
                    AppData.notifyIcon.CloseBalloon();
                    AppData.notifyIcon.ShowBalloonTip(StringsFunctions.ResourceString("resGPUPdateFail"), StringsFunctions.ResourceString("resVersion"), BalloonIcon.Error);
                }
                         ).Start();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Validate that
        ///     <para>Card number must contain only numbers</para>
        ///     <para>Card number already exist?</para>
        /// </summary>
        /// <param name="item">
        ///     Item с данными
        /// </param>
        /// <param name="exceptItem">
        ///     ExceptItem как правило тот набор данных, который мы изначально открыли для редактирования
        ///     <para>Если не указан, то скорее всего проверка перед добавлением новой записи</para>
        /// </param>
        /// <returns></returns>
        private bool IsCreditCardValid(ItemTypeExtended item, ItemTypeExtended existingItem = null)
        {
            // Card number must contain only numbers
            if (!StringsFunctions.StringContainOnlyDigits(item.CardNumber))
            {
                return(false);
            }

            // Card number already exist?
            if (existingItem == null)
            {
                if (items.Where(x => x.CardNumber == item.CardNumber).Count() > 0)
                {
                    return(false);
                }
            }
            else
            {
                if (items.Where(x => x.CardNumber == item.CardNumber && x != existingItem).Count() > 0)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 6
0
 public void BytesAsStringWith1NumberAndSplitter()
 {
     Assert.AreEqual(
         StringsFunctions.BytesAsString(new byte[] { 45 }, "@"),
         "45"
         );
 }
Exemplo n.º 7
0
 public void BytesAsStringWith1Numbers()
 {
     Assert.AreEqual(
         StringsFunctions.BytesAsString(new byte[] { 66 }),
         "66"
         );
 }
Exemplo n.º 8
0
 public void BytesAsStringWithEmptyString()
 {
     Assert.AreEqual(
         StringsFunctions.BytesAsString(new byte[] { }),
         ""
         );
 }
Exemplo n.º 9
0
 public void BytesAsStringWith9LargeNumbersAndSplitter()
 {
     Assert.AreEqual(
         StringsFunctions.BytesAsString(new byte[] { 255, 255, 255, 255, 255, 255, 255, 255, 255 }, "^^^"),
         "255^^^255^^^255^^^255^^^255^^^255^^^255^^^255^^^255"
         );
 }
Exemplo n.º 10
0
 public void BytesAsStringWith9LargeNumbers()
 {
     Assert.AreEqual(
         StringsFunctions.BytesAsString(new byte[] { 255, 255, 255, 255, 255, 255, 255, 255, 255 }),
         "255255255255255255255255255"
         );
 }
Exemplo n.º 11
0
 public void BytesAsStringWith8ZerosAndSplitter()
 {
     Assert.AreEqual(
         StringsFunctions.BytesAsString(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, "&"),
         "0&0&0&0&0&0&0&0"
         );
 }
Exemplo n.º 12
0
 public void BytesAsStringWith8Zeros()
 {
     Assert.AreEqual(
         StringsFunctions.BytesAsString(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }),
         "00000000"
         );
 }
Exemplo n.º 13
0
        private void DeleteItemCommandProc(Object selectedItems)
        {
            ItemType selectedItem = (ItemType)((ObservableCollection <object>)selectedItems).FirstOrDefault();

            if (selectedItem == null)
            {
                return;
            }

            bool result = true;

            WindowsUI.RunWindowDialog(() =>
            {
                if (MessageBox.Show(
                        String.Format(StringsFunctions.ResourceString("resDeleteConfirmation"), selectedItem.FirstName, selectedItem.Surname),
                        StringsFunctions.ResourceString("resConfirmationRequired"), MessageBoxButton.YesNo) != MessageBoxResult.Yes)
                {
                    result = false;
                }
            }
                                      );
            if (!result)
            {
                return;
            }

            TestItems.Remove((ItemTypeExtended)selectedItem);
        }
Exemplo n.º 14
0
 public void BytesAsHexStringWith7Numbers()
 {
     Assert.AreEqual(
         StringsFunctions.BytesAsHexString(new byte[] { 0, 4, 1, 13, 255, 254, 88 }),
         "0004010DFFFE58"
         );
 }
Exemplo n.º 15
0
 public void BytesAsHexStringWith1NumberAndSplitter()
 {
     Assert.AreEqual(
         StringsFunctions.BytesAsHexString(new byte[] { 66 }, ";"),
         "42"
         );
 }
Exemplo n.º 16
0
 public void BytesAsHexStringWith9LargeNumbersAndSplitter()
 {
     Assert.AreEqual(
         StringsFunctions.BytesAsHexString(new byte[] { 255, 255, 255, 255, 255, 255, 255, 255, 255 }, "&"),
         "FF&FF&FF&FF&FF&FF&FF&FF&FF"
         );
 }
Exemplo n.º 17
0
 public void BytesAsHexStringWithZero()
 {
     Assert.AreEqual(
         StringsFunctions.BytesAsHexString(new byte[] { 0 }),
         "00"
         );
 }
Exemplo n.º 18
0
        private void LoadSetProc(object o)
        {
            // Ask for a file name
            string fileName = "";

            WindowsUI.RunWindowDialog(() =>
            {
                OpenFileDialog openFileDialog   = new OpenFileDialog();
                openFileDialog.Filter           = StringsFunctions.ResourceString("resConfigFileType");
                openFileDialog.InitialDirectory = Environment.CurrentDirectory;
                if (openFileDialog.ShowDialog() == true)
                {
                    fileName = openFileDialog.FileName;
                }
            }
                                      );

            if (String.IsNullOrEmpty(fileName))
            {
                return;
            }

            // Load
            string jsonString = File.ReadAllText(fileName);

            Model.BaseModel = JsonConvert.DeserializeObject <MainWindowBaseModel>(jsonString);
        }
Exemplo n.º 19
0
 public void BytesAsStringWith7NumbersAndSplitter()
 {
     Assert.AreEqual(
         StringsFunctions.BytesAsString(new byte[] { 0, 4, 1, 13, 255, 254, 88 }, "~"),
         "0~4~1~13~255~254~88"
         );
 }
Exemplo n.º 20
0
        private void SaveSetProc(object o)
        {
            // Ask for a file name
            string fileName = "";

            WindowsUI.RunWindowDialog(() =>
            {
                SaveFileDialog saveFileDialog   = new SaveFileDialog();
                saveFileDialog.Filter           = StringsFunctions.ResourceString("resConfigFileType");
                saveFileDialog.InitialDirectory = Environment.CurrentDirectory;
                if (saveFileDialog.ShowDialog() == true)
                {
                    fileName = saveFileDialog.FileName;
                }
            }
                                      );

            if (String.IsNullOrEmpty(fileName))
            {
                return;
            }

            // Save
            string jsonStr = JsonConvert.SerializeObject(Model.BaseModel);

            File.WriteAllText(fileName, jsonStr);
        }
Exemplo n.º 21
0
 public void BytesAsStringWith3Numbers()
 {
     Assert.AreEqual(
         StringsFunctions.BytesAsString(new byte[] { 1, 13, 255 }),
         "113255"
         );
 }
Exemplo n.º 22
0
 public void BytesAsStringWith3NumbersAndSplitter()
 {
     Assert.AreEqual(
         StringsFunctions.BytesAsString(new byte[] { 1, 13, 255 }, "+"),
         "1+13+255"
         );
 }
Exemplo n.º 23
0
 public void BytesAsStringWith7Numbers()
 {
     Assert.AreEqual(
         StringsFunctions.BytesAsString(new byte[] { 0, 4, 1, 13, 255, 254, 88 }),
         "0411325525488"
         );
 }
Exemplo n.º 24
0
        private void LoginCommandProc(object o)
        {
            // PasswordBox is MVVM violation
            if (o == null || !(o is PasswordBox))
            {
                return;
            }

            // PasswordBox is MVVM violation
            bool result = UserFunctions.ValidateUsernameAndPassword(Model.Username, ((PasswordBox)o).SecurePassword);

            // OMG! MVVM Violation! If fact mostly we need it in case of failed validation
            ((PasswordBox)o).Clear();

            if (!result)
            {
                WindowsUI.RunWindowDialog(() =>
                {
                    MessageBox.Show(
                        StringsFunctions.ResourceString("resLoginFailed"),
                        StringsFunctions.ResourceString("resError"),
                        MessageBoxButton.OK, MessageBoxImage.Hand
                        );
                }
                                          );
                return;
            }

            CloseAsOkEvent();
        }
Exemplo n.º 25
0
        /// <summary>
        ///     Main function. Load all SRP rules from registry.
        /// </summary>
        public void ProceedSrp(ObservableCollection <AwlRuleType> rules)
        {
            const string CONST_PC = "PC";

            RegistryKey registryKey = Registry.LocalMachine;

            using (RegistryKey key = registryKey.OpenSubKey(AppConsts.KEY_SRP_NODE + AppConsts.SRP_OFF))
            {
                if (key != null)
                {
                    ProceedSrpValues(key, rules, StringsFunctions.ResourceString("resDisallowed"), CONST_PC);
                }
            }

            using (RegistryKey key = registryKey.OpenSubKey(AppConsts.KEY_SRP_NODE + AppConsts.SRP_ON))
            {
                if (key != null)
                {
                    ProceedSrpValues(key, rules, StringsFunctions.ResourceString("resUnrestricted"), CONST_PC);
                }
            }

            using (RegistryKey key = registryKey.OpenSubKey(AppConsts.KEY_SRP_NODE + AppConsts.SRP_BASIC))
            {
                if (key != null)
                {
                    ProceedSrpValues(key, rules, StringsFunctions.ResourceString("resBasic"), CONST_PC);
                }
            }

            //------

            //registryKey = Registry.CurrentUser;

            //using (RegistryKey key = registryKey.OpenSubKey(AppConsts.KEY_SRP_NODE + AppConsts.SRP_OFF))
            //{
            //    if (key != null)
            //    {
            //        ProceedSrpValues(key, rules, StringsFunctions.ResourceString("resDisallowed"), "User");
            //    }
            //}

            //using (RegistryKey key = registryKey.OpenSubKey(AppConsts.KEY_SRP_NODE + AppConsts.SRP_ON))
            //{
            //    if (key != null)
            //    {
            //        ProceedSrpValues(key, rules, StringsFunctions.ResourceString("resUnrestricted"), "User");
            //    }
            //}

            //using (RegistryKey key = registryKey.OpenSubKey(AppConsts.KEY_SRP_NODE + AppConsts.SRP_BASIC))
            //{
            //    if (key != null)
            //    {
            //        ProceedSrpValues(key, rules, "Basic", "User");
            //    }
            //}
        }
Exemplo n.º 26
0
        public void TestWithRegularString2()
        {
            byte[] result = StringsFunctions.StringToUtf8Bytes("Hack The Planet!!!");

            CollectionAssert.AreEqual(
                result,
                new byte[] { 72, 97, 99, 107, 32, 84, 104, 101, 32, 80, 108, 97, 110, 101, 116, 33, 33, 33 }
                );
        }
Exemplo n.º 27
0
        public void TestWithOneCharString()
        {
            byte[] result = StringsFunctions.StringToUtf8Bytes("0");

            CollectionAssert.AreEqual(
                result,
                new byte[] { 48 }
                );
        }
Exemplo n.º 28
0
        public void TestWithRegularString1()
        {
            byte[] result = StringsFunctions.StringToUtf8Bytes("Test1");

            CollectionAssert.AreEqual(
                result,
                new byte[] { 84, 101, 115, 116, 49 }
                );
        }
Exemplo n.º 29
0
        public void TestWithNullString()
        {
            byte[] result = StringsFunctions.StringToUtf8Bytes(null);

            CollectionAssert.AreEqual(
                result,
                null
                );
        }
Exemplo n.º 30
0
 private void AboutProc(object o)
 {
     WindowsUI.RunWindowDialog(() =>
     {
         MessageBox.Show(
             "SQL OVER EXCEL" + Environment.NewLine + "RIGA, LATVIA",
             StringsFunctions.ResourceString("resInfo"),
             MessageBoxButton.OK, MessageBoxImage.Information
             );
     }
                               );
 }