Skip to content

Commit

Permalink
add scrollbar
Browse files Browse the repository at this point in the history
  • Loading branch information
luvletter2333 committed May 15, 2021
1 parent db554a5 commit 59ea9a9
Show file tree
Hide file tree
Showing 5 changed files with 637 additions and 46 deletions.
144 changes: 144 additions & 0 deletions Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 51 additions & 8 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ enum RenderMode
RenderConfig NDI_Config;
NDIRender Renderer;
CancellationTokenSource cancelNDI;
float Font_Size;


//Screen Output
Expand Down Expand Up @@ -74,17 +73,19 @@ private void Form1_Load(object sender, EventArgs e)
else
NDI_Config = new RenderConfig(true);
if (Config.ContainsKey("Font-Size"))
Font_Size = Convert.ToSingle(Config["Font-Size"].ToString());
NDI_Config.fontSize = Convert.ToSingle(Config["Font-Size"].ToString());
else
Font_Size = 50;
NDI_Config.fontSize = 50;
}
catch (Exception ex)
{
Console.WriteLine("Reading Config File Failed");
Console.WriteLine(ex.ToString());
NDI_Config = new RenderConfig(true);
Font_Size = 50;
NDI_Config.fontSize = 50;
}
scroll_fontSize.Value = (int)NDI_Config.fontSize;

}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
Expand Down Expand Up @@ -159,7 +160,7 @@ private void btn_start_Click(object sender, EventArgs e)
if (Renderer != null)
return;
cancelNDI = new CancellationTokenSource();
Renderer = new NDIRender(cancelNDI.Token, NDI_Config, new Font(new FontFamily(cmb_Fonts.SelectedItem.ToString()), Font_Size));
Renderer = new NDIRender(cancelNDI.Token, NDI_Config, new Font(new FontFamily(cmb_Fonts.SelectedItem.ToString()), NDI_Config.fontSize));
Task.Run(async () => await Renderer.Run());
lb_Status.ForeColor = Color.Green;
lb_Status.Text = "NDI On";
Expand Down Expand Up @@ -269,10 +270,10 @@ private void cmb_Fonts_SelectedIndexChanged(object sender, EventArgs e)
if (render_mode == RenderMode.FullScreen)
{
if (render_form != null)
render_form.ChangeFont(new Font(new FontFamily(cmb.SelectedItem.ToString()), Font_Size));
render_form.ChangeFont(new FontFamily(cmb.SelectedItem.ToString()));
}
else if (Renderer != null)
Renderer.ChangeFont(new Font(new FontFamily(cmb.SelectedItem.ToString()), Font_Size));
Renderer.ChangeFont(new Font(new FontFamily(cmb.SelectedItem.ToString()), NDI_Config.fontSize));
}
}

Expand Down Expand Up @@ -430,7 +431,7 @@ private void btn_scnStart_Click(object sender, EventArgs e)
{
if (cmb_monitor.Enabled == false) //has locked
{
render_form = new Render_Form(display_screen, scn_width, scn_height, new Font(new FontFamily(cmb_Fonts.SelectedItem.ToString()), Font_Size), NDI_Config);
render_form = new Render_Form(display_screen, scn_width, scn_height, new Font(new FontFamily(cmb_Fonts.SelectedItem.ToString()), NDI_Config.fontSize), NDI_Config);
render_form.Run(50.0f, 50.0f);
}
else
Expand Down Expand Up @@ -467,6 +468,45 @@ private void rdo_Render_FullScreen_CheckedChanged(object sender, EventArgs e)

}

private void scroll_sub1X_Scroll(object sender, ScrollEventArgs e)
{
NDI_Config.Point_Sub1.X = e.NewValue;
txt_sub1X.Text = e.NewValue + ""; NotifyChanges();
}

private void scroll_sub1Y_Scroll(object sender, ScrollEventArgs e)
{
NDI_Config.Point_Sub1.Y = e.NewValue;
txt_sub1Y.Text = e.NewValue + ""; NotifyChanges();
}
private void hScrollBar3_Scroll(object sender, ScrollEventArgs e)
{
NDI_Config.Point_Sub2.X = e.NewValue;
txt_sub2X.Text = e.NewValue + ""; NotifyChanges();
}

private void hScrollBar4_Scroll(object sender, ScrollEventArgs e)
{
NDI_Config.Point_Sub2.Y = e.NewValue;
txt_sub2Y.Text = e.NewValue + ""; NotifyChanges();
}

private void NotifyChanges()
{
if (render_mode == RenderMode.FullScreen)
{
if (render_form != null)
render_form.onChanged(NDI_Config);
}
}

private void scroll_fontSize_Scroll(object sender, ScrollEventArgs e)
{
NDI_Config.fontSize = e.NewValue / 10.0f;
txt_fontSize.Text = e.NewValue / 10.0f + "";
NotifyChanges();
}

// TODO: Add lock
private void btn_lock_screen_Click(object sender, EventArgs e)
{
Expand All @@ -480,6 +520,9 @@ private void btn_lock_screen_Click(object sender, EventArgs e)
display_screen = DisplayDevice.GetDisplay((DisplayIndex)id);
scn_height = Convert.ToInt32(txt_screen_height.Text);
scn_width = Convert.ToInt32(txt_screen_width.Text);
scroll_sub1X.Maximum = scroll_sub2X.Maximum = scn_height;
scroll_sub1Y.Maximum = scroll_sub2Y.Maximum = scn_width;

cmb_monitor.Enabled = false;
btn_lock_screen.Text = "Locked";
btn_lock_screen.ForeColor = Color.Green;
Expand Down
Loading

0 comments on commit 59ea9a9

Please sign in to comment.