Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
mjr129 committed Nov 1, 2016
1 parent f9f244b commit 3d10d67
Show file tree
Hide file tree
Showing 61 changed files with 3,162 additions and 1,335 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected override IEnumerable<Cluster> Cluster( IntensityMatrix vmatrix, Distan
// SEED GROUP
GroupInfo groupInfo = (GroupInfo)tag.UntypedArgs.Parameters[3];
// DO-K-MEANS?
bool doKMeans = (int)tag.UntypedArgs.Parameters[4] != 0;
bool doKMeans = (bool)tag.UntypedArgs.Parameters[4];

// Create the seed cluster
Cluster seedCluster = new Cluster("1", tag);
Expand Down Expand Up @@ -150,7 +150,7 @@ protected override AlgoParameterCollection CreateParamaterDesription()
new AlgoParameter("d", "Minimum distance between exemplars before no more are selected (use MIN for no limit)", AlgoParameterTypes.Double),
new AlgoParameter("seed.peak", "The peak to act as the first exemplar", AlgoParameterTypes.WeakRefPeak),
new AlgoParameter("seed.group", "The group to act as the first exemplar (only if one vector is generated per group, otherwise this is ignored)", AlgoParameterTypes.Group),
new AlgoParameter("use.kmeans", "Whether to perform k-means after the exemplars have been selected (0 = no, 1 = yes).", AlgoParameterTypes.Integer)
new AlgoParameter("use.kmeans", "Whether to perform k-means after the exemplars have been selected (0 = no, 1 = yes).", AlgoParameterTypes.Boolean)
);
}

Expand Down
58 changes: 57 additions & 1 deletion MetaboliteLevels/Data/Algorithms/General/EAlgoParameterType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ internal interface IAlgoParameterType
internal static class AlgoParameterTypes
{
public static IAlgoParameterType Integer = new _Integer();
public static IAlgoParameterType Boolean = new _Boolean();
public static IAlgoParameterType Double = new _Double();
public static IAlgoParameterType WeakRefStatisticArray = new _WeakRefStatisticArray();
public static IAlgoParameterType WeakRefPeak = new _WeakRefPeak();
Expand Down Expand Up @@ -177,7 +178,62 @@ public string TryToString( object x )
}

internal abstract string OnTryToString( T x );
}
}

private class _Boolean : _AlgoParameterType<bool>
{
public override IEnumerable<string> Aliases => new[] { "Boolean", "Bool" };

protected override object OnBrowse( Form owner, Core _core, object value )
{
MsgBoxButton[] btns =
{
new MsgBoxButton( "YES", Resources.MnuUp, DialogResult.Yes ),
new MsgBoxButton( "NO", Resources.MnuDown, DialogResult.No ),
new MsgBoxButton( "Cancel", Resources.MnuCancel, DialogResult.Cancel )
};

switch (FrmMsgBox.Show( owner, "Select Value", null, "Select a value", Resources.MsgHelp, btns, DialogResult.Cancel, DialogResult.Cancel ))
{
case DialogResult.Yes:
return (object)true;

case DialogResult.No:
return (object)false;

default:
return null;
}
}

protected override object OnFromString( FromStringArgs args )
{
switch (args.Text.ToUpper())
{
case "1":
case "YES":
case "Y":
case "TRUE":
case "T":
return true;

case "0":
case "NO":
case "N":
case "FALSE":
case "F":
return false;

default:
return null;
}
}

internal override string OnTryToString( bool x )
{
return x ? "Yes" : "No";
}
}

private class _Integer : _AlgoParameterType<int>
{
Expand Down
13 changes: 11 additions & 2 deletions MetaboliteLevels/Gui/Controls/Charts/ChartHelperForPeaks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ private void AddUpperAndLowerShade(
}
}

/// <summary>
/// Adds the mean and standard deviation lines to the plot.
/// </summary>
/// <param name="plot">Target plot</param>
/// <param name="o">Options</param>
/// <param name="observations">Set of observations</param>
/// <param name="peak">Peak being plotted</param>
/// <param name="groupLegends">Dictionary to get group legends from</param>
private void AddMeanAndSdLines(
MCharting.Plot plot,
StylisedPeakOptions o,
Expand Down Expand Up @@ -331,8 +339,9 @@ private void AddMeanAndSdLines(
sMin.Style.DrawLines = new Pen( c, this._core.Options.LineWidth );
sMax.Style.DrawLines = new Pen( c, this._core.Options.LineWidth );

sMin.Style.DrawLines.DashStyle = DashStyle.Dot;
sMax.Style.DrawLines.DashStyle = DashStyle.Dot;
sMean.Style.DrawLines.DashStyle = DashStyle.Dash;
sMin.Style.DrawLines.DashStyle = DashStyle.Dash;
sMax.Style.DrawLines.DashStyle = DashStyle.Dash;

// Add the points
AddDataPoint( sMean, xLeft, yMean, @group );
Expand Down
11 changes: 6 additions & 5 deletions MetaboliteLevels/Gui/Controls/CtlContextHelpInner.Designer.cs

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

2 changes: 1 addition & 1 deletion MetaboliteLevels/Gui/Controls/EditableComboBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public bool Enabled
{
get
{
return this.ComboBox.Enabled && this._button.Enabled;
return this.ComboBox.Enabled;
}
set
{
Expand Down
10 changes: 6 additions & 4 deletions MetaboliteLevels/Gui/Forms/Activities/FrmActDataLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,13 @@ private static void Load_3_Adducts( FileLoadInfo dataInfo, List<Adduct> adducts,

if (fileName.StartsWith( "resx:\\\\" ))
{
using (var s = Resx.Scripts.ResourceManager.GetStream( fileName.Substring( 7 ) ))
{
using (StreamReader sr = new StreamReader( s ))
byte[] text = (byte[])Resx.Scripts.ResourceManager.GetObject( fileName.Substring( 7 ) );

using (MemoryStream ms = new MemoryStream( text ))
{
using (StreamReader sr = new StreamReader( ms ))
{
mat = reader.Read<string>( sr, fileName );
mat = reader.Read<string>( sr, fileName );
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion MetaboliteLevels/Gui/Forms/Activities/FrmActPca.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using MetaboliteLevels.Data.Session.General;
using MetaboliteLevels.Data.Session.Main;
using MetaboliteLevels.Gui.Controls.Lists;
using MetaboliteLevels.Gui.Forms.Editing;
using MetaboliteLevels.Gui.Forms.Selection;
using MetaboliteLevels.Utilities;
using MGui.Datatypes;
Expand Down Expand Up @@ -734,7 +735,9 @@ private void _btnColour_DropDownOpening(object sender, EventArgs e)

default:
throw new SwitchException(this.WhatPlotting);
}
}

FrmEditColumns.Show( this, columns, selected );

foreach (Column column in columns)
{
Expand Down
2 changes: 1 addition & 1 deletion MetaboliteLevels/Gui/Forms/Activities/FrmMain.Designer.cs

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

2 changes: 1 addition & 1 deletion MetaboliteLevels/Gui/Forms/Activities/FrmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public FrmMain()
this._btnSubAnnot.Tag = EVisualClass.Annotation;
this._btnSubAss.Tag = EVisualClass.Assignment;
this._btnSubComp.Tag = EVisualClass.Compound;
this._btnSubInfo.Tag = EVisualClass.SpecialMeta;
this._btnSubInfo.Tag = EVisualClass.SpecialAll;
this._btnSubStat.Tag = EVisualClass.SpecialStatistic;
this._btnSubPat.Tag = EVisualClass.Cluster;
this._btnSubPeak.Tag = EVisualClass.Peak;
Expand Down
11 changes: 9 additions & 2 deletions MetaboliteLevels/Gui/Forms/Editing/FrmDebug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,15 @@ private void AddMethod( string p, MethodInvoker invoker, string description )
lvi.SubItems[1].ForeColor = Color.Gray;

this.listView1.Items.Add( lvi );
}

}

[InList]
[Description( "Throws an unhandled exception (crashes the program)." )]
void unhandled_exception()
{
throw new InvalidOperationException( "This exception is intentionally unhandled." );
}

[InList]
[Description( "Creates a cluster from each of the pathways, allowing you to explore pathways as you do with clusters." )]
void create_clusters_from_pathways()
Expand Down
34 changes: 32 additions & 2 deletions MetaboliteLevels/Gui/Forms/Editing/FrmEditColumns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,22 @@ internal partial class FrmEditColumns : Form
private readonly HashSet<Column> _selected;
private readonly HashSet<object> _view = new HashSet<object>();

public static Column Show( IWin32Window owner, IEnumerable<Column> available, Column selected )
{
using (FrmEditColumns frm = new FrmEditColumns( available, new[] { selected }, false ))
{
if (frm.ShowDialog( owner ) == DialogResult.OK)
{
return frm._selected.FirstOrDefault();
}

return null;
}
}

public static HashSet<Column> Show( IWin32Window owner, IEnumerable<Column> available, IEnumerable<Column> selected )
{
using (FrmEditColumns frm = new FrmEditColumns( available, selected ))
using (FrmEditColumns frm = new FrmEditColumns( available, selected, true ))
{
if (frm.ShowDialog( owner ) == DialogResult.OK)
{
Expand All @@ -32,7 +45,7 @@ public static HashSet<Column> Show( IWin32Window owner, IEnumerable<Column> avai
}
}

internal FrmEditColumns(IEnumerable<Column> available, IEnumerable<Column> selected )
internal FrmEditColumns(IEnumerable<Column> available, IEnumerable<Column> selected, bool multiSelect )
{
this.InitializeComponent();
UiControls.SetIcon( this );
Expand All @@ -48,6 +61,8 @@ internal FrmEditColumns(IEnumerable<Column> available, IEnumerable<Column> selec
this._chkDefault.ForeColor = ColumnManager.COLCOL_VISIBLE;
this._chkFolders.ForeColor = ColumnManager.COLCOL_FOLDER;

this._multiSelect = multiSelect;

_view.AddRange( new[] { _chkMetaFields , _chkNormal , _chkStatistics, _chkDefault, _chkFolders } );

ctlContextHelp1.Bind( this, ctlTitleBar1, null, CtlContextHelp.EFlags.None );
Expand Down Expand Up @@ -199,6 +214,7 @@ public void AllNodes( List<TreeNode> all, TreeNodeCollection col )
}

bool _ignoreCheck = false;
private readonly bool _multiSelect;

private void treeView1_AfterCheck( object sender, TreeViewEventArgs e )
{
Expand All @@ -207,6 +223,20 @@ private void treeView1_AfterCheck( object sender, TreeViewEventArgs e )
return;
}

if (!_multiSelect)
{
if (e.Node.Nodes.Count != 0)
{
e.Node.Checked = false;
return;
}

foreach (TreeNode node in treeView1.GetAllNodes() )
{
node.Checked = node == e.Node;
}
}

Column col = e.Node.Tag as Column;

if (col != null)
Expand Down
Loading

0 comments on commit 3d10d67

Please sign in to comment.