コード例 #1
0
ファイル: FormChart.cs プロジェクト: Jaex/TDMaker
 private void FormChart_FormClosed(
     object sender,
     FormClosedEventArgs e)
 {
     GraphControl.Dispose();
     GC.Collect();
 }
コード例 #2
0
 public void Dispose()
 {
     if (_client != null)
     {
         _client.Closed -= new EventHandler(GraphControl_Closed);
         _client.Dispose();
         _client = null;
     }
 }
コード例 #3
0
 public override void Unload()
 {
     graph.Dispose();
     graph = null;
     val0  = null;
     val1  = null;
     val2  = null;
     val3  = null;
 }
コード例 #4
0
        /// <summary>
        /// Paint the style representation.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void styleListBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            ListBox listBox = (ListBox)sender;
            int     i       = e.Index;

            e.DrawBackground();
            INode node = listBox.Items[i] as INode;

            var     bounds = e.Bounds;
            InsetsD insets = new InsetsD(2);

            var canvasControl = new GraphControl();

            canvasControl.Size = new Size(bounds.Width - (int)insets.HorizontalInsets,
                                          bounds.Height - (int)insets.VerticalInsets);
            Bitmap   bm = new Bitmap(canvasControl.Size.Width, canvasControl.Size.Height);
            Graphics g  = Graphics.FromImage(bm);

            canvasControl.HorizontalScrollBarPolicy = ScrollBarVisibility.Never;
            canvasControl.VerticalScrollBarPolicy   = ScrollBarVisibility.Never;
            var dummyNode = canvasControl.Graph.CreateNode(node.Layout.ToRectD(), node.Style, node.Tag);

            foreach (var label in node.Labels)
            {
                canvasControl.Graph.AddLabel(dummyNode, label.Text, label.LayoutParameter, label.Style, label.PreferredSize, label.Tag);
            }
            foreach (var port in node.Ports)
            {
                canvasControl.Graph.AddPort(dummyNode, port.LocationParameter, port.Style, port.Tag);
            }
            canvasControl.ContentRect = new RectD(0, 0, 70, 70);
            canvasControl.FitContent();
            e.DrawBackground();
            g.SmoothingMode = SmoothingMode.HighQuality;
            g.Clear(Color.White);

            ContextConfigurator cc = new ContextConfigurator(canvasControl.ContentRect);
            var renderContext      = cc.CreateRenderContext(canvasControl, g);

            canvasControl.RenderContent(renderContext, g);
            var listGraphics = e.Graphics;
            var oldClip      = listGraphics.Clip;

            listGraphics.IntersectClip(bounds);
            listGraphics.Clear(listBox.BackColor);
            listGraphics.DrawImage(bm, bounds.X + (int)insets.Left, bounds.Y + (int)insets.Top, bm.Width, bm.Height);
            listGraphics.Clip = oldClip;
            e.DrawFocusRectangle();

            canvasControl.Dispose();
            g.Dispose();
            bm.Dispose();
        }
コード例 #5
0
		/// <summary>
		/// This method is called to print an individual page.
		/// </summary>
		protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e) {
			GraphControl printControl = new GraphControl();
			Rectangle b = e.MarginBounds, clip;
			Graphics g = e.Graphics;
			g.TranslateTransform(b.X, b.Y, MatrixOrder.Append);
			clip = new Rectangle(0, 0, b.Width, b.Height);
			g.SetClip(clip);
			printControl.Bounds = b;
			printControl.SetRange(printControl.x0, printControl.x1, printControl.y0, printControl.y1);
			printControl.Model = model;
			printControl.AsyncDraw = false;
			g.SmoothingMode = SmoothingMode.HighQuality;
			printControl.PaintGraph(g);
			printControl.Dispose();
		}
コード例 #6
0
        /// <summary>
        /// Paint <see cref="IGraph">component</see> as elements of the palette.
        /// </summary>
        private static void OnDrawItem(object sender, DrawItemEventArgs e)
        {
            if (sender is ListBox listBox && listBox.Items[e.Index] is IGraph component)
            {
                var     bounds = e.Bounds;
                InsetsD insets = new InsetsD(10);

                // create a GraphControl that shows the component
                var componentControl = new GraphControl {
                    Size = new Size(bounds.Width - (int)insets.HorizontalInsets, bounds.Height - (int)insets.VerticalInsets),
                    HorizontalScrollBarPolicy = ScrollBarVisibility.Never,
                    VerticalScrollBarPolicy   = ScrollBarVisibility.Never,
                    Graph = component
                };
                componentControl.FitGraphBounds();

                // create a bitmap with the same size as the GraphControl
                Bitmap   bm = new Bitmap(componentControl.Size.Width, componentControl.Size.Height);
                Graphics g  = Graphics.FromImage(bm);
                e.DrawBackground();
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.Clear(Color.White);

                // render the content of the GraphControl into the bitmap
                ContextConfigurator cc = new ContextConfigurator(componentControl.ContentRect);
                var renderContext      = cc.CreateRenderContext(componentControl, g);
                componentControl.RenderContent(renderContext, g);

                // render the image as an element of the palette
                var listGraphics = e.Graphics;
                var oldClip      = listGraphics.Clip;
                listGraphics.IntersectClip(bounds);
                listGraphics.Clear(listBox.BackColor);
                listGraphics.DrawImage(bm, bounds.X + (int)insets.Left, bounds.Y + (int)insets.Top, bm.Width, bm.Height);
                listGraphics.Clip = oldClip;
                e.DrawFocusRectangle();

                componentControl.Dispose();
                g.Dispose();
                bm.Dispose();
            }
        }
コード例 #7
0
 public override void Unload()
 {
     graph.Dispose();
     graph      = null;
     lineSeries = null;
 }
コード例 #8
0
ファイル: AppContext.cs プロジェクト: ewin66/media
        public void Run(string[] args)
        {
            bool   useVideoServer = true;
            string sourceName     = "Vid1";
            string serverAddress  = "localhost";

            Console.WriteLine("ZViewer is used to troubleshoot videoserver problems.");
            //   try
            {
                foreach (string arg in args)
                {
                    string[] parts = arg.Split(new char[] { '=' });
                    switch (parts[0])
                    {
                    case "server":
                        serverAddress = parts[1];
                        break;

                    case "source":
                        sourceName = parts[1];
                        break;

                    case "sinkurl":
                        _sessionDescription           = new SessionDescription();
                        _sessionDescription.ClientURL = parts[1];
                        useVideoServer = false;
                        break;

                    default:
                        Console.WriteLine("Invalid Option " + parts[0]);
                        break;
                    }
                }
                _proxy = new GraphControl(serverAddress);
                Console.WriteLine("server=" + _proxy.ServerAddress);
                Console.WriteLine("source=" + sourceName);
                ClientConnectRequest clientRequest = new ClientConnectRequest(sourceName);
                _sessionDescription = _proxy.OpenGraph(clientRequest);
                Console.WriteLine("sinkURL=" + _sessionDescription.ClientURL);
                if (_sessionDescription.ClientURL.Contains("http:"))
                {
                    Console.WriteLine("The graph is now running but nothing will be rendered here.");
                }
                else if (!_sessionDescription.ClientURL.Contains("rtp:"))
                {
                    _graph = new Graph(_sessionDescription.ClientURL, null);
                    _graph.Run();
                }
                Console.WriteLine("b\tshow current bitrate");
                Console.WriteLine("r\tstart recording");
                Console.WriteLine("s\tstop recording");
                Console.WriteLine("x\tstop viewing");
                bool running = true;

                while (running)
                {
                    ConsoleKeyInfo keyInfo = Console.ReadKey(true);
                    switch (keyInfo.KeyChar)
                    {
                    case 'b':
                        if (_graph != null)
                        {
                            int bitRate = _graph.AvgBitRate;
                            Console.WriteLine(bitRate / 1024 + " kbps");
                        }
                        break;

                    case 'x':
                        running = false;
                        break;

                    case 'r':
                    {
                        string recFileName = sourceName + @"\";
                        Directory.CreateDirectory(recFileName);
                        DateTime utc = DateTime.UtcNow;
                        recFileName += utc.Year.ToString() + utc.Month.ToString() + utc.Day.ToString() + utc.Hour.ToString() + utc.Minute.ToString() + ".lts";
                        _graph.RecordingFileName = recFileName;
                        Console.WriteLine("Started recording to file: " + recFileName);
                    }
                    break;

                    case 's':
                        _graph.RecordingFileName = null;
                        Console.WriteLine("Stopped recording");
                        break;
                    }
                }
                if (_graph != null)
                {
                    _graph.Dispose();
                    _graph = null;
                }
                if (_quickTimeProcess != null)
                {
                    Console.WriteLine("trying to kill QuickTime.");
                    _quickTimeProcess.CloseMainWindow();
                    _quickTimeProcess.Kill();
                    _quickTimeProcess.Dispose();
                    _quickTimeProcess = null;
                }
                _proxy.Dispose();
                System.Threading.Thread.Sleep(3000);
                _proxy = null;
            }
            //   catch (Exception exc)
            //    {
            //      Console.WriteLine(exc.Message);
            //  }
        }