private void Diagram_BeginNodeRender(object sender, BeginNodeRenderEventArgs args) { var node = args.Item; node.ShapeType = ShapeType.RoundedRectangle; node.Style.StrokeWidth = 0; if ((node.Content as Employee).Designation == "Manager") { node.Style.Brush = new SolidBrush(Color.FromRgb(23, 132, 206)); } else if ((node.Content as Employee).Designation == "CEO") { node.Style.Brush = new SolidBrush(Color.FromRgb(201, 32, 61)); RootNode = node; } else if ((node.Content as Employee).Designation == "Team Lead" || (node.Content as Employee).Designation == "Co-ordinator") { node.Style.Brush = new SolidBrush(Color.FromRgb(4, 142, 135)); } else { node.Style.Brush = new SolidBrush(Color.FromRgb(206, 98, 9)); } if (Device.RuntimePlatform == Device.UWP) { node.Width = 100; node.Height = 50; } else { node.Width = 144 * DiagramUtility.factor; node.Height = 60 * DiagramUtility.factor; } AnnotationCollection annotations = new AnnotationCollection(); if (Device.RuntimePlatform == Device.Android) { annotations.Add(new Annotation() { Content = (node.Content as Employee).Designation, FontSize = 14 * DiagramUtility.factor, TextBrush = new SolidBrush(Color.White) }); } else { annotations.Add(new Annotation() { Content = (node.Content as Employee).Designation, FontSize = 15 * DiagramUtility.factor, TextBrush = new SolidBrush(Color.White) }); } node.Annotations = annotations; }
private static void AddBuySellMarker( TradeDirection direction, AnnotationCollection annotations, Trade trade, DateTime timeLocal, decimal price, bool makeSmaller, bool isFilled = true, Color?colour = null) { var buyMarker = new BuyMarkerAnnotation(); var sellMarker = new SellMarkerAnnotation(); var annotation = direction == TradeDirection.Long ? buyMarker : (CustomAnnotation)sellMarker; annotation.Width = makeSmaller ? 12 : 24; annotation.Height = makeSmaller ? 12 : 24; ((Path)annotation.Content).Stretch = Stretch.Fill; annotation.Margin = new Thickness(0, direction == TradeDirection.Long ? 5 : -5, 0, 0); annotation.DataContext = trade; var brush = new SolidColorBrush { Color = colour ?? (direction == TradeDirection.Long ? Colors.Green : Colors.DarkRed) }; if (isFilled) { ((Path)annotation.Content).Fill = brush; } buyMarker.StrokeBrush = brush; buyMarker.Opacity = makeSmaller ? 0.6 : 0.8; sellMarker.StrokeBrush = brush; sellMarker.Opacity = makeSmaller ? 0.6 : 0.8; annotation.X1 = timeLocal; annotation.BorderThickness = new Thickness(20); annotation.Y1 = (double)price; annotations.Add(annotation); }
private void Diagram_BeginNodeRender(object sender, BeginNodeRenderEventArgs args) { var node = args.Item; node.ShapeType = ShapeType.RoundedRectangle; node.Style.StrokeWidth = 0; if ((node.Content as Employee).Designation == "Manager") { node.Style.Brush = new SolidBrush(Color.Rgb(23, 132, 206)); } else if ((node.Content as Employee).Designation == "CEO") { node.Style.Brush = new SolidBrush(Color.Rgb(201, 32, 61)); } else if ((node.Content as Employee).Designation == "Team Lead" || (node.Content as Employee).Designation == "Co-ordinator") { node.Style.Brush = new SolidBrush(Color.Rgb(4, 142, 135)); } else { node.Style.Brush = new SolidBrush(Color.Rgb(206, 98, 9)); } node.Width = 144 * MainActivity.factor; node.Height = 60 * MainActivity.factor; AnnotationCollection annotations = new AnnotationCollection(node); annotations.Add(new Annotation() { Content = (node.Content as Employee).Designation, FontSize = 14 * MainActivity.factor, TextBrush = new SolidBrush(Color.White) }); node.Annotations = annotations; }
public void AddEntryToChart(ChartArea area, Series series, AnnotationCollection annotations, double y = 0) { if (Date == null) { throw new Exception(); } var p1 = new DataPoint(Date.Value.AddDays(-1).ToOADate(), y); var p2 = new DataPoint(GetEndDate.ToOADate(), y); series.Points.Add(p1); series.Points.Add(p2); var line = new LineAnnotation { LineWidth = 10, Height = 0, LineColor = DrawColor ?? Color.Red, ClipToChartArea = area.Name, }; line.SetAnchor(p1, p2); var callout = new CalloutAnnotation { Text = Note ?? "ERROR: NOT SET", AnchorDataPoint = p1, CalloutStyle = CalloutStyle.RoundedRectangle, ForeColor = DrawColor ?? Color.Red, LineColor = DrawColor ?? Color.Red, //BackColor = Color.Transparent, Font = new Font(FontFamily.GenericSansSerif, 8, FontStyle.Bold), SmartLabelStyle = { IsMarkerOverlappingAllowed = true, AllowOutsidePlotArea = LabelOutsidePlotAreaStyle.Yes, MaxMovingDistance = 100, IsOverlappedHidden = false, MovingDirection = LabelAlignmentStyles.Bottom | LabelAlignmentStyles.BottomLeft | LabelAlignmentStyles.BottomRight }, AnchorAlignment = ContentAlignment.TopCenter, ToolTip = (Note ?? "ERROR: NOT SET") + "\n(" + Date.Value.ToShortDateString() + " - " + GetEndDate.ToShortDateString() + ")", Alignment = ContentAlignment.MiddleCenter }; annotations.Add(line); annotations.Add(callout); }
/// <summary> /// Create an annotation line and add it to the chart area. and return annotation. /// </summary> Annotation AddAnnotationLine(string name, string text, float value, bool isHorizontalAnnotationLine, Charting.Base.AnnotationDrawingLayer drawingLayer = Charting.Base.AnnotationDrawingLayer.FrontOfSeriesAndAxisAndGrid) { AnnotationLine annot; if (isHorizontalAnnotationLine) { annot = new HorizontalAnnotationLine(this); } else { annot = new VerticalAnnotationLine(this); } annot.Name = name; annot.DrawingLayer = drawingLayer; annot.value = value; annot.Text = text; annotations.Add(annot); annot.Initialize(device); ReDrawLayer(drawingLayer); return(annot); }
private static AnnotationCollection CreateAnnotations(IEnumerable <Trade> trades, List <NewsEvent> newsEvents) { var annotations = new AnnotationCollection(); foreach (var trade in trades) { IAnnotation annotation = trade.BuySell == BuySell.Buy ? new BuyMarkerAnnotation() : (IAnnotation) new SellMarkerAnnotation(); // The datacontext allows the tooltip inside the buy or sell marker to bind to elements of the Trade annotation.DataContext = trade; // X1,Y1 we set up manually annotation.X1 = trade.TradeDate; annotation.Y1 = trade.DealPrice; annotations.Add(annotation); } foreach (var newsEvent in newsEvents) { var annotation = new NewsBulletAnnotation(); // The datacontext allows the tooltip to bind to news data annotation.DataContext = newsEvent; // X1 is equal to the news date annotation.X1 = newsEvent.EventDate; // Y1 is set to 0.99, which is the just inside the vertical bottom edge of the chart in relative mode annotation.Y1 = 0.99; // Finally we use CoordinateMode.RelativeY to have a fractional coordinate on Y-Axis // this ensures the news bullets always appear at the bottom of the chart regardless // of YAxis.VisibleRange annotation.CoordinateMode = AnnotationCoordinateMode.RelativeY; annotations.Add(annotation); } return(annotations); }
public void Annotate(AnnotationCollection annotations) { var member = annotations.Get <IMemberAnnotation>()?.Member; if (member == null) { return; } if (member.TypeDescriptor == TypeData.FromType(typeof(IPAddress)) == false) { return; } // now its known that it is an IPAddress annotations.Add(new IPAnnotation(annotations)); }
private static void AddLineAnnotations( List <DatePrice> prices, IDataSeries series, AnnotationCollection annotations, Color colour) { int? startIndex = null; DateTime?startDate = null; decimal? currentPrice = null; foreach (var p in prices) { if (p.Price != currentPrice) { // Price changed if (currentPrice != null && startIndex != null) { var endIndex = series.FindIndex(p.Date.ToLocalTime(), SearchMode.Nearest); if (endIndex == startIndex.Value) { endIndex++; } var brush = new SolidColorBrush(colour) { Opacity = 0.3 }; var annotation = new LineAnnotation { X1 = startDate, //startIndex.Value, X2 = p.Date.ToLocalTime(), //endIndex, Y1 = currentPrice.Value, Y2 = currentPrice.Value, Stroke = brush }; annotations.Add(annotation); } startIndex = series.FindIndex(p.Date.ToLocalTime(), SearchMode.Nearest); startDate = p.Date.ToLocalTime(); currentPrice = p.Price; } } }
public static void AddHorizontalLine(decimal price, DateTime start, DateTime end, IDataSeries dataSeries, AnnotationCollection annotations, Trade trade, Color colour, bool extendLeftAndRight = false, bool extendRightIfZeroLength = false, DoubleCollection strokeDashArray = null) { var dateStartIndex = dataSeries.FindIndex(start, SearchMode.RoundDown); var dateEndIndex = dataSeries.FindIndex(end, SearchMode.RoundUp); if (extendLeftAndRight) { dateStartIndex -= 4; } if (dateStartIndex < 0) { dateStartIndex = 0; } if (extendLeftAndRight) { dateEndIndex += 4; } if (extendRightIfZeroLength && dateStartIndex == dateEndIndex) { dateEndIndex++; } var lineAnnotation = new LineAnnotation { DataContext = trade, X1 = dateStartIndex, Y1 = price, X2 = dateEndIndex, Y2 = price, StrokeThickness = 3, Opacity = 0.8, Stroke = new SolidColorBrush(colour) }; if (strokeDashArray != null) { lineAnnotation.StrokeDashArray = strokeDashArray; } annotations.Add(lineAnnotation); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { oldAnnotations = new AnnotationCollection(); microsoftAnnotations = new List<Annotation>(); editedAnnotations = new List<Annotation>(); object returnValue = value; try { if ((provider != null) && (((IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService))) != null)) { ((AnnotationCollection)value).CopyTo(oldAnnotations); form = new Form(); form.Icon = BIDSHelper.Resources.Common.BIDSHelper; form.Text = "BIDS Helper Attributes Editor"; form.MaximizeBox = true; form.MinimizeBox = false; form.Width = 550; form.Height = 400; form.SizeGripStyle = SizeGripStyle.Show; form.MinimumSize = new System.Drawing.Size(form.Width,form.Height); check = new CheckBox(); check.Anchor = AnchorStyles.Left | AnchorStyles.Top; check.Text = "Hide Microsoft Annotations?"; check.Click += new EventHandler(check_Click); check.Width = 160; check.Left = 5; check.Checked = true; form.Controls.Add(check); Label labelAnnotation = new Label(); labelAnnotation.Text = "Annotation:"; labelAnnotation.Top = 25; labelAnnotation.Left = 5; labelAnnotation.Width = 65; labelAnnotation.Anchor = AnchorStyles.Left | AnchorStyles.Top; labelAnnotation.TextAlign = System.Drawing.ContentAlignment.TopRight; form.Controls.Add(labelAnnotation); combo = new ComboBox(); combo.DropDownStyle = ComboBoxStyle.DropDownList; combo.Width = form.Width - 40 - labelAnnotation.Width; combo.Left = labelAnnotation.Right + 5; combo.Top = 25; combo.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; combo.SelectedIndexChanged += new EventHandler(combo_SelectedIndexChanged); form.Controls.Add(combo); foreach (Annotation a in oldAnnotations) { if (!a.Name.StartsWith("http://schemas.microsoft.com")) { combo.Items.Add(a.Name); editedAnnotations.Add(a); } else { microsoftAnnotations.Add(a); } } combo.Items.Add("<Add New Annotation>"); combo.SelectedIndex = -1; check.Left = combo.Left; Label labelName = new Label(); labelName.Text = "Name:"; labelName.Top = 50; labelName.Left = 5; labelName.Width = 65; labelName.TextAlign = System.Drawing.ContentAlignment.TopRight; labelName.Anchor = AnchorStyles.Left | AnchorStyles.Top; form.Controls.Add(labelName); textName = new TextBox(); textName.Text = ""; textName.Top = labelName.Top; textName.Left = labelName.Right + 5; textName.Width = combo.Width; textName.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; textName.Enabled = false; textName.Leave += new EventHandler(textName_Leave); form.Controls.Add(textName); Label labelValue = new Label(); labelValue.Text = "Value:"; labelValue.Top = 75; labelValue.Left = 5; labelValue.Width = 65; labelValue.TextAlign = System.Drawing.ContentAlignment.TopRight; labelValue.Anchor = AnchorStyles.Left | AnchorStyles.Top; form.Controls.Add(labelValue); textValue = new TextBox(); textValue.Text = ""; textValue.Top = labelValue.Top; textValue.Left = labelName.Right + 5; textValue.Width = combo.Width; textValue.ScrollBars = ScrollBars.Vertical; textValue.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom; textValue.Enabled = false; textValue.Multiline = true; textValue.Height = form.Height - 85 - textValue.Top; textValue.Leave += new EventHandler(textValue_Leave); form.Controls.Add(textValue); Button okButton = new Button(); okButton.Text = "OK"; okButton.Anchor = AnchorStyles.Right | AnchorStyles.Bottom; okButton.Left = form.Right - okButton.Width * 2 - 40; okButton.Top = form.Bottom - okButton.Height*2 - 20; okButton.Click += new EventHandler(okButton_Click); //form.AcceptButton = okButton; //don't want enter to cause this window to close because of multiline value textbox form.Controls.Add(okButton); Button cancelButton = new Button(); cancelButton.Text = "Cancel"; cancelButton.Anchor = AnchorStyles.Right | AnchorStyles.Bottom; cancelButton.Left = okButton.Right + 10; cancelButton.Top = okButton.Top; form.CancelButton = cancelButton; form.Controls.Add(cancelButton); deleteButton = new Button(); deleteButton.Text = "Delete Annotation"; deleteButton.Anchor = AnchorStyles.Left | AnchorStyles.Bottom; deleteButton.Left = textValue.Left; deleteButton.Top = okButton.Top; deleteButton.Width += 30; deleteButton.Enabled = false; deleteButton.Click += new EventHandler(deleteButton_Click); form.Controls.Add(deleteButton); DialogResult result = form.ShowDialog(); if (result == DialogResult.OK) { AnnotationCollection coll = new AnnotationCollection(); foreach (Annotation a in this.microsoftAnnotations) coll.Add(a.Clone()); foreach (Annotation a in this.editedAnnotations) coll.Add(a.Clone()); DesignerTransaction transaction1 = null; try { IDesignerHost host1 = (IDesignerHost)provider.GetService(typeof(IDesignerHost)); transaction1 = host1.CreateTransaction("BidsHelperAnnotationCollectionEditorUndoBatchDesc"); IComponentChangeService service1 = (IComponentChangeService)context.GetService(typeof(IComponentChangeService)); Microsoft.DataWarehouse.VsIntegration.Designer.NamedCustomTypeDescriptor instance = (Microsoft.DataWarehouse.VsIntegration.Designer.NamedCustomTypeDescriptor)context.Instance; ModelComponent m = (ModelComponent)instance.BrowsableObject; //use ModelComponent from which Cube, Dimension, Measure, etc. are derived... ModelComponent contains the definition for Annotations service1.OnComponentChanging(m, null); m.Annotations.Clear(); coll.CopyTo(m.Annotations); service1.OnComponentChanged(m, null, null, null); returnValue = coll; return returnValue; } catch (CheckoutException exception1) { if (transaction1 != null) transaction1.Cancel(); if (exception1 != CheckoutException.Canceled) { throw exception1; } return returnValue; } finally { if (transaction1 != null) transaction1.Commit(); } } else { returnValue = oldAnnotations; } form.Dispose(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } return returnValue; }
public static void CreateTradeAnnotations(AnnotationCollection annotations, ChartViewModel cvm, TradeAnnotationsToShow annotationsToShow, IList <Candle> candles, Trade trade) { // Setup annotations if (candles.Count == 0) { return; } if (trade.EntryDateTime != null && trade.EntryDateTime > candles[candles.Count - 1].CloseTime()) { return; } if (trade.OrderDateTime != null && trade.OrderDateTime > candles[candles.Count - 1].CloseTime()) { return; } var dataSeries = cvm.ChartPaneViewModels[0].ChartSeriesViewModels[0].DataSeries; var startTime = trade.StartDateTimeLocal; var entryCloseMarketSmaller = annotationsToShow.HasFlag(TradeAnnotationsToShow.MakeEntryCloseMarkerSmaller); if (startTime != null && (trade.OrderPrice != null || trade.EntryPrice != null)) { if (trade.EntryPrice != null && (annotationsToShow.HasFlag(TradeAnnotationsToShow.All) || annotationsToShow.HasFlag(TradeAnnotationsToShow.EntryMarker))) { var profit = trade.NetProfitLoss ?? trade.GrossProfitLoss; var colour = (profit != null && profit < 0) || (trade.RMultiple != null && trade.RMultiple.Value < 0) ? Colors.DarkRed : Colors.Green; AddBuySellMarker(trade.TradeDirection.Value, annotations, trade, trade.EntryDateTimeLocal.Value, trade.EntryPrice.Value, entryCloseMarketSmaller, colour: colour); } if (annotationsToShow.HasFlag(TradeAnnotationsToShow.All) || annotationsToShow.HasFlag(TradeAnnotationsToShow.OrderOrEntryLines)) { if (trade.OrderPrice != null && trade.OrderDateTimeLocal != null) { var orderPrices = trade.OrderPrices.ToList(); if (orderPrices.Count > 0) { orderPrices.Add(new DatePrice( trade.EntryDateTime ?? trade.CloseDateTime ?? new DateTime(candles[candles.Count - 1].CloseTimeTicks, DateTimeKind.Utc), null)); AddLineAnnotations(orderPrices, cvm.ChartPaneViewModels[0].ChartSeriesViewModels[0].DataSeries, annotations, Colors.Gray); } } } } // Add order price line if (trade.OrderPrice != null && trade.CloseDateTime == null && trade.EntryPrice == null) { var brush = new SolidColorBrush(Colors.Gray) { Opacity = 0.3 }; var annotation = new LineAnnotation { X1 = 0, X2 = cvm.ChartPaneViewModels[0].ChartSeriesViewModels[0].DataSeries.Count - 1, Y1 = trade.OrderPrice, Y2 = trade.OrderPrice, Stroke = brush, StrokeDashArray = new DoubleCollection(new[] { 5.0, 3.0 }) }; annotations.Add(annotation); } // Add close price line if (trade.ClosePrice != null) { var oppositeTradeDirection = trade.TradeDirection.Value == TradeDirection.Long ? TradeDirection.Short : TradeDirection.Long; if (annotationsToShow.HasFlag(TradeAnnotationsToShow.All) || annotationsToShow.HasFlag(TradeAnnotationsToShow.CloseMarker)) { var profit = trade.NetProfitLoss ?? trade.GrossProfitLoss; var colour = (profit != null && profit < 0) || (trade.RMultiple != null && trade.RMultiple.Value < 0) ? Colors.DarkRed : Colors.Green; AddBuySellMarker(oppositeTradeDirection, annotations, trade, trade.CloseDateTimeLocal.Value, trade.ClosePrice.Value, entryCloseMarketSmaller, colour: colour); // Add line between buy/sell marker /*var brush = new SolidColorBrush(colour) { Opacity = 0.6 }; * var annotation = new LineAnnotation * { * X1 = dataSeries.FindIndex(trade.EntryDateTimeLocal, SearchMode.Nearest), * X2 = dataSeries.FindIndex(trade.CloseDateTimeLocal, SearchMode.Nearest), * Y1 = trade.EntryPrice.Value, * Y2 = trade.ClosePrice.Value, * Stroke = brush, * StrokeThickness = 3, * StrokeDashArray = new DoubleCollection(new[] { 2.0, 2.0 }) * }; * * annotations.Add(annotation);*/ } } // Add stop prices if (annotationsToShow.HasFlag(TradeAnnotationsToShow.All) || annotationsToShow.HasFlag(TradeAnnotationsToShow.StopsLines)) { var stopPrices = trade.StopPrices.ToList(); if (stopPrices.Count > 0) { stopPrices.Add(new DatePrice(trade.CloseDateTime != null ? trade.CloseDateTime.Value : new DateTime(candles[candles.Count - 1].CloseTimeTicks, DateTimeKind.Utc), null)); AddLineAnnotations(stopPrices, cvm.ChartPaneViewModels[0].ChartSeriesViewModels[0].DataSeries, annotations, Colors.Red); } // Add dummy series just to add stop to legend if (cvm.ChartPaneViewModels[0].ChartSeriesViewModels.All(x => x.DataSeries.SeriesName != "Stop")) { var series = new FastLineRenderableSeries() { AntiAliasing = false, SeriesColor = Colors.Red }; series.SetValue(FilteringLegendModifier.IncludeSeriesProperty, true); var d = new XyDataSeries <DateTime, double>(); d.SeriesName = "Stop"; cvm.ChartPaneViewModels[0].ChartSeriesViewModels.Add(new ChartSeriesViewModel(d, series)); } } // Add current stop price line if (trade.StopPrice != null && trade.CloseDateTime == null) { var brush = new SolidColorBrush(Colors.Red) { Opacity = 0.3 }; var annotation = new LineAnnotation { X1 = 0, X2 = cvm.ChartPaneViewModels[0].ChartSeriesViewModels[0].DataSeries.Count - 1, Y1 = trade.StopPrice.Value, Y2 = trade.StopPrice.Value, Stroke = brush, StrokeDashArray = new DoubleCollection(new[] { 5.0, 3.0 }) }; annotations.Add(annotation); } // Add limit prices if (annotationsToShow.HasFlag(TradeAnnotationsToShow.All) || annotationsToShow.HasFlag(TradeAnnotationsToShow.LimitsLines)) { var limitPrices = trade.LimitPrices.ToList(); if (limitPrices.Count > 0) { limitPrices.Add(new DatePrice(trade.CloseDateTime ?? new DateTime(candles[candles.Count - 1].CloseTimeTicks, DateTimeKind.Utc), null)); AddLineAnnotations(limitPrices, cvm.ChartPaneViewModels[0].ChartSeriesViewModels[0].DataSeries, annotations, Colors.DarkGreen); } } // Add current limit price line if (trade.LimitPrice != null && trade.CloseDateTime == null) { var brush = new SolidColorBrush(Colors.DarkGreen) { Opacity = 0.3 }; var annotation = new LineAnnotation { X1 = 0, X2 = cvm.ChartPaneViewModels[0].ChartSeriesViewModels[0].DataSeries.Count - 1, Y1 = trade.LimitPrice.Value, Y2 = trade.LimitPrice.Value, Stroke = brush, StrokeDashArray = new DoubleCollection(new[] { 5.0, 3.0 }) }; annotations.Add(annotation); } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { oldAnnotations = new AnnotationCollection(); microsoftAnnotations = new List <Annotation>(); editedAnnotations = new List <Annotation>(); object returnValue = value; try { if ((provider != null) && (((IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService))) != null)) { ((AnnotationCollection)value).CopyTo(oldAnnotations); form = new Form(); form.Icon = BIDSHelper.Resources.Common.BIDSHelper; form.Text = "BIDS Helper Attributes Editor"; form.MaximizeBox = true; form.MinimizeBox = false; form.Width = 550; form.Height = 400; form.SizeGripStyle = SizeGripStyle.Show; form.MinimumSize = new System.Drawing.Size(form.Width, form.Height); check = new CheckBox(); check.Anchor = AnchorStyles.Left | AnchorStyles.Top; check.Text = "Hide Microsoft Annotations?"; check.Click += new EventHandler(check_Click); check.Width = 160; check.Left = 5; check.Checked = true; form.Controls.Add(check); Label labelAnnotation = new Label(); labelAnnotation.Text = "Annotation:"; labelAnnotation.Top = 25; labelAnnotation.Left = 5; labelAnnotation.Width = 65; labelAnnotation.Anchor = AnchorStyles.Left | AnchorStyles.Top; labelAnnotation.TextAlign = System.Drawing.ContentAlignment.TopRight; form.Controls.Add(labelAnnotation); combo = new ComboBox(); combo.DropDownStyle = ComboBoxStyle.DropDownList; combo.Width = form.Width - 40 - labelAnnotation.Width; combo.Left = labelAnnotation.Right + 5; combo.Top = 25; combo.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; combo.SelectedIndexChanged += new EventHandler(combo_SelectedIndexChanged); form.Controls.Add(combo); foreach (Annotation a in oldAnnotations) { if (!a.Name.StartsWith("http://schemas.microsoft.com")) { combo.Items.Add(a.Name); editedAnnotations.Add(a); } else { microsoftAnnotations.Add(a); } } combo.Items.Add("<Add New Annotation>"); combo.SelectedIndex = -1; check.Left = combo.Left; Label labelName = new Label(); labelName.Text = "Name:"; labelName.Top = 50; labelName.Left = 5; labelName.Width = 65; labelName.TextAlign = System.Drawing.ContentAlignment.TopRight; labelName.Anchor = AnchorStyles.Left | AnchorStyles.Top; form.Controls.Add(labelName); textName = new TextBox(); textName.Text = ""; textName.Top = labelName.Top; textName.Left = labelName.Right + 5; textName.Width = combo.Width; textName.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; textName.Enabled = false; textName.Leave += new EventHandler(textName_Leave); form.Controls.Add(textName); Label labelValue = new Label(); labelValue.Text = "Value:"; labelValue.Top = 75; labelValue.Left = 5; labelValue.Width = 65; labelValue.TextAlign = System.Drawing.ContentAlignment.TopRight; labelValue.Anchor = AnchorStyles.Left | AnchorStyles.Top; form.Controls.Add(labelValue); textValue = new TextBox(); textValue.Text = ""; textValue.Top = labelValue.Top; textValue.Left = labelName.Right + 5; textValue.Width = combo.Width; textValue.ScrollBars = ScrollBars.Vertical; textValue.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom; textValue.Enabled = false; textValue.Multiline = true; textValue.Height = form.Height - 85 - textValue.Top; textValue.Leave += new EventHandler(textValue_Leave); form.Controls.Add(textValue); Button okButton = new Button(); okButton.Text = "OK"; okButton.Anchor = AnchorStyles.Right | AnchorStyles.Bottom; okButton.Left = form.Right - okButton.Width * 2 - 40; okButton.Top = form.Bottom - okButton.Height * 2 - 20; okButton.Click += new EventHandler(okButton_Click); //form.AcceptButton = okButton; //don't want enter to cause this window to close because of multiline value textbox form.Controls.Add(okButton); Button cancelButton = new Button(); cancelButton.Text = "Cancel"; cancelButton.Anchor = AnchorStyles.Right | AnchorStyles.Bottom; cancelButton.Left = okButton.Right + 10; cancelButton.Top = okButton.Top; form.CancelButton = cancelButton; form.Controls.Add(cancelButton); deleteButton = new Button(); deleteButton.Text = "Delete Annotation"; deleteButton.Anchor = AnchorStyles.Left | AnchorStyles.Bottom; deleteButton.Left = textValue.Left; deleteButton.Top = okButton.Top; deleteButton.Width += 30; deleteButton.Enabled = false; deleteButton.Click += new EventHandler(deleteButton_Click); form.Controls.Add(deleteButton); DialogResult result = form.ShowDialog(); if (result == DialogResult.OK) { AnnotationCollection coll = new AnnotationCollection(); foreach (Annotation a in this.microsoftAnnotations) { coll.Add(a.Clone()); } foreach (Annotation a in this.editedAnnotations) { coll.Add(a.Clone()); } DesignerTransaction transaction1 = null; try { IDesignerHost host1 = (IDesignerHost)provider.GetService(typeof(IDesignerHost)); transaction1 = host1.CreateTransaction("BidsHelperAnnotationCollectionEditorUndoBatchDesc"); IComponentChangeService service1 = (IComponentChangeService)context.GetService(typeof(IComponentChangeService)); Microsoft.DataWarehouse.VsIntegration.Designer.NamedCustomTypeDescriptor instance = (Microsoft.DataWarehouse.VsIntegration.Designer.NamedCustomTypeDescriptor)context.Instance; ModelComponent m = (ModelComponent)instance.BrowsableObject; //use ModelComponent from which Cube, Dimension, Measure, etc. are derived... ModelComponent contains the definition for Annotations service1.OnComponentChanging(m, null); m.Annotations.Clear(); coll.CopyTo(m.Annotations); service1.OnComponentChanged(m, null, null, null); returnValue = coll; return(returnValue); } catch (CheckoutException exception1) { if (transaction1 != null) { transaction1.Cancel(); } if (exception1 != CheckoutException.Canceled) { throw exception1; } return(returnValue); } finally { if (transaction1 != null) { transaction1.Commit(); } } } else { returnValue = oldAnnotations; } form.Dispose(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } return(returnValue); }
void ClickObject(GameObject go) { if (go.tag == "opened_series") { selectedObject = go; var annotation = Instantiate(annotationPrefab, go.transform); annotation.transform.position = go.transform.position; var ah = annotation.GetComponent <AnnotationHandler>(); var seriesId = directoryMap[go].Get <string>(DicomTag.SeriesInstanceUID, "no series id"); ah.annotation = new Annotation(seriesId); ah.annotation.SetFromTransform(annotation.transform); annotations.Add(ah.annotation); return; } if (go == selectedObject) // object is already selected { return; } else { selectedObject = null; } if (!directoryMap.ContainsKey(go)) { return; } if (openedItems.ContainsKey(go) && openedItems[go]) // clicking on an open directory or study - close it { Close(go); return; } foreach (var otherGo in GameObject.FindGameObjectsWithTag(go.tag)) // opening a directory or study - close all other directories or studies { if (openedItems[otherGo]) { Close(otherGo); } } openedItems[go] = true; // this is now open var record = directoryMap[go]; if (record.DirectoryRecordType == "SERIES") // opening a series - bring it out of the tree { var clone = Instantiate(go, transform); clone.transform.localScale = go.transform.lossyScale; clone.transform.position = go.transform.position; clone.transform.rotation = go.transform.rotation; clone.transform.Translate(0, 0, -.5f, Space.Self); selectedObject = clone; directoryMap[clone] = record; clone.tag = "opened_series"; clone.GetComponent <TwoHandManipulatable>().enabled = true; clone.transform.Find("3D_toggle").gameObject.SetActive(true); var slider = clone.transform.Find("zstack slider"); slider.gameObject.SetActive(true); var sliderComponent = slider.GetComponent <SliderGestureControl>(); var n_images = record.LowerLevelDirectoryRecordCollection.Count(); sliderComponent.SetSpan(0, n_images); sliderComponent.SetSliderValue(n_images / 2f); var openSeriesHandler = clone.GetComponent <OpenSeriesHandler>(); openSeriesHandler.record = record; openSeriesHandler.loadDicomInstance = this; var seriesId = record.Get <string>(DicomTag.SeriesInstanceUID, "no series id"); foreach (var a in annotations.annotations) { if (a.series == seriesId) { var annotation = Instantiate(annotationPrefab, clone.transform); annotation.transform.localPosition = DeserializeVector(a.position, Vector3.zero); annotation.transform.localRotation = Quaternion.Euler(DeserializeVector(a.rotation, Vector3.zero)); annotation.transform.localScale = DeserializeVector(a.scale, Vector3.one); } } return; } var rootDirectory = rootDirectoryMap[record]; var offset = 0; status.text = "Loading..."; foreach (var subRecord in record.LowerLevelDirectoryRecordCollection) { rootDirectoryMap[subRecord] = rootDirectory; var desc = ""; var quad = Instantiate(quadPrefab, go.transform); if (subRecord.DirectoryRecordType == "STUDY") { var studyDate = GetDicomTag(subRecord, DicomTag.StudyDate); var studyDesc = GetDicomTag(subRecord, DicomTag.StudyDescription); var studyComments = GetDicomTag(subRecord, DicomTag.StudyCommentsRETIRED); desc = "Study: " + studyDate + "\n" + studyDesc + "\n" + studyComments; quad.tag = "study"; } else if (subRecord.DirectoryRecordType == "SERIES") { var modality = GetDicomTag(subRecord, DicomTag.Modality); var seriesDesc = GetDicomTag(subRecord, DicomTag.SeriesDescription); desc = "Series: " + modality + "\n" + seriesDesc; quad.tag = "series"; } else if (subRecord.DirectoryRecordType == "IMAGE") { desc = "Image: " + subRecord.Get <string>(DicomTag.InstanceNumber); quad.tag = "image"; } var tex = GetTexture2DForRecord(subRecord); quad.GetComponent <Renderer>().material.mainTexture = tex; quad.transform.localPosition += new Vector3(offset, -2, 0); quad.transform.Find("Canvas").Find("title").GetComponent <Text>().text = desc; quad.name = desc.Replace("\n", ":"); directoryMap[quad] = subRecord; openedItems[quad] = false; offset += 1; } status.text = ""; }
public static void AddBuySellMarker( TradeDirection direction, AnnotationCollection annotations, Trade trade, DateTime time, decimal price, bool makeSmaller, bool isFilled = true, Color?colour = null) { annotations.Add(CreateBuySellMarker(direction, trade, time, price, makeSmaller, isFilled, colour)); }