Пример #1
0
        public void Notify(NotifyControl control, int timeout)
        {
            if (_mainForm.InvokeRequired)
            {
                _mainForm.BeginInvoke(new Action <NotifyControl, int>(Notify), control, timeout);
                return;
            }

            var notifyForm = new NotifyForm(control)
            {
                NotifyControl = control,
                Timeout       = timeout
            };

            notifyForm.SetPosition(GetNextPosition(notifyForm.Width, notifyForm.Height));
            lock (_notifyForms)
            {
                _notifyForms.Add(notifyForm);
            }

            notifyForm.FormClosed += NotifyFormClosed;

            control.NotifyForm = notifyForm;
            control.NotifyOnCreate();

            notifyForm.ShowGracefully();
        }
Пример #2
0
        //消息提醒
        public static void Msg(string msg)
        {
            NotifyControl notify = new NotifyControl();

            notify.Text = msg;
            notify.Show();
        }
Пример #3
0
        public static async Task <string> HttpGets(string uri)
        {
            if (Config.IsNetWork)
            {
                NotifyControl notify = new NotifyControl();
                notify.Text = "亲,努力加载中...";

                notify.Show();
                using (HttpClient httpClient = new HttpClient())
                {
                    try
                    {
                        HttpResponseMessage response = new HttpResponseMessage();
                        response = await httpClient.GetAsync(new Uri(uri, UriKind.Absolute));

                        responseString = await response.Content.ReadAsStringAsync();

                        notify.Hide();
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message.ToString());
                    }
                }
            }
            return(responseString);
        }
Пример #4
0
        public static void NotifyUser(NotifyControl control, int timeout)
        {
            if (_instance == null)
            {
                return;
            }

            _instance.Notify(control, timeout);
        }
Пример #5
0
        public static async Task <string> HttpGet(string uri)
        {
            if (Config.IsNetWork)
            {
                NotifyControl notify = new NotifyControl();
                notify.Text = "亲,努力加载中...";
                notify.Show();

                var _filter = new HttpBaseProtocolFilter();
                using (HttpClient httpClient = new HttpClient(_filter))
                {
                    _filter.CacheControl.WriteBehavior = HttpCacheWriteBehavior.NoCache;
                    HttpResponseMessage response = new HttpResponseMessage();
                    response = await httpClient.GetAsync(new Uri(uri, UriKind.Absolute));

                    responseString = await response.Content.ReadAsStringAsync();

                    notify.Hide();
                }
            }
            return(responseString);
        }
Пример #6
0
        private async void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Wait, 10);
            try
            {
                await OAuthHelper.Authorize();

                if (BangumiApi.BgmOAuth.IsLogin)
                {
                    this.Frame.Navigate(typeof(MainPage), null, new DrillInNavigationTransitionInfo());
                }
            }
            catch (Exception ex)
            {
                await NotifyControl.AddNotification($"登录失败,请重试!\n{ex.Message}", Controls.NotifyType.Error);

                //NotificationHelper.Notify($"登录失败,请重试!\n{ex.Message}", NotificationHelper.NotifyType.Error);
            }
            finally
            {
                Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Arrow, 10);
            }
        }
Пример #7
0
        public async void HttpPost(string uid, string uimage, string name, string content, List <string> imagePsthList, string songPath, string date, int type)
        {
            NotifyControl notify = new NotifyControl();

            notify.Text = "亲,努力发送中...";
            notify.Show();
            HttpClient httpClient     = new HttpClient();
            uint       MaxImageWidth  = 480;
            uint       MaxImageHeight = 800;
            uint       width;
            uint       height;

            try
            {
                string posturi = Config.apiDreamingPublish;
                HttpMultipartFormDataContent fileContent = new HttpMultipartFormDataContent();
                if (imagePsthList.Count > 0)
                {
                    for (int i = 0; i < imagePsthList.Count; i++)
                    {
                        StorageFile inFile = await StorageFile.GetFileFromPathAsync(imagePsthList[i]);

                        var inStream = await inFile.OpenReadAsync();

                        InMemoryRandomAccessStream outStream = new InMemoryRandomAccessStream();
                        BitmapDecoder decoder = await ImageHelp.GetProperDecoder(inStream, inFile);

                        if (decoder == null)
                        {
                            return;
                        }


                        if (decoder.OrientedPixelWidth > MaxImageWidth && decoder.OrientedPixelHeight > MaxImageHeight)
                        {
                            width  = MaxImageWidth;
                            height = MaxImageHeight;
                        }
                        else
                        {
                            width  = decoder.OrientedPixelWidth;
                            height = decoder.OrientedPixelHeight;
                        }



                        PixelDataProvider provider = await decoder.GetPixelDataAsync();

                        byte[] data = provider.DetachPixelData(); //获取像素数据的字节数组


                        BitmapPropertySet propertySet  = new BitmapPropertySet();
                        BitmapTypedValue  qualityValue = new BitmapTypedValue(0.5, PropertyType.Single);
                        propertySet.Add("ImageQuality", qualityValue);


                        var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, outStream, propertySet);//建立编码器

                        encoder.SetPixelData(decoder.BitmapPixelFormat,
                                             decoder.BitmapAlphaMode,
                                             decoder.OrientedPixelWidth,
                                             decoder.OrientedPixelHeight,
                                             decoder.DpiX,
                                             decoder.DpiY,
                                             data
                                             );

                        encoder.BitmapTransform.ScaledWidth  = width;
                        encoder.BitmapTransform.ScaledHeight = height;
                        await encoder.FlushAsync();

                        HttpStreamContent streamContent1 = new HttpStreamContent(outStream);
                        fileContent.Add(streamContent1, "pic", inFile.Name);
                    }
                }


                if (songPath != null)
                {
                    StorageFile file1 = await StorageFile.GetFileFromPathAsync(songPath);

                    IRandomAccessStreamWithContentType stream1 = await file1.OpenReadAsync();

                    HttpStreamContent streamContent1 = new HttpStreamContent(stream1);
                    fileContent.Add(streamContent1, "song", file1.Name);
                }

                HttpStringContent stringContent = new HttpStringContent(content);
                HttpStringContent stringName    = new HttpStringContent(name);
                HttpStringContent stringUid     = new HttpStringContent(uid);
                HttpStringContent stringUimage  = new HttpStringContent(uimage);
                HttpStringContent stringTime    = new HttpStringContent(date);
                HttpStringContent stringType    = new HttpStringContent(type.ToString());


                fileContent.Add(stringContent, "content");
                fileContent.Add(stringUid, "phone");
                fileContent.Add(stringUimage, "uimage");

                fileContent.Add(stringName, "name");
                fileContent.Add(stringTime, "time");
                fileContent.Add(stringType, "type");

                HttpResponseMessage response = await httpClient.PostAsync(new Uri(posturi), fileContent);

                Init();
                notify.Hide();
                PostCommand.CanExecutes = true;
                NavigationHelp.NavigateTo(typeof(AllDreaming));
            }
            catch (Exception ex)
            {
                HelpMethods.Msg(ex.Message.ToString());
            }
        }
Пример #8
0
 public void Notify(NotifyControl control)
 {
     Notify(control, 5000);
 }
Пример #9
0
 public static void NotifyUser(NotifyControl control)
 {
     NotifyUser(control, 5000);
 }