Ejemplo n.º 1
0
        public PickShowerMV()
        {
            BMP = Data.Bmp;

            Refresh = new CustomCUMmand <string>(
                async(s) =>
            {
                try
                {
                    string tempJson   = await HttpMessage.MethodGetBut <string>("api/ByteJpeg/" + Data.Pc.id);
                    ByteJpeg byteJpeg = JsonSerializer.Deserialize <ByteJpeg>(tempJson);
                    BMP      = Translate(byteJpeg.Jpeg);
                    Data.Bmp = BMP;
                }
                catch (Exception)
                {
                    return;
                }
            });

            Save = new CustomCUMmand <string>(
                (s) =>
            {
                Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog();
                sfd.Filter = "Png files(*.png)|*.png";
                if (sfd.ShowDialog() != true)
                {
                    return;
                }

                using (FileStream fs = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write))
                {
                    BitmapEncoder bme = new BmpBitmapEncoder();
                    bme.Frames.Add(BitmapFrame.Create(BMP));
                    bme.Save(fs);
                }
            });
        }
Ejemplo n.º 2
0
 private async void UpdatePc() //TODO Добавить как-то в вечный цикл
 {
     PcLoad = await HttpMessage.MethodGetBut <PcLoadInfo>("api/Pcs/" + SelectedPC.id);
 }
Ejemplo n.º 3
0
        public OverSeerMV()
        {
            timer.Tick    += Timer_Tick;
            timer.Interval = 3000;

            CpuChart = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title  = "Cpu%",
                    Values = new ChartValues <double> {
                        0
                    }
                }
            };

            RamChart = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title  = "Ram%",
                    Values = new ChartValues <double> {
                        0
                    }
                }
            };


            /*
             * CpuChartByCore = new SeriesCollection();
             *
             * for (int i = 0; i < 5; i++)
             * {
             *  CpuChartByCore.Add(new LineSeries { Title = $"Core{i + 1}", Values = new ChartValues<double>() });
             * }
             */

            dbInit();

            MenuButton = new CustomCUMmand <string>(
                (s) =>
            {
                switch (s)
                {
                case "Edit":
                    if (Data.PcGroupe.Count == 0)
                    {
                        System.Windows.MessageBox.Show("Please, Update DB");
                        return;
                    }
                    Manager.AddWindowsOpen(new EditV()); PcGroupes = Data.PcGroupe; break;

                case "UpdateDB": dbInit(); break;

                case "Log":
                    if (Data.PcGroupe.Count == 0)
                    {
                        System.Windows.MessageBox.Show("Please, Update DB");
                        return;
                    }
                    Manager.AddWindowsOpen(new LogsV()); break;

                case "Settings": break;

                case "About":  Manager.AddWindowsOpen(new AboutV()); break;
                }
            });

            GetInfo = new CustomCUMmand <string>(
                (s) =>
            {
                //МертвыйМетод (на всякий случай)
            });

            UpdateProcessList = new CustomCUMmand <string>(
                async(s) =>
            {
                string tempJson = await HttpMessage.MethodGetBut <string>("api/ListProc/" + SelectedPC.id);
                if (tempJson == null)
                {
                    return;
                }

                List <Proc> tempProc = JsonSerializer.Deserialize <List <Proc> >(tempJson);
                ProcessList          = new ObservableCollection <Proc>(tempProc);
            },
                () =>
            {
                if (SelectedPC == null)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            });

            UpdateJPEG = new CustomCUMmand <string>(
                async(s) =>
            {
                try
                {
                    string tempJson = await HttpMessage.MethodGetBut <string>("api/ByteJpeg/" + SelectedPC.id);
                    if (tempJson == null)
                    {
                        return;
                    }
                    ByteJpeg byteJpeg = JsonSerializer.Deserialize <ByteJpeg>(tempJson);
                    JPEG     = Translate(byteJpeg.Jpeg);
                    Data.Bmp = JPEG;
                }
                catch
                {
                    return;
                }
            },
                () =>
            {
                if (SelectedPC == null)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            });

            ShowPick = new CustomCUMmand <string>(
                (s) =>
            {
                Data.Pc = SelectedPC;
                new PickShowerV().ShowDialog();
                JPEG = Data.Bmp;
            },
                () =>
            {
                if (SelectedPC == null)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            });
        }