/// <summary> /// Perform undo of this command. /// </summary> public override void Undo() { //create a new group GroupShape group = new GroupShape(this.Controller.Model); //asign the entities to the group group.Entities = bundle.Entities; foreach (IDiagramEntity entity in group.Entities) { //this will be recursive if an entity is itself an IGroup entity.Group = group; } //add the new group to the layer this.Controller.Model.DefaultPage.DefaultLayer.Entities.Add(group); mGroup = group; //select the newly created group CollectionBase <IDiagramEntity> col = new CollectionBase <IDiagramEntity>(); col.Add(mGroup); this.Controller.Model.Selection.SelectedItems = col; mGroup.Invalidate(); }
/// <summary> /// Perform redo of this command. /// </summary> public override void Redo() { //create a new group; use the standard GroupShape or the CollapsibleGroupShape for a painted group with collapse/expand features. //GroupShape group = new GroupShape(this.Controller.Model); CollapsibleGroupShape group = new CollapsibleGroupShape(this.controller.Model); //asign the entities to the group group.Entities.Clear(); foreach (IDiagramEntity entity in bundle.Entities) { //this will be recursive if an entity is itself an IGroup entity.Group = group; group.Entities.Add(entity); } //add the new group to the layer this.Controller.Model.DefaultPage.DefaultLayer.Entities.Add(group); mGroup = group; //select the newly created group CollectionBase<IDiagramEntity> col = new CollectionBase<IDiagramEntity>(); col.Add(mGroup); Selection.SelectedItems = col; mGroup.Invalidate(); }
/// <summary> /// this is the basic method that will be used by the underlying instance TestObjects. /// </summary> /// <param name="sqlCmd">sql command</param> /// <param name="generateCollectionDelegateObject">The collection generator method delegate. /// The passed delegate object will be used to call the appropriate collection generator method from the caller class.</param> /// <returns>The object collection.</returns> public static CollectionBase ExecuteReaderCmd(SqlCommand sqlCmd, GenerateCollectionFromReader generateCollectionDelegateObject, string connectionString) { if (connectionString == null) { throw (new ArgumentNullException("connectionString")); } if (connectionString.Length == 0) { throw (new ArgumentOutOfRangeException("connectionString")); } if (generateCollectionDelegateObject == null) { throw (new ArgumentNullException("generateCollectionDelegateObject")); } if (sqlCmd == null) { throw (new ArgumentNullException("sqlCmd")); } using (SqlConnection cn = new SqlConnection(connectionString)) { sqlCmd.Connection = cn; cn.Open(); CollectionBase temp = generateCollectionDelegateObject(sqlCmd.ExecuteReader()); return(temp); } }
/// <summary> /// The sample below retutns a set of tabular data, getting the data tables dynamically /// for this run time solution we need to use the set of data collection with EXACT same set of 'data fields' /// </summary> /// <returns></returns> //Utils.GenerationCommandType.CustomEntityTabularCollection public static ArrayList SelectTwoLevelBossesSameCustomEntity() { IDataReader myDataReader; // Execute SQL Command SqlConnection cn = new SqlConnection(ConnectionStringManager.DefaultDBConnectionString); SqlCommand sqlCmd = new SqlCommand(); sqlCmd.Connection = cn; DatabaseUtility.SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_CUSTOM_EMPLOYEES_GETALLEMPLOYEEBOSSES); cn.Open(); myDataReader = sqlCmd.ExecuteReader(); ArrayList customEntitySet = new ArrayList(); do { CollectionBase objCollection = Boss.GenerateBossCollectionFromReader(myDataReader); customEntitySet.Add(objCollection); }while (myDataReader.NextResult()); cn.Close(); return(customEntitySet); }
// ------------------------------------------------------------------- /// <summary> /// Deserialization constructor /// </summary> /// <param name="info">The info.</param> /// <param name="context">The context.</param> // ------------------------------------------------------------------- protected ShapeBase( SerializationInfo info, StreamingContext context) : base(info, context) { if (Tracing.BinaryDeserializationSwitch.Enabled) { Trace.WriteLine("Deserializing the fields of 'ShapeBase'."); } double version = info.GetDouble("ShapeBaseVersion"); mConnectors = new CollectionBase<IConnector>(); //transform to the new bounding rectangle Transform( (Rectangle)info.GetValue("Rectangle", typeof(Rectangle)) ); this.mConnectors = info.GetValue( "Connectors", typeof(CollectionBase<IConnector>)) as CollectionBase<IConnector>; mShowConnectors = info.GetBoolean("ShowConnectors"); mIsFixed = info.GetBoolean("IsFixed"); }
private static Boolean Generate(CollectionBase busineesObject, Object item, Boolean writeHeader, String[] Headers, String columnDemiliter, String textQualifier, QualifierType qType, String outputFile, Boolean isAppend) { ArrayList items = GetList(busineesObject); DataTable dt = GetDataSource(items, item); return(Generate(dt.DefaultView, writeHeader, Headers, columnDemiliter, textQualifier, qType, outputFile, isAppend)); }
public void AddRange(CollectionBase objects) { foreach (object obj in objects) { this.Add(obj); } }
public void ClearStrictCollectionAndDisposesItGeneric() { MockRepository mocks = new MockRepository(); CollectionBase collection = mocks.StrictMultiMock <CollectionBase>(typeof(IDisposable)); ClearStrictCollectionAndDisposesItCommon(mocks, collection); }
public void ClearStrictCollectionAndDisposesItNonGeneric() { CollectionBase collection = MockRepository.MockMulti <CollectionBase>(new Type[] { typeof(IDisposable) }); collection.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault); ClearStrictCollectionAndDisposesItCommon(collection); }
public async Task <ActionResult <CollectionBase <GetProductsSummaryResponse> > > GetAllProducts() { CollectionBase <GetProductsSummaryResponse> response = await _productLookups.GetAllProductsInInventoryAsync(); return(Ok(response)); }
/// <summary> /// Initializes a new instance of the <see cref="T:DeleteCommand"/> class. /// </summary> /// <param name="controller">The controller.</param> /// <param name="bundle">The bundle.</param> public DeleteCommand(IController controller, CollectionBase<IDiagramEntity> bundle) : base(controller) { this.Text = "Delete"; this.controller = controller; this.bundle = bundle; }
/// <summary> /// Initializes a new instance of the <see cref="T:PenStyleCommand"/> class. /// </summary> /// <param name="controller">The controller.</param> /// <param name="bundle">The bundle.</param> /// <param name="penStyle">The pen style.</param> public PenStyleCommand(IController controller, CollectionBase<IDiagramEntity> bundle, IPenStyle penStyle) : base(controller) { this.Text = "Fill style"; this.controller = controller; this.bundle = bundle;//the bundle should contain only IShape and IConnection entities! this.newStyle = penStyle; }
public async Task <OneOf <DbCollection> > CreateAsync(ObjectType type, CollectionBase model, string userId, string[] items = null, CancellationToken cancellationToken = default) { if (items != null && items.Length != 0) { var newItems = new string[items.Length]; var set = new HashSet <string>(items.Length, StringComparer.Ordinal); var count = 0; foreach (var item in items) { if (set.Add(item)) { newItems[count++] = item; } } Array.Resize(ref newItems, count); items = newItems; } var collection = new DbCollection { Type = type, OwnerIds = new[] { userId }, Items = items ?? Array.Empty <string>() }.ApplyBase(model, _services); return(await _client.Entry(collection).CreateAsync(cancellationToken)); }
public void ClearStrictCollectionAndDisposesItGeneric() { CollectionBase collection = MockRepository.Mock <CollectionBase, IDisposable>(); collection.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault); ClearStrictCollectionAndDisposesItCommon(collection); }
/// <summary> /// 初始化,由框架调用 /// </summary> /// <param name="setting"></param> public void Init(IConfigSetting setting) { if (!this.initialized) { this.setting = setting; this.questions = new CollectionBase<Question>(); IConfigSetting[] questionSettings = setting["questions"].GetChildSettings(); for (int i = 0; i < questionSettings.Length; i++) { string id = questionSettings[i].Property["id"].Value; if (this.questions.Contains(id)) { throw new Exception("重复加载"); } Question question = new Question(); question.ID = questionSettings[i].Property["id"].Value; question.Text = questionSettings[i].Property["text"].Value; question.Answer = questionSettings[i].Property["answer"].Value; this.questions.Add(id,question); } this.initialized = true; } }
/// <summary> /// Perform redo of this command. /// </summary> public override void Redo() { //remove the group from the layer this.Controller.Model.DefaultPage.DefaultLayer.Entities.Remove(mGroup); //detach the entities from the group foreach (IDiagramEntity entity in mGroup.Entities) { //this will be recursive if an entity is itself an IGroup entity.Group = null; bundle.Entities.Add(entity); //mGroup.Entities.Remove(entity); Controller.Model.AddEntity(entity); } //change the visuals such that the entities in the group are selected CollectionBase<IDiagramEntity> col = new CollectionBase<IDiagramEntity>(); col.AddRange(mGroup.Entities); this.Controller.Model.Selection.SelectedItems = col; mGroup.Invalidate(); mGroup = null; //note that the entities have never been disconnected from the layer //so they don't have to be re-attached to the anything. //The insertion of the Group simply got pushed in the scene-graph. }
public ComplexShapeBase(IModel model) : base(model) { mChildren = new CollectionBase<IShapeMaterial>(); mChildren.OnItemAdded += new EventHandler<CollectionEventArgs<IShapeMaterial>>(mChildren_OnItemAdded); mServices = new Dictionary<Type, IInteraction>(); }
/// <summary> /// Save model collection to file. /// </summary> /// <param name="collection"> /// Domain object collection to save. /// </param> /// <param name="fileName"> /// Data is saved to this text file. /// </param> public static async void Save(CollectionBase <TDomainClass> collection, string fileName) { var saveFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(fileName, CreationCollisionOption.OpenIfExists); string modelAsString = JsonConvert.SerializeObject(collection.All); await FileIO.WriteTextAsync(saveFile, modelAsString); }
/// <summary> /// Perform redo of this command. /// </summary> public override void Redo() { //remove the group from the layer this.Controller.Model.DefaultPage.DefaultLayer.Entities.Remove(mGroup); //detach the entities from the group foreach (IDiagramEntity entity in mGroup.Entities) { //this will be recursive if an entity is itself an IGroup entity.Group = null; bundle.Entities.Add(entity); //mGroup.Entities.Remove(entity); Controller.Model.AddEntity(entity); } //change the visuals such that the entities in the group are selected CollectionBase <IDiagramEntity> col = new CollectionBase <IDiagramEntity>(); col.AddRange(mGroup.Entities); this.Controller.Model.Selection.SelectedItems = col; mGroup.Invalidate(); mGroup = null; //note that the entities have never been disconnected from the layer //so they don't have to be re-attached to the anything. //The insertion of the Group simply got pushed in the scene-graph. }
/// <summary> /// Binds an object's properties to <see cref="Control"/>s with the same ID as the propery name. 将对象的属性值表现到控件上. /// </summary> /// <param name="obj">The object whose properties are being bound to forms Controls</param> /// <param name="container">The control in which the form Controls reside (usually a Page or ContainerControl)</param> public static void BindObjectToTableRow(CollectionBase cb, HtmlTable tb, string fileName) { if (cb == null) { return; } // Get the properties of the business object // //获取列的信息 PreViewColumnCollection pcc = (new PageBase()).GetColumns(fileName); //生成表头 HtmlTableRow th = new HtmlTableRow(); th.BgColor = "#ffffff"; foreach (PreViewColumn column in pcc) { HtmlTableCell tc = new HtmlTableCell(); tc.Width = column.Width.ToString(); tc.Align = "center"; tc.InnerHtml = column.Caption; tc.NoWrap = true; th.Cells.Add(tc); } tb.Rows.Add(th); //生成表的内容 foreach (object obj in cb) { HtmlTableRow tr = new HtmlTableRow(); tr.BgColor = "#ffffff"; Type objType = obj.GetType(); PropertyInfo[] objPropertiesArray = objType.GetProperties(); foreach (PreViewColumn column in pcc) { foreach (PropertyInfo objProperty in objPropertiesArray) { if (objProperty.Name == column.ID) { string propertyValue = objProperty.GetValue(obj, null).ToString(); if (column.Fomat == "num") { propertyValue = (double.Parse(propertyValue)).ToString("n2"); } HtmlTableCell tc = new HtmlTableCell(); tc.InnerText = propertyValue; tc.Align = column.Align; tc.Width = column.Width.ToString(); tr.Cells.Add(tc); } } tb.Rows.Add(tr); } } }
/// <summary> /// Perform redo of this command. /// </summary> public override void Redo() { //create a new group; use the standard GroupShape or the CollapsibleGroupShape for a painted group with collapse/expand features. //GroupShape group = new GroupShape(this.Controller.Model); //CollapsibleGroupShape group = new CollapsibleGroupShape(this.controller.Model); GroupShape group = new GroupShape(this.controller.Model); //asign the entities to the group group.Entities.Clear(); foreach (IDiagramEntity entity in bundle.Entities) { //this will be recursive if an entity is itself an IGroup entity.Group = group; group.Entities.Add(entity); } //add the new group to the layer this.Controller.Model.AddEntity(group); mGroup = group; //select the newly created group CollectionBase <IDiagramEntity> col = new CollectionBase <IDiagramEntity>(); col.Add(mGroup); this.Controller.Model.Selection.SelectedItems = col; mGroup.Invalidate(); }
public void DatabindChildrenToBlock(IBlock block) { this.linkedBlock = block; foreach (Control c in this.GetChildFields()) { if (block != null) { c.Enabled = true; Field field = (c as Field); if (!(c is Block)) { IField binding = (LocateFieldByName(this.linkedBlock, field.BoundPropertyName) as IField); field.DataBind(binding); Binding[] bindings = field.GetDataBindings(); foreach (Binding bind in bindings) { bind.Parse += new ConvertEventHandler(bind_Parse); } } else { CollectionBase binding = (LocateFieldByName(this.linkedBlock, field.BoundPropertyName) as CollectionBase); (c as Block).DataBindCollection(binding); (c as Block).Initialize(); } } else { c.Enabled = false; } } }
public static XmlElement Serialization(object obj, XmlElement eleParent, String strTagName) { if (eleParent == null) { return(null); } if (obj is CollectionBase) { CollectionBase collection = obj as CollectionBase; if (collection.Count > 0) { XmlElement eleCollection = eleParent.OwnerDocument.CreateElement(strTagName); foreach (object child in collection) { Serialization(child, eleCollection, "Item"); } eleParent.AppendChild(eleCollection); return(eleCollection); } } else { XmlElement eleChild = Serialization(eleParent.OwnerDocument, obj, strTagName); eleParent.AppendChild(eleChild); return(eleChild); } return(null); }
/// <summary> /// Converts the hashtable of GraphML-marked properties to types /// </summary> /// <param name="properties"></param> /// <returns></returns> private DataType[] DataTypesFromAttributes(PropertiesHashtable properties) { DataType[] dts = new DataType[properties.Count]; for (int k = 0; k < properties.Count; k++) { dts[k] = new DataType(); dts[k].Name = properties.Keys[k]; object val = null; if ((val = properties[k]) != null) { //the color is a bit different if (typeof(Color).IsInstanceOfType(val)) { int num = ((Color)val).ToArgb(); dts[k].Value.Add(num.ToString()); } else if (typeof(Shape).IsInstanceOfType(val)) { dts[k].Value.Add((val as Shape).UID.ToString()); } else if (typeof(Guid).IsInstanceOfType(val)) { dts[k].Value.Add(((Guid)val).ToString()); } else if (typeof(CollectionBase).IsInstanceOfType(val)) { CollectionBase col = val as CollectionBase; IEnumerator enumer = col.GetEnumerator(); while (enumer.MoveNext()) { object obj = enumer.Current; PropertiesHashtable props = GraphMLDataAttribute.GetValuesOfTaggedFields(obj); DataType[] tps = DataTypesFromAttributes(props); DataType dt = new DataType(); dt.Name = obj.GetType().Name; //the name of the collection element dt.IsCollection = true; for (int m = 0; m < tps.Length; m++) { dt.Value.Add(tps[m]); } dts[k].Value.Add(dt); dts[k].IsCollection = true; } } else { dts[k].Value.Add(val.ToString()); } } /* * makes the union of all properties in the different shapes * if ( !keyList.Contains(properties.Keys[k])) * keyList.Add(properties.Keys[k],val); */ } return(dts); }
public GroupShape(IModel model) : base(model) { this.mEntities = new CollectionBase<IDiagramEntity>(); this.mEntities.OnItemAdded += new EventHandler<CollectionEventArgs<IDiagramEntity>>(mEntities_OnItemAdded); this.mEntities.OnClear += new EventHandler(mEntities_OnClear); this.mEntities.OnItemRemoved += new EventHandler<CollectionEventArgs<IDiagramEntity>>(mEntities_OnItemRemoved); }
private static void ClearStrictCollectionAndDisposesItCommon(CollectionBase collection) { collection.Expect(x => x.Clear()); ((IDisposable)collection).Expect(x => x.Dispose()); CleanCollection(collection); collection.VerifyAllExpectations(); }
public Layer(string name) { mName = name; mEntities = new CollectionBase<IDiagramEntity>(); mEntities.OnItemAdded += new EventHandler<CollectionEventArgs<IDiagramEntity>>(mEntities_OnItemAdded); mEntities.OnItemRemoved += new EventHandler<CollectionEventArgs<IDiagramEntity>>(mEntities_OnItemRemoved); mEntities.OnClear += new EventHandler(mEntities_OnClear); }
public static CollectionBase <ArticleBase> GetList(int count, string type, IArticleRepository rep) { var articleBases = new CollectionBase <ArticleBase>(); articleBases.AddRange(rep.FetchList(count, type).Select(article => ((ArticleBase)Reflector.CreateObject(article.ArticleType.Assembly, article.ArticleType.Class)). Desrialize(article.Content.ToString()))); articleBases.ForEach(ab => ab.MarkOld()); return(articleBases); }
public ShapeBase() : base() { mRectangle = new Rectangle(0, 0, 100, 70); connectors = new CollectionBase<IConnector>(); shapeColor = ArtPallet.RandomLowSaturationColor; SetBrush(); }
{ /// <summary> /// /// </summary> /// <typeparam name="TC">type of collection</typeparam> /// <typeparam name="TV">type of collection element</typeparam> /// <param name="collection"></param> protected void AddCollection(CollectionBase collection) { if (IsDisposed) { return; } collection.Serializers.Add(GetCollectionSerializer(collection)); collection.CollectionChanged += Collection_CollectionChanged <TV>; }
public static CollectionBase <ArticleBase> Search(string search, IArticleRepository rep) { search = search.ToLower(); var articleBases = new CollectionBase <ArticleBase>(); articleBases.AddRange(rep.Search(search).Select(article => ((ArticleBase)Reflector.CreateObject(article.ArticleType.Assembly, article.ArticleType.Class)). Desrialize(article.Content.ToString()))); articleBases.ForEach(ab => ab.MarkOld()); return(articleBases); }
public void StaticEqualityComparerWithNull() { ArrayList <double> arr = new ArrayList <double>(); SCG.IEqualityComparer <double> eqc = C5.EqualityComparer <double> .Default; Assert.IsTrue(CollectionBase <double> .StaticEquals(arr, arr, eqc)); Assert.IsTrue(CollectionBase <double> .StaticEquals(null, null, eqc)); Assert.IsFalse(CollectionBase <double> .StaticEquals(arr, null, eqc)); Assert.IsFalse(CollectionBase <double> .StaticEquals(null, arr, eqc)); }
private static void CleanCollection(CollectionBase collection) { collection.Clear(); IDisposable disposable = collection as IDisposable; if (disposable != null) { disposable.Dispose(); } }
public static IList <T> ToList <T>(this CollectionBase coll) { var list = new List <T>(); foreach (T item in coll) { list.Add(item); } return(list); }
public async Task <OneOf <DbCollection> > CreateAsync(ObjectType type, CollectionBase model, string userId, CancellationToken cancellationToken = default) { var collection = new DbCollection { Type = type, OwnerIds = new[] { userId }, Items = Array.Empty <string>() }.ApplyBase(model, _services); return(await _client.Entry(collection).CreateAsync(cancellationToken)); }
private static ArrayList GetList(CollectionBase busineesObject) { ArrayList items = new ArrayList(); IEnumerator ie = busineesObject.GetEnumerator(); while (ie.MoveNext()) { items.Add(ie.Current); } return(items); }
public static string toString(this CollectionBase coll) { StringBuilder b = new StringBuilder(); foreach (var item in coll) { b.Append(item); b.AppendLine(); } return(b.ToString()); }
public async Task <ActionResult <Collection> > UpdateAsync(string id, CollectionBase model) { var result = await _collections.UpdateAsync(id, model, CurrentConstraint); if (!result.TryPickT0(out var collection, out _)) { return(ResultUtilities.NotFound(id)); } return(collection.Convert(_services)); }
public static T FirstOrDefault <T> (this CollectionBase coll, Func <T, bool> func) { foreach (T t in coll) { if (func(t)) { return(t); } } return(default(T)); }
public override async Task <CollectionBase <TDomainClass> > Load() { CollectionBase <TDomainClass> collection = new CollectionBase <TDomainClass>(); foreach (var obj in _objectSource.ObjectList) { collection.Insert(obj); } return(collection); }
/// <summary> /// Deserialization constructor /// </summary> /// <param name="info">The info.</param> /// <param name="context">The context.</param> protected ConnectorBase(SerializationInfo info, StreamingContext context) : base(info, context) { if(Tracing.BinaryDeserializationSwitch.Enabled) Trace.WriteLine("Deserializing the fields of 'ConnectorBase'."); this.mPoint = (Point) info.GetValue("Point", typeof(Point)); attachedConnectors = new CollectionBase<IConnector>(); #region Preparation of the anchoring process Guid tuid = new Guid(info.GetString("AttachedTo")); Anchors.Add(this.Uid, new Anchor(tuid, this)); #endregion }
/// <summary> /// Returns the bounding rectangle of the given collection of entities. /// </summary> /// <param name="collection"></param> /// <returns></returns> public static Rectangle BoundingRectangle(CollectionBase<IDiagramEntity> collection) { //get the bounding rectangle bool first = true; Rectangle rec = Rectangle.Empty; foreach (IDiagramEntity entity in collection) { if (first) { rec = entity.Rectangle; first = false; } else rec = Rectangle.Union(rec, entity.Rectangle); } return rec; }
public Page(string name) { mLayers = new CollectionBase<ILayer>(); //the one and only and indestructible layer mDefaultLayer = new Layer("Default Layer"); mDefaultLayer.OnEntityAdded += new EventHandler<EntityEventArgs>(defaultLayer_OnEntityAdded); mDefaultLayer.OnEntityRemoved += new EventHandler<EntityEventArgs>(mDefaultLayer_OnEntityRemoved); mDefaultLayer.OnClear += new EventHandler(mDefaultLayer_OnClear); mLayers.Add(mDefaultLayer); mName = name; }
///<summary> ///Default constructor ///</summary> public Page(string name, IModel model) { this.mModel = model; mName = name; mAmbience = new Ambience(this); //the one and only and indestructible layer mLayers = new CollectionBase<ILayer>(); mLayers.Add(new Layer("Default Layer")); Init(); }
/// <summary> /// Creates a new bundle using a given collection of diagram entities. /// </summary> /// <param name="collection"></param> public Bundle(CollectionBase<IDiagramEntity> collection) { mEntities = new CollectionBase<IDiagramEntity>(); //we could assign it directly but let's make sure the collection does not //contain unwanted elements foreach (IDiagramEntity entity in collection) { if ((entity is IShape) || (entity is IConnection) || (entity is IGroup)) mEntities.Add(entity); } //the following line would give problem. The event handler attached to the Selection would be triggered when //the mEntities collection is changed! //mEntities = collection; }
/// <summary> /// Depth-first traversal of an <see cref="IGroup"/> /// </summary> /// <param name="group"></param> /// <param name="collection"></param> public static void TraverseCollect(IGroup group, ref CollectionBase<IDiagramEntity> collection) { #region Checks if (group == null) throw new InconsistencyException("Cannot collect entities of a 'null' IGroup"); if (collection == null) throw new InconsistencyException("You need to instantiate a collection before using this method."); #endregion foreach (IDiagramEntity entity in group.Entities) { if (entity is IGroup) TraverseCollect(entity as IGroup, ref collection); else collection.Add(entity); } }
/// <summary> /// Deserialization constructor /// </summary> /// <param name="info">The info.</param> /// <param name="context">The context.</param> protected ClassShape(SerializationInfo info, StreamingContext context) : base(info, context) { if(Tracing.BinaryDeserializationSwitch.Enabled) Trace.WriteLine("Deserializing the fields of 'ClassShape'."); this.Resizable = false; this.mTitle = info.GetString("Title"); this.mSubTitle = info.GetString("SubTitle"); sf.Trimming = StringTrimming.EllipsisCharacter; this.textMaterial = info.GetValue("TextMaterial", typeof(LabelMaterial)) as LabelMaterial; mFolders = new CollectionBase<FolderMaterial>(); this.Resizable = false; this.mCollapsed = info.GetBoolean("Collapsed"); this.mBodyType = (BodyType) Enum.Parse(typeof(BodyType), info.GetString("BodyType")); }
/// <summary> /// Runs the layout for a specified time. /// </summary> /// <param name="time">The time.</param> public override void Run(int time) { rnd = new Random(); entities = this.Model.CurrentPage.DefaultLayer.Entities; speeds = new Dictionary<IDiagramEntity, SpeedVector>(); foreach (IDiagramEntity entity in entities) { if (entity is IShape) { vectorx = -20 + 40 * rnd.NextDouble(); vectory = -20 + 40 * rnd.NextDouble(); speeds.Add(entity, new SpeedVector(vectorx, vectory)); } } this.time = time; worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler(worker_DoWork); worker.RunWorkerAsync(time); }
///<summary> ///Default constructor ///</summary> public CollapsibleGroupShape(IModel model) : base(model) { this.mEntities = new CollectionBase<IDiagramEntity>(); this.mEntities.OnItemAdded += new EventHandler<CollectionEventArgs<IDiagramEntity>>(mEntities_OnItemAdded); this.mEntities.OnClear += new EventHandler(mEntities_OnClear); this.mEntities.OnItemRemoved += new EventHandler<CollectionEventArgs<IDiagramEntity>>(mEntities_OnItemRemoved); xicon = new SwitchIconMaterial(SwitchIconType.PlusMinus); this.Children.Add(xicon); //do this before attaching the next event handler, otherwise the shape will be added twice to the paintables xicon.Collapsed = false; xicon.OnCollapse += new EventHandler(xicon_OnCollapse); xicon.OnExpand += new EventHandler(xicon_OnExpand); connectorMemory = new Dictionary<IConnector, Point>(); expandLabel = new ClickableLabelMaterial("Expand..."); this.Children.Add(expandLabel); expandLabel.Visible = false; expandLabel.OnClick += new EventHandler(expandLabel_OnClick); }
public Model() { mAmbience = new Ambience(this); //listen to events AttachToAmbience(mAmbience); //here I'll have to work on the scene graph this.mShapes = new ShapeCollection(); //the page collection mPages = new CollectionBase<IPage>(); //the default page mDefaultPage = new Page("Default Page"); mDefaultPage.OnEntityAdded += new EventHandler<EntityEventArgs>(mDefaultPage_OnEntityAdded); mDefaultPage.OnEntityRemoved += new EventHandler<EntityEventArgs>(mDefaultPage_OnEntityRemoved); mDefaultPage.OnClear += new EventHandler(mDefaultPage_OnClear); mPages.Add(mDefaultPage); //initially the current page is the one and only default page mCurrentPage = mDefaultPage; //the paintables mPaintables = new CollectionBase<IDiagramEntity>(); }
/// <summary> /// Perform undo of this command. /// </summary> public override void Undo() { //create a new group GroupShape group = new GroupShape(this.Controller.Model); //asign the entities to the group group.Entities = bundle.Entities; foreach (IDiagramEntity entity in group.Entities) { //this will be recursive if an entity is itself an IGroup entity.Group = group; } //add the new group to the layer this.Controller.Model.DefaultPage.DefaultLayer.Entities.Add(group); mGroup = group; //select the newly created group CollectionBase<IDiagramEntity> col = new CollectionBase<IDiagramEntity>(); col.Add(mGroup); this.Controller.Model.Selection.SelectedItems = col; mGroup.Invalidate(); }
/// <summary> /// Initializes a new instance of the <see cref="T:ConnectorBase"/> class. /// </summary> /// <param name="p">The p.</param> protected ConnectorBase(Point p) : base() { attachedConnectors = new CollectionBase<IConnector>(); this.mPoint = p; }
private CollectionBase<INode> sortedChildren(INode n) { double basevalue = 0; // update basevalue angle for node ordering INode p = n.ParentNode; if (p != null) { basevalue = normalize(Math.Atan2(p.Y - n.Y, p.X - n.X)); } int cc = n.ChildCount; if (cc == 0) return null; INode c = (INode)n.FirstChild; // TODO: this is hacky and will break when filtering // how to know that a branch is newly expanded? // is there an alternative property we should check? //if ( !c.isStartVisible() ) //{ // // use natural ordering for previously invisible nodes // return n.Children; //} double[] angle = new double[cc]; int[] idx = new int[cc]; for (int i = 0; i < cc; ++i, c = c.NextSibling) { idx[i] = i; angle[i] = normalize(-basevalue + Math.Atan2(c.Y - n.Y, c.X - n.X)); } Array.Sort(angle, idx);//or is it the other way around CollectionBase<INode> col = new CollectionBase<INode>(); CollectionBase<INode> children = n.Children; for (int i = 0; i < cc; ++i) { col.Add(children[idx[i]]); } return col; // return iterator over sorted children //return new Iterator() { // int cur = 0; // public Object next() { // return n.getChild(idx[cur++]); // } // public bool hasNext() { // return cur < idx.Length; // } // public void remove() { // throw new UnsupportedOperationException(); // } //}; }
/// <summary> /// Initializes a new instance of the <see cref="T:Bundle"/> class. /// </summary> public Bundle() : base() { mEntities = new CollectionBase<IDiagramEntity>(); }
/// <summary> /// Initializes a new instance of the <see cref="T:Bundle"/> class. /// </summary> public Bundle(IModel model) : base(model) { mEntities = new CollectionBase<IDiagramEntity>(); }
/// <summary> /// Moves the connectors of the children to the central group connector location. /// </summary> internal void MoveConnectors(CollectionBase<IDiagramEntity> entities, Point point) { IConnection cnn; foreach (IDiagramEntity entity in entities) { if (entity is IGroup) { continue; //since we use a flattened collection (the Leafs) we don't care about the groups here //the inclusion of the subgroups in the Leafs is however important to make the subgroups //(in)visible when collapsed/expanded. } if (entity is IShape) { foreach (IConnector cn in (entity as IShape).Connectors) { if (cn.AttachedConnectors.Count > 0) { foreach (IConnector cn2 in cn.AttachedConnectors) { if (cn2.Parent is IConnection) { cnn = cn2.Parent as IConnection; //the ends have to be connected if (cnn.From.AttachedTo.Parent is IShape && cnn.To.AttachedTo.Parent is IShape) { if (entities.Contains(cnn.From.AttachedTo.Parent as IShape) && entities.Contains(cnn.To.AttachedTo.Parent as IShape)) continue;//both endconnectors are internal else//one of the connectors is external { if (entities.Contains(cnn.From.AttachedTo.Parent as IShape)) //the From is internal { MoveConnector(cnn.From, point); } else //the To is internal { MoveConnector(cnn.To, point); } } } } } } } } } }
/// <summary> /// Initializes this instance. /// </summary> private void Init() { mChildren = new CollectionBase<IShapeMaterial>(); mChildren.OnItemAdded += new EventHandler<CollectionEventArgs<IShapeMaterial>>(mChildren_OnItemAdded); mServices = new Dictionary<Type, IInteraction>(); //mChildren.Clear(); //mServices.Clear(); mServices[typeof(IMouseListener)] = this; mServices[typeof(IHoverListener)] = this; }
// ------------------------------------------------------------------ /// <summary> /// Loops through all pages and returns ALL entities that belong to /// this Document. /// </summary> /// <returns>CollectionBase</returns> // ------------------------------------------------------------------ public CollectionBase<IDiagramEntity> GetAllEntities() { CollectionBase<IDiagramEntity> entities = new CollectionBase<IDiagramEntity>(); foreach (IPage page in this.mModel.Pages) { foreach (ILayer layer in page.Layers) { entities.AddRange(layer.Entities); } } return entities; }
private void AttachToEntityCollection(CollectionBase<IDiagramEntity> collection) { collection.OnItemAdded += new EventHandler<CollectionEventArgs<IDiagramEntity>>(mEntities_OnItemAdded); collection.OnItemRemoved += new EventHandler<CollectionEventArgs<IDiagramEntity>>(mEntities_OnItemRemoved); collection.OnClear += new EventHandler(mEntities_OnClear); }
/// <summary> /// Initializes a new instance of the <see cref="T:Layer"/> class. /// </summary> /// <param name="name">The name.</param> public Layer(string name) { mName = name; mEntities = new CollectionBase<IDiagramEntity>(); Init(); }