Esempio n. 1
0
        public async void Search(string SearchStr)
        {
            ShowCoverFlow = Visibility.Hidden;
            if (SearchStr.IsBlank())
            {
                Growl.Error("Search string is empty!", "SearchMsg");
                return;
            }

            //Search
            ShowWait();
            object SearchObj = await Task.Run(() => { return(TidalTool.tryGet(SearchStr, out SearchType)); });

            if (SearchType == eObjectType.None)
            {
                Growl.Error("Search Err!", "SearchMsg");
            }
            else if (SearchType == Tidal.eObjectType.SEARCH)
            {
                SearchResult   = ((Tidal.SearchResult)SearchObj);
                ShowDetailView = Visibility.Hidden;
            }
            else
            {
                LoadDetail(SearchObj);
                ShowDetailView = Visibility.Visible;
            }
            ShowWait(false);
        }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         UpdateHelper.GithubReleaseModel ver = UpdateHelper.CheckForUpdateGithubRelease("ghost1372", "SubtitleDownloader");
         lblCreatedAt.Text               = ver.CreatedAt.ToString();
         lblPublishedAt.Text             = ver.PublishedAt.ToString();
         lblDownloadUrl.CommandParameter = lblDownloadUrl.Content = ver.Asset[0].browser_download_url;
         lblCurrentVersion.Text          = Assembly.GetExecutingAssembly().GetName().Version.ToString();
         lblVersion.Text   = ver.TagName.Replace("v", "");
         txtChangelog.Text = ver.Changelog;
         if (ver.IsExistNewVersion)
         {
             Growl.InfoGlobal(Properties.Langs.Lang.NewVersion);
         }
         else
         {
             Growl.ErrorGlobal(Properties.Langs.Lang.LatestVersion);
         }
     }
     catch (System.Exception)
     {
         Growl.ErrorGlobal(Properties.Langs.Lang.ReleaseNotFound);
     }
 }
Esempio n. 3
0
 protected void OnForwardedNotificationCallback(Growl.Connector.Response response, Growl.Connector.CallbackData callbackData)
 {
     if (this.ForwardedNotificationCallback != null)
     {
         this.ForwardedNotificationCallback(response, callbackData);
     }
 }
Esempio n. 4
0
        private void DictArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (_dict != null)
            {
                if (e.ClickCount == 2)
                {
                    //双击事件
                    TextBlock textBlock = sender as TextBlock;

                    string ret = _dict.SearchInDict(textBlock.Text);
                    if (ret != null)
                    {
                        if (ret == string.Empty)
                        {
                            Growl.ErrorGlobal(Application.Current.Resources["TranslateWin_DictError_Hint"] + _dict.GetLastError());
                        }
                        else
                        {
                            dtimer.Stop();
                            DictResWindow _dictResWindow = new DictResWindow(textBlock.Text, (string)textBlock.Tag, _textSpeechHelper);
                            _dictResWindow.ShowDialog();
                            dtimer.Start();
                        }
                    }
                    else
                    {
                        Growl.ErrorGlobal(Application.Current.Resources["TranslateWin_DictError_Hint"] + _dict.GetLastError());
                    }
                }
            }
        }
        public void CheckAuthThreadFunc(object[] datas)
        {
            NetHelper.OpenWeb("https://" + DeviceCode.VerificationUri);

            //Proxy
            HttpHelper.ProxyInfo PROXY = Settings.ProxyEnable ? new HttpHelper.ProxyInfo(Settings.ProxyHost, Settings.ProxyPort, Settings.ProxyUser, Settings.ProxyPwd) : null;

            (string msg, LoginKey key) = Client.CheckAuthStatus(DeviceCode, PROXY).Result;
            if (msg.IsNotBlank())
            {
                Growl.Error(msg, Global.TOKEN_LOGIN);
                goto RETURN_POINT;
            }

            Settings.Userid       = key.UserID;
            Settings.Countrycode  = key.CountryCode;
            Settings.Accesstoken  = key.AccessToken;
            Settings.Refreshtoken = key.RefreshToken;
            Settings.Save();
            Global.AccessKey = key;
            Global.CommonKey = key;
            Global.VideoKey  = key;

            this.View.Dispatcher.Invoke(new Action(() => {
                Manager.ShowWindow(VMMain);
                RequestClose();
            }));

RETURN_POINT:
            BtnLoginEnable = true;
        }
Esempio n. 6
0
        /// <summary>
        /// 键盘鼠标钩子初始化
        /// </summary>
        private void MouseKeyboardHook_Init()
        {
            if (Common.UsingHotKey.IsMouse)
            {
                //初始化钩子对象
                if (hook == null)
                {
                    hook = new GlobalHook();
                    hook.OnMouseActivity += Hook_OnMouseActivity;
                }
            }
            else
            {
                //初始化钩子对象
                if (hook == null)
                {
                    hook          = new GlobalHook();
                    hook.KeyDown += Hook_OnKeyBoardActivity;
                }
            }

            bool r = hook.Start();

            if (!r)
            {
                Growl.ErrorGlobal(Application.Current.Resources["Hook_Error_Hint"].ToString());
            }
        }
Esempio n. 7
0
 // this class cannot be created from VB
 public CallbackData(Growl.Connector.CallbackData callbackData)
 {
     this.notificationID = callbackData.NotificationID;
     this.data = callbackData.Data;
     this.type = callbackData.Type;
     this.result = callbackData.Result.ToString();
 }
Esempio n. 8
0
        private void btnAddInstaller_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(txtUrl.Text) || !string.IsNullOrEmpty(txtHash.Text))
            {
                var arch = (cmbArchitecture.SelectedItem as ComboBoxItem).Content.ToString();
                var item = new Installer
                {
                    Architecture    = arch,
                    InstallerUrl    = txtUrl.Text,
                    InstallerSha256 = txtHash.Text
                };

                if (!Installers.Contains(item, new GenericCompare <Installer>(x => x.Architecture)))
                {
                    Installers.Add(item);
                }
                else
                {
                    Growl.ErrorGlobal($"{arch} Architecture already exist.");
                }
            }
            else
            {
                Growl.ErrorGlobal("Installer Url and Installer Sha256 must be filled");
            }
        }
Esempio n. 9
0
 private async void btnGetHashWeb_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (!string.IsNullOrEmpty(txtUrl.Text) && txtUrl.Text.IsUrl())
         {
             prgStatus.IsIndeterminate = false;
             btnGetHashWeb.IsEnabled   = false;
             btnGetHashLocal.IsEnabled = false;
             txtHash.IsEnabled         = false;
             try
             {
                 var downloader = new DownloadService();
                 downloader.DownloadProgressChanged += OnDownloadProgressChanged;
                 downloader.DownloadFileCompleted   += OnDownloadFileCompleted;
                 await downloader.DownloadFileTaskAsync(txtUrl.Text, new DirectoryInfo(Consts.TempSetupPath));
             }
             catch (Exception ex)
             {
                 prgStatus.IsIndeterminate = true;
                 prgStatus.ShowError       = true;
                 Growl.ErrorGlobal(ex.Message);
             }
         }
         else
         {
             Growl.ErrorGlobal("Url field is Empty or Invalid");
         }
     }
     catch (Exception ex)
     {
         Growl.ErrorGlobal(ex.Message);
     }
 }
 protected override void InternalOnNotificationCallback(Growl.CoreLibrary.NotificationCallbackEventArgs args)
 {
     if (this.NotificationCallback != null)
     {
         this.NotificationCallback(args);
     }
 }
Esempio n. 11
0
        private async void CheckUpdate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                btnCheck.IsEnabled = false;
                var ver = await UpdateHelper.CheckUpdateAsync("HandyOrg", "HandyWinGet");

                if (ver.IsExistNewVersion)
                {
                    Growl.AskGlobal("we found a new Version, do you want to download?", b =>
                    {
                        if (!b)
                        {
                            return(true);
                        }
                        StartProcess(ver.Assets[0].Url);
                        return(true);
                    });
                }
                else
                {
                    Growl.InfoGlobal("you are using Latest Version.");
                }

                btnCheck.IsEnabled = true;
            }
            catch (Exception ex)
            {
                Growl.ErrorGlobal(ex.Message);
            }
        }
Esempio n. 12
0
        private void CompareVersions()
        {
            if (IsVersionLater(newVersion, getAppVersion))
            {
                Growl.Info(new GrowlInfo
                {
                    Message           = $"A new version {newVersion} has been detected!Do you want to update?",
                    ShowDateTime      = false,
                    ActionBeforeClose = isConfirm =>
                    {
                        if (isConfirm)
                        {
                            Process.Start(url);
                        }

                        return(true);
                    },
                    CancelStr  = "Cancel",
                    ConfirmStr = "Confirm"
                });
                Growl.Info(ChangeLog);
            }
            else
            {
                Growl.Error($"You are using latest version {getAppVersion}");
            }
        }
Esempio n. 13
0
        private void ButtonLangs_OnClick(object sender, RoutedEventArgs e)
        {
            if (e.OriginalSource is Button button && button.Tag is string tag)
            {
                PopupConfig.IsOpen = false;
                if (tag.Equals(GlobalData.Config.Lang))
                {
                    return;
                }

                Growl.Ask(new GrowlInfo
                {
                    Message           = Properties.Langs.Lang.ChangeLangAsk,
                    ShowDateTime      = false,
                    CancelStr         = Properties.Langs.Lang.Cancel,
                    ConfirmStr        = Properties.Langs.Lang.Confirm,
                    ActionBeforeClose = isConfirm =>
                    {
                        if (isConfirm)
                        {
                            GlobalData.Config.Lang = tag;
                            GlobalData.Save();
                            System.Diagnostics.Process.Start(Assembly.GetExecutingAssembly().Location);
                            Environment.Exit(0);
                        }

                        return(true);
                    }
                });
            }
        }
Esempio n. 14
0
        protected override void OnInitialized(EventArgs e) //此为窗口已加载
        {
            base.OnInitialized(e);
            Instance = this;
            //默认设定为日间模式
            ResourceDictionary theme = new ResourceDictionary
            {
                Source = new Uri("pack://application:,,,/Resource/Style/Theme/BaseLight.xaml")
            };

            Resources.MergedDictionaries.Add(theme);

            //判断之前设定的路径是否存在
            string location = Properties.Settings.Default.FileLocation;

            if (location != null && location != string.Empty && !Directory.Exists(location))
            {
                Growl.Warning("所指定的文件夹位置已不存在, 请重新指定.");
                Properties.Settings.Default.FileLocation = null;
            }
            else
            {
                RefreshFiles(null, null);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// 键盘鼠标钩子初始化
        /// </summary>
        private void MouseKeyboardHook_Init()
        {
            if (hook == null)
            {
                hook = new KeyboardMouseHook();
                bool r = false;

                if (Common.UsingHotKey.IsMouse)
                {
                    hook.OnMouseActivity += Hook_OnMouseActivity;
                    if (Common.UsingHotKey.MouseButton == System.Windows.Forms.MouseButtons.Left)
                    {
                        r = hook.Start(true, 1);
                    }
                    else if (Common.UsingHotKey.MouseButton == System.Windows.Forms.MouseButtons.Right)
                    {
                        r = hook.Start(true, 2);
                    }
                }
                else
                {
                    hook.onKeyboardActivity += Hook_OnKeyBoardActivity;
                    int keycode = (int)Common.UsingHotKey.KeyCode;
                    r = hook.Start(false, keycode);
                }

                if (!r)
                {
                    Growl.ErrorGlobal(Application.Current.Resources["Hook_Error_Hint"].ToString());
                }
            }
        }
Esempio n. 16
0
 private void PinBox_OnCompleted(object sender, RoutedEventArgs e)
 {
     if (e.OriginalSource is PinBox pinBox)
     {
         Growl.Info(pinBox.Password);
     }
 }
        public async void Search(string SearchStr)
        {
            if (SearchStr.IsBlank())
            {
                Growl.Error("Search string is empty!", Global.TOKEN_MAIN);
                return;
            }

            ShowWait = true;

            (string msg, eType type, object data) = await Client.Get(Global.CommonKey, SearchStr, eType.NONE, Global.Settings.SearchNum, Global.Settings.IncludeEP, false);

            if (msg.IsNotBlank() || data == null)
            {
                Growl.Error("Search Err!" + msg, Global.TOKEN_MAIN);
            }
            else if (type == eType.SEARCH)
            {
                SearchResult = (SearchResult)data;
                ShowDetail   = false;
                ShowList     = true;
            }
            else
            {
                Detail     = Detail.Creat(data, type);
                ShowDetail = true;
                ShowList   = false;
            }

            ShowWait = false;
        }
Esempio n. 18
0
 /// <summary>
 /// Errors the specified message.
 /// </summary>
 /// <param name="message">The message.</param>
 public void Error(string message)
 {
     Application.Current.Dispatcher.Invoke(() =>
     {
         Growl.ErrorGlobal(message);
     });
 }
Esempio n. 19
0
        private void btnSend_Click(object sender, RoutedEventArgs e)
        {
            List <Client> SelectedClientList = ListClients.SelectedItems.Cast <Client>().ToList();

            if (!String.IsNullOrWhiteSpace(MesssageSend.Text) && ListClients.SelectedItem != null)
            {
                int    i        = 0;
                String clientip = String.Empty;
                foreach (Socket item in listclient)
                {
                    clientip = item.RemoteEndPoint.ToString().Substring(0, item.RemoteEndPoint.ToString().IndexOf(':'));
                    if (SelectedClientList.Count > 1)
                    {
                        if (SelectedClientList[i].Ip.Equals(clientip))
                        {
                            Send(item, MesssageSend.Text);
                        }
                        i++;
                    }
                    else if (SelectedClientList.Count <= 1)
                    {
                        if (SelectedClientList[0].Ip.Equals(clientip))
                        {
                            Send(item, MesssageSend.Text);
                        }
                    }
                }
            }
            else
            {
                Growl.WarningGlobal("chưa nhập tin nhắn hoặc chưa chọn người cần gửi");
            }
        }
Esempio n. 20
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            var username = Username.Text;

            _sr.InteractiveTask(() =>
            {
                int ret;

                _sr.Procedure = null;
                var local     = new LoginProcedure();

                try
                {
                    ret = local.Step1(username, Helper.GetTrace());
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    _sr.Procedure = local;
                    SubwindowNavigator.Navigate(SubwindowPage.Login2);
                }
            });
        }
        private void ButtonLangs_OnClick(object sender, RoutedEventArgs e)
        {
            if (e.OriginalSource is Button button && button.Tag is string tag)
            {
                PopupConfig.IsOpen = false;
                if (tag.Equals(GlobalDataHelper <AppConfig> .Config.Lang))
                {
                    return;
                }

                Growl.Ask(Lang.ResourceManager.GetString("ChangeLanguage"), b =>
                {
                    if (!b)
                    {
                        return(true);
                    }

                    GlobalDataHelper <AppConfig> .Config.Lang = tag;
                    GlobalDataHelper <AppConfig> .Save();
                    LocalizationManager.Instance.CurrentCulture = new System.Globalization.CultureInfo(tag);
                    ConfigHelper.Instance.SetLang(GlobalDataHelper <AppConfig> .Config.Lang);
                    return(true);
                });
            }
        }
Esempio n. 22
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();
        }
Esempio n. 23
0
        private void showGrowlNotification(bool isSuccess, params string[] param)
        {
            if (isSuccess)
            {
                Growl.Info(new GrowlInfo
                {
                    Message           = string.Format(Properties.Langs.Lang.NewVersionFind, param[0]) + Environment.NewLine + ChangeLog,
                    CancelStr         = Properties.Langs.Lang.Cancel,
                    ConfirmStr        = Properties.Langs.Lang.Download,
                    ShowDateTime      = false,
                    ActionBeforeClose = isConfirm =>
                    {
                        if (isConfirm)
                        {
                            System.Diagnostics.Process.Start(param[1]);
                        }

                        return(true);
                    }
                });
            }
            else
            {
                Growl.Error(new GrowlInfo {
                    Message = string.Format(Properties.Langs.Lang.CurrentIsLastVersion, Assembly.GetExecutingAssembly().GetName().Version.ToString()), ShowDateTime = false
                });
            }
        }
 public SubscribedForwardDestination(Growl.Daemon.Subscriber subscriber, int ttl)
     : this(subscriber.Name, true, subscriber.IPAddress, subscriber.Port, subscriber.Key.Password, KnownDestinationPlatformType.FromString(subscriber.PlatformName), ttl)
 {
     base.Key = subscriber.ID;
     this.hashAlgorithm = subscriber.Key.HashAlgorithm;
     this.encryptionAlgorithm = subscriber.Key.EncryptionAlgorithm;
 }
Esempio n. 25
0
        public string OpizoShorten(string longUrl)
        {
            string link = string.Empty;

            using (WebClient wb = new WebClient())
            {
                wb.Headers.Add("X-API-KEY", OpizoApiKey);
                NameValueCollection data = new NameValueCollection
                {
                    ["url"] = longUrl
                };
                byte[] response         = wb.UploadValues("https://opizo.com/api/v1/shrink/", "POST", data);
                string responseInString = Encoding.UTF8.GetString(response);

                OpizoRootObject root = JsonConvert.DeserializeObject <OpizoRootObject>(responseInString);

                if (root.status.Equals("success"))
                {
                    link = root.data.url;
                }
                else
                {
                    Growl.Error("something is wrong try again");
                }
            }

            return(link);
        }
Esempio n. 26
0
        public string YonShorten(string longUrl, string customURL = "")
        {
            string link = string.Empty;

            using (WebClient wb = new WebClient())
            {
                NameValueCollection data = new NameValueCollection
                {
                    ["url"]  = longUrl,
                    ["wish"] = customURL
                };

                byte[] response         = wb.UploadValues("http://api.yon.ir", "POST", data);
                string responseInString = Encoding.UTF8.GetString(response);
                Yon    result           = JsonConvert.DeserializeObject <Yon>(responseInString);
                if (result.status)
                {
                    link = "http://yon.ir/" + result.output;
                }
                else
                {
                    Growl.Error("that custom URL is already taken");
                }
            }

            return(link);
        }
Esempio n. 27
0
        public async Task <string> Do0Shorten(string longUrl)
        {
            string link = string.Empty;

            Dictionary <string, string> values = new Dictionary <string, string>
            {
                { "link", longUrl }
            };

            FormUrlEncodedContent content = new FormUrlEncodedContent(values);

            HttpResponseMessage response = await client.PostAsync("https://do0.ir/post/SJAj4Ik6Q9Rd/2.5", content);

            string responseString = await response.Content.ReadAsStringAsync();

            Do0Data root = JsonConvert.DeserializeObject <Do0Data>(responseString);

            if (root.success)
            {
                link = "https://do0.ir/" + root.@short;
            }
            else
            {
                Growl.Error(root.error);
            }

            return(link);
        }
        public async void Confim()
        {
            if (AccessToken.IsNotBlank())
            {
                (string msg, LoginKey key) = await Client.Login(AccessToken);

                if (msg.IsNotBlank() || key == null)
                {
                    Growl.Warning("Accesstoken is not valid! " + msg, Global.TOKEN_MAIN);
                }
                else if (key.UserID != Global.CommonKey.UserID)
                {
                    Growl.Warning("User mismatch! Please use your own accesstoken.", Global.TOKEN_MAIN);
                }
                else
                {
                    UserSettings user = UserSettings.Read();
                    user.Accesstoken = AccessToken;
                    user.Save();
                    Global.AccessKey = key;
                }
            }

            Settings.Change(Settings, Global.Settings);

            Global.Settings = Settings;
            Global.Settings.Save();

            Load();
            Growl.Success("Refresh settings success!", Global.TOKEN_MAIN);
        }
 public MainWindowViewModel()
 {
     Directory.CreateDirectory(".\\UserData");
     if (File.Exists("UserData\\Config.json"))
     {
         LoadConfig();
         ViewContent = new GachaAnalysisView(SelectedUserData);
     }
     else
     {
         UserDataList = new List <UserData>();
         ViewContent  = new WelcomeView();
     }
     if (File.Exists("UserData\\Account"))
     {
         try
         {
             CloudClient = CloudClient.GetClientFromEncryption();
         }
         catch (Exception e)
         {
             Growl.Error(e.Message);
         }
     }
     if (File.Exists("Resource\\ShowUpdateLog"))
     {
         ViewContent = new UpdateLogView();
         File.Delete("Resource\\ShowUpdateLog");
     }
 }
        public async void Login()
        {
            BtnLoginEnable = false;

            //Proxy
            HttpHelper.ProxyInfo PROXY = Settings.ProxyEnable ? new HttpHelper.ProxyInfo(Settings.ProxyHost, Settings.ProxyPort, Settings.ProxyUser, Settings.ProxyPwd) : null;

            if (DeviceCode == null)
            {
                //get device code
                (string msg1, TidalDeviceCode code) = await Client.GetDeviceCode(PROXY);

                if (msg1.IsNotBlank())
                {
                    Growl.Error("Get device code failed!", Global.TOKEN_LOGIN);
                    BtnLoginEnable = true;
                    return;
                }
                else
                {
                    DeviceCode = code;
                }
            }

            ThreadHelper.Start(CheckAuthThreadFunc);
            return;
        }
Esempio n. 31
0
        private async void Button_ImportExcel_Click(object sender, RoutedEventArgs e)
        {
            var result = await Dialog.Show(new ExcelImportDialog()).GetResultAsync <(bool, UserData, List <WishData>)>();

            if (result.Item1)
            {
                try
                {
                    var str = JsonSerializer.Serialize(result.Item3, Const.JsonOptions);
                    File.WriteAllText(result.Item2.WishLogFile, str);
                    result.Item2.LastUpdateTime = DateTime.Now;
                    Growl.Success("导入数据成功");
                }
                catch (Exception ex)
                {
                    Growl.Error(ex.Message);
                }
            }
            else
            {
                if (result.Item2 != null)
                {
                    Growl.Error("导入数据失败");
                }
            }
        }
Esempio n. 32
0
        public SettingsForm()
        {
            this._Version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            if (this.Config.CheckForUpdates)
            {
                System.Threading.ThreadPool.QueueUserWorkItem(this.CheckForUpdates);
            }

            InitializeComponent();

            this.utorrent = new WebUIAPI(this.Config);
            this.utorrent.TorrentAdded += new WebUIAPI.TorrentAddedEventHandler(utorrent_TorrentAdded);
            this.utorrent.DownloadComplete += new WebUIAPI.DownloadFinishedEventHandler(utorrent_DownloadComplete);
            this.utorrent.LoginError += new WebUIAPI.LoginErrorEventHandler(utorrent_LoginError);
            this.utorrent.Start();

            this.prowl = new Prowl(this.Config.Prowl);
            this.growl = new Growl(this.Config.Growl);
            this.twitter = new Twitter(this.Config.Twitter);
            this.boxcar = new Boxcar(this.Config.Boxcar);

            if (this.Config.Prowl.Enable)
            {
                this.prowl.ProwlError += new Prowl.ProwlErrorHandler(prowl_ProwlError);
            }

            this.btnBoxcarInvite.Enabled = this.Config.Boxcar.Enable;
        }
Esempio n. 33
0
        public override async Task Execute()
        {
            var linkId = Storage.GetLinkIdByGid(_gid);

            if (!string.IsNullOrEmpty(_path))
            {
                await Growl.Notify($"Download complete!\n{_path}");
            }

            if (string.IsNullOrEmpty(linkId))
            {
                await RemoveDownloadResult(_gid);

                return;
            }

            if (!await Hltv.SetState(linkId, LinkState.Finished))
            {
                LoggerManager.Error("Error from server for setting link {0} to finished", linkId);
                await ShutdownAriaIfNoLinksLeft();

                return;
            }

            Storage.RemoveLinkId(_gid);
            await RemoveDownloadResult(_gid);
        }
Esempio n. 34
0
        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            _sr.InteractiveTask(() =>
            {
                int ret;

                _sr.Procedure = null;
                var local     = new LogoutProcedure();

                try
                {
                    ret = local.Step1();
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    ApiVendor.SetRenew(null);
                    SubwindowNavigator.Navigate(SubwindowPage.LoggedOut);
                }
            });
            _sr.InteractiveTask(() => SubwindowNavigator.Navigate(SubwindowPage.LoggedOut));
        }
Esempio n. 35
0
        private void ButtonLangs_OnClick(object sender, RoutedEventArgs e)
        {
            if (e.OriginalSource is Button button && button.Tag is string tag)
            {
                PopupConfig.IsOpen = false;
                if (tag.Equals(GlobalData.Config.Lang))
                {
                    return;
                }

                Growl.Ask(Lang.ResourceManager.GetString("ChangeLanguage"), b =>
                {
                    if (!b)
                    {
                        return(true);
                    }

                    GlobalData.Config.Lang = tag;
                    GlobalData.Save();
                    TranslationSource.Instance.Language = tag;
                    ((MainWindowViewModel)(DataContext)).SetFlowDirection();
                    return(true);
                });
            }
        }
Esempio n. 36
0
 /// <summary>
 /// Fires the <see cref="NotificationClicked"/> event
 /// </summary>
 /// <param name="args"><see cref="Growl.CoreLibrary.NotificationCallbackEventArgs"/> containing information about the event</param>
 void win_NotificationClicked(Growl.CoreLibrary.NotificationCallbackEventArgs args)
 {
     if (this.NotificationClicked != null)
     {
         this.NotificationClicked(args);
     }
 }
Esempio n. 37
0
        void growl_NotificationCallback(Growl.Connector.Response response, Growl.Connector.CallbackData callbackData, object state)
        {
            if (callbackData != null)
            {
                if (callbackData.Result == Growl.CoreLibrary.CallbackResult.CLICK)
                {
                    if (response.CustomTextAttributes.ContainsKey("Rating"))
                    {
                        string r = response.CustomTextAttributes["Rating"];
                        int rating = Convert.ToInt32(r);

                        string[] parts = callbackData.Data.Split('|');
                        int sourceID = Convert.ToInt32(parts[0]);
                        int playlistID = Convert.ToInt32(parts[1]);
                        int trackID = Convert.ToInt32(parts[2]);
                        int databaseID = Convert.ToInt32(parts[3]);

                        IITTrack song = (IITTrack) this.GetITObjectByID(sourceID, playlistID, trackID, databaseID);
                        if (song != null)
                        {
                            song.Rating = rating;
                        }
                    }
                }
            }
        }
 public ProwlForwardDestination(string name, bool enabled, string apiKey, Growl.Connector.Priority? minimumPriority, bool onlyWhenIdle)
     : base(name, enabled)
 {
     this.apiKey = apiKey;
     this.minimumPriority = minimumPriority;
     this.onlyWhenIdle = onlyWhenIdle;
     this.Platform = KnownDestinationPlatformType.IPhone;
 }
 public EmailForwardDestination(string name, bool enabled, string to, SMTPConfiguration smtpConfig, Growl.Connector.Priority? minimumPriority, bool onlyWhenIdle)
     : base(name, enabled)
 {
     this.to = to;
     this.smtpConfig = (smtpConfig != null ? smtpConfig : SMTPConfiguration.Local);
     this.minimumPriority = minimumPriority;
     this.onlyWhenIdle = onlyWhenIdle;
     this.Platform = KnownDestinationPlatformType.Email;
 }
Esempio n. 40
0
 public ClassRegistry()
 {
     this._config      = new Config();
     this._webuiapi    = new WebUIAPI(this._config);
     this._prowl       = new Prowl(this._config.Prowl);
     this._growl       = new Growl(this._config.Growl);
     this._twitter     = new Twitter(this._config.Twitter);
     this._boxcar      = new Boxcar(this._config.Boxcar);
 }
 public ToastyForwardDestination(string name, bool enabled, string deviceID, Growl.Connector.Priority? minimumPriority, bool onlyWhenIdle, bool enableQuietHours, DateTime quietHoursStart, DateTime quietHoursEnd, QuietHoursDayChoice quietHoursDaysChoice)
     : base(name, enabled)
 {
     this.deviceID = deviceID;
     this.minimumPriority = minimumPriority;
     this.onlyWhenIdle = onlyWhenIdle;
     this.enableQuietHours = enableQuietHours;
     this.quietHoursStart = quietHoursStart;
     this.quietHoursEnd = quietHoursEnd;
     this.quietHoursDaysChoice = quietHoursDaysChoice;
 }
Esempio n. 42
0
        protected override bool OnBeforeSend(Growl.Connector.MessageBuilder mb)
        {
            //from <hostname> by <hostname> [with Growl] [id <identifier>]; <ISO 8601 date>

            foreach (Header header in this.RequestInfo.PreviousReceivedHeaders)
            {
                mb.AddHeader(header);
            }

            string received = String.Format("from {0} by {1}{2}{3}; {4}", this.RequestInfo.ReceivedFrom, this.RequestInfo.ReceivedBy, (this.RequestInfo.ReceivedWith != null ? String.Format(" with {0}", this.RequestInfo.ReceivedWith) : String.Empty), (this.RequestInfo.RequestID != null ? String.Format(" id {0}", this.RequestInfo.RequestID) : String.Empty), this.RequestInfo.TimeReceived.ToString("u"));
            Header receivedHeader = new Header("Received", received);
            mb.AddHeader(receivedHeader);

            return base.OnBeforeSend(mb);
        }
Esempio n. 43
0
 public static string getPathToIcon(Growl.Connector.Notification notification)
 {
     string returnValue = "";
     if (notification.Icon.IsSet)
     {
         if (notification.Icon.IsUrl)
         {
             returnValue = notification.Icon.Url;
         }
         else
         {
             returnValue = Path.GetTempFileName();
             System.Drawing.Image Icon = notification.Icon;
             Icon.Save(returnValue);
         }
     }
     return returnValue;
 }
Esempio n. 44
0
 public static string getPathToIcon(Growl.Connector.Application app)
 {
     string returnValue = "";
     if (app.Icon != null)
     {
         if (app.Icon.IsSet)
         {
             if (app.Icon.IsUrl)
             {
                 returnValue = app.Icon.Url;
             }
             else
             {
                 returnValue = Path.GetTempFileName();
                 System.Drawing.Image Icon = app.Icon;
                 Icon.Save(returnValue);
             }
         }
     }
     return returnValue;
 }
        public override void ForwardRegistration(Growl.Connector.Application application, List<Growl.Connector.NotificationType> notificationTypes, Growl.Connector.RequestInfo requestInfo, bool isIdle)
        {
            // IGNORE REGISTRATION NOTIFICATIONS (since we have no way of filtering out already-registered apps at this point)
            //Send(application.Name, Properties.Resources.SystemNotification_AppRegistered_Title, String.Format(Properties.Resources.SystemNotification_AppRegistered_Text, application.Name));

            requestInfo.SaveHandlingInfo("Forwarding to Toasty cancelled - Application Registrations are not forwarded.");
        }
        public override void ForwardNotification(Growl.Connector.Notification notification, Growl.Connector.CallbackContext callbackContext, Growl.Connector.RequestInfo requestInfo, bool isIdle, ForwardedNotificationCallbackHandler callbackFunction)
        {
            bool send = true;

            if (requestInfo == null) requestInfo = new Growl.Connector.RequestInfo();

            // if this notification originated from Toasty in the first place, dont re-forward it
            if (((notification.ApplicationName == "Toasty") && notification.CustomTextAttributes.ContainsKey("ToastyDeviceID")) && notification.CustomTextAttributes["ToastyDeviceID"].Equals(this.DeviceID, StringComparison.InvariantCultureIgnoreCase))
            {
                requestInfo.HandlingInfo.Add(String.Format("Aborted forwarding due to circular notification (deviceID:{0})", this.DeviceID));
                send = false;
            }

            // if a minimum priority is set, check that
            if (send && this.MinimumPriority != null && this.MinimumPriority.HasValue && notification.Priority < this.MinimumPriority.Value)
            {
                requestInfo.SaveHandlingInfo(String.Format("Forwarding to Toasty ({0}) cancelled - Notification priority must be at least '{1}' (was actually '{2}').", this.Description, this.MinimumPriority.Value.ToString(), notification.Priority.ToString()));
                send = false;
            }

            // if only sending when idle, check that
            if (send && this.OnlyWhenIdle && !isIdle)
            {
                requestInfo.SaveHandlingInfo(String.Format("Forwarding to Toasty ({0}) cancelled - Currently only configured to forward when idle", this.Description));
                send = false;
            }

            // if quiet hours enabled, check that
            if (send && DuringQuietHours())
            {
                requestInfo.SaveHandlingInfo(String.Format("Forwarding to Toasty ({0}) cancelled - Quiet hours enabled on {1} from {2} to {3}. Current time: {4} {5}", this.Description, this.QuietHoursDaysChoice, this.QuietHoursStart.ToShortTimeString(), this.QuietHoursEnd.ToShortTimeString(), DateTime.Now.DayOfWeek, DateTime.Now.ToShortTimeString()));
                send = false;
            }

            if (send)
            {
                requestInfo.SaveHandlingInfo(String.Format("Forwarded to Toasty '{0}' - Minimum Priority:'{1}', Actual Priority:'{2}'", this.Description, (this.MinimumPriority != null && this.MinimumPriority.HasValue ? this.MinimumPriority.Value.ToString() : "<any>"), notification.Priority.ToString()));

                string url = BuildUrl(NOTIFY_URL_FORMAT, this.DeviceID);

                System.Collections.Specialized.NameValueCollection data = new System.Collections.Specialized.NameValueCollection();
                data.Add("target", this.DeviceID);
                data.Add("sender", notification.ApplicationName);
                data.Add("title", notification.Title);
                data.Add("text", notification.Text);

                byte[] bytes = null;
                if (notification.Icon != null && notification.Icon.IsSet)
                {
                    System.Drawing.Image image = (System.Drawing.Image)notification.Icon;
                    using (image)
                    {
                        bytes = GenerateThumbnail(image, 128, 128);
                    }
                }

                APIRequestInfo info = new APIRequestInfo();
                info.RequestInfo = requestInfo;
                info.Url = url;
                info.Data = data;
                info.ImageBytes = bytes;

                System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(SendAsync), info);
            }
        }
 public void SetPasswordManager(Growl.Connector.PasswordManager passwordManager)
 {
     this.pm = passwordManager;
     RefreshItems();
 }
 /// <summary>
 /// Registers the specified application with GfW.
 /// </summary>
 /// <param name="application">The <see cref="Growl.Connector.Application"/> to register</param>
 /// <param name="notificationTypes">A list of <see cref="Growl.Connector.NotificationType"/>s to register</param>
 protected void Register(Growl.Connector.Application application, Growl.Connector.NotificationType[] notificationTypes)
 {
     if(this.Enabled)
         this.growl.Register(application, notificationTypes);
 }
 /// <summary>
 /// Triggers a notification
 /// </summary>
 /// <param name="notification">The <see cref="Growl.Connector.Notification"/> to display</param>
 /// <param name="callbackContext">The <see cref="Growl.Connector.CallbackContext"/> of the notification</param>
 protected void Notify(Growl.Connector.Notification notification, Growl.Connector.CallbackContext callbackContext)
 {
     if(this.Enabled)
         this.growl.Notify(notification, callbackContext);
 }
Esempio n. 50
0
        void sc_ErrorResponse(Growl.Daemon.SubscriptionResponse response)
        {
            this.isSubscribing = false;
            string additionalInfo = (this.Enabled ? (response.ErrorCode == Growl.Connector.ErrorCode.NOT_AUTHORIZED ? "invalid password" : "server unavailable") : null);
            ChangeStatus(false, additionalInfo);

            // if the subscription failed, the SubscriptionConnector will take care of trying to reestablish it
        }
 public PriorityChoice(Growl.Connector.Priority? priority)
 {
     this.priority = priority;
     if (priority != null && this.priority.HasValue)
         this.name = ToastyForwardDestinationHandler.Fetch(priority);
     else
         this.name = "[Any Priority]";
 }
Esempio n. 52
0
 public NotificationReceivedEventArgs(Growl.DisplayStyle.Notification n)
 {
     this.n = n;
 }
 public override void ForwardNotification(Growl.Connector.Notification notification, Growl.Connector.CallbackContext callbackContext, Growl.Connector.RequestInfo requestInfo, bool isIdle, ForwardedNotificationCallbackHandler callbackFunction)
 {
     Forwarder growl = new Forwarder(this.Password, this.IPAddress, this.Port, requestInfo);
     growl.KeyHashAlgorithm = this.HashAlgorithm;
     growl.EncryptionAlgorithm = this.EncryptionAlgorithm;
     #if DEBUG
     //growl.EncryptionAlgorithm = Cryptography.SymmetricAlgorithmType.PlainText;
     #endif
     growl.ForwardedNotificationCallback += callbackFunction;
     growl.Notify(notification, callbackContext);
 }
 public override void ForwardRegistration(Growl.Connector.Application application, List<Growl.Connector.NotificationType> notificationTypes, Growl.Connector.RequestInfo requestInfo, bool isIdle)
 {
     Forwarder growl = new Forwarder(this.Password, this.IPAddress, this.Port, requestInfo);
     growl.KeyHashAlgorithm = this.HashAlgorithm;
     growl.EncryptionAlgorithm = this.EncryptionAlgorithm;
     #if DEBUG
     //growl.EncryptionAlgorithm = Cryptography.SymmetricAlgorithmType.PlainText;
     #endif
     growl.Register(application, notificationTypes.ToArray());
 }
Esempio n. 55
0
        void sc_OKResponse(Growl.Daemon.SubscriptionResponse response)
        {
            this.isSubscribing = false;
            string additionalInfo = (this.Enabled ? String.Format("TTL: {0}", response.TTL) : null);
            this.Platform = KnownDestinationPlatformType.FromString(response.PlatformName);
            ChangeStatus(true, additionalInfo);

            // if the subscription succeeds, the SubscriptionConnecter will take care of keeping the subscription alive
        }
Esempio n. 56
0
        void sc_OKResponse(Growl.Daemon.SubscriptionResponse response)
        {
            if (this.Enabled)
            {
                this.AdditionalOfflineDisplayInfo = null;
                this.AdditionalOnlineDisplayInfo = String.Format("TTL: {0}", response.TTL);
            }
            this.Platform = ForwardDestinationPlatformType.FromString(response.PlatformName);
            this.available = true;
            OnStatusChanged();

            // if the subscription succeeds, the SubscriptionConnecter will take care of keeping the subscription alive
        }
 /// <summary>
 /// Triggers a notification
 /// </summary>
 /// <param name="notification">The <see cref="Growl.Connector.Notification"/> to display</param>
 protected void Notify(Growl.Connector.Notification notification)
 {
     if(this.Enabled)
         Notify(notification, null);
 }
 /// <summary>
 /// Fires the <see cref="NotificationClosed"/> event
 /// </summary>
 /// <param name="args"><see cref="Growl.CoreLibrary.NotificationCallbackEventArgs"/> containing data about the event</param>
 protected void OnNotificationClosed(Growl.CoreLibrary.NotificationCallbackEventArgs args)
 {
     if (!this.alreadyClicked && this.NotificationClosed != null)
     {
         this.NotificationClosed(args);
     }
 }
        public static PastNotification Save(Growl.DisplayStyle.Notification notification, string requestID, DateTime timestamp)
        {
            Growl.DisplayStyle.NotificationLite notificationLite = Growl.DisplayStyle.NotificationLite.Clone(notification);
            string path = Growl.CoreLibrary.PathUtility.Combine(historyFolder, Growl.CoreLibrary.PathUtility.GetSafeFolderName(notificationLite.ApplicationName));
            Growl.CoreLibrary.PathUtility.EnsureDirectoryExists(path);

            // save image data
            string imageFile = null;
            if (notification.Image != null && notification.Image.IsSet)
            {
                System.Drawing.Image image = (System.Drawing.Image)notification.Image;
                using (image)
                {
                    System.Drawing.Image thumbnail = GenerateThumbnail(image, 48, 48);
                    if (thumbnail != null)
                    {
                        using (thumbnail)
                        {
                            string imagefilename = String.Format(@"{0}.img", requestID);
                            imageFile = Growl.CoreLibrary.PathUtility.Combine(path, imagefilename);

                            thumbnail.Save(imageFile);
                        }
                    }
                }
            }

            PastNotification pn = new PastNotification(notificationLite, timestamp, imageFile);

            // save text data
            string filename = String.Format(@"{0}.notification", requestID);
            string filepath = Growl.CoreLibrary.PathUtility.Combine(path, filename);
            System.IO.StreamWriter w = System.IO.File.CreateText(filepath);
            using (w)
            {
                string data = Serialization.SerializeObject(pn);
                w.Write(data);
                data = null;
            }

            return pn;
        }
Esempio n. 60
0
        private void Test_Register(string testName, Growl.Connector.Application app, List<NotificationType> types, Cryptography.SymmetricAlgorithmType ea, Cryptography.HashAlgorithmType ha)
        {
            GrowlConnector g = new GrowlConnector(this.textBox2.Text);
            g.EncryptionAlgorithm = ea;
            g.KeyHashAlgorithm = ha;

            //string r = g.Register(app, types.ToArray());

            //WriteTestRequest(r);
        }