コード例 #1
0
ファイル: Kuaidi.cs プロジェクト: zx110101/X.K.e-Paper
        public override void Init()
        {
            appPath              = Path.Combine("Apps", "Kuaidi");
            keyboard             = XingKongScreen.GetKeyboard();
            keyboard.KeyPressed += new Keyboard.KeyPressedHandler(Keyboard_KeyPressed);

            LogData("1");

            mainWindow = new XingKongWindow();
            XingKongWindow.Entity entity = JsonConvert.DeserializeObject <XingKongWindow.Entity>(File.ReadAllText(Path.Combine(appPath, "KuaidiMainForm.json")));
            mainWindow.SetEntity(entity);
            lbTitle   = mainWindow.ControlsSet["lbTitle"] as XingKongLabel;
            lbKuaidis = mainWindow.ControlsSet["lbKuaidis"] as XingKongListBox;

            ShowMainWindow();
            LogData("2");

            kuaidiInfoWindow = new XingKongWindow();
            XingKongWindow.Entity entity2 = JsonConvert.DeserializeObject <XingKongWindow.Entity>(File.ReadAllText(Path.Combine(appPath, "KuaidiInfoForm.json")));
            kuaidiInfoWindow.SetEntity(entity2);
            g1           = new KuaidiInfoFormControlGroup(kuaidiInfoWindow, 1);
            g2           = new KuaidiInfoFormControlGroup(kuaidiInfoWindow, 2);
            g3           = new KuaidiInfoFormControlGroup(kuaidiInfoWindow, 3);
            g4           = new KuaidiInfoFormControlGroup(kuaidiInfoWindow, 4);
            infoGroup[0] = g1;
            infoGroup[1] = g2;
            infoGroup[2] = g3;
            infoGroup[3] = g4;
            lbg1g2       = kuaidiInfoWindow.ControlsSet["lbg1g2"] as XingKongLabel;
            lbg2g3       = kuaidiInfoWindow.ControlsSet["lbg2g3"] as XingKongLabel;
            lbg3g4       = kuaidiInfoWindow.ControlsSet["lbg3g4"] as XingKongLabel;
            lbInfoTitle  = kuaidiInfoWindow.ControlsSet["lbInfoTitle"] as XingKongLabel;

            LogData("Controls Reference Load Completed!");
        }
コード例 #2
0
ファイル: RemotePlayer.cs プロジェクト: zx110101/X.K.e-Paper
        public override void Init()
        {
            appPath       = Path.Combine("Apps", "RemotePlayer");
            currentWindow = new XingKongWindow();
            XingKongWindow.Entity entity = JsonConvert.DeserializeObject <XingKongWindow.Entity>(File.ReadAllText(Path.Combine(this.appPath, "RemotePlayerForm.json")));
            currentWindow.SetEntity(entity);
            pbAlbum      = currentWindow.ControlsSet["pbAlbum"] as XingKongImageBox;
            lbNowPlaying = currentWindow.ControlsSet["lbNowPlaying"] as XingKongLabel;
            lbName       = currentWindow.ControlsSet["lbName"] as XingKongLabel;
            lbSinger     = currentWindow.ControlsSet["lbSinger"] as XingKongLabel;
            lbAlbum      = currentWindow.ControlsSet["lbAlbum"] as XingKongLabel;
            lbExit       = currentWindow.ControlsSet["lbExit"] as XingKongLabel;

            lbName.Text   = "暂无信息";
            lbSinger.Text = "暂无信息";
            lbAlbum.Text  = "暂无信息";

            //pbAlbum.SkipPreProceed = true;
            defaultAlubmPath = Path.Combine(appPath, "album.png");
            pbAlbum.LoadPicture(defaultAlubmPath);

            XingKongScreen.ClearScreen();
            currentWindow.HardworkDraw();
            XingKongScreen.FreshScreen();

            keyboard                      = XingKongScreen.GetKeyboard();
            keyboard.KeyPressed          += new Keyboard.KeyPressedHandler(Keyboard_KeyPressed);
            tcpListener                   = new TcpListener();
            tcpListener.MusicInfoReceived = MusicInfoReceived;
            tcpListener.Start();
        }
コード例 #3
0
ファイル: SystemUI.cs プロジェクト: zx110101/X.K.e-Paper
        /// <summary>
        /// 显示关机界面
        /// </summary>
        private void showShutdownInterface()
        {
            string shutdownWindowJson = File.ReadAllText(@"ShutdownForm.json");

            XingKongWindow.Entity windowEntity   = JsonConvert.DeserializeObject <XingKongWindow.Entity>(shutdownWindowJson);
            XingKongWindow        shutdownWindow = new XingKongWindow();

            shutdownWindow.SetEntity(windowEntity);
            XingKongImageBox pbLogo       = shutdownWindow.ControlsSet["pbLogo"] as XingKongImageBox;
            XingKongImageBox pbCopyright  = shutdownWindow.ControlsSet["pbCopyright"] as XingKongImageBox;
            XingKongImageBox pbEarth      = shutdownWindow.ControlsSet["pbEarth"] as XingKongImageBox;
            XingKongImageBox pbDisconnect = shutdownWindow.ControlsSet["pbDisconnect"] as XingKongImageBox;

            pbLogo.SkipPreProceed       = true;
            pbCopyright.SkipPreProceed  = true;
            pbEarth.SkipPreProceed      = true;
            pbDisconnect.SkipPreProceed = true;

            pbLogo.LoadPicture(Path.Combine("SystemUI", "Logo_cut_1.bmp"));
            pbCopyright.LoadPicture(Path.Combine("SystemUI", "Logo_cut_2.bmp"));
            pbEarth.LoadPicture(Path.Combine("SystemUI", "Icon_Earth.bmp"));
            pbDisconnect.LoadPicture(Path.Combine("SystemUI", "Icon_Disconnected.bmp"));
            XingKongScreen.ClearScreen();
            shutdownWindow.HardworkDraw();
            XingKongScreen.FreshScreen();
        }
コード例 #4
0
ファイル: SystemUI.cs プロジェクト: zx110101/X.K.e-Paper
 private void ShutdownComputer()
 {
     if (XingKongScreen.IsRunningOnMono())
     {
         showShutdownInterface();
         Console.WriteLine(Bash("sudo shutdown -h now"));
     }
 }
コード例 #5
0
ファイル: Kuaidi.cs プロジェクト: zx110101/X.K.e-Paper
        private void ShowInfoWindow(KuaidiListItem selectedItem)
        {
            currentWindow = kuaidiInfoWindow;
            LogData(selectedItem.ToString());
            try
            {
                string url         = string.Format(urlFormat, selectedItem.ComPyName, selectedItem.KdNumber);
                string responseStr = XingKongUtils.HttpUtils.Get(url);
                LogData(responseStr);
                //Regex reg = new Regex(@"(?i)\\[uU]([0-9a-f]{4})");
                //responseStr = reg.Replace(responseStr, delegate (Match m) { return ((char)Convert.ToInt32(m.Groups[1].Value, 16)).ToString(); });

                EntityHelper.ResponseEntity response = JsonConvert.DeserializeObject <EntityHelper.ResponseEntity>(responseStr);

                lbInfoTitle.Text = selectedItem.ComCnName + " " + selectedItem.KdNumber;
                if (response.data != null && response.data.Count > 0)
                {
                    ShowDashedLineByCount(response.data.Count);
                    for (int i = 0; i < 4; i++)
                    {
                        if (i + 1 <= response.data.Count)
                        {
                            LogData(string.Format("i={0}, desc={1}, time={2}", i, response.data[i].context, response.data[i].time));
                            infoGroup[i].Msg        = response.data[i].context;
                            infoGroup[i].Time       = response.data[i].time;
                            infoGroup[i].Visibility = true;
                        }
                        else
                        {
                            infoGroup[i].Visibility = false;
                        }
                    }
                }
                else
                {
                    g1.Visibility = true;
                    g2.Visibility = false;
                    g3.Visibility = false;
                    g4.Visibility = false;
                    g1.Msg        = response.message + "";
                    g1.Time       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }
            }
            catch (Exception ex)
            {
                lbInfoTitle.Text = "错误";
                g1.Visibility    = false;
                g2.Visibility    = false;
                g3.Visibility    = false;
                g4.Visibility    = false;
                LogData(ex.Message);
            }


            XingKongScreen.ClearScreen();
            currentWindow.HardworkDraw();
            XingKongScreen.FreshScreen();
        }
コード例 #6
0
ファイル: SystemUI.cs プロジェクト: zx110101/X.K.e-Paper
 private void AutoFreshTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     autoFreshTimer.Enabled = false;
     UpdateIp();
     UpdateTime();
     UpdateSystemInfo();
     currentForm.Draw();
     XingKongScreen.FreshScreen();
     SyncMiniuteTimer();//重新校时
 }
コード例 #7
0
 private static void PortDemonTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     if (!File.Exists(XingKongScreen.PortName))
     {
         if (XingKongScreen.PortName.Equals(config.PortName))
         {
             XingKongScreen.OpenScreen(config.BackupPortName);
         }
         else
         {
             XingKongScreen.OpenScreen(config.PortName);
         }
     }
 }
コード例 #8
0
        public void Init()
        {
            thisWindow = new XingKongWindow();
            string shutdownWindowJson = File.ReadAllText(@"AppForm.json");

            XingKongWindow.Entity windowEntity = JsonConvert.DeserializeObject <XingKongWindow.Entity>(shutdownWindowJson);
            thisWindow.SetEntity(windowEntity);

            btLaunch  = thisWindow.ControlsSet["btLaunch"] as XingKongButton;
            btBack    = thisWindow.ControlsSet["btBack"] as XingKongButton;
            pbIcon    = thisWindow.ControlsSet["pbIcon"] as XingKongImageBox;
            lbAllApps = thisWindow.ControlsSet["lbAllApps"] as XingKongLabel;
            lbApps    = thisWindow.ControlsSet["lbApps"] as XingKongListBox;

            lbApps.Refresh();

            pbIcon.SkipPreProceed = true;
            pbIcon.LoadPicture(Path.Combine("SystemUI", "appstore.png"));

            apps = AppFinder.GetAppList();
            if ((apps == null) || (apps.Count == 0))
            {
                XingKongMessageBox box1 = new XingKongMessageBox
                {
                    Caption = "提示",
                    Title   = "然而一个应用都没有。"
                };
                box1.btOk.IsChecked = true;
                box1.DialogStyle    = XingKongMessageBox.Style.OK;
                Console.WriteLine("user clicked: " + box1.ShowAsync().Result);
            }
            else
            {
                if (lbApps.Items == null)
                {
                    lbApps.Items = new List <string>();
                }
                foreach (AppInfo info in apps)
                {
                    lbApps.Items.Add(info.AppName);
                }
                lbApps.Refresh();
            }
            XingKongScreen.ClearScreen();
            thisWindow.HardworkDraw();
            XingKongScreen.FreshScreen();
            keyboard             = XingKongScreen.GetKeyboard();
            keyboard.KeyPressed += new Keyboard.KeyPressedHandler(Keyboard_KeyPressed);
        }
コード例 #9
0
ファイル: SystemUI.cs プロジェクト: zx110101/X.K.e-Paper
        public override void Resume()
        {
            XingKongScreen.ClearScreen();
            UpdateTime();
            UpdateIp();
            UpdateSystemInfo();
            currentForm.HardworkDraw();
            XingKongScreen.FreshScreen();

            SyncMiniuteTimer();
            UpdateWeather();
            autoWeatherTimer.Enabled = true;

            keyboard.KeyPressed += Keyboard_KeyPressed;
        }
コード例 #10
0
ファイル: Kuaidi.cs プロジェクト: zx110101/X.K.e-Paper
        private void ShowMainWindow()
        {
            currentWindow = mainWindow;
            List <string> kuaidiListSource = new List <string>();

            KuaidiItemList = GetKuaidiList();
            foreach (var item in KuaidiItemList)
            {
                kuaidiListSource.Add(item.DisplayName);
            }
            lbKuaidis.Items = kuaidiListSource;
            lbKuaidis.Refresh();

            XingKongScreen.ClearScreen();
            currentWindow.HardworkDraw();
            XingKongScreen.FreshScreen();
        }
コード例 #11
0
 public override void Init()
 {
     appPath       = Path.Combine("Apps", "PhotoLibrary");
     currentWindow = new XingKongWindow();
     XingKongWindow.Entity entity = JsonConvert.DeserializeObject <XingKongWindow.Entity>(File.ReadAllText(Path.Combine(this.appPath, "MainForm.json")));
     currentWindow.SetEntity(entity);
     lbHint          = this.currentWindow.ControlsSet["lbHint"] as XingKongLabel;
     lbCaption       = this.currentWindow.ControlsSet["lbCaption"] as XingKongLabel;
     lbPicList       = this.currentWindow.ControlsSet["lbPicList"] as XingKongListBox;
     lbPicList.Items = this.GetPicFileNames();
     lbPicList.Refresh();
     keyboard             = XingKongScreen.GetKeyboard();
     keyboard.KeyPressed += new Keyboard.KeyPressedHandler(this.Keyboard_KeyPressed);
     XingKongScreen.ClearScreen();
     currentWindow.HardworkDraw();
     XingKongScreen.FreshScreen();
 }
コード例 #12
0
        private static System.Timers.Timer PortDemonTimer;//狗日的辣鸡pi有的时候会把ttyUSB0突然变成ttyUSB1

        static void Main(string[] args)
        {
            Utils.ConfigManager configManager = Utils.ConfigManager.GetInstance();
            config = configManager.Config;
            Console.WriteLine("PortName: " + config.PortName);

            if (args != null && args.Length >= 2 && args[0].Equals("-ip"))
            {
                XingKongScreen.IsRemote = true;
                XingKongScreen.RemoteIp = args[1];
            }
            else if (!string.IsNullOrWhiteSpace(config.BackupPortName) && XingKongScreen.IsRunningOnMono())
            {
                Console.WriteLine("BackupPortName: " + config.BackupPortName);
                PortDemonTimer          = new System.Timers.Timer();
                PortDemonTimer.Elapsed += PortDemonTimer_Elapsed;
                PortDemonTimer.Interval = 1000 * 30;//30秒检查一次
                PortDemonTimer.Enabled  = true;
            }

            XingKongScreen.OpenScreen(config.PortName);
            XingKongScreen.SetColor();
            XingKongScreen.ClearScreen();

            SystemUI = LoadAppAsync("SystemUI");

            if (args != null && args.Length >= 1 && args[0].Equals("-bg"))
            {
                //让程序在linux下在后台执行不退出
                //需要输入下列命令来启动本程序
                //nohup mono AppLoader.exe -bg &
                Thread.CurrentThread.Suspend();
            }
            else
            {
                Console.Write("> ");
                string input = Console.ReadLine();
                while (!input.Equals("exit"))
                {
                    Console.Write("> ");
                    input = Console.ReadLine();
                }
            }
            XingKongScreen.CloseScreen();
        }
コード例 #13
0
ファイル: Kuaidi.cs プロジェクト: zx110101/X.K.e-Paper
        private void Keyboard_KeyPressed(Keys pressedKey)
        {
            if (currentWindow == mainWindow)
            {
                switch (pressedKey)
                {
                case Keys.Escape:
                    Suspend();
                    Quit();
                    break;

                case Keys.Up:
                    lbKuaidis.SelectPrevious();
                    currentWindow.Draw();
                    XingKongScreen.FreshScreen();
                    break;

                case Keys.Down:
                    lbKuaidis.SelectNext();
                    currentWindow.Draw();
                    XingKongScreen.FreshScreen();
                    break;

                case Keys.Enter:
                    int selectedIndex = lbKuaidis.SelectedIndex;
                    ShowInfoWindow(KuaidiItemList[selectedIndex]);
                    break;

                default:
                    break;
                }
            }
            else if (currentWindow == kuaidiInfoWindow)
            {
                switch (pressedKey)
                {
                case Keys.Escape:
                    ShowMainWindow();
                    break;

                default:
                    break;
                }
            }
        }
コード例 #14
0
ファイル: SystemUI.cs プロジェクト: zx110101/X.K.e-Paper
        /// <summary>
        /// 显示启动界面
        /// </summary>
        private void showStartingInterface()
        {
            string startingWindowJson = File.ReadAllText(@"StartingForm.json");

            XingKongWindow.Entity windowEntity  = JsonConvert.DeserializeObject <XingKongWindow.Entity>(startingWindowJson);
            XingKongWindow        loadingWindow = new XingKongWindow();

            loadingWindow.SetEntity(windowEntity);
            XingKongImageBox pbLogo      = loadingWindow.ControlsSet["pbLogo"] as XingKongImageBox;
            XingKongImageBox pbCopyright = loadingWindow.ControlsSet["pbCopyright"] as XingKongImageBox;

            pbLogo.SkipPreProceed      = true;
            pbCopyright.SkipPreProceed = true;
            pbLogo.LoadPicture(Path.Combine("SystemUI", "Logo_cut_1.bmp"));
            pbCopyright.LoadPicture(Path.Combine("SystemUI", "Logo_cut_2.bmp"));
            loadingWindow.HardworkDraw();
            XingKongScreen.FreshScreen();
            XingKongScreen.ClearScreen();
        }
コード例 #15
0
        protected void LocalShow()
        {
            if (Program.Args != null && Program.Args.Length >= 2 && Program.Args[0].Equals("-ip"))
            {
                XingKongScreen.IsRemote = true;
                XingKongScreen.RemoteIp = Program.Args[1];
            }


            XingKongScreen.OpenScreen(PortName);

            XingKongScreen.ClearScreen();

            XingKongWindow window = GetXingKongWindow();

            window.Draw();

            XingKongScreen.FreshScreen();
            XingKongScreen.CloseScreen();
        }
コード例 #16
0
ファイル: RemotePlayer.cs プロジェクト: zx110101/X.K.e-Paper
        public void MusicInfoReceived(MusicInfo mi)
        {
            //Console.WriteLine(mi.Name);
            //Console.WriteLine(mi.Singer);
            //Console.WriteLine(mi.Album);
            //Console.WriteLine(mi.picBase64);
            udpsend = new XingKongUtils.UdpUtils.UdpSend(tcpListener.RemoteIp.ToString(), 7777);//每次建立连接后都重新初始化一下udp对象

            lbName.Text   = mi.Name;
            lbSinger.Text = mi.Singer;
            lbAlbum.Text  = mi.Album;
            if (!string.IsNullOrWhiteSpace(mi.picBase64))
            {
                pbAlbum.LoadPicture(ToImage(mi.picBase64));
            }

            XingKongScreen.ClearScreen();
            currentWindow.HardworkDraw();
            XingKongScreen.FreshScreen();
        }
コード例 #17
0
        public override void Init()
        {
            appPath       = Path.Combine("Apps", "TpLinkNetMonitor");
            currentWindow = new XingKongWindow();
            XingKongWindow.Entity entity = JsonConvert.DeserializeObject <XingKongWindow.Entity>(File.ReadAllText(Path.Combine(this.appPath, "MainForm.json")));
            currentWindow.SetEntity(entity);

            XingKongPanel plGlobal = currentWindow.ControlsSet["plGlobal"] as XingKongPanel;

            lbGlobalDownload = plGlobal.ControlsSet["lbGlobalDownload"] as XingKongLabel;
            lbGlobalUpload   = plGlobal.ControlsSet["lbGlobalUpload"] as XingKongLabel;

            XingKongPanel plArea0 = currentWindow.ControlsSet["plArea0"] as XingKongPanel;

            lbArea0PcName = plArea0.ControlsSet["lbArea0PcName"] as XingKongLabel;
            lbArea0Ip     = plArea0.ControlsSet["lbArea0Ip"] as XingKongLabel;
            lbArea0Up     = plArea0.ControlsSet["lbArea0Up"] as XingKongLabel;
            lbArea0Down   = plArea0.ControlsSet["lbArea0Down"] as XingKongLabel;

            XingKongPanel plArea1 = currentWindow.ControlsSet["plArea1"] as XingKongPanel;

            lbArea1PcName = plArea1.ControlsSet["lbArea1PcName"] as XingKongLabel;
            lbArea1Ip     = plArea1.ControlsSet["lbArea1Ip"] as XingKongLabel;
            lbArea1Up     = plArea1.ControlsSet["lbArea1Up"] as XingKongLabel;
            lbArea1Down   = plArea1.ControlsSet["lbArea1Down"] as XingKongLabel;

            XingKongPanel plArea2 = currentWindow.ControlsSet["plArea2"] as XingKongPanel;

            lbArea2PcName = plArea2.ControlsSet["lbArea2PcName"] as XingKongLabel;
            lbArea2Ip     = plArea2.ControlsSet["lbArea2Ip"] as XingKongLabel;
            lbArea2Up     = plArea2.ControlsSet["lbArea2Up"] as XingKongLabel;
            lbArea2Down   = plArea2.ControlsSet["lbArea2Down"] as XingKongLabel;

            XingKongPanel plArea3 = currentWindow.ControlsSet["plArea3"] as XingKongPanel;

            lbArea3PcName = plArea3.ControlsSet["lbArea3PcName"] as XingKongLabel;
            lbArea3Ip     = plArea3.ControlsSet["lbArea3Ip"] as XingKongLabel;
            lbArea3Up     = plArea3.ControlsSet["lbArea3Up"] as XingKongLabel;
            lbArea3Down   = plArea3.ControlsSet["lbArea3Down"] as XingKongLabel;

            XingKongPanel plPage = currentWindow.ControlsSet["plPage"] as XingKongPanel;

            lbPage = plPage.ControlsSet["lbPage"] as XingKongLabel;
            btPrev = currentWindow.ControlsSet["btPrev"] as XingKongButton;
            btNext = currentWindow.ControlsSet["btNext"] as XingKongButton;

            //显示初始内容
            lbGlobalDownload.Text = "下载:N/A";
            lbGlobalUpload.Text   = "上传:N/A";
            for (int i = 0; i < 4; i++)
            {
                setAreaContent(i, null);
            }
            lbPage.Text = "退出:Esc";

            pageManager = new PageManager();

            XingKongScreen.ClearScreen();
            currentWindow.HardworkDraw();
            XingKongScreen.FreshScreen();

            //登陆并启动定时刷新计时器
            if (Login(out token))
            {
                LogData("登陆成功,token:" + token);

                request_url = string.Format("http://192.168.0.1/stok={0}/ds", token);

                if (timer == null)
                {
                    timer          = new System.Timers.Timer();
                    timer.Interval = 1000;
                    timer.Elapsed += Timer_Elapsed;
                    timer.Start();
                }
            }
            else
            {
                LogData("登陆失败");
                XingKongMessageBox msgBox = new XingKongMessageBox();
                msgBox.Title       = "登陆TP-Link后台失败";
                msgBox.Caption     = "提示";
                msgBox.DialogStyle = XingKongMessageBox.Style.OK;
                XingKongMessageBox.DialogResult result = msgBox.ShowAsync().Result;
                LogData("user click : " + result.ToString());
                Quit();
            }

            keyboard             = XingKongScreen.GetKeyboard();
            keyboard.KeyPressed += new Keyboard.KeyPressedHandler(this.Keyboard_KeyPressed);
        }
コード例 #18
0
        private void Keyboard_KeyPressed(System.Windows.Forms.Keys pressedKey)
        {
            switch (pressedKey)
            {
            case System.Windows.Forms.Keys.Left:
                buttonIndex = (--buttonIndex % 3);
                break;

            case System.Windows.Forms.Keys.Right:
                buttonIndex = (++buttonIndex % 3);
                break;

            default:
                break;
            }
            if (buttonIndex < 0)
            {
                buttonIndex += 3;
            }

            switch (pressedKey)
            {
            case System.Windows.Forms.Keys.Left:
            case System.Windows.Forms.Keys.Right:
                switchButton(buttonIndex);
                XingKongScreen.FreshScreen();
                //防止过多刷新导致眼花……,重置剩余刷新时间
                remaningSeconds = 7;
                break;

            case System.Windows.Forms.Keys.Enter:
                if (btNext.IsChecked)
                {
                    pageIndex++;
                    pageIndex = pageIndex % pageCount;
                }
                else if (btPrev.IsChecked)
                {
                    pageIndex--;
                    if (pageIndex < 0)
                    {
                        pageIndex += pageCount;
                    }
                }
                LogData("PageIndex: " + pageIndex);
                //切换页
                List <EntityHelper.HostInfoEntity> page = pageManager.GetPageByIndex(pageIndex);
                for (int i = 0; i < 4; i++)
                {
                    if (i > (page.Count - 1))
                    {
                        setAreaContent(i, null);
                    }
                    else
                    {
                        setAreaContent(i, page[i]);
                    }
                }
                //防止过多刷新导致眼花……,重置剩余刷新时间
                remaningSeconds = 7;
                currentWindow.Draw();
                XingKongScreen.FreshScreen();
                break;

            case System.Windows.Forms.Keys.Escape:
                Suspend();
                Quit();
                break;

            default:
                break;
            }
        }
コード例 #19
0
        private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            remaningSeconds--;
            if (remaningSeconds < 0)
            {
                //重置剩余刷新时间
                remaningSeconds = 7;

                if (isUpdating)
                {
                    return;
                }
                isUpdating = true;
                try
                {
                    bool needDraw = false;

                    //获取全局速度
                    string response = HttpUtils.Post(request_url, wan_status_args, HttpUtils.RequestType.Raw);
                    EntityHelper.WanStatusReponseEntity wanStatusEntity = JsonConvert.DeserializeObject <EntityHelper.WanStatusReponseEntity>(response);
                    if (upSpeed != wanStatusEntity.network.wan_status.up_speed || downSpeed != wanStatusEntity.network.wan_status.down_speed)
                    {
                        lbGlobalDownload.Text = string.Format("下载:{0}KB/s", wanStatusEntity.network.wan_status.down_speed);
                        lbGlobalUpload.Text   = string.Format("上传:{0}KB/s", wanStatusEntity.network.wan_status.up_speed);

                        needDraw  = true;
                        upSpeed   = wanStatusEntity.network.wan_status.up_speed;
                        downSpeed = wanStatusEntity.network.wan_status.down_speed;
                    }

                    //获取各个机器的速度
                    response = HttpUtils.Post(request_url, hosts_info_args, HttpUtils.RequestType.Raw);
                    List <EntityHelper.HostInfoEntity> hostsInfo = EntityHelper.AnalysHostInfoJson(response);
                    pageManager.SetDataSource(hostsInfo);
                    pageCount = pageManager.GetPageCount();
                    if (pageCount > 0)
                    {
                        lbPage.Text = string.Format("第{0}页,共{1}页", pageIndex + 1, pageCount);
                        List <EntityHelper.HostInfoEntity> page = pageManager.GetPageByIndex(pageIndex);
                        for (int i = 0; i < 4; i++)
                        {
                            if (i > (page.Count - 1))
                            {
                                setAreaContent(i, null);
                            }
                            else
                            {
                                setAreaContent(i, page[i]);
                            }
                        }
                    }
                    else
                    {
                        lbPage.Text = "路由器智障了(╯‵□′)╯︵┻━┻";
                    }

                    if (needDraw)
                    {
                        currentWindow.Draw();
                        XingKongScreen.FreshScreen();
                    }
                }
                catch (Exception ex)
                {
                    LogData(ex.Message);
                    LogData(ex.StackTrace);
                }
                isUpdating = false;
            }
        }
コード例 #20
0
ファイル: SystemUI.cs プロジェクト: zx110101/X.K.e-Paper
        private void UpdateSystemInfo()
        {
            if (cpuCounter == null)
            {
                cpuCounter = new PerformanceCounter();
                cpuCounter.CategoryName = "Processor";
                cpuCounter.CounterName  = "% Processor Time";
                cpuCounter.InstanceName = "_Total";
            }
            string cpuStatus = cpuCounter.NextValue().ToString("F1") + "%  ";
            string memStatus = string.Empty;

            if (XingKongScreen.IsRunningOnMono())
            {
                string cmdResult = Bash(@"cat /sys/class/thermal/thermal_zone0/temp").Trim();
                float  cpuTemp   = float.Parse(cmdResult) / 1000;
                cpuStatus += cpuTemp.ToString("F1");
                cpuStatus += "℃";


                cmdResult = Bash(@"free");
                string[] lines = cmdResult.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
                if (lines.Length > 2)
                {
                    string[] fields = lines[1].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    if (fields.Length > 3)
                    {
                        memStatus = string.Format(@"{1}MB / {0}MB", int.Parse(fields[1]) / 1000, int.Parse(fields[2]) / 1000);
                    }
                }
            }
            else
            {
                Assembly vbDll = Assembly.LoadFrom(vbDllPath);
                if (vbDll != null)
                {
                    Type vbModule = vbDll.GetType("Microsoft.VisualBasic.Devices.ComputerInfo");
                    if (vbModule != null)
                    {
                        PropertyInfo AvailablePhysicalMemory = vbModule.GetProperty("AvailablePhysicalMemory");
                        PropertyInfo TotalPhysicalMemory     = vbModule.GetProperty("TotalPhysicalMemory");

                        MethodInfo getAPM = AvailablePhysicalMemory.GetGetMethod();
                        MethodInfo getTPM = TotalPhysicalMemory.GetGetMethod();

                        object computerInfo = System.Activator.CreateInstance(vbModule);
                        ulong? avaMem       = getAPM.Invoke(computerInfo, null) as ulong?;
                        ulong? totMem       = getTPM.Invoke(computerInfo, null) as ulong?;
                        //Console.WriteLine("系统物理内存(M):" + totMem / 1024 / 1024);
                        //Console.WriteLine("可用物理内存(M):" + avaMem / 1024 / 1024);

                        memStatus = string.Format(@"{0}MB / {1}MB", (totMem - avaMem) / 1024 / 1024, totMem / 1024 / 1024);
                    }
                    else
                    {
                        Console.WriteLine("[SystemUI]\terror while finding class ComputerInfo.");
                    }
                }
                else
                {
                    Console.WriteLine("[SystemUI]\terror while loading VB moudle");
                }
            }

            lbCpuStatus.Text = cpuStatus;
            lbRamStatus.Text = memStatus;
        }
コード例 #21
0
ファイル: SystemUI.cs プロジェクト: zx110101/X.K.e-Paper
        private async void Keyboard_KeyPressed(System.Windows.Forms.Keys pressedKey)
        {
            switch (pressedKey)
            {
            case System.Windows.Forms.Keys.Left:
                buttonIndex = (--buttonIndex % 3);
                break;

            case System.Windows.Forms.Keys.Right:
                buttonIndex = (++buttonIndex % 3);
                break;

            default:
                break;
            }
            if (buttonIndex < 0)
            {
                buttonIndex += 3;
            }
            switch (pressedKey)
            {
            case System.Windows.Forms.Keys.Left:
            case System.Windows.Forms.Keys.Right:
                switchButton(buttonIndex);
                XingKongScreen.FreshScreen();
                break;

            case System.Windows.Forms.Keys.Enter:
                if (buttonIndex == 2)
                {
                    //用户选择并点击了了关机按钮
                    XingKongMessageBox mb = new XingKongMessageBox();
                    mb.Caption            = "提示";
                    mb.Title              = "确定要关机吗?";
                    mb.btOk.IsChecked     = false;
                    mb.btCancel.IsChecked = true;
                    Suspend();
                    XingKongMessageBox.DialogResult result = await mb.ShowAsync();

                    Console.WriteLine("user clicked: " + result.ToString());
                    switch (result)
                    {
                    case XingKongMessageBox.DialogResult.OK:
                        Thread t = new Thread(new ThreadStart(ShutdownComputer));
                        t.IsBackground = true;
                        t.Start();
                        break;

                    case XingKongMessageBox.DialogResult.Cancel:
                        Resume();
                        break;

                    default:
                        Resume();
                        break;
                    }
                }
                else if (buttonIndex == 1)
                {
                    //用户选择并点击了应用按钮
                    Suspend();
                    AppForm appForm = new AppForm();
                    appForm.QuitAction    = Resume;
                    appForm.LoadAppAction = LoadAppAction;

                    Thread t = new Thread(new ThreadStart(appForm.Init));
                    t.IsBackground = true;
                    t.Start();
                }
                break;

            case System.Windows.Forms.Keys.F5:
                XingKongScreen.ClearScreen();
                currentForm.HardworkDraw();
                XingKongScreen.FreshScreen();
                break;

            default:
                break;
            }
        }
コード例 #22
0
ファイル: SystemUI.cs プロジェクト: zx110101/X.K.e-Paper
        public override void Init()
        {
            //先显示启动画面
            showStartingInterface();

            if (!XingKongScreen.IsRunningOnMono())
            {
                Thread.Sleep(1000);
            }

            string appLoaderWindowJson = File.ReadAllText(@"MainForm.json");

            XingKongWindow.Entity windowEntity = JsonConvert.DeserializeObject <XingKongWindow.Entity>(appLoaderWindowJson);
            currentForm = new XingKongWindow();
            currentForm.SetEntity(windowEntity);

            #region 初始化日期控件
            XingKongPanel panel1 = currentForm.ControlsSet["panel1"] as XingKongPanel;
            lbWeek = panel1.ControlsSet["lbWeek"] as XingKongLabel;
            lbDate = panel1.ControlsSet["lbDate"] as XingKongLabel;
            pbM1   = currentForm.ControlsSet["pbM1"] as XingKongImageBox;
            pbM2   = currentForm.ControlsSet["pbM2"] as XingKongImageBox;
            pbS    = currentForm.ControlsSet["pbS"] as XingKongImageBox;
            pbH1   = currentForm.ControlsSet["pbH1"] as XingKongImageBox;
            pbH2   = currentForm.ControlsSet["pbH2"] as XingKongImageBox;

            pbM1.SkipPreProceed = true;
            pbM2.SkipPreProceed = true;
            pbS.SkipPreProceed  = true;
            pbH1.SkipPreProceed = true;
            pbH2.SkipPreProceed = true;

            pbS.LoadPicture(getNumPic(':'));
            #endregion

            #region 初始化天气控件
            XingKongPanel panel2 = currentForm.ControlsSet["panel2"] as XingKongPanel;
            XingKongPanel panel3 = currentForm.ControlsSet["panel3"] as XingKongPanel;
            pbWeatherIcon  = currentForm.ControlsSet["pbWeatherIcon"] as XingKongImageBox;
            lbCity         = panel2.ControlsSet["lbCity"] as XingKongLabel;
            lbWeather      = panel2.ControlsSet["lbWeather"] as XingKongLabel;
            lbTemp         = panel2.ControlsSet["lbTemp"] as XingKongLabel;
            lbWind         = panel2.ControlsSet["lbWind"] as XingKongLabel;
            lbTempCurrDesc = panel3.ControlsSet["lbTempCurrDesc"] as XingKongLabel;
            lbTempCurr     = panel3.ControlsSet["lbTempCurr"] as XingKongLabel;

            pbWeatherIcon.SkipPreProceed = true;

            lbTomoWeatherAndWind = panel2.ControlsSet["lbTomoWeatherAndWind"] as XingKongLabel;
            lbTomoTemp           = panel2.ControlsSet["lbTomoTemp"] as XingKongLabel;
            #endregion

            #region 初始化系统信息控件
            XingKongPanel panel4 = currentForm.ControlsSet["panel4"] as XingKongPanel;
            lbIp        = panel4.ControlsSet["lbIp"] as XingKongLabel;
            lbCpuStatus = panel4.ControlsSet["lbCpuStatus"] as XingKongLabel;
            lbRamStatus = panel4.ControlsSet["lbRamStatus"] as XingKongLabel;
            #endregion

            #region 初始化按钮控件
            pbPower = currentForm.ControlsSet["pbPower"] as XingKongImageBox;
            pbApp   = currentForm.ControlsSet["pbApp"] as XingKongImageBox;
            btPower = currentForm.ControlsSet["btPower"] as XingKongButton;
            btApp   = currentForm.ControlsSet["btApp"] as XingKongButton;

            pbPower.SkipPreProceed = true;
            pbApp.SkipPreProceed   = true;

            pbPower.LoadPicture(Path.Combine("SystemUI", "POWER.BMP"));
            pbApp.LoadPicture(Path.Combine("SystemUI", "APP.BMP"));
            if (XingKongScreen.IsRunningOnMono())
            {
                btPower.TextXoffset = -9;
                btApp.TextXoffset   = -9;
            }
            else
            {
                btPower.TextXoffset = -2;
                btApp.TextXoffset   = -2;
            }
            #endregion

            UpdateIp();
            UpdateTime();
            UpdateSystemInfo();
            UpdateWeather();
            currentForm.HardworkDraw();

            XingKongScreen.FreshScreen();

            keyboard             = XingKongScreen.GetKeyboard();
            keyboard.KeyPressed += Keyboard_KeyPressed;

            autoSyncMiniuteTimer          = new System.Timers.Timer();//同步时钟间隔
            autoSyncMiniuteTimer.Elapsed += AutoSyncMiniuteTimer_Elapsed;
            SyncMiniuteTimer();

            autoFreshTimer          = new System.Timers.Timer();
            autoFreshTimer.Interval = 1000 * 60;//一分钟刷新一次
            autoFreshTimer.Elapsed += AutoFreshTimer_Elapsed;

            autoWeatherTimer          = new System.Timers.Timer();
            autoWeatherTimer.Interval = 1000 * 60 * 10;//十分钟刷新一次
            autoWeatherTimer.Elapsed += AutoWeatherTimer_Elapsed;
            autoWeatherTimer.Enabled  = true;
        }
コード例 #23
0
 private void Keyboard_KeyPressed(Keys pressedKey)
 {
     if (pressedKey <= Keys.Escape)
     {
         if (pressedKey != Keys.Enter)
         {
             if (pressedKey == Keys.Escape)
             {
                 this.LogData("inPicViewMode: " + (this.inPicViewMode ? "true" : "false"));
                 if (this.inPicViewMode)
                 {
                     this.inPicViewMode = false;
                     XingKongScreen.ClearScreen();
                     this.currentWindow.HardworkDraw();
                     XingKongScreen.FreshScreen();
                 }
                 else
                 {
                     this.Suspend();
                     this.Quit();
                 }
             }
         }
         else if (!this.inPicViewMode)
         {
             XingKongImageBox control = new XingKongImageBox();
             string           data    = Path.Combine(this.appPath, this.lbPicList.Items[this.lbPicList.SelectedIndex]);
             this.LogData(data);
             ImageHelper.Size size = ImageHelper.getPictureSize(data);
             this.LogData(string.Format("Width:{0} Height:{1}", size.Width, size.Height));
             if ((size.Height > 600) || (size.Width > 800))
             {
                 Bitmap pic = ImageHelper.Scale(new Bitmap(data), 600, 800);
                 control.LoadPicture(pic);
             }
             else
             {
                 control.LoadPicture(data);
             }
             control.Name = "imageBox1";
             control.Left = (800 - control.Width) / 2;
             control.Top  = (600 - control.Height) / 2;
             //control.SkipPreProceed = true;
             XingKongWindow window1 = new XingKongWindow();
             window1.AddChild(control);
             this.inPicViewMode = true;
             XingKongScreen.ClearScreen();
             window1.Draw();
             XingKongScreen.FreshScreen();
         }
     }
     else
     {
         if (pressedKey != Keys.Up)
         {
             if (pressedKey != Keys.Down)
             {
                 return;
             }
         }
         else
         {
             if (!this.inPicViewMode)
             {
                 this.lbPicList.SelectPrevious();
                 this.lbPicList.Draw();
                 XingKongScreen.FreshScreen();
             }
             return;
         }
         if (!this.inPicViewMode)
         {
             this.lbPicList.SelectNext();
             this.lbPicList.Draw();
             XingKongScreen.FreshScreen();
         }
     }
 }
コード例 #24
0
 private void Keyboard_KeyPressed(System.Windows.Forms.Keys pressedKey)
 {
     if (pressedKey == Keys.Left)
     {
         isListHasFocus = true;
         switchFocus();
     }
     else if (pressedKey == Keys.Right)
     {
         isListHasFocus = false;
         switchFocus();
     }
     else if (pressedKey == Keys.Up)
     {
         if (isListHasFocus)
         {
             lbApps.SelectPrevious();
         }
         else
         {
             btLaunch.IsChecked = true;
             btBack.IsChecked   = false;
         }
     }
     else if (pressedKey == Keys.Down)
     {
         if (isListHasFocus)
         {
             lbApps.SelectNext();
         }
         else
         {
             btLaunch.IsChecked = false;
             btBack.IsChecked   = true;
         }
     }
     else if (pressedKey == Keys.Enter)
     {
         if (!isListHasFocus)
         {
             if (btBack.IsChecked)
             {
                 Suspend();
                 QuitAction?.Invoke();
                 return;
             }
             if ((btLaunch.IsChecked && (lbApps.SelectedIndex >= 0)) && (lbApps.SelectedIndex <= apps.Count))
             {
                 Suspend();
                 LoadAppAction?.Invoke(apps[lbApps.SelectedIndex].MoudlePath);
                 return;
             }
         }
         else if ((lbApps.SelectedIndex >= 0) && (lbApps.SelectedIndex <= apps.Count))
         {
             Suspend();
             Console.WriteLine(apps[lbApps.SelectedIndex].MoudlePath);
             LoadAppAction?.Invoke(apps[lbApps.SelectedIndex].MoudlePath);
             return;
         }
     }
     thisWindow.Draw();
     XingKongScreen.FreshScreen();
 }