public virtual DiagramSelection CreateDragSelection() { DiagramSelection selection1 = new DiagramSelection(null); Shapes.RectangleGraph rectangle1 = new Shapes.RectangleGraph(); rectangle1.Bounds = base.CurrentObject.Bounds; rectangle1.Visible = false; base.View.Layers.Default.Add(rectangle1); selection1.Add(rectangle1); Shapes.DiagramShapeCollection collection1 = new Shapes.DiagramShapeCollection(); CollectionEnumerator enumerator1 = ((this.EffectiveSelection != null) ? this.EffectiveSelection : base.Selection).GetEnumerator(); while (enumerator1.MoveNext()) { Shapes.DiagramShape obj1 = enumerator1.Current; collection1.Add(obj1.DraggingObject); } RectangleF ef1 = DiagramDocument.ComputeBounds(collection1, base.View); float single1 = base.View.WorldScale.Width; if (((ef1.Width * single1) > 2000f) || ((ef1.Height * single1) > 2000f)) { single1 *= System.Math.Min((float)(2000f / (ef1.Width * single1)), (float)(2000f / (ef1.Height * single1))); } Bitmap bitmap1 = base.View.GetBitmapFromCollection(collection1, ef1, single1, false); Shapes.DiagramImage image1 = new Shapes.DiagramImage(); image1.Image = bitmap1; image1.Bounds = new RectangleF(ef1.X, ef1.Y, ((float)bitmap1.Width) / single1, ((float)bitmap1.Height) / single1); base.View.Layers.Default.Add(image1); selection1.Add(image1); return(selection1); }
protected override void OnLayerChanged(DiagramLayer oldLayer, DiagramLayer newLayer, DiagramShape mainObj) { base.OnLayerChanged(oldLayer, newLayer, mainObj); if (((oldLayer != null) && (newLayer == null)) && oldLayer.IsInDocument) { DiagramDocument document1 = oldLayer.Document; IDictionaryEnumerator enumerator1 = this.Map.GetEnumerator(); while (enumerator1.MoveNext()) { DictionaryEntry entry1 = enumerator1.Entry; DiagramView view1 = (DiagramView)entry1.Key; Control control1 = (Control)entry1.Value; if ((view1 != null) && (control1 != null)) { this.DisposeControl(control1, view1); } } this.Map.Clear(); } else if (((oldLayer != null) && (newLayer == null)) && oldLayer.IsInView) { DiagramView view2 = oldLayer.View; Control control2 = this.FindControl(view2); if (control2 != null) { this.Map.Remove(view2); if (control2 != null) { this.DisposeControl(control2, view2); } } } }
private void Button_Click(object sender, RoutedEventArgs e) { var button = sender as Button; if (button == null) { return; } Rest.Config.ProductionInstance = InstanceBox.Text; var oauth = new Rest.OAuth.ImpersonationParam { ClientId = ClientIdBox.Text, ClientSecret = ClientSecretBox.Text, Username = UsernameBox.Text, Password = PasswordEntry.Password, SecurityToken = SecurityTokenBox.Text }; if (document == null) { document = new DiagramDocument(); } document.Credentials = Credentials.From(oauth); document.Credentials.Instance = InstanceBox.Text; documentStorage.Save(document, Filename); CheckCredentials(); }
public ChangedEventArgs FindBeforeChangingEdit() { if (!this.IsBeforeChanging) { DiagramDocument document1 = this.Document; if (document1 == null) { return(null); } DiagramUndoManager manager1 = document1.UndoManager; if (manager1 == null) { return(null); } UndoManagerCompoundEdit edit1 = manager1.CurrentEdit; if (edit1 == null) { return(null); } IList list1 = edit1.AllEdits; for (int num1 = list1.Count - 1; num1 >= 0; num1--) { ChangedEventArgs args1 = list1[num1] as ChangedEventArgs; if ((((args1 != null) && args1.IsBeforeChanging) && ((args1.Document == this.Document) && (args1.Hint == this.Hint))) && ((args1.SubHint == this.SubHint) && (args1.Object == this.Object))) { return(args1); } } } return(null); }
public virtual void AddDocument(DiagramDocument doc) { if (!this.myDocuments.Contains(doc)) { this.myDocuments.Add(doc); } }
public void Save(DiagramDocument document, string filename) { lock (locker) { var json = JsonConvert.SerializeObject(document); File.WriteAllText(filename, json); } }
protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); document = documentStorage.LoadDocument(Filename); if (document?.Credentials != null) { ClientIdBox.Text = document.Credentials.ClientId; ClientSecretBox.Text = document.Credentials.ClientSecret; UsernameBox.Text = document.Credentials.Username; PasswordEntry.Password = document.Credentials.Password; SecurityTokenBox.Text = document.Credentials.SecurityToken; InstanceBox.Text = document.Credentials.Instance; CheckCredentials(); } }
public void SetContext(DiagramDocument context) { var existingContext = context as ISelectionContext; if (existingContext != null) { existingContext.SelectionChanged -= Context_SelectionChanged; } var graphAdapter = new HyperGraphAdapter(); graphAdapter.HighlightCompatible = true; graphAdapter.LargeGridStep = 160F; graphAdapter.SmallGridStep = 20F; graphAdapter.LargeStepGridColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(90)))), ((int)(((byte)(90))))); graphAdapter.SmallStepGridColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); graphAdapter.ShowLabels = false; graphAdapter.Model = context.Model; graphAdapter.Selection = context.DiagramSelection; graphAdapter.Context = context.UnderlyingDocument; graphAdapter.ModelConversion = _modelConversion; graphAdapter.NodeFactory = _nodeFactory; graphAdapter.Document = context.UnderlyingDocument; // calling Adapt will unbind previous adapters var hoverAdapter = new HoverAdapter(); hoverAdapter.HoverStarted += (object sender, HoverEventArgs <object, object> args) => { if (_hover != null) { return; } var n = args.Object as HyperGraph.Node; if (n == null) { var i = args.Object as HyperGraph.NodeItem; if (i != null) { n = i.Node; } } if (n != null) { _hover = new HoverLabel(n.Title) { Location = new Point(MousePosition.X - 8, MousePosition.Y + 8) }; _hover.ShowWithoutFocus(); } }; hoverAdapter.HoverStopped += EndHover; MouseLeave += EndHover; Adapt( new IControlAdapter[] { graphAdapter, new PickingAdapter { Context = context }, new CanvasAdapter(), new ViewingAdapter(graphAdapter), hoverAdapter }); context.SelectionChanged += Context_SelectionChanged; // Our context is actually a collection of 2 separate context objects // - What represents the model itself // - Another is the "ViewingContext", which is how we're looking at the model // Curiously, there seems to be a bit of an overlap between control adapters // and the viewing context. For example, ViewingContext, PickingAdapter and ViewingAdapter // duplicate some of the same functionality. // However, all of these are needed to use the standard ATF commands for framing and aligning _contextSet = new AdaptableSet(new object[] { context, new ViewingContext { Control = this } }); Context = _contextSet; }
public CopyDictionary() { this._SourceCollection = null; this._DestinationDocument = null; this._Delayeds = new CopyDelayedsCollection(); }
public virtual void RemoveDocument(DiagramDocument doc) { this.myDocuments.Remove(doc); }
public void SetContext(DiagramDocument context) { var existingContext = context as ISelectionContext; if (existingContext != null) existingContext.SelectionChanged -= Context_SelectionChanged; var graphAdapter = new HyperGraphAdapter(); graphAdapter.HighlightCompatible = true; graphAdapter.LargeGridStep = 160F; graphAdapter.SmallGridStep = 20F; graphAdapter.LargeStepGridColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(90)))), ((int)(((byte)(90))))); graphAdapter.SmallStepGridColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); graphAdapter.ShowLabels = false; graphAdapter.Model = context.Model; graphAdapter.Selection = context.DiagramSelection; graphAdapter.Context = context.UnderlyingDocument; graphAdapter.ModelConversion = _modelConversion; graphAdapter.NodeFactory = _nodeFactory; graphAdapter.Document = context.UnderlyingDocument; // calling Adapt will unbind previous adapters var hoverAdapter = new HoverAdapter(); hoverAdapter.HoverStarted += (object sender, HoverEventArgs<object, object> args) => { if (_hover != null) return; var n = args.Object as HyperGraph.Node; if (n == null) { var i = args.Object as HyperGraph.NodeItem; if (i != null) n = i.Node; } if (n != null) { _hover = new HoverLabel(n.Title) { Location = new Point(MousePosition.X - 8, MousePosition.Y + 8) }; _hover.ShowWithoutFocus(); } }; hoverAdapter.HoverStopped += EndHover; MouseLeave += EndHover; Adapt( new IControlAdapter[] { graphAdapter, new PickingAdapter { Context = context }, new CanvasAdapter(), new ViewingAdapter(graphAdapter), hoverAdapter }); context.SelectionChanged += Context_SelectionChanged; // Our context is actually a collection of 2 separate context objects // - What represents the model itself // - Another is the "ViewingContext", which is how we're looking at the model // Curiously, there seems to be a bit of an overlap between control adapters // and the viewing context. For example, ViewingContext, PickingAdapter and ViewingAdapter // duplicate some of the same functionality. // However, all of these are needed to use the standard ATF commands for framing and aligning _contextSet = new AdaptableSet(new object[]{ context, new ViewingContext { Control = this } }); Context = _contextSet; }