コード例 #1
0
        private async Task PopToast()
        {
            // Generate the toast notification content and pop the toast
            var loginRes = await RouterAPI.Login();

            if (!loginRes)
            {
                return;
            }
            var clients = await RouterAPI.GetClients();

            banList = await RouterAPI.FireWall.GetBanList();

            if (clients == null)
            {
                return;
            }
            if (clients.NotInBlackDevices.Count == 0)
            {
                return;
            }
            clients.Update();
            blackDevs = clients.NotInBlackDevices.Where(o => banList.Contains(o.mac) == false).ToList();
            if (blackDevs.Count == 0)
            {
                return;
            }
            ToastContent content = GenerateToastContent();

            ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(content.GetXml()));
        }
コード例 #2
0
        /// <summary>
        /// 确定保存WiFi设置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SaveWiFiYes_Clicked(object sender, RoutedEventArgs e)
        {
            notification.Dismiss();
            if (data.wlanInfo == null)
            {
                return;
            }
            if (data.wlanInfo.wl0_ssid.Length == 0 || data.wlanInfo.wl1_ssid.Length == 0)
            {
                notification.Show(Utils.AppResources.GetString("NullSSID"));
                return;
            }
            if (data.wlanInfo.wl0_wpa_psk.Length == 0 || data.wlanInfo.wl1_wpa_psk.Length == 0)
            {
                notification.Show(Utils.AppResources.GetString("NullPassword"));
                return;
            }
            var res = await RouterAPI.SetWlan(data.wlanInfo);

            if (res)
            {
                notification.Show(Utils.AppResources.GetString("WiFiSetSuccess"));
            }
            else
            {
                notificationError.Show(Utils.AppResources.GetString("WiFiSetError"));
            }
        }
コード例 #3
0
        /// <summary>
        /// 确定保存WiFi设置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SaveWiFiYes_Clicked(object sender, RoutedEventArgs e)
        {
            notification.Dismiss();
            if (wlanInfo == null)
            {
                return;
            }
            if (wlanInfo.wl0_ssid.Length == 0 || wlanInfo.wl1_ssid.Length == 0)
            {
                notification.Show("请输入SSID");
                return;
            }
            if (wlanInfo.wl0_wpa_psk.Length == 0 || wlanInfo.wl1_wpa_psk.Length == 0)
            {
                notification.Show("请输入密码");
                return;
            }
            var res = await RouterAPI.SetWlan(wlanInfo);

            if (res)
            {
                notification.Show("WiFi设置保存成功");
            }
            else
            {
                notificationError.Show("WiFi设置保存失败");
            }
        }
コード例 #4
0
ファイル: LoginPage.xaml.cs プロジェクト: kkmaple/ASUS-Router
        private async void LoginBtn_Click(object sender, RoutedEventArgs e)
        {
            if (!host.Contains("http"))
            {
                notificationError.Show("地址错误");
                return;
            }
            if (user.Length == 0)
            {
                notificationError.Show("请输入账号");
                return;
            }
            if (pwd.Length == 0)
            {
                notificationError.Show("请输入密码");
                return;
            }
            RouterAPI.Url.Host = host;
            var loginRes = await RouterAPI.Login(user, pwd);

            if (loginRes)
            {
                this.Frame.Navigate(typeof(MainPage), null);
            }
            else
            {
                notificationError.Show("登录失败", 2000);
            }
        }
コード例 #5
0
 /// <summary>
 /// 定时更新数据
 /// </summary>
 private void InitUpdateTheard()
 {
     if (updateTimer == null)
     {
         updateSpan  = TimeSpan.FromSeconds(2);
         updateTimer = ThreadPoolTimer.CreatePeriodicTimer(async(source) => {
             if (wanInfo == null)
             {
                 wanInfo = await RouterAPI.GetWANinfo();
             }
             netRate    = await RouterAPI.GetNetRate();
             cpuMemInfo = await RouterAPI.GetCpuMemInfo();
             clients    = await RouterAPI.GetClients();
             devRate    = await RouterAPI.GetDeviceRate();
             banList    = await RouterAPI.FireWall.GetBanList();
             if (wlanInfo == null)
             {
                 wlanInfo = await RouterAPI.GetWLANInfo();
             }
             await Dispatcher.RunAsync(CoreDispatcherPriority.High, () => {
                 UpdateUI();
             });
         }, updateSpan);
     }
 }
コード例 #6
0
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            Setting.DeviceName.SetDeviceName(client.mac, client.name);
            Setting.DeviceType.SetDeviceType(client.mac, (comboBox.SelectedItem as TypeModel).type);
            if (checkBox.IsChecked == true)
            {
                Setting.WhiteList.AddDevice(client.mac);
            }
            else if (checkBox.IsChecked == false)
            {
                Setting.WhiteList.RemoveDevice(client.mac);
            }
            long down = qos_down * 1024;
            long up   = qos_up * 1024;

            if (qos_enable != client.isQosLimit || down != client.qos_down || up != client.qos_up)
            {
                var qosRules = await RouterAPI.GetQosRuleList();

                qosRules.AppendRule(new Model.QosRule()
                {
                    mac    = client.mac,
                    enable = qos_enable,
                    up     = up,
                    down   = down
                });
                await RouterAPI.SetQosRuleList(qosRules);
            }
        }
コード例 #7
0
        private async void LoginBtn_Click(object sender, RoutedEventArgs e)
        {
            if (!host.Contains("http"))
            {
                notificationError.Show(Utils.AppResources.GetString("HostError"));
                return;
            }
            if (user.Length == 0)
            {
                notificationError.Show(Utils.AppResources.GetString("NullUserName"));
                return;
            }
            if (pwd.Length == 0)
            {
                notificationError.Show(Utils.AppResources.GetString("NullPassword"));
                return;
            }
            RouterAPI.Url.Host = host;
            var loginRes = await RouterAPI.Login(user, pwd);

            if (loginRes)
            {
                this.Frame.Navigate(typeof(MainPage), null);
            }
            else
            {
                notificationError.Show(Utils.AppResources.GetString("LoginFailure"), 2000);
            }
        }
コード例 #8
0
ファイル: App.xaml.cs プロジェクト: zuozishi/ASUS-Router
        protected async override void OnFileActivated(FileActivatedEventArgs e)
        {
            var args = e as FileActivatedEventArgs;

            if (args.Files.Count > 0)
            {
                string json = await FileIO.ReadTextAsync((IStorageFile)args.Files[0]);

                Setting.FileStart = true;
                Setting.FileData  = json;
                ApplyColorToTitleBar();
                var rootFrame = new Frame();
                Window.Current.Content = rootFrame;
                if (RouterAPI.HasLogin())
                {
                    var loginRes = await RouterAPI.Login();

                    if (loginRes)
                    {
                        rootFrame.Navigate(typeof(MainPage), e);
                    }
                    else
                    {
                        rootFrame.Navigate(typeof(LoginPage), e);
                    }
                }
                else
                {
                    rootFrame.Navigate(typeof(LoginPage), e);
                }
                Window.Current.Activate();
            }
        }
コード例 #9
0
        /// <summary>
        /// 重启路由器
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void RebootYes_Clicked(object sender, RoutedEventArgs e)
        {
            notification.Dismiss();
            var res = await RouterAPI.Reboot();

            if (res)
            {
                notification.Show(Utils.AppResources.GetString("RouterRebootSuccess"));
            }
            else
            {
                notificationError.Show(Utils.AppResources.GetString("RouterRebootError"));
            }
        }
コード例 #10
0
        /// <summary>
        /// 重启路由器
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void RebootYes_Clicked(object sender, RoutedEventArgs e)
        {
            notification.Dismiss();
            var res = await RouterAPI.Reboot();

            if (res)
            {
                notification.Show("路由器正在重启");
            }
            else
            {
                notificationError.Show("路由器重启失败");
            }
        }
コード例 #11
0
        private async void LoginBtn_Click(object sender, RoutedEventArgs e)
        {
            string url = "";

            if (Protocol_Http)
            {
                url += "http://";
            }
            else
            {
                url += "https://";
            }
            url += host;
            var ipres = Uri.TryCreate(url, UriKind.Absolute, out Uri uri);

            if (!ipres)
            {
                notificationError.Show(Utils.AppResources.GetString("HostError"));
                return;
            }
            if (user.Length == 0)
            {
                notificationError.Show(Utils.AppResources.GetString("NullUserName"));
                return;
            }
            if (pwd.Length == 0)
            {
                notificationError.Show(Utils.AppResources.GetString("NullPassword"));
                return;
            }
            RouterAPI.Url.Host = url;
            var loginRes = await RouterAPI.Login(user, pwd);

            if (loginRes)
            {
                this.Frame.Navigate(typeof(MainPage), null);
            }
            else
            {
                notificationError.Show(Utils.AppResources.GetString("LoginFailure"), 2000);
            }
        }
コード例 #12
0
 /// <summary>
 /// 定时更新数据
 /// </summary>
 private void InitUpdateTheard()
 {
     if (updateTimer == null)
     {
         updateSpan  = TimeSpan.FromSeconds(2);
         updateTimer = ThreadPoolTimer.CreatePeriodicTimer(async(source) => {
             if (App.DemoAccount)
             {
                 await Dispatcher.RunAsync(CoreDispatcherPriority.High, async() => {
                     data = await MainPageData.GetDemoData();
                     UpdateUI();
                 });
                 updateTimer.Cancel();
             }
             else
             {
                 if (data == null)
                 {
                     data = new MainPageData();
                 }
                 if (data.wanInfo == null)
                 {
                     data.wanInfo = await RouterAPI.GetWANinfo();
                 }
                 data.netRate    = await RouterAPI.GetNetRate();
                 data.cpuMemInfo = await RouterAPI.GetCpuMemInfo();
                 data.clients    = await RouterAPI.GetClients();
                 data.devRate    = await RouterAPI.GetDeviceRate();
                 data.banList    = await RouterAPI.FireWall.GetBanList();
                 if (data.wlanInfo == null)
                 {
                     data.wlanInfo = await RouterAPI.GetWLANInfo();
                 }
                 await Dispatcher.RunAsync(CoreDispatcherPriority.High, () => {
                     UpdateUI();
                 });
             }
         }, updateSpan);
     }
 }
コード例 #13
0
ファイル: App.xaml.cs プロジェクト: zuozishi/ASUS-Router
        /// <summary>
        /// 在应用程序由最终用户正常启动时进行调用。
        /// 将在启动应用程序以打开特定文件等情况下使用。
        /// </summary>
        /// <param name="e">有关启动请求和过程的详细信息。</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                /*
                 * this.DebugSettings.EnableFrameRateCounter = false;
                 * debugView = CoreApplication.CreateNewView();
                 * int id = 0;
                 * await debugView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                 * {
                 *  debugFrame = new Frame();
                 *  debugFrame.Navigate(typeof(DebugPage), null);
                 *  Window.Current.Content = debugFrame;
                 *  Window.Current.Activate();
                 *  id = ApplicationView.GetForCurrentView().Id;
                 * });
                 * bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(id);
                 */
            }
#endif
            Frame rootFrame = Window.Current.Content as Frame;

            // 不要在窗口已包含内容时重复应用程序初始化,
            // 只需确保窗口处于活动状态
            if (rootFrame == null)
            {
                // 创建要充当导航上下文的框架,并导航到第一页
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: 从之前挂起的应用程序加载状态
                }
                // 将框架放在当前窗口中
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // 当导航堆栈尚未还原时,导航到第一页,
                    // 并通过将所需信息作为导航参数传入来配置
                    // 参数
                    ApplyColorToTitleBar();
                    if (RouterAPI.HasLogin())
                    {
                        var loginRes = await RouterAPI.Login();

                        if (loginRes)
                        {
                            rootFrame.Navigate(typeof(MainPage), e);
                        }
                        else
                        {
                            rootFrame.Navigate(typeof(LoginPage), e);
                        }
                    }
                    else
                    {
                        rootFrame.Navigate(typeof(LoginPage), e);
                    }
                }
                // 确保当前窗口处于活动状态
                Window.Current.Activate();
            }
        }
コード例 #14
0
ファイル: App.xaml.cs プロジェクト: zuozishi/ASUS-Router
        override protected async void OnActivated(IActivatedEventArgs e)
        {
            if (e.Kind == ActivationKind.ContactPanel)
            {
                Setting.ContactStart = true;
                ApplyColorToTitleBar();
                // Create a Frame to act as the navigation context and navigate to the first page
                var rootFrame = new Frame();

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
                if (RouterAPI.HasLogin())
                {
                    var loginRes = await RouterAPI.Login();

                    if (loginRes)
                    {
                        rootFrame.Navigate(typeof(PeopleViewPage), e);
                    }
                    else
                    {
                        rootFrame.Navigate(typeof(LoginPage), e);
                    }
                }
                else
                {
                    rootFrame.Navigate(typeof(LoginPage), e);
                }
                // Navigate to the page that shows the Contact UI.


                // Ensure the current window is active
                Window.Current.Activate();
            }
            else if (e.Kind == ActivationKind.ToastNotification)
            {
                var args = e as ToastNotificationActivatedEventArgs;
                if (args.Argument == "Select")
                {
                    Setting.ToastStart = true;
                    ApplyColorToTitleBar();
                    // Create a Frame to act as the navigation context and navigate to the first page
                    var rootFrame = new Frame();

                    // Place the frame in the current Window
                    Window.Current.Content = rootFrame;
                    if (Class.RouterAPI.HasLogin())
                    {
                        var loginRes = await RouterAPI.Login();

                        if (loginRes)
                        {
                            rootFrame.Navigate(typeof(MainPage), e);
                        }
                        else
                        {
                            rootFrame.Navigate(typeof(LoginPage), e);
                        }
                    }
                    else
                    {
                        rootFrame.Navigate(typeof(LoginPage), e);
                    }
                    Window.Current.Activate();
                }
            }
        }