Display more video information in MediaInfo Tab.
[marukotoolbox.git] / mp4box / Supplements.cs
blobb46a90e940c9380e1ac1f0677f1ea51a52bcc42c
1 // ------------------------------------------------------------------
2 // Copyright (C) 2011-2014 Maruko Toolbox Project
3 //
4 // Authors: LunarShaddow <aflyhorse@hotmail.com>
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
15 // express or implied.
16 // See the License for the specific language governing permissions
17 // and limitations under the License.
18 // -------------------------------------------------------------------
21 using System;
22 using System.Collections.Generic;
23 using System.ComponentModel;
24 using System.Drawing;
25 using System.Windows.Forms;
26 using System.Text;
28 namespace mp4box
30 namespace Extension
32 /// <summary>
33 /// A wrapper to make Invoke more easy by using Method Extension.
34 /// </summary>
35 static class Invoker
37 public static void InvokeIfRequired(this ISynchronizeInvoke control, MethodInvoker action)
39 if (control.InvokeRequired)
40 control.Invoke(action, null);
41 else
42 action();
46 /// <summary>
47 /// Handmade progress bar. Currently not in use.
48 /// </summary>
49 class ProgressBarEx : ProgressBar
51 public ProgressBarEx()
53 // Modify the ControlStyles flags
54 //http://msdn.microsoft.com/en-us/library/system.windows.forms.controlstyles.aspx
55 SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
56 // Initialize Property
57 CustomText = "";
58 Format = new StringFormat(StringFormatFlags.NoWrap);
59 Format.Alignment = StringAlignment.Center;
60 Format.LineAlignment = StringAlignment.Center;
63 public String CustomText { get; set; }
65 private StringFormat Format { get; set; }
67 protected override void OnPaint(PaintEventArgs e)
69 // let the system do base work first
70 base.OnPaint(e);
71 // grab some tools
72 var rect = ClientRectangle;
73 var g = e.Graphics;
74 // draw the background
75 ProgressBarRenderer.DrawHorizontalBar(g, rect);
76 rect.Inflate(-3, -3);
77 // then chunk
78 if (Value > 0)
80 Rectangle clip = new Rectangle(rect.X, rect.Y, Value * rect.Width / Maximum, rect.Height);
81 ProgressBarRenderer.DrawHorizontalChunks(g, clip);
83 // append text
84 g.DrawString(CustomText, SystemFonts.DefaultFont, SystemBrushes.ControlText,
85 this.DisplayRectangle, Format);