Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor feature update #162

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion EDSEditorGUI/Form1.Designer.cs

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

67 changes: 49 additions & 18 deletions EDSEditorGUI/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ You should have received a copy of the GNU General Public License
using System.Windows.Forms;
using System.IO;
using libEDSsharp;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
//using static System.Windows.Forms.VisualStyles.VisualStyleElement;
//using SourceGrid.Cells.Controllers;
//using ToolTip = System.Windows.Forms.ToolTip;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe remove the commented code?


namespace ODEditor
{
Expand Down Expand Up @@ -189,6 +191,12 @@ private void openEDSfile(string path,InfoSection.Filetype ft)
{
EDSsharp eds = new EDSsharp();

if (!File.Exists(path))
{
MessageBox.Show("File " +path + "\ndoes not exist.");
return;
}

eds.Loadfile(path);

DeviceView device = new DeviceView(eds, network);
Expand Down Expand Up @@ -327,6 +335,11 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e)

private void openXDDfile(string path)
{
if (!File.Exists(path))
{
MessageBox.Show("File " + path + "\ndoes not exist.");
return;
}
try
{
EDSsharp eds;
Expand Down Expand Up @@ -449,13 +462,13 @@ private void Eds_onDataDirty(bool dirty, EDSsharp sender)
{
foreach(Control c in page.Controls)
{
if(c.GetType() == typeof(DeviceView))
if (c.GetType() == typeof(DeviceView))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (c.GetType() == typeof(DeviceView))
if(c.GetType() == typeof(DeviceView))

{
DeviceView d = (DeviceView)c;
if (d.eds.Dirty == true)
{
page.BackColor = Color.Tomato;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

else
{
page.BackColor = default(Color);
Expand Down Expand Up @@ -1329,34 +1342,52 @@ private void preferencesToolStripMenuItem_Click(object sender, EventArgs e)

private void tabControl1_MouseClick(object sender, MouseEventArgs e)
{
TabPage tp;
if (e.Button == MouseButtons.Right)
{
for (int i = 0; i <= tabControl1.TabCount - 1; i++)
{
if (tabControl1.GetTabRect(i).Contains(e.Location))
{
tp = tabControl1.TabPages[i];

DialogResult dialogResult = MessageBox.Show(tabControl1.TabPages[i].Text, "Close file?", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{

DeviceView device = (DeviceView)tabControl1.TabPages[i].Controls[0];

if (device.eds.Dirty == true)
{
if (MessageBox.Show("All unsaved changes will be lost\n continue?", "Unsaved changes", MessageBoxButtons.YesNo) == DialogResult.No)
return;
}

network.Remove(device.eds);

tabControl1.TabPages.Remove(tabControl1.TabPages[i]);
DeviceView device = (DeviceView)tabControl1.TabPages[i].Controls[0];
if (device.eds.Dirty == true)
{
if (MessageBox.Show("All unsaved changes will be lost\n continue?", "Unsaved changes", MessageBoxButtons.YesNo) == DialogResult.No)
return;
}
network.Remove(device.eds);
tabControl1.TabPages.Remove(tabControl1.TabPages[i]);
}
}
}
}
}
private void tabControl1_MouseHover(object sender, EventArgs e)
{

TabControl tabControl = sender as TabControl;
Point mousePosition = tabControl.PointToClient(Cursor.Position);
for (int i = 0; i < tabControl.TabCount; i++)
{
Rectangle tabRect = tabControl.GetTabRect(i);
if (tabRect.Contains(mousePosition))
{
ToolTip toolTip = new ToolTip();
// Set up the delays for the ToolTip.

toolTip.AutoPopDelay = 5000;
toolTip.InitialDelay = 1000;
toolTip.ReshowDelay = 500;
// Force the ToolTip text to be displayed whether or not the form is active.
toolTip.ShowAlways = true;
DeviceView device = (DeviceView)tabControl1.TabPages[i].Controls[0];
toolTip.SetToolTip(tabControl, device.eds.projectFilename);
break;
}
}
}

}
}
2 changes: 1 addition & 1 deletion EDSEditorGUI/Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
gqUTTxJHNd2gfCHts8Z5i7NeLLN6n/yF4ayxvMR1qkHEsYBFyBChoowNFOEgRrtBio0knUst/AOeXyaX
Sq4NMHLMowQdiucH/4Pfs7VzE+N+UlgC2l9c92MYCO0CtYrrfh+7bu0ECD4DV0bDX6oC05+kVxpa9Ajo
2QYurhuaugdc7gD9T6ZiKZ4UpBJyOeD9jL4pA/TeAp2r/tzq5zh9AFI0q8QNcHAIjOQpe63Fuzua5/bn
HW9+kH4AMgFyjcd8GS4AAAAJcEhZcwAACw4AAAsOAUC+4UEAAAAHdElNRQfkCwILIglO4xvLAAAAD3RF
HW9+kH4AMgFyjcd8GS4AAAAJcEhZcwAACwwAAAsMAT9AIsgAAAAHdElNRQfkCwILIglO4xvLAAAAD3RF
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need a little help with the changes here :D

WHRDb21tZW50AENBTm9wZW7cllV1AAAC8UlEQVRYR9WWz2sTQRTHkx6SQy5RxFv1JDGHogiVIkqFEqLE
QigetKY3iSUpPYh/gD8uoQiJIEKJ0UNNRZKjTaQiHozePAk21eagCC20NdW1plTa8X3f7mw3cZNuzSr6
hQ+8zn6/M29nZts6/hWdIu4T4xZJE2cJ23QvGAyKRCJhCXgp80CN2qNxTAyVP5QZZVXhn6H5mRlGCl5k
Expand Down
9 changes: 7 additions & 2 deletions libEDSsharp/CanOpenEDS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{
public partial class InfoSection
{
public virtual void Parse(Dictionary<string, string> section, string sectionname)

Check warning on line 31 in libEDSsharp/CanOpenEDS.cs

View workflow job for this annotation

GitHub Actions / build (net481, Release)

Missing XML comment for publicly visible type or member 'InfoSection.Parse(Dictionary<string, string>, string)'
{
this.section = section;

Expand Down Expand Up @@ -84,9 +84,9 @@
}
}

public partial class MandatoryObjects : SupportedObjects

Check warning on line 87 in libEDSsharp/CanOpenEDS.cs

View workflow job for this annotation

GitHub Actions / build (net481, Release)

Missing XML comment for publicly visible type or member 'MandatoryObjects'
{
public MandatoryObjects(Dictionary<string, string> section)

Check warning on line 89 in libEDSsharp/CanOpenEDS.cs

View workflow job for this annotation

GitHub Actions / build (net481, Release)

Missing XML comment for publicly visible type or member 'MandatoryObjects.MandatoryObjects(Dictionary<string, string>)'
: this()
{
Parse(section);
Expand Down Expand Up @@ -825,8 +825,13 @@
int lineno = 1;
foreach (string linex in System.IO.File.ReadLines(filename))
{
Parseline(linex, lineno);
lineno++;
try
{
Parseline(linex, lineno);
lineno++;
}
catch (Exception) { Warnings.warning_list.Add("Failed to open file \n" + filename);}

}

di = new DeviceInfo(eds["DeviceInfo"]);
Expand Down
10 changes: 9 additions & 1 deletion libEDSsharp/CanOpenXDD_1_1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,16 @@ public EDSsharp ReadXML(string file)
dev = (ISO15745ProfileContainer)serializer.Deserialize(reader);
reader.Close();
}
catch (Exception)
catch (Exception e)
{
if (e is System.InvalidOperationException)
{
Warnings.warning_list.Add(String.Format("{0} {1} Action aborted!", e.Message, e.InnerException.Message));
}
else
{
Warnings.warning_list.Add(String.Format("{0} Action aborted!", e.ToString()));
}
return null;
}

Expand Down
Loading