private void alphaToolStripMenuItem_Click(object sender, EventArgs e) { ToolStripMenuItem tsmi = (ToolStripMenuItem)sender; Visualisable vis = (Visualisable)tsmi.Tag; this._sourceList.ActivateItem(vis); }
/// <summary> /// Generates a unique name /// </summary> public string Name(Visualisable x) { string name; if (this._names.TryGetValue(x, out name)) { return(name); } name = x.DefaultDisplayName; int index = 0; string type = x.GetType().Name + "."; bool renamed = false; while (this._used.Contains(type + name)) { renamed = true; name = x.DefaultDisplayName + "." + ++index; } this._used.Add(type + name); this._names.Add(x, name); if (renamed) { this.Renamed.Add(x); } return(name); }
/// <summary> /// Private helper method: Gets comment for an IVisualisable /// </summary> private static string _GetComment(Visualisable vis) { if (!string.IsNullOrEmpty(vis.Comment)) { return("Comments: " + vis.Comment); } return(null); }
private void listView1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete && this.listView1.SelectedIndices.Count != 0) { Visualisable item = _items[this.listView1.SelectedIndices[0]]; item.Hidden = !item.Hidden; listView1.Refresh(); } }
private void listView1_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) { Visualisable item = this._items[e.ItemIndex]; e.Item = new ListViewItem(item.DisplayName); e.Item.ImageIndex = this.GeneratePreviewImage(item); if (item.Hidden) { e.Item.ForeColor = Color.Gray; e.Item.Font = FontHelper.StrikeFont; } }
internal StylisedCluster CreateStylisedCluster(Core core, Visualisable toHighlight) { Cluster fakeCluster = new Cluster(this.DisplayName, null); fakeCluster.Assignments.Add(this); StylisedCluster c = new StylisedCluster(fakeCluster, this, null); c.IsFake = true; c.CaptionFormat = "Plot of {0}."; return(c); }
/// <summary> /// Updates the item /// </summary> private void DoUpdate(ListViewItem lvi, object tag) { Visualisable vis = tag as Visualisable; // Update icon lvi.ImageKey = this._imageList.GetAssociatedImageKey(tag, () => this.GeneratePreviewImage(tag)); // Update columns foreach (ColumnHeader h in this._listView.Columns) { Column c = (Column)h.Tag; System.Diagnostics.Debug.Assert(c.Visible); if (!c.IsAlwaysEmpty) { ListViewItem.ListViewSubItem lvsi = new ListViewItem.ListViewSubItem(); string result = c.GetRowAsString(tag); Color color; if (vis?.Hidden ?? false) { lvsi.Font = FontHelper.ItalicFont; color = Color.Gray; } else { lvsi.Font = FontHelper.RegularFont; color = c.GetColour(tag); } lvsi.Text = result; lvsi.ForeColor = color; lvi.SubItems.Add(lvsi); } } // Invert selection? if (lvi.Selected) { this.Invert(lvi); } }
public static Bitmap CreatePlaceholderBitmap(object x, Size sz) { Visualisable xx = x as Visualisable; int width = sz.Width; int height = sz.Height; Bitmap result = new Bitmap(width, height); using (Graphics g = Graphics.FromImage(result)) { g.Clear(Color.LightGray); g.DrawLine(Pens.Silver, 0, 0, width, height); g.DrawLine(Pens.Silver, width, 0, 0, height); Image icon = UiControls.EmboldenImage(xx?.Icon ?? Resources.IconUnknown); Rectangle rect = new Rectangle(sz.Width / 2 - icon.Width / 2, sz.Height / 2 - icon.Height / 2, icon.Width, icon.Height); g.FillRectangle(Brushes.White, rect); g.DrawImage(icon, rect); g.DrawRectangle(Pens.Silver, rect); } return(result); }
private int GeneratePreviewImage(Visualisable item) { int index; if (item.Hidden) { return(0); } if (!this._imgListPreviewIndexes.TryGetValue(item, out index)) { Image img = this._previewProvider.ProvidePreview(this._imageSize, item) ?? ChartHelperForClusters.CreatePlaceholderBitmap(item, this._imageSize); index = this.imageList1.Images.Count; this.imageList1.Images.Add(item.DisplayName, img); this._imgListPreviewIndexes.Add(item, index); } return(index); }
private void Export(string fileName, IDataSet x) { IEnumerable utlist = x.UntypedGetList(false); Visualisable[] list; if (utlist.FirstOrDefault2() is Visualisable) { list = utlist.Cast <Visualisable>().ToArray(); } else { list = utlist.Cast <object>().Select(z => new VisualisableWrapper(x, z)).ToArray(); } Column[] columns = ColumnManager.GetColumns(this._core, list[0]).Where(z => z.Special != EColumn.Advanced).ToArray(); Spreadsheet <string> ss = new Spreadsheet <string>(list.Length, columns.Length); for (int nObs = 0; nObs < columns.Length; ++nObs) { ss.ColNames[nObs] = columns[nObs].Id; } for (int nPeak = 0; nPeak < list.Length; ++nPeak) { Visualisable peak = list[nPeak]; ss.RowNames[nPeak] = this._uniqueTable.Name(peak); for (int nObs = 0; nObs < columns.Length; ++nObs) { ss[nPeak, nObs] = Column.AsString(columns[nObs].GetRow(peak), EListDisplayMode.Content); } } ss.SaveCsv(fileName); }
private void _selectionButtonMenu_Opening(object senderu, EventArgs e) { ToolStripDropDownButton sender = (ToolStripDropDownButton)senderu; sender.DropDownItems.Clear(); HashSet <Visualisable> items = new HashSet <Visualisable>(); foreach (MCharting.Series series in this._chart.SelectedItem.Series) { Visualisable visualisable = series.Tag as Visualisable; if (visualisable == null || items.Contains(visualisable)) { continue; } items.Add(visualisable); ToolStripItem mnuSelectSelection = sender.DropDownItems.Add("Navigate to " + visualisable.DisplayName, null, this._menu_navigateTo); mnuSelectSelection.Font = new Font(mnuSelectSelection.Font, FontStyle.Bold); mnuSelectSelection.Tag = visualisable; mnuSelectSelection.Enabled = this._selector != null; } }
/// <summary> /// Private helper method: Gets display name for an IVisualisable /// </summary> private static string _GetDisplayName(Visualisable z) { return(z.DisplayName); }
public static string AsString(object result, EListDisplayMode listDisplayMode) { if (result == null) { return(""); } if (result is string) { return((string)result); } if (result is IEnumerable) { ICollection col = result as ICollection; IEnumerable enu = (IEnumerable)result; int count; if (col != null) { count = col.Count; } else { count = enu.CountAll(); } switch (listDisplayMode) { case EListDisplayMode.Smart: if (count == 1) { return(AsString(enu.FirstOrDefault2())); } else if (count == 0) { return(""); } else { return("(" + count.ToString() + ")"); } case EListDisplayMode.Count: return(count.ToString()); case EListDisplayMode.CountAndContent: return("(" + count.ToString() + ") " + StringHelper.ArrayToString(enu, AsString)); case EListDisplayMode.Content: return(StringHelper.ArrayToString(enu, AsString)); } } if (result is Visualisable) { Visualisable v = (Visualisable)result; return(v.DisplayName); } if (result is double) { double d = (double)result; if (double.IsNaN(d)) { return(""); } return(Maths.SignificantDigits(d)); } if (result is int) { if ((int)result == 0) { return(""); } else { return(result.ToString()); } } if (result is bool) { if ((bool)result) { return("☑"); } else { return("☐"); } } if (result is Type) { return(((Type)result).ToUiString()); } if (result is WeakReference) { object t = ((WeakReference)result).Target; if (t == null) { return("(Expired reference)"); } return("&" + AsString(t, listDisplayMode)); } if (ReflectionHelper.IsOfGenericType(result, typeof(WeakReference <>))) { object t = WeakReferenceHelper.GetUntypedTarget(result); if (t == null) { return("(Expired reference)"); } return("&" + AsString(t, listDisplayMode)); } return(result.ToString()); }
public HighlightElement(Visualisable visualisable, GroupInfo group) { this.Peak = visualisable; this.Group = group; }
private static MCharting.Series GetOrCreateSeriesForValue(MCharting.Plot plot, Column column, Visualisable vis, ref bool isGroup) { object value = column.GetRow(vis); MCharting.Series series = plot.Series.FirstOrDefault(z => (z.Tag == null && value == null) || (z.Tag != null && z.Tag.Equals(value))); if (series == null) { series = new MCharting.Series(); series.Name = Column.AsString(value, column.DisplayMode); series.Tag = value; if (value is GroupInfoBase) { GroupInfoBase group = (GroupInfoBase)value; UiControls.CreateIcon(series, group); isGroup = true; } else { series.Style.DrawPoints = new SolidBrush(column.GetColour(vis)); } plot.Series.Add(series); } return(series); }
private void ListView_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete) { Visualisable selection = this.Selection as Visualisable; if (selection != null) { selection.Hidden = !selection.Hidden; e.Handled = true; return; } } if (this._core.Options.EnablePeakFlagging) { foreach (UserFlag f in this._core.Options.UserFlags) { if (f.Key == (char)e.KeyCode) { IFlaggable flaggable = this.Selection as IFlaggable; if (flaggable == null) { FrmMsgBox.ShowInfo(_listView.FindForm(), "Toggle flag", $"You have bound the key \"{f.Key}\" to toggle the \"{f.DisplayName}\" flag, but the selection in the list does not support flags.", FrmMsgBox.EDontShowAgainId.ToggleFlagFailed); return; } NativeMethods.Beep(f.BeepFrequency, f.BeepDuration); if (e.Control) { bool add = !flaggable.UserFlags.Contains(f); if (FrmMsgBox.ShowOkCancel(_listView.FindForm(), f.ToString(), (add ? "Apply this flag to" : "Remove this flag from") + " all peaks shown in list?")) { foreach (object xx in this.GetVisible()) { IFlaggable peak = xx as IFlaggable; if (peak == null) { continue; } if (add) { if (!peak.UserFlags.Contains(f)) { peak.UserFlags.Add(f); } } if (!add) { if (peak.UserFlags.Contains(f)) { peak.UserFlags.Remove(f); } } } this.Rebuild(EListInvalids.ValuesChanged); } } else { if (!flaggable.UserFlags.Contains(f)) { flaggable.UserFlags.Add(f); } else { flaggable.UserFlags.Remove(f); } this.Update(flaggable); } e.Handled = true; return; } } } }