Ejemplo n.º 1
0
		// Setups router restrictions
		public void SetupRouter(ISMRouter objRouter)
		{
			ISMRouterSetup2 objRouterSetup = null;
			objRouterSetup = objRouter as ISMRouterSetup2;

			try
			{
				// Clear all previous changes
				objRouterSetup.ClearAllRestrictions();

				foreach (RestrictionsInfo objInfo in m_arrRestrictions)
				{
					if (objInfo.m_bChecked)
					{
						// New restriction
						ISMRestriction objRestr = new SMRestrictionClass();

						objRestr.Attribute = objInfo.m_objAttr2 as SMNetAttribute;

						// restriction type
						if (objInfo.m_eType == RestrictControl.ERSType.eStrict)
							objRestr.Type = esriSMRestrictionType.esriSMRTStrict;
						else
							objRestr.Type = esriSMRestrictionType.esriSMRTRelaxed;

                        // Parameter
						if (objInfo.m_bUseParameter)
							objRestr.Param = objInfo.m_dParameter;

						// Add restriction to router
						objRouterSetup.SetRestriction(objRestr as SMRestriction);
					}
				}
			}
			catch (Exception ex)
			{
				objRouterSetup.ClearAllRestrictions();
				MessageBox.Show("Cannot set restrictions.");
			}
		}
Ejemplo n.º 2
0
        // Receives restriction from route and inits controls 
		public void Init(ISMRouter objRouter)
		{
			// clear controls
			ClearAll();

			try
			{
				this.SuspendLayout();
				m_pnlRestrictions.SuspendLayout();

				// Get Net attributes
				ISMNetAttributesCollection objAttrColl = null;
				objAttrColl = objRouter.NetAttributes;

				// attributes count
				int nCount = objAttrColl.Count;

				for (int i = 0; i < nCount; i++)
				{
					// get attribute
					SMNetAttribute objAttr = null;
					objAttr = objAttrColl.get_Item(i);

					if ((objAttr) is ISMNetAttribute2)
					{
						ISMNetAttribute2 objAttr2 = null;
						objAttr2 = objAttr as ISMNetAttribute2;

						// If Usage type is restriction
						esriSMNetAttributeUsageType eType = 0;
						eType = objAttr2.UsageType;

						if (eType == esriSMNetAttributeUsageType.esriSMNAUTRestrictionBoolean 
							|| eType == esriSMNetAttributeUsageType.esriSMNAUTRestrictionMinAllowed 
							|| eType == esriSMNetAttributeUsageType.esriSMNAUTRestrictionMaxAllowed)
						{

							// create control for restriction
							RestrictControl ctrlRestriction = null;
							ctrlRestriction = new RestrictControl();

							// create restriction info
							RestrictionsInfo objRestriction = null;
							objRestriction = new RestrictionsInfo();

							// Init info
							objRestriction.m_objAttr2 = objAttr2;
							objRestriction.m_strName = objAttr2.Name;
							objRestriction.m_bChecked = false;
							objRestriction.m_eType = RestrictControl.ERSType.eStrict;
							objRestriction.m_bUseParameter = false;

							if (eType != esriSMNetAttributeUsageType.esriSMNAUTRestrictionBoolean)
							{
								objRestriction.m_bUseParameter = true;
								objRestriction.m_dParameter = 0.0;
							}

							// Add controls (reverse order)
							ctrlRestriction.Dock = DockStyle.Top;
							m_pnlRestrictions.Controls.Add(ctrlRestriction);

							m_arrRestrictions.Add(objRestriction);
						}
					}
				}

				// Set restriction info to controls
				UpdateControls();

			}
			catch (Exception ex)
			{
				ClearAll();
			}
			finally
			{
				m_pnlRestrictions.ResumeLayout(false);
				this.ResumeLayout(false);
			}
		}