Ejemplo n.º 1
0
        public AddPCMV()
        {
            IPAddress ip;

            Pc = Data.Pc;

            Save = new CustomCUMmand <string>(
                (s) =>
            {
                if (!IPAddress.TryParse(Pc.IP, out ip))
                {
                    System.Windows.MessageBox.Show("Wrong IP");
                    return;
                }
                ;

                PC res = HttpMessage.MethodPost("api/PcEditor/", Pc).Result;

                if (res.id == -1)
                {
                    System.Windows.MessageBox.Show("Wrong Input");
                    return;
                }


                Manager.Close(typeof(AddPC));
            }, () =>
            {
                if (string.IsNullOrEmpty(Pc.Name) || string.IsNullOrEmpty(Pc.IP) || string.IsNullOrEmpty(Pc.Port.ToString()))
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            });
        }
Ejemplo n.º 2
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.º 3
0
        public EditMV()
        {
            Init();

            AddPC = new CustomCUMmand <string>(
                (s) =>
            {
                switch (s)
                {
                case "Chouse": Data.Pc = ChosenGroupePC; break;

                case "All": Data.Pc = ChosenAllPC; break;
                }

                Manager.AddWindowsOpen(new AddPC());

                Data.Pc = new PC();
            });



            Save = new CustomCUMmand <string>(
                (s) =>
            {
                List <PcGroupe> temp = new List <PcGroupe>();
                temp.Add(UnGroupe);
                temp.AddRange(MainGroupe);

                Data.PcGroupe = new ObservableCollection <PcGroupe>(temp);
                Manager.Close(typeof(EditV));
            });

            Remove = new CustomCUMmand <string>(
                (s) =>
            {
                PC ret = HttpMessage.MethodDell <PC>("api/PcEditor/", ChosenGroupePC.id).Result;

                if (ret.id == -1)
                {
                    System.Windows.MessageBox.Show("Wrong Input");
                    return;
                }

                PC temp = ChosenGroupePC;
                UnGroupe.PcMs.Add(temp);
                SelectedGroupe.PcMs.Remove(temp);
                ChosenGroupePC = null;
            },
                () =>
            {
                if (ChosenGroupePC == null)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            });

            Add = new CustomCUMmand <string>(
                (s) =>
            {
                PC ret = HttpMessage.MethodPut("api/PcEditor/" + SelectedGroupe.id, ChosenAllPC).Result;

                if (ret.id == -1)
                {
                    System.Windows.MessageBox.Show("Wrong Input");
                    return;
                }


                PC temp = ChosenAllPC;
                SelectedGroupe.PcMs.Add(temp);
                UnGroupe.PcMs.Remove(temp);
                ChosenAllPC = null;
            },
                () =>
            {
                if (ChosenAllPC == null || SelectedGroupe == null)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            });

            AddGroupe = new CustomCUMmand <string>(
                (s) =>
            {
                PcGroupe newGroup = new PcGroupe()
                {
                    Name = "NewGroup"
                };
                newGroup = HttpMessage.MethodPost("api/PcGroups", newGroup).Result;

                if (newGroup.id == 0 || string.IsNullOrWhiteSpace(newGroup.Name))
                {
                    System.Windows.MessageBox.Show("Wrong Input");
                    return;
                }

                MainGroupe.Add(newGroup);
            });


            UpdateName = new CustomCUMmand <string>(
                (s) =>
            {
                PcGroupe result = HttpMessage.MethodPut("api/PcGroups/" + SelectedGroupe.id, SelectedGroupe).Result;
                if (result.id != selectedGroupe.id)
                {
                    System.Windows.MessageBox.Show("Wrong Input");
                }
            }, () =>
            {
                if (SelectedGroupe != null)
                {
                    if (!string.IsNullOrWhiteSpace(SelectedGroupe.Name))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            });



            RemoveGroupe = new CustomCUMmand <string>(
                (s) =>
            {
                //TODO Ебанет?
                PcGroupe respounce = HttpMessage.MethodDell <PcGroupe>("api/PcGroups", SelectedGroupe.id).Result;

                if (respounce.id == -1)
                {
                    System.Windows.MessageBox.Show("WrongInput");
                    return;
                }



                PcGroupe temp = SelectedGroupe;
                temp.PcMs.ToList().ForEach(x => unGroupe.PcMs.Add(x));
                MainGroupe.Remove(temp);
                Data.PcGroupe.Remove(temp);
                SelectedGroupe = null;
            },
                () =>
            {
                if (SelectedGroupe == null)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            });
        }
Ejemplo n.º 4
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);
                }
            });
        }