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 AnnotationGroup () { Annotations = new AnnotationCollection (); }
public PictureBoxEx() { InitComponent(); base.SetStyle(ControlStyles.DoubleBuffer, true); base.SetStyle(ControlStyles.UserPaint, true); base.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.Paint += new PaintEventHandler(PictureBox_Paint); this.Click += new EventHandler(PictureBox_Click); _annotations = new AnnotationCollection(this); dragPen = new Pen(Color.Black, 1); dragPen.DashStyle = DashStyle.Custom; dragPen.DashPattern = dashPattern; _annotations.AnnotationsChanged += new EventHandler(OnAnnotationsChanged); AllowScrollingChanged += new EventHandler(OnAllowScrollingChanged); BorderStyleChanged += new EventHandler(OnBorderStyleChanged); CurrentZoomChanged += new EventHandler(OnCurrentZoomChanged); DefaultZoomChanged += new EventHandler(OnDefaultZoomChanged); DoubleClickRestoreChanged += new EventHandler(OnDoubleClickRestoreChanged); DragOptionsChanged += new EventHandler(OnDragOptionsChanged); DragWindowColorChanged += new EventHandler(OnDragWindowColorChanged); DragWindowMinimumChanged += new EventHandler(OnDragWindowMinimumChanged); DragWindowDashPatternChanged += new EventHandler(OnDragWindowDashPatternChanged); DrawModeChanged += new EventHandler(OnDrawModeChanged); ImageChanged += new EventHandler(OnImageChanged); ImagePortionCopied += new ImagePortionCopiedEventHandler(OnImagePortionCopied); MaximumZoomChanged += new EventHandler(OnMaximumZoomChanged); MinimumZoomChanged += new EventHandler(OnMinimumZoomChanged); ScrollPositionChanged += new EventHandler(OnScrollPositionChanged); }
private void BuildLocaleNameIdTableEntry( ParserContext parser, ByteBuffer output, ClassDefinition cd, Locale[] localesUsed, Locale classOriginalLocale) { // TODO: This would be so much easier if there was an interface. This is super goofy. List <TopLevelEntity> topLevelConstructs = new List <TopLevelEntity>(); List <AnnotationCollection> tlcAnnotations = new List <AnnotationCollection>(); List <string> tlcDefaultNames = new List <string>(); List <int> memberIds = new List <int>(); foreach (FieldDefinition field in cd.Fields) { if (field.Modifiers.HasStatic) { continue; } topLevelConstructs.Add(field); tlcAnnotations.Add(field.Annotations); tlcDefaultNames.Add(field.NameToken.Value); memberIds.Add(field.MemberID); } foreach (FunctionDefinition method in cd.Methods) { if (method.Modifiers.HasStatic) { continue; } topLevelConstructs.Add(method); tlcAnnotations.Add(method.Annotations); tlcDefaultNames.Add(method.NameToken.Value); memberIds.Add(method.MemberID); } // Apparently static members are getting allocated member ID's. They shouldn't be. // Adding this hack to get the total member count including static members. int effectiveMemberCount = topLevelConstructs.Count; int perceivedMemberCount = 0; // updated as members are encountered // Build a lookup of all the localized names by member ID by locale ID Dictionary <int, List <int> > nameIdByMemberIdByLocaleId = new Dictionary <int, List <int> >(); for (int i = 0; i < effectiveMemberCount; ++i) { TopLevelEntity tlc = topLevelConstructs[i]; int memberId = memberIds[i]; perceivedMemberCount = Math.Max(memberId + 1, perceivedMemberCount); AnnotationCollection annotations = tlcAnnotations[i]; string defaultName = tlcDefaultNames[i]; Dictionary <Locale, string> localizedNames = annotations.GetNamesByLocale(1); localizedNames[classOriginalLocale] = defaultName; int defaultNameId = parser.LiteralLookup.GetNameId(defaultName); foreach (Locale locale in localesUsed) { // If this locale isn't even used anywhere, don't bother adding it to the lookup. int localeId = parser.GetLocaleId(locale); if (localeId == -1) { throw new Exception(); } List <int> nameIdByMemberId = null; if (!nameIdByMemberIdByLocaleId.ContainsKey(localeId)) { nameIdByMemberId = new List <int>(); nameIdByMemberIdByLocaleId[localeId] = nameIdByMemberId; } else { nameIdByMemberId = nameIdByMemberIdByLocaleId[localeId]; } string name = localizedNames.ContainsKey(locale) ? localizedNames[locale] : defaultName; int nameId = parser.LiteralLookup.GetNameId(name); while (nameIdByMemberId.Count <= memberId) { nameIdByMemberId.Add(-1); // there are some gaps due to static members. } nameIdByMemberId[memberId] = nameId; } } List <int> op = new List <int>(); op.Add(cd.ClassID); op.Add(perceivedMemberCount); foreach (int localeId in nameIdByMemberIdByLocaleId.Keys.OrderBy(k => k)) { op.Add(localeId); List <int> nameIdsByMemberId = nameIdByMemberIdByLocaleId[localeId]; for (int i = 0; i < perceivedMemberCount; ++i) { int nameId = -1; if (i < nameIdsByMemberId.Count) { int localizedNameId = nameIdsByMemberId[i]; if (localizedNameId != -1) { nameId = localizedNameId; } } op.Add(nameId); } } output.Add(null, OpCode.LOC_TABLE, op.ToArray()); }
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)); NamedCustomTypeDescriptor instance = (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 event menuclicked meventmenuclicked; /// <summary> /// Create a new extended picturebox /// </summary> public PictureBoxEx() { InitComponent(); base.SetStyle(ControlStyles.DoubleBuffer, true); base.SetStyle(ControlStyles.UserPaint, true); base.SetStyle(ControlStyles.AllPaintingInWmPaint, true); base.AutoScroll = true; this.Size = new Size(200, 200); this.Paint += new PaintEventHandler(PictureBoxEx_Paint); _diagnosticMode = false; _doubleClickRestore = true; _borderStyle = BorderStyle.None; _drawMode = InterpolationMode.Default; // Init zoom fields _currentZoom = 1.0F; _defaultZoom = 1.0F; _maximumZoom = 3.0F; _minimumZoom = 0.10F; // Init drag window fields dashPattern = new Single[]{ 5, 2, 5, 2}; dragWindow = Rectangle.Empty; dragStart = Point.Empty; dragEnd = Point.Empty; dragPen = new Pen(Color.Black, 1); dragPen.DashStyle = DashStyle.Custom; dragPen.DashPattern = dashPattern; _dragOptions = DragOptions.Prompt; _dragWindowMinimum = SystemInformation.DragSize; lmbDown = false; // Annotation fields _annotations = new AnnotationCollection(this); _annotations.AnnotationsChanged += new EventHandler(Annotations_AnnotationsChanged); selectedAnnote = null; generateTime = 0L; drawTime = 0L; setTime = 0L; }