本文整理匯總了C#中System.Drawing.Rectangle.IsValid方法的典型用法代碼示例。如果您正苦於以下問題:C# Rectangle.IsValid方法的具體用法?C# Rectangle.IsValid怎麽用?C# Rectangle.IsValid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Drawing.Rectangle
的用法示例。
在下文中一共展示了Rectangle.IsValid方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
Rectangle fillRect = new Rectangle(0, 0, ClientSize.Width, ClientSize.Height);
if (fillRect.IsValid())
{
using (LinearGradientBrush brush = new LinearGradientBrush(fillRect, Color.FromArgb(80, 80, 80), Color.FromArgb(40, 40, 40), LinearGradientMode.Vertical))
{
g.FillRectangle(brush, fillRect);
}
}
base.OnPaint(e);
}
示例2: StartRecording
public void StartRecording(TaskSettings taskSettings)
{
if (taskSettings.CaptureSettings.RunScreencastCLI)
{
if (!Program.Settings.VideoEncoders.IsValidIndex(taskSettings.CaptureSettings.VideoEncoderSelected))
{
MessageBox.Show("There is no valid CLI video encoder selected.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
else if (!Program.Settings.VideoEncoders[taskSettings.CaptureSettings.VideoEncoderSelected].IsValid())
{
MessageBox.Show("CLI video encoder file does not exist: " + Program.Settings.VideoEncoders[taskSettings.CaptureSettings.VideoEncoderSelected].Path,
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
if (taskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.FFmpeg)
{
if (!File.Exists(taskSettings.CaptureSettings.FFmpegOptions.CLIPath))
{
string ffmpegText = string.IsNullOrEmpty(taskSettings.CaptureSettings.FFmpegOptions.CLIPath) ? "ffmpeg.exe" : taskSettings.CaptureSettings.FFmpegOptions.CLIPath;
if (MessageBox.Show(ffmpegText + " does not exist." + Environment.NewLine + Environment.NewLine + "Would you like to automatically download it?",
Application.ProductName + " - Missing ffmpeg.exe", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
if (FFmpegHelper.DownloadFFmpeg(false, DownloaderForm_InstallRequested) == DialogResult.OK)
{
Program.DefaultTaskSettings.CaptureSettings.FFmpegOptions.CLIPath = taskSettings.TaskSettingsReference.CaptureSettings.FFmpegOptions.CLIPath =
taskSettings.CaptureSettings.FFmpegOptions.CLIPath = Path.Combine(Program.ToolsFolder, "ffmpeg.exe");
}
}
else
{
return;
}
}
if (!taskSettings.CaptureSettings.FFmpegOptions.IsSourceSelected)
{
MessageBox.Show("FFmpeg video and audio source both can't be \"None\".", Application.ProductName + " - FFmpeg error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
if (taskSettings.AdvancedSettings.ScreenRecorderUseActiveWindow)
{
ActiveWindowRegion(taskSettings);
}
else
{
SelectRegion();
}
captureRectangle = CaptureHelpers.EvenRectangleSize(captureRectangle);
if (IsRecording || !captureRectangle.IsValid() || screenRecorder != null)
{
return;
}
IsRecording = true;
Screenshot.CaptureCursor = taskSettings.CaptureSettings.ShowCursor;
TrayIcon.Text = "ShareX - Waiting...";
TrayIcon.Icon = Resources.control_record_yellow.ToIcon();
TrayIcon.Visible = true;
string path = "";
float duration = taskSettings.CaptureSettings.ScreenRecordFixedDuration ? taskSettings.CaptureSettings.ScreenRecordDuration : 0;
regionForm = ScreenRegionForm.Show(captureRectangle, StopRecording, duration);
TaskEx.Run(() =>
{
try
{
if (taskSettings.CaptureSettings.ScreenRecordAutoDisableAero)
{
dwmManager = new DWMManager();
dwmManager.AutoDisable();
}
if (taskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.AVI)
{
path = Path.Combine(taskSettings.CaptureFolder, TaskHelpers.GetFilename(taskSettings, "avi"));
}
else if (taskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.FFmpeg)
{
path = Path.Combine(taskSettings.CaptureFolder, TaskHelpers.GetFilename(taskSettings, taskSettings.CaptureSettings.FFmpegOptions.Extension));
}
else
{
path = Program.ScreenRecorderCacheFilePath;
}
ScreencastOptions options = new ScreencastOptions()
{
FFmpeg = taskSettings.CaptureSettings.FFmpegOptions,
AVI = taskSettings.CaptureSettings.AVIOptions,
//.........這裏部分代碼省略.........