Ejemplo n.º 1
0
 protected CollectorsForm2()
     : base()
 {
     // Init panel before ApplyResources
     Panel = new GraphPanel();
     InitializeComponent();
 }
Ejemplo n.º 2
0
        private void PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (e.Source == _sourceElement)
            {
                return;
            }
            if (e.Source is VertexVisual)
            {
                VertexVisual vv = (VertexVisual)e.Source;
                _isDown = true;
                SetSourceElement(vv);

                _startPoint       = e.GetPosition(GraphPanel);//new Point(e.GetPosition(pnlMap).X / Zoom, e.GetPosition(pnlMap).Y / Zoom);
                _positionOnSource = new Point(_startPoint.X - vv.Node.Location.X * Zoom, _startPoint.Y - vv.Node.Location.Y * Zoom);
                GraphPanel.CaptureMouse();
                e.Handled = true;
            }
            else if (e.Source is EdgeVisual)
            {
                EdgeVisual ev = (EdgeVisual)e.Source;
                _isDown = true;
                SetSourceElement(ev);
                e.Handled = true;
            }
            else if (e.Source is Ellipse)
            {
                _isDown = true;
                SetSourceElement(e.Source);
                e.Handled = true;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Attaches the model to the view.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="view">The view.</param>
        /// <param name="explorerPresenter">The explorer presenter.</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.view      = view as IGraphPanelView;
            this.panel     = model as GraphPanel;
            this.presenter = explorerPresenter;
            graphs         = new List <GraphTab>();

            if (this.view == null || this.panel == null || this.presenter == null)
            {
                throw new ArgumentException();
            }

            presenter.CommandHistory.ModelChanged += OnModelChanged;
            this.view.GraphViewCreated            += ModifyGraphView;

            properties = new PropertyPresenter();
            properties.Attach(panel, this.view.PropertiesView, presenter);

            processingThread                            = new BackgroundWorker();
            processingThread.DoWork                    += WorkerThread;
            processingThread.RunWorkerCompleted        += OnProcessingFinished;
            processingThread.WorkerSupportsCancellation = true;

            processingThread.RunWorkerAsync();
        }
Ejemplo n.º 4
0
 protected LoadedCollectorsForm() : base()
 {
     // do not use! for designer only!
     // Init panel before ApplyResources
     Panel = new GraphPanel();
     InitializeComponent();
 }
Ejemplo n.º 5
0
 private void DrawGraphFirstTime()
 {
     // Bind graph to viewer engine
     viewer.Graph = graph;
     // Bind viewer engine to the panel
     GraphPanel.SuspendLayout();
     viewer.Dock = System.Windows.Forms.DockStyle.Fill;
     GraphPanel.Controls.Add(viewer);
     GraphPanel.ResumeLayout();
 }
Ejemplo n.º 6
0
        private void DrawingTimer_Tick(object sender, EventArgs e)
        {
            bool isLive      = ((SignalDocument)document).DataIsLive;
            int  signalCount = ((SignalDocument)document).Signals.Count;

            if (isLive && prevSignalCount != signalCount)
            {
                GraphPanel.Invalidate();
            }
        }
Ejemplo n.º 7
0
 private void GraphPanel_Paint(object sender, PaintEventArgs e)
 {
     graph = GraphPanel.CreateGraphics();
     graph.Clear(GraphPanel.BackColor);
     offset = 10 - scrollOffset;
     foreach (var element in Statistics.OrderByDescending(x => x.Value))
     {
         graph.FillRectangle(brush, offset, 50, LetterWidth / 2, FullColumnHeight * Convert.ToSingle(element.Value));
         offset += LetterWidth;
     }
 }
Ejemplo n.º 8
0
        public LoadedCollectorsForm(Graph graph, string fileName, bool hint)
            : base(graph, hint)
        {
            // Init panel before ApplyResources
            Panel = new GraphPanel();
            InitializeComponent();
            // TODO: different for precise & scan
            Panel.Init(graph);

            _fileName = fileName;
            Text      = DisplayedFileName;
        }
Ejemplo n.º 9
0
 public void ClearGraphPanelCache(object sender, EventArgs e)
 {
     try
     {
         GraphPanel panel = Apsim.Get(explorerPresenter.ApsimXFile, explorerPresenter.CurrentNodePath) as GraphPanel;
         panel.Cache.Clear();
     }
     catch (Exception err)
     {
         explorerPresenter.MainPresenter.ShowError(err);
     }
 }
Ejemplo n.º 10
0
 public void ClearGraphPanelCache(object sender, EventArgs e)
 {
     try
     {
         GraphPanel panel = explorerPresenter.CurrentNode as GraphPanel;
         panel.Cache.Clear();
         explorerPresenter.HideRightHandPanel();
         explorerPresenter.ShowRightHandPanel();
     }
     catch (Exception err)
     {
         explorerPresenter.MainPresenter.ShowError(err);
     }
 }
Ejemplo n.º 11
0
 public Form1()
 {
     InitializeComponent();
     DoubleBuffered = true;
     LowX           = LowY = -5;
     HighX          = HighY = 5;
     sizeX          = 800;
     sizeY          = 600;
     DoubleBuffered = true;
     Trans          = new Translator()
     {
         Lx = LowX, Ly = LowY, Tx = HighX, Ty = HighY, h = sizeY, w = sizeX
     };
     GraphPanel.Invalidate();
 }
Ejemplo n.º 12
0
 private void ShowStatistics()
 {
     GraphPanel.Controls.Clear();
     graph  = GraphPanel.CreateGraphics();
     offset = 10;
     foreach (var element in Statistics.OrderByDescending(x => x.Value))
     {
         Label l = new Label();
         l.Text     = element.Key + "";
         l.Location = new Point(offset, l.Location.Y);
         l.Width    = LetterWidth;
         GraphPanel.Controls.Add(l);
         graph.FillRectangle(brush, offset, 50, LetterWidth / 2, FullColumnHeight * Convert.ToSingle(element.Value));
         offset += LetterWidth;
     }
 }
Ejemplo n.º 13
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (_points.Count == 0)
            {
                return;
            }

            var graphics = GraphPanel.CreateGraphics();

            graphics.Clear(Color.White);

            DrawGrid(graphics);
            DrawFunction(graphics);

            base.OnPaint(e);
        }
Ejemplo n.º 14
0
        protected override void LoadContent()
        {
            GameManager.SpriteBatch = new SpriteBatch(GraphicsDevice);

            #region MainMenu

            MainMenu mainMenu = new MainMenu(GameManager);
            mainMenu.Tags.Add("menu");
            mainMenu.Tags.Add("collade-item");
            mainMenu.Click += MainMunuOnClick;
            _gameEngine.Add(mainMenu);
            #endregion

            #region GraphPanel

            var graphWidth  = GameManager.GraphicsDeviceManager.PreferredBackBufferWidth;
            var graphHeight = GameManager.GraphicsDeviceManager.PreferredBackBufferHeight;
            GraphPanel = new GraphPanel(GameManager)
            {
                Position = new Vector2(0, 42),
                Size     = new Vector2(graphWidth, graphHeight - 70),
                Border   = new Border {
                    Color = Color.Gold, Width = 3
                }
            };
            _gameEngine.Add(GraphPanel);
            GraphBuilder = new GraphBuilder(GameManager, GraphPanel);

            #endregion

            #region MessageLabel

            MessageLabel = new Label(GameManager)
            {
                Color = Color.Black, Position = new Vector2(50, graphHeight - 20)
            };
            _gameEngine.Add(MessageLabel);

            #endregion

            _gameEngine.Add(new Cursor(GameManager));
        }
Ejemplo n.º 15
0
        private void RefreshButton_Click(object sender, EventArgs e)
        {
            AddDataToGraph("Speed", 0.1, 0.2);
            AddDataToGraph("Speed", 1.1, 2.1);
            AddDataToGraph("Speed", 2.1, 4.2);
            AddDataToGraph("Speed", 3.1, 1.8);
            foreach (BicycleCustomControl bicycle in bikes)
            {
                bicycle.Refresh();
                bicycle.Update();
            }
            BicyclePanel.Refresh();

            foreach (GraphCustomControll graph in graphs)
            {
                graph.Refresh();
                graph.Update();
            }
            GraphPanel.Refresh();
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Attaches the model to the view.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="view">The view.</param>
        /// <param name="explorerPresenter">The explorer presenter.</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.view      = view as IGraphPanelView;
            this.panel     = model as GraphPanel;
            this.presenter = explorerPresenter;
            graphs         = new List <GraphTab>();

            if (this.view == null || this.panel == null || this.presenter == null)
            {
                throw new ArgumentException();
            }

            presenter.CommandHistory.ModelChanged += OnModelChanged;
            this.view.GraphViewCreated            += ModifyGraphView;

            properties = new PropertyPresenter();
            properties.Attach(panel, this.view.PropertiesView, presenter);

            (processingThread, startTime) = StartWork();
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Create a new instance an prepare the some Datatypes
        /// </summary>
        /// <param name="pb"></param>
        /// <param name="click"></param>
        public GraphBuilder(System.Windows.Forms.Control pb, System.EventHandler click)
        {
            colors = new Hashtable();
            names  = new Hashtable();

            colors.Add("CRES", Color.RoyalBlue);
            colors.Add("SHPE", Color.GreenYellow);
            colors.Add("GMND", Color.Yellow);
            colors.Add("GMDC", Color.Thistle);
            colors.Add("TXMT", Color.Orange);
            colors.Add("TXTR", Color.MediumVioletRed);
            colors.Add("LIFO", Color.PaleVioletRed);
            colors.Add("LGHT", Color.White);

            gc         = new GraphPanel();
            gc.Parent  = pb;
            this.click = click;

            coords = new Hashtable();
        }
Ejemplo n.º 18
0
        private void MW(object sender, MouseEventArgs e)
        {
            float inc = (float)Math.Pow(2, (e.Delta / 120));

            if (HighX * inc - LowX * inc != 0 && HighY * inc - LowY * inc != 0)
            {
                if (!(HighX * inc > float.MaxValue / 10 || HighY * inc > float.MaxValue / 10 || LowX * inc < float.MinValue / 10 || LowY * inc < float.MinValue / 10) &&
                    !(HighX * inc - LowX * inc < 1E-10 || HighY * inc - LowY * inc < 1E-10))
                {
                    LowX  -= (HighX - LowX) * (inc - 1) / 2;
                    LowY  -= (HighY - LowY) * (inc - 1) / 2;
                    HighY += (HighY - LowY) * (inc - 1) / 2;
                    HighX += (HighX - LowX) * (inc - 1) / 2;
                    Trans  = new Translator()
                    {
                        Lx = LowX, Ly = LowY, Tx = HighX, Ty = HighY, h = sizeY, w = sizeX
                    };
                    GraphPanel.Invalidate();
                }
            }
        }
Ejemplo n.º 19
0
        private void Move(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (oldX == null)
                {
                    oldX = e.X;
                    oldY = e.Y;
                }
                else
                {
                    //Move Along based on distance in IS
                    PointIS trans = PointIS.FromPoint(new Point(e.X - (int)oldX, (e.Y - (int)oldY)), Trans);
                    if (!(float.IsInfinity(trans.X) || float.IsInfinity(trans.Y)))
                    {
                        if (!(HighX + trans.X > float.MaxValue / 10 || HighY + trans.Y > float.MaxValue / 10 || LowX - trans.X < float.MinValue / 10 || LowY - trans.Y < float.MinValue / 10))
                        {
                            LowX  += trans.X;
                            HighX += trans.X;
                            LowY  += trans.Y;
                            HighY += trans.Y;
                            oldY   = e.Y;
                            oldX   = e.X;
                            Trans  = new Translator()
                            {
                                Lx = LowX, Ly = LowY, Tx = HighX, Ty = HighY, h = sizeY, w = sizeX
                            };

                            GraphPanel.Invalidate();
                        }
                    }
                }
            }
            else
            {
                oldX = oldY = null;
            }
        }
Ejemplo n.º 20
0
        public override void DrawGraphPanel(Rect position)
        {
            bool flag = false;

            if (isGraphPenelHidden && graphPanelContainer != null)
            {
                graphPanelContainer.ShowElement();
                isGraphPenelHidden = false;
                flag = true;
            }
            if (graphPanelContainer == null)
            {
                if (graphPanelContainer != null)
                {
                    graphPanelContainer.RemoveFromHierarchy();
                }
                graphPanelContainer = new VisualElement()
                {
                    name = "graph-panel-container"
                };
                //graphPanelContainer.styleSheets.Add(Resources.Load<StyleSheet>("uNodeStyles/Tabbar"));
                window.rootVisualElement.Add(graphPanelContainer);
                graphPanelContainer.SendToBack();
                if (panel != null)
                {
                    panel.Dispose();
                }
                graphPanelContainer.Add(panel = new GraphPanel(this));
                flag = true;
            }
            if (flag || graphPanelContainer.resolvedStyle.width != position.width)
            {
                graphPanelContainer.StretchToParentSize();
                graphPanelContainer.style.left  = position.x;
                graphPanelContainer.style.top   = position.y;
                graphPanelContainer.style.width = position.width;
            }
        }
Ejemplo n.º 21
0
 void DoRecalculate(GraphPanel gp)
 {
     CalculateWaveform();
 }
Ejemplo n.º 22
0
 private void MinusButton_Click(object sender, EventArgs e)
 {
     scale /= 1.2f;
     GraphPanel.Invalidate();
 }
Ejemplo n.º 23
0
 private void graphCombo_SelectedIndexChanged(object sender, EventArgs e)
 {
     GraphPanel.Refresh();
 }
Ejemplo n.º 24
0
        private void SearchButton_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
            NamaFile.Text = openFileDialog1.FileName;
            string[] lines = System.IO.File.ReadAllLines(NamaFile.Text);
            a.nodes.Clear();
            foreach (string line in lines)
            {
                string[] y = line.Split(" ");
                if (!a.contain(y[0]))
                {
                    node temp = new node(y[0]);
                    a.addNode(temp);
                    if (!a.contain(y[1]))
                    {
                        node temp1 = new node(y[1]);
                        a.addNode(temp1);
                        temp.addAdj(temp1);
                    }
                    else
                    {
                        foreach (node i in a.nodes)
                        {
                            if (i.vertex == y[1])
                            {
                                temp.addAdj(i);
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < a.nodes.Count; i++)
                    {
                        if (a.nodes[i].vertex == y[0])
                        {
                            if (!a.contain(y[1]))
                            {
                                node temp1 = new node(y[1]);
                                a.addNode(temp1);
                                a.nodes[i].addAdj(temp1);
                            }
                            else
                            {
                                foreach (node j in a.nodes)
                                {
                                    if (j.vertex == y[1])
                                    {
                                        a.nodes[i].addAdj(j);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            richTextBox1.Text = File.ReadAllText(NamaFile.Text);
            Awal.Items.Clear();
            Akhir.Items.Clear();
            Awal.Items.Add("NONE");
            Akhir.Items.Add("NONE");
            Awal.Text  = "NONE";
            Akhir.Text = "NONE";
            foreach (node i in a.nodes)
            {
                Awal.Items.Add(i.vertex);
                Akhir.Items.Add(i.vertex);
            }

            GraphPanel.Controls.Clear();
            //create a viewer object
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            //create a graph object
            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
            //create the graph content
            foreach (node i in a.nodes)
            {
                foreach (node j in a.nodes[a.searchIdxNode(i.vertex)].adjacent)
                {
                    graph.AddEdge(i.vertex, j.vertex);
                }
            }
            //bind the graph to the viewer
            viewer.Graph = graph;

            //associate the viewer with the form
            GraphPanel.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            GraphPanel.Controls.Add(viewer);
            GraphPanel.ResumeLayout();
            //show the form
            GraphPanel.Show();
        }
Ejemplo n.º 25
0
        public void UpdateGraph(Wrapper.SDesc sdsc, Wrapper.ExtFamilyTies famt)
        {
            this.BeginUpdate();
            if (Parent != null)
            {
                this.Width  = Parent.ClientRectangle.Width;
                this.Height = Parent.ClientRectangle.Height;
            }
            bool run = WaitingScreen.Running;

            WaitingScreen.Wait();
            try
            {
                this.SaveBounds = false;
                this.AutoSize   = true;
                this.Clear();
                baseip = null;

                if (famt == null || sdsc == null)
                {
                    this.EndUpdate();
                    if (!run)
                    {
                        WaitingScreen.Stop();
                    }
                    return;
                }

                FamilyTieSim    tie      = famt.FindTies(sdsc);
                Wrapper.SDesc[] parents  = famt.ParentSims(sdsc);
                Wrapper.SDesc[] siblings = famt.SiblingSims(sdsc);
                Wrapper.SDesc[] childs   = famt.ChildSims(sdsc);

                int maxct = parents.Length + siblings.Length + childs.Length;
                if (maxct < 4)
                {
                    this.LinearUpdateGraph(sdsc, famt);
                    if (!run)
                    {
                        WaitingScreen.Stop();
                    }
                    return;
                }

                double r      = GraphPanel.GetPinCircleRadius(this.ItemSize, this.ItemSize, maxct);
                Point  center = new Point(
                    Math.Max(Width / 2, (int)r + 16 + ItemSize.Width / 2),
                    Math.Max(Height / 2, (int)r + ItemSize.Height / 2)
                    );

                baseip               = CreateItem(sdsc, 0, 0);
                baseip.Location      = GraphPanel.GetCenterLocationOnPinCircle(center, r, ItemSize);
                baseip.Parent        = this;
                this.SelectedElement = baseip;
                baseip.PanelColor    = Color.Black;
                baseip.ForeColor     = Color.White;
                baseip.EndUpdate();

                int ct = 0;

                if (tie != null)
                {
                    foreach (SDesc s in childs)
                    {
                        ImagePanel ip = AddTieToGraph(s, 0, 0, tie.FindTie(s).Type, false);
                        ip.Location = GraphPanel.GetItemLocationOnPinCricle(center, r, ct++, maxct, ItemSize);
                        ip.EndUpdate();
                    }

                    foreach (SDesc s in siblings)
                    {
                        ImagePanel ip = AddTieToGraph(s, 0, 0, tie.FindTie(s).Type, false);
                        ip.Location = GraphPanel.GetItemLocationOnPinCricle(center, r, ct++, maxct, ItemSize);
                        ip.EndUpdate();
                    }

                    foreach (SDesc s in parents)
                    {
                        ImagePanel ip = AddTieToGraph(s, 0, 0, tie.FindTie(s).Type, false);
                        ip.Location = GraphPanel.GetItemLocationOnPinCricle(center, r, ct++, maxct, ItemSize);
                        ip.EndUpdate();
                    }
                }


                this.EndUpdate();
            }
            finally { if (!run)
                      {
                          WaitingScreen.Stop();
                      }
            }
        }
Ejemplo n.º 26
0
 private void trackBar1_Scroll(object sender, EventArgs e)
 {
     a = trackBar1.Value;
     GraphPanel.Invalidate();
 }
Ejemplo n.º 27
0
 private void EquationIO_TextChanged(object sender, EventArgs e)
 {
     input = EquationIO.Text;
     GraphPanel.Invalidate();
 }
Ejemplo n.º 28
0
 private void Hover(object sender, EventArgs e)
 {
     GraphPanel.Focus();
 }
Ejemplo n.º 29
0
 public GraphBuilder(GameManager gameManager, GraphPanel graphPanel)
 {
     GameManager       = gameManager;
     GraphPanel        = graphPanel;
     graphPanel.Click += GraphPanelClick;
 }
Ejemplo n.º 30
0
 public RayPad()
 {
     InitializeComponent();
     draw_graph = GraphPanel.CreateGraphics();
 }