Skip to content

Commit

Permalink
Add api call to change grid view remotely
Browse files Browse the repository at this point in the history
  • Loading branch information
ispysoftware committed Jan 1, 2022
1 parent 2a7f9ac commit d600118
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
23 changes: 20 additions & 3 deletions GridView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ namespace iSpyApplication
{
public partial class GridView : Form
{
private readonly Controls.GridView _gv;
private readonly configurationGrid _layout;
private Controls.GridView _gv;
private configurationGrid _layout;
public configurationGrid Cg;
private PersistWindowState _mWindowState;
private MainForm _mainForm;

public GridView(MainForm parent, ref configurationGrid layout)
{
_mainForm = parent;
InitializeComponent();
_gv = new Controls.GridView(parent, ref layout, this);
_gv = new Controls.GridView(_mainForm, ref layout, this);
_gv.KeyDown += GridView_KeyDown;
Controls.Add(_gv);
_gv.Dock = DockStyle.Fill;
Expand All @@ -35,6 +37,21 @@ public GridView(MainForm parent, ref configurationGrid layout)

}

public void Reinit(ref configurationGrid layout)
{
Controls.Remove(_gv);
_gv.Dispose();

_gv = new Controls.GridView(_mainForm, ref layout, this);
_gv.KeyDown += GridView_KeyDown;
Controls.Add(_gv);

_gv.Dock = DockStyle.Fill;
_layout = layout;
Cg = layout;
Text = _gv.Text;
}

private void RenderResources()
{
LocRm.SetString(editToolStripMenuItem, "Edit");
Expand Down
27 changes: 27 additions & 0 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,33 @@ private void MainInit()
_houseKeepingTimer.Start();
}

public void ShowGridViewRemote(string index)
{
if (InvokeRequired)
{
Invoke(new Delegates.ExternalCommandDelegate(ShowGridViewRemote), index);
return;
}

int ind = Convert.ToInt32(index);
var cg = Conf.GridViews.ToList()[ind];
if (cg != null)
{
if (_views.Count==0)
{
var gv = new GridView(this, ref cg);
gv.Show();
gv.BringToFront();
gv.Focus();
_views.Add(gv);
return;
}
_views[0].Reinit(ref cg);
_views[0].BringToFront();
_views[0].Focus();
}

}
internal void ShowGridView(string name)
{
configurationGrid cg = Conf.GridViews.FirstOrDefault(p => p.name == name);
Expand Down
7 changes: 7 additions & 0 deletions Server/LocalServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2432,6 +2432,13 @@ private string DoCommand(string sRequest, int otid, string resp, string cmd, int
}
resp = "OK";
break;
case "showgridview":
{
string index = GetVar(sRequest, "index");
MainForm.InstanceReference.ShowGridViewRemote(index);
resp = "OK";
}
break;
case "getgrabs":
sd = GetVar(sRequest, "startdate");
ed = GetVar(sRequest, "enddate");
Expand Down

0 comments on commit d600118

Please sign in to comment.