Esempio n. 1
0
		/// <summary>
		/// Show a configuration dialog (modal) for JMDWriter
		/// </summary>
		/// <param name="threads">number of threads</param>
		/// <param name="complevel">compression level</param>
		/// <param name="tmin">minimum possible number of threads</param>
		/// <param name="tmax">maximum possible number of threads</param>
		/// <param name="cmin">minimum compression level, assumed to be "no compression"</param>
		/// <param name="cmax">maximum compression level</param>
		/// <param name="hwnd">hwnd of parent</param>
		/// <returns>false if user canceled; true if user consented</returns>
		public static bool DoCompressionDlg(ref int threads, ref int complevel, int tmin, int tmax, int cmin, int cmax, IWin32Window hwnd)
		{
			JMDForm j = new JMDForm();
			j.threadsBar.Minimum = tmin;
			j.threadsBar.Maximum = tmax;
			j.compressionBar.Minimum = cmin;
			j.compressionBar.Maximum = cmax;
			j.threadsBar.Value = threads;
			j.compressionBar.Value = complevel;
			j.threadsBar_Scroll(null, null);
			j.compressionBar_Scroll(null, null);
			j.threadLeft.Text = String.Format("{0}", tmin);
			j.threadRight.Text = String.Format("{0}", tmax);
			j.compressionLeft.Text = String.Format("{0}", cmin);
			j.compressionRight.Text = String.Format("{0}", cmax);

			DialogResult d = j.ShowDialog(hwnd);

			threads = j.threadsBar.Value;
			complevel = j.compressionBar.Value;

			j.Dispose();
			if (d == DialogResult.OK)
				return true;
			else
				return false;
		}
Esempio n. 2
0
        /// <summary>
        /// Show a configuration dialog (modal) for JMDWriter
        /// </summary>
        /// <param name="threads">number of threads</param>
        /// <param name="complevel">compression level</param>
        /// <param name="tmin">minimum possible number of threads</param>
        /// <param name="tmax">maximum possible number of threads</param>
        /// <param name="cmin">minimum compression level, assumed to be "no compression"</param>
        /// <param name="cmax">maximum compression level</param>
        /// <param name="hwnd">hwnd of parent</param>
        /// <returns>false if user canceled; true if user consented</returns>
        public static bool DoCompressionDlg(ref int threads, ref int complevel, int tmin, int tmax, int cmin, int cmax, IWin32Window hwnd)
        {
            JMDForm j = new JMDForm();

            j.threadsBar.Minimum     = tmin;
            j.threadsBar.Maximum     = tmax;
            j.compressionBar.Minimum = cmin;
            j.compressionBar.Maximum = cmax;
            j.threadsBar.Value       = threads;
            j.compressionBar.Value   = complevel;
            j.threadsBar_Scroll(null, null);
            j.compressionBar_Scroll(null, null);
            j.threadLeft.Text       = $"{tmin}";
            j.threadRight.Text      = $"{tmax}";
            j.compressionLeft.Text  = $"{cmin}";
            j.compressionRight.Text = $"{cmax}";

            DialogResult d = j.ShowDialog(hwnd);

            threads   = j.threadsBar.Value;
            complevel = j.compressionBar.Value;

            j.Dispose();
            if (d == DialogResult.OK)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        /// <summary>
        /// obtain a set of recording compression parameters
        /// </summary>
        /// <param name="hwnd">hwnd to attach to if the user is shown config dialog</param>
        /// <returns>codec token, dispose of it when you're done with it</returns>
        public IDisposable AcquireVideoCodecToken(System.Windows.Forms.IWin32Window hwnd)
        {
            CodecToken ret = new CodecToken();

            // load from config and sanitize
            int t = Math.Min(Math.Max(Global.Config.JMDThreads, 1), 6);

            int c = Math.Min(Math.Max(Global.Config.JMDCompression, Deflater.NO_COMPRESSION), Deflater.BEST_COMPRESSION);

            if (!JMDForm.DoCompressionDlg(ref t, ref c, 1, 6, Deflater.NO_COMPRESSION, Deflater.BEST_COMPRESSION, hwnd))
            {
                return(null);
            }

            Global.Config.JMDThreads     = ret.numthreads = t;
            Global.Config.JMDCompression = ret.compressionlevel = c;

            return(ret);
        }