Beispiel #1
0
 /// <summary>
 /// Successes the specified message.
 /// </summary>
 /// <param name="message">The message.</param>
 public void Success(string message)
 {
     Application.Current.Dispatcher.Invoke(() =>
     {
         Growl.SuccessGlobal(message);
     });
 }
Beispiel #2
0
        /// <summary>
        /// Hàm khởi tạo kết nối
        /// </summary>
        /// <param name="ipaddress">Truyền vào địa chỉ IP</param>
        private void Connect(IPAddress ipaddress)
        {
            IP      = new IPEndPoint(ipaddress, 9999);
            sClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
            IPHost  = Dns.GetHostEntry(Dns.GetHostName());
            try
            {
                sClient.Connect(IP);
                Growl.SuccessGlobal("Ket Noi thanh cong");
                foreach (var item in IPHost.AddressList)
                {
                    if (item.AddressFamily == AddressFamily.InterNetwork)
                    {
                        sClient.Send(Serialize(item.ToString()));
                    }
                }

                sClient.Send(Serialize(IPHost.HostName.ToString() + " da ket noi"));
            }
            catch (Exception)
            {
                return;
            }
            Thread t = new Thread(Recieve);

            t.IsBackground = true;
            t.Start();
        }
        public void GenerateScript(GenerateScriptMode mode)
        {
            try
            {
                if (!string.IsNullOrEmpty(txtAppName.Text) && !string.IsNullOrEmpty(txtPublisher.Text) &&
                    !string.IsNullOrEmpty(txtId.Text) && !string.IsNullOrEmpty(txtVersion.Text) &&
                    !string.IsNullOrEmpty(txtLicense.Text) && !string.IsNullOrEmpty(txtUrl.Text) && txtUrl.Text.IsUrl())
                {
                    var builder = new YamlPackageModel
                    {
                        PackageIdentifier = txtId.Text,
                        PackageVersion    = txtVersion.Text,
                        PackageName       = txtAppName.Text,
                        Publisher         = txtPublisher.Text,
                        License           = txtLicense.Text,
                        LicenseUrl        = txtLicenseUrl.Text,
                        ShortDescription  = txtDescription.Text,
                        PackageUrl        = txtHomePage.Text,
                        ManifestType      = "singleton",
                        ManifestVersion   = "1.0.0",
                        PackageLocale     = "en-US",
                        Installers        = Installers.ToList()
                    };

                    var serializer = new SerializerBuilder().Build();
                    var yaml       = serializer.Serialize(builder);
                    switch (mode)
                    {
                    case GenerateScriptMode.CopyToClipboard:
                        Clipboard.SetText(yaml);
                        Growl.SuccessGlobal("Script Copied to clipboard.");
                        ClearInputs();
                        break;

                    case GenerateScriptMode.SaveToFile:
                        var dialog = new SaveFileDialog();
                        dialog.Title      = "Save Package";
                        dialog.FileName   = $"{txtId.Text}.yaml";
                        dialog.DefaultExt = "yaml";
                        dialog.Filter     = "Yaml File (*.yaml)|*.yaml";
                        if (dialog.ShowDialog() == true)
                        {
                            File.WriteAllText(dialog.FileName, yaml);
                            ClearInputs();
                        }

                        break;
                    }
                }
                else
                {
                    Growl.ErrorGlobal("Required fields must be filled");
                }
            }
            catch (Exception ex)
            {
                Growl.ErrorGlobal(ex.Message);
            }
        }
 private void StartScanning()
 {
     scannerThreadStart  = ScanningStart;
     scannerThreadStart += () => {
         popup.Dispatcher.Invoke(() => {
             popup.Close();
             Growl.SuccessGlobal("Done analyzing photos");
         });
     };
     scannerThread = new Thread(scannerThreadStart);
     scannerThread.Start();
 }
Beispiel #5
0
 private static void ShowNotificationInDesktop(string message, ENotificationType type)
 {
     Action action = type switch
     {
         ENotificationType.Success => () => Growl.SuccessGlobal(message),
         ENotificationType.Info => () => Growl.InfoGlobal(message),
         ENotificationType.Warning => () => Growl.WarningGlobal(message),
         ENotificationType.Error => () => Growl.ErrorGlobal(message),
         ENotificationType.Fatal => () => Growl.FatalGlobal(message),
         _ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
     };
     Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, action);
 }
Beispiel #6
0
        public async void Success(string msg)
        {
            await WaitForTokenLoaded();

            App.Current.Dispatcher.Invoke(() =>
            {
                if (Program.CliOptions.GlobalNotification)
                {
                    Growl.SuccessGlobal(ParseMsg(msg));
                }
                else
                {
                    Growl.Success(ParseMsg(msg), Token);
                }
            });
        }
Beispiel #7
0
        private void HitTest(Key key)
        {
            if (IsModifierKey(key))
            {
                return;
            }

            var modifierKeys = Keyboard.Modifiers;
            var keyStr       = modifierKeys != ModifierKeys.None ? $"{modifierKeys.ToString()} + {key.ToString()}" : key.ToString();

            Hot.Modifiers = Keyboard.Modifiers;
            Hot.Key       = key;
            (DataContext as MainViewModel).KeyText = keyStr;
            //(DataContext as MainViewModel).ModifierKeys = modifierKeys;
            //(DataContext as MainViewModel).Key = key;
            var keybinds = GlobalShortcut.GetKeyBindings(this).ToList();

            GlobalShortcut.Init(keybinds);
            GlobalData.Config.TransConfig.HotKey = (DataContext as MainViewModel).KeyText;
            GlobalData.Save();
            Growl.SuccessGlobal($"HotKey is {keyStr}");
        }