コード例 #1
0
        public static GraphVM GenerateClique(uint nodesCount)
        {
            GraphVM graph = new GraphVM();

            // Create Nodes
            for (uint i = 0; i < nodesCount; i++)
            {
                graph.Nodes.Add(new GraphNodeVM()
                {
                    Name = Names[i],
                });
            }

            // Connect each node with every node (without itself)
            foreach (var node in graph.Nodes)
            {
                foreach (var neighbour in graph.Nodes.Where(n => n != node))
                {
                    var edge = new GraphEdgeVM()
                    {
                        Begin = node,
                        End   = neighbour,
                    };
                    node.Edges.Add(edge);
                    graph.Edges.Add(edge);
                }
            }

            return(graph);
        }
コード例 #2
0
        private void initializeComponents()
        {
            FileReader f = new FileReader();

            f.ReadFile(anomalyCsvPath);
            this.fdm = new FlightDetectorModel(f.LinesOfData, "localhost", 5400, anomalyCsvPath, normalCsvPath);

            if (anomalies != null)   //if there is anomalies
            {
                fdm.AnomaliesList     = this.anomalies.anomaliesList;
                fdm.CorrlativeCircles = this.anomalies.anomaliesRangeCircles;
            }


            ProgressBarVM pbvm = new ProgressBarVM(fdm);

            ProgressBar.Pbvm = pbvm;

            // create VM for the navigator
            NavigatorStateVM nsvm = new NavigatorStateVM(fdm);

            Navigator.Nsvm = nsvm;

            // create VM for the dataInfo
            DataInfoVM divm = new DataInfoVM(fdm);

            DataInfo.Divm = divm;

            // create VM for the grpah
            GraphVM gvm = new GraphVM(fdm);

            graph.Gvm = gvm;
        }
コード例 #3
0
 public static void FillEdges(GraphVM graph)
 {
     foreach (var edge in graph.Edges)
     {
         edge.Begin.Edges.Add(edge);
         edge.End.Edges.Add(edge);
     }
 }
コード例 #4
0
ファイル: MainViewModel.cs プロジェクト: heater404/HTOL
        private void Disconnect()
        {
            SitesVM.StopMonitorRegister();
            GraphVM.StopMonitorInstrument();
            GraphVM.StopMonitorTemp();

            comm.DestoryClient();
        }
コード例 #5
0
 public Graph(string id)
 {
     InitializeComponent();
     GraphVM          = new GraphVM(id);
     this.DataContext = GraphVM;
     //showColumnChart();
     //LoadLineChartData();
 }
コード例 #6
0
ファイル: ControlViewModel.cs プロジェクト: taxmeapp/taxapp
        // Colections of calls to update only what is shown on the graph (e.g. checkboxes ticked/unticked)
        private void displayOnlyGraphReset()
        {
            if (GraphVM != null)
            {
                // Clear the graph
                GraphVM.ClearSeries();

                // Graph everything that is checked
                GraphVM.GraphAllChecked();
            }
        }
コード例 #7
0
 public ConstVM(Constraint constraint, GraphVM graph_vm)
 {
     this.Constraint            = constraint;
     this._name                 = "C." + (Constraint.ConstraintIndex + 1).ToString();
     this._constraintlimit      = constraint.LimitValue;
     this._constrainttype       = (int)constraint.MyType;
     this._currentvalue         = Constraint.CurrentValue;
     this._isactive             = constraint.IsActive;
     this.GraphVM               = graph_vm;
     this.GraphVM.LineGraphName = this.Name;
     this.OptRunning            = false;
 }
コード例 #8
0
ファイル: App.xaml.cs プロジェクト: ofirshtrosberg/WpfApp1
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     Graph_VM        = new GraphVM(new GraphModel());
     Clock_VM        = new ClockVM(new ClockModel());
     MediaPlayer_VM  = new MediaPlayerVM(new MediaPlayerModel(new Client()));
     ProgressBar_VM  = new ProgressBarVM(new ProgressBarModel());
     JoystickBars_VM = new JoystickBarsVM(new JoystickBarsModel());
     // load names
     Load_Names();
     // event - observer pattern
     Load_Communication();
 }
コード例 #9
0
ファイル: MainViewModel.cs プロジェクト: heater404/HTOL
        private void Connect()
        {
            if (!comm.CreatClient())
            {
                MessageBox.Show("Init USB Fail");
                return;
            }

            DateTime time = DateTime.Now;

            Task.Run(() => SitesVM.MonitorRegister(30 * 1000));
            Task.Run(() => GraphVM.MonitorInstrument(30 * 1000, time));
            //Task.Run(() => GraphVM.MonitorTemp(30 + 1000, time));
        }
コード例 #10
0
ファイル: ControlViewModel.cs プロジェクト: taxmeapp/taxapp
        /*
         *  Calls to recalculate and regraph based on user input
         */

        // Collection of calls to update data, clear graph, regraph
        private void totalGraphReset()
        {
            // Update all data

            if (DataVM != null)
            {
                DataVM.TotalRecalculation();
            }

            if (GraphVM != null)
            {
                GraphVM.ClearSeries();

                GraphVM.GraphAllChecked();
            }
        }
コード例 #11
0
ファイル: ControlViewModel.cs プロジェクト: taxmeapp/taxapp
        // Collections of calls to update only the new data (e.g. max % or # of max brackets changed)
        private void newDataGraphReset()
        {
            if (DataVM != null)
            {
                // Recalculate all the *new* data only
                DataVM.NewDataRecalcuation();
            }

            if (GraphVM != null)
            {
                // Clear the graph
                GraphVM.ClearSeries();

                // Graph everything that is checked
                GraphVM.GraphAllChecked();
            }
        }
コード例 #12
0
        public GraphsV(DataBase db)
        {
            InitializeComponent();
            graphVM            = new GraphVM(new Graph(), db);
            GraphABorder.Child = new GraphAV(graphVM);
            GraphBBorder.Child = new GraphBV(graphVM); //need to add graphVM to constrctor

            RegressionGraphBorder.Child = new RegressionGraphV(graphVM);
            List <string> features = this.graphVM.getParameters();

            // here need to get list of graph
            foreach (string a in features)
            {
                ListBoxItem newItem = new ListBoxItem();
                newItem.Content = a;
                featureListBox.Items.Add(newItem);
            }
        }
コード例 #13
0
        private void SmartGraphPathParentChanged()
        {
            GraphVM previous = Graph;

            Graph = GraphPath?.Parent;
            if (Graph != null && Graph == previous)
            {
                return;
            }
            previous = Graph;

            Nodes.Clear();
            Edges.Clear();
            NodesNames.Clear();
            EdgesPath.Clear();
            NodesPathOrder.Clear();

            if (Graph == null)
            {
                return;
            }

            positioner = new CircleGraphPositioner(Graph);

            double actualWidth  = ActualWidth;
            double actualHeight = ActualHeight;

            foreach (var node in Graph.Nodes)
            {
                Nodes[node]      = CalculatePosition(node, NodesMargin, actualWidth, actualHeight);
                NodesNames[node] = CalculatePosition(node, NamesMargin, actualWidth, actualHeight);
            }

            foreach (var edge in Graph.Edges)
            {
                Edges.Add(edge);
            }

            ++ChangeCount;
        }
コード例 #14
0
        private GraphVM GetAllTransactionData(int instrumentID)
        {
            var     returnData               = new GraphVM(instrumentID);
            var     intersections            = Data.Where(x => x.IsIntersection).Count();
            decimal CurrentPercentage        = 1;
            decimal previousTransactionPrice = 0;
            decimal initialPrice             = 0;

            if (intersections > 2)
            {
                int counter = 0;

                for (int i = 0; i < Data.Count - 1; i++)
                {
                    if (Data[i].IsIntersection)
                    {
                        if (counter == 0)
                        {
                            initialPrice = Data[i + 1].OpeningPrice;
                        }
                        //Köp!
                        if (counter % 2 == 0)
                        {
                            previousTransactionPrice = Data[i + 1].OpeningPrice;
                            // Handla med negativt innehav?
                            //CurrentPercentage /= (Data[i + 1].OpeningPrice / lastOpeningPrice);
                        }
                        //Sälj!
                        else if (counter % 2 != 0)
                        {
                            CurrentPercentage *= (Data[i + 1].OpeningPrice / previousTransactionPrice);
                        }
                        returnData.GraphPoints.Add(new GraphData(Data[i].TimeStamp, CurrentPercentage, Data[i + 1].OpeningPrice));
                        counter++;
                    }
                }
            }
            return(returnData);
        }
コード例 #15
0
        public Graph1()
        {
            InitializeComponent();
            CurrentVM = new GraphVM(this);
            //fromDP.SelectedDate = DateTime.Today;
            //toDP.SelectedDate = DateTime.Today;
            //OnPropertyChanged("FromDate");
            //OnPropertyChanged("ToDP");
            // CurrentVM.ViewService = (IAddReportViewService)this;
            // DataContext = CurrentVM;
            SeriesCollection = new SeriesCollection
            {
                new ColumnSeries
                {
                    Values = new ChartValues <ObservableValue>
                    {
                    },
                    //DataLabels = true,
                    //LabelPoint = point =>point.Y
                }
            };

            Labels = new string[]
            {
                //    "1",
                //    "2",
                //    "3",
                //    "4",
                //    "5",
                //    "6",
                //    "7"
            };
            Formatter             = value => value + "";
            DataContext           = this;
            searchBtn.DataContext = CurrentVM;
            fromDP.DataContext    = CurrentVM;
            toDP.DataContext      = CurrentVM;
        }
コード例 #16
0
        public static GraphPathVM GeneratePath(GraphVM graph, Individual individual)
        {
            GraphPathVM path = new GraphPathVM(graph);

            for (uint i = 1; i < individual.Length; i++)
            {
                var b    = (int)individual[i];
                var p    = (int)individual[i - 1];
                var edge = new GraphEdgeVM()
                {
                    Begin = graph.Nodes[p],
                    End   = graph.Nodes[b],
                };
                path.Edges.Add(edge);
            }

            // add last - first
            path.Edges.Add(new GraphEdgeVM()
            {
                Begin = path.Edges.Last().End,
                End   = path.Edges.First().Begin,
            });

            foreach (var edge in path.Edges)
            {
                if (!path.Nodes.Contains(edge.Begin))
                {
                    path.Nodes.Add(edge.Begin);
                }
                if (!path.Nodes.Contains(edge.End))
                {
                    path.Nodes.Add(edge.End);
                }
            }

            return(path);
        }
コード例 #17
0
        public GraphBV(GraphVM g)
        {
            InitializeComponent();
            this.vm          = g;
            this.feature2    = "Feature B";
            this.DataContext = this;

            FeaturASeries = new SeriesCollection
            {
                new LineSeries
                {
                    AreaLimit = -10,
                    Values    = new ChartValues <ObservableValue>
                    {
                        new ObservableValue(0),
                        new ObservableValue(0),
                        new ObservableValue(0),
                        new ObservableValue(0),
                        new ObservableValue(0),
                        new ObservableValue(0),
                        new ObservableValue(0),
                        new ObservableValue(0),
                        new ObservableValue(0),
                        new ObservableValue(0),
                        new ObservableValue(0),
                        new ObservableValue(0),
                        new ObservableValue(0),
                        new ObservableValue(0),
                        new ObservableValue(0),
                        new ObservableValue(0),
                        new ObservableValue(0),
                        new ObservableValue(0)
                    }
                }
            };

            Task.Run(() =>
            {
                while (true)  // currently not in sync with simulator
                {
                    int csvSize = vm.VM_CsvSize;
                    int time    = vm.VM_TimeStep;
                    Thread.Sleep(500);
                    if (System.Windows.Application.Current != null)
                    {
                        if (csvSize > 0 && time < csvSize)
                        {
                            this.data     = this.vm.getDataCol('B');
                            this.Feature2 = this.vm.VM_FeatureB;
                            if (this.data != null && time < csvSize)
                            {
                                value = data[time];
                            }
                            else
                            {
                                value = 0;
                            }

                            if (System.Windows.Application.Current != null)
                            {
                                Application.Current.Dispatcher.Invoke(() =>
                                {
                                    FeaturASeries[0].Values.Add(new ObservableValue(value));
                                    FeaturASeries[0].Values.RemoveAt(0);
                                    SetLecture();
                                });
                            }
                            else
                            {
                                Environment.Exit(0);
                            }
                        }
                    }
                }
            });
        }
コード例 #18
0
 public CircleGraphPositioner(GraphVM graph)
 {
     this.graph = graph;
 }
コード例 #19
0
        public RegressionGraphV(GraphVM g)
        {
            InitializeComponent();
            this.vm = g;
            this.vm.PropertyChanged +=
                delegate(Object sender, PropertyChangedEventArgs e) {
                NotifyPropertyChanged("VM_" + e.PropertyName);
            };

            SeriesCollection = new SeriesCollection
            {
                new ScatterSeries //grey
                {
                    Values = new ChartValues <ScatterPoint>
                    {
                        //   new ScatterPoint(2.6, 5, 5), //xP,yP,r
                    },
                    Title = "old",
                    Fill  = Brushes.Gray,
                    MinPointShapeDiameter = 5,
                    MaxPointShapeDiameter = 5
                },
                new ScatterSeries //blue
                {
                    Values = new ChartValues <ScatterPoint>
                    {
                    },
                    //PointGeometry = DefaultGeometries.Diamond,
                    // DataLabels = true,
                    Title = "last 30 sec",
                    Fill  = Brushes.CornflowerBlue,
                    //ScalesXAt = 100, only for acxes
                    // PointGeometry = Defa
                    MinPointShapeDiameter = 5,
                    MaxPointShapeDiameter = 5
                },
                new ScatterSeries //red
                {
                    Values = new ChartValues <ScatterPoint>
                    {
                        //  new ScatterPoint( x, y, 7),
                    },
                    PointGeometry = DefaultGeometries.Diamond,
                    // DataLabels = true,
                    Title = "annomly",
                    Fill  = Brushes.Red,
                    //ScalesXAt = 100, only for acxes
                    MinPointShapeDiameter = 7,
                    MaxPointShapeDiameter = 7
                },
                new LineSeries
                {
                    Title         = "Liner regrssion", // need to calc two range points and draw a line between
                    Values        = new ChartValues <ObservablePoint> {
                        //new ObservablePoint(start.X,start.Y),
                        //new ObservablePoint(end.X, end.Y),
                    },
                    PointGeometry = null,

                    Stroke = Brushes.Transparent,
                    Fill   = Brushes.Transparent
                },

                new ScatterSeries // transparent
                {
                    Values = new ChartValues <ScatterPoint>
                    {
                        //new ScatterPoint( 50, 50, 100),// x,y,radius
                    },
                    Fill            = Brushes.Transparent,
                    StrokeThickness = 1,
                    Stroke          = Brushes.Transparent,
                    PointGeometry   = DefaultGeometries.Circle,
                    //ScalesXAt = 100, only for acxes
                    Title = "Minimal Circle",
                    //MinPointShapeDiameter = 1,
                    // MaxPointShapeDiameter = 100000
                },

                new ScatterSeries // transparent
                {
                    Values = new ChartValues <ScatterPoint> {
                    },
                    Fill   = Brushes.Transparent,
                    Stroke = Brushes.Transparent,
                },
            };

            DataContext = this;
        }
コード例 #20
0
ファイル: DataViewModel.cs プロジェクト: taxmeapp/taxapp
 public void DataInit()
 {
     ControlVM.ControlInit();
     GraphVM.GraphInit();
 }