Skip to content

Commit

Permalink
Simplyfies layout
Browse files Browse the repository at this point in the history
  • Loading branch information
rappen committed Aug 2, 2021
1 parent 13f657b commit f25aaec
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 330 deletions.
1 change: 0 additions & 1 deletion XRMTokensRun/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace XRMTokensRun
/// </remarks>
public class Settings
{
public bool ExeAuto { get; set; }
public string Table { get; set; }
public List<KeyValuePair> Token { get; set; } = new List<KeyValuePair>();
}
Expand Down
76 changes: 5 additions & 71 deletions XRMTokensRun/XRMTR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Rappen.XTB.Helpers.Extensions;
using System;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using XrmToolBox.Extensibility;
Expand Down Expand Up @@ -72,7 +71,6 @@ private void LoadSetting()
{
settings = new Settings();
}
chkAuto.Checked = settings.ExeAuto;
}

private void SaveSettings()
Expand All @@ -81,7 +79,6 @@ private void SaveSettings()
{
settings = new Settings();
}
settings.ExeAuto = chkAuto.Checked;
settings.Table = tableselect.SelectedEntity.LogicalName;
if (settings.Token?.FirstOrDefault(t => t.key == tableselect.SelectedEntity.LogicalName) is KeyValuePair token)
{
Expand All @@ -98,7 +95,6 @@ private void Enable(bool on)
{
tableselect.Enabled = on && Service != null;
btnGetRecord.Enabled = on && tableselect.SelectedEntity != null;
gbTokenHelp.Enabled = on && record?.Record != null;
gbTokens.Enabled = on && record?.Record != null;
btnAddToken.Enabled = on && record?.Record != null && cmbTokenHelp.SelectedItem is TokenHelp;
btnSmartToken.Enabled = on && record?.Record != null && cmbTokenHelp.SelectedItem is TokenHelp;
Expand All @@ -108,7 +104,6 @@ private void tableselect_SelectedIndexChanged(object sender, EventArgs e)
{
var entity = tableselect.SelectedEntity;
record.Record = null;
ShowColumns();
if (entity != null && settings != null)
{
var token = settings.Token?.FirstOrDefault(t => t.key == entity.LogicalName)?.value;
Expand All @@ -117,7 +112,7 @@ private void tableselect_SelectedIndexChanged(object sender, EventArgs e)
Enable(true);
}

private void btnGetRecurd_Click(object sender, EventArgs e)
private void btnGetRecord_Click(object sender, EventArgs e)
{
var look = new XRMLookupDialog
{
Expand All @@ -126,13 +121,9 @@ private void btnGetRecurd_Click(object sender, EventArgs e)
};
if (look.ShowDialog() == DialogResult.OK)
{
record.Record = look.Record;
}
ShowColumns();
if (chkAuto.Checked)
{
Execute();
record.Record = Service.Retrieve(look.Record.LogicalName, look.Record.Id, new ColumnSet(true));
}
Execute();
Enable(true);
}

Expand All @@ -156,52 +147,11 @@ private void Execute()
}
}

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("https://jonasr.app/xrm-tokens/");
}

private void toolStripLabel1_Click(object sender, EventArgs e)
{
Process.Start("https://jonasr.app/xrm-tokens/");
}

private void btnReload_Click(object sender, EventArgs e)
{
var rec = Service.Retrieve(record.Record.LogicalName, record.Record.Id, new ColumnSet(true));
record.Record = null;
record.Record = rec;
ShowColumns();
}

private void ShowColumns()
{
lstRecord.Items.Clear();
if (record.Record != null)
{
lstRecord.Items.AddRange(record.Record.Attributes.Keys.OrderBy(k => k).Select(k => new ListViewItem(k)).ToArray());
}
}

private void lstRecord_DoubleClick(object sender, EventArgs e)
{
if (lstRecord.SelectedItems == null || lstRecord.SelectedItems.Count == 0)
{
return;
}
txtTokensIn.Text += "{" + lstRecord.SelectedItems[0].Text + "}";
}

private void toolStripButton1_Click(object sender, EventArgs e)
{
Execute();
}

private void chkAuto_CheckedChanged(object sender, EventArgs e)
{
Auto();
}

private void timer1_Tick(object sender, EventArgs e)
{
Execute();
Expand All @@ -215,24 +165,7 @@ private void txtTokensIn_TextChanged(object sender, EventArgs e)
private void Auto()
{
timer1.Stop();
if (chkAuto.Checked)
{
timer1.Start();
}
}

private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
AddToken("columb");
}

private void AddToken(string token)
{
var pos = txtTokensIn.SelectionStart;
txtTokensIn.Paste("{" + token + "}");
txtTokensIn.SelectionStart = pos + 1;
txtTokensIn.SelectionLength = token.Length;
txtTokensIn.Focus();
timer1.Start();
}

private void btnAddToken_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -274,6 +207,7 @@ private string GetSmartToken(string tokentype)
{
case "column":
return GetColumn(false);

case "columnraw":
return GetColumn(true);
}
Expand Down
Loading

0 comments on commit f25aaec

Please sign in to comment.