public void Features_IsEnabled_ReturnsTrue_WhenPathIsMoreComplexThanFeatureInRegistry()
 {
     // test feature a/b/c where value in registry is just a (signifying all features registered)
     var feature = new Feature("a");
     var attribute = new FeatureAttribute("a", "b", "c");
     Assert.True(Features.IsEnabled(SetupRegistry(feature), new[] { "a", "b", "c" }));
 }
		public GenericHandler(string contentType, EndpointAttributes handlerAttributes, Feature format)
		{
			this.HandlerContentType = contentType;
			this.ContentTypeAttribute = ContentFormat.GetEndpointAttributes(contentType);
			this.HandlerAttributes = handlerAttributes;
			this.format = format;
		}
        void CheckOverlayWithinBounds(Feature feature)
        {
            var errors = new List<string>();
            _geoArray = GeoArray.FromWellKnownText(feature.GetWellKnownText());
            OnPropertyChanged("GeoArray");
#if false
            if (_writeKML)
            {
                var kml = new KMLRoot();
                var folder = new Folder("Overlay Segment Test");
                var segments = _geoArray.Segments.ToArray();
                for (var segment = 0; segment < segments.Length; segment++)
                {
                    segments[segment].Placemark.name = string.Format("Segment {0}", segment);
                    folder.Add(segments[segment].Placemark);
                }
                kml.Document.Add(folder);
                var savePath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), "Overlay Segment Tests", "OverlaySegmentTest.kml");
                kml.Save(savePath);
                _writeKML = false;
            }
#endif
            if (_geoArray.HasCrossingSegments && !AreCrossingSegmentsAllowed) errors.Add("Perimeter segments may not cross");
            if (_locationBoundsRectangle != null && !_locationBoundsRectangle.Contains(feature.GetShape())) errors.Add("Perimeter must be within location bounds");
            var areaStyle = errors.Count > 0 ? _errorAreaStyle : _normalAreaStyle;
            _wpfMap.EditOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = areaStyle;
            _wpfMap.EditOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            Errors = errors.Count == 0 ? string.Empty : string.Join("\n", errors);
            HasErrors = errors.Count > 0;
            if (HasErrors) Debug.WriteLine(string.Format("Errors: {0}", Errors));
        }
        public void ShouldRecordGateInstrumentationForIsEnabledFor([Values(true,false)] Boolean enabled)
        {
            var instrumenter = new MockInstrumenter();
            var feature = new Feature("Name", new MemoryAdapter(), instrumenter);

            var flipperActor = MockActor("User:5");
            if (enabled)
            {
                feature.EnableActor(flipperActor);
            } else
            {
                feature.DisableActor(flipperActor);
            }
            instrumenter.Events.Clear();

            feature.IsEnabledFor(flipperActor);

            var expectedPayload = new InstrumentationPayload {
                FeatureName = "Name",
                GateName = "actor",
                Operation = "open?",
                Thing = flipperActor,
                Result = enabled,
            };
            if (enabled)
            {
                expectedPayload.GateName = feature.ActorGate.Name;
            }
            var expectedEvent = new MockInstrumenter.Event {
                Type = InstrumentationType.GateOperation,
                Payload = expectedPayload,
            };

            Assert.That(instrumenter.Events, Has.Member(expectedEvent));
        }
Beispiel #5
0
 public FeatureViewModel(Feature feature)
 {
     Text = MarkdownHelper.Markdown(feature.Text);
     FriendlyTime = FriendlyTimeHelper.Parse(feature.Time);
     Author = feature.User.UserName;
     GravatarUrl = (string.IsNullOrEmpty(feature.User.AvatarUrl)) ? feature.User.Email.ToGravatarUrl(40) : feature.User.AvatarUrl;
 }
Beispiel #6
0
 public Scenario(Feature feature)
 {
     Steps = new List<Step>();
     Components = new List<Component>();
     Container = feature.Container.Scope();
     Props = new Dictionary<string, object>();
 }
Beispiel #7
0
 /// <summary>
 /// Creates a specified number of random point features inside a single polygon feature. 
 /// </summary>
 /// <param name="ConstrainingFeature">Random points will be generated inside this polygon feature.</param>
 /// <param name="NumberOfPoints">The number of points to be randomly generated.</param>
 /// <returns>A point feature set with the randomly created features.</returns>
 public static FeatureSet RandomPoints(Feature ConstrainingFeature, int NumberOfPoints)
 {
     //This function generates random points within the boundaries of one polygon feature
     FeatureSet fsOut = new FeatureSet();
     fsOut.FeatureType = FeatureType.Point;
     Coordinate c = new Coordinate();
     Random r = new Random();
     int i = 0;
     while (i < NumberOfPoints)
     {
         c = new Coordinate();
         //make a random point somewhere in the rectangular extents of the feature
         double rndx = r.Next(0, 100000) / 100000.0;
         double rndy = r.Next(0, 100000) / 100000.0;
         c.X = rndx * (ConstrainingFeature.Envelope.Right() - ConstrainingFeature.Envelope.Left()) + ConstrainingFeature.Envelope.Left();
         c.Y = rndy * (ConstrainingFeature.Envelope.Top() - ConstrainingFeature.Envelope.Bottom()) + ConstrainingFeature.Envelope.Bottom();
         //check if the point falls within the polygon featureset
         if (ConstrainingFeature.Intersects(c))
         {
             fsOut.AddFeature(new Feature(c));
             i++;
         }
     }
     return fsOut;
 }
Beispiel #8
0
        private void ExceptionsScreen_OnLoaded(object sender, RoutedEventArgs e)
        {
            var core = AppContextObsolete.AppContext;
            var feature = new Feature(@"Exceptions", @"Load");
            try
            {
                var s = Stopwatch.StartNew();

                try
                {
                    FeatureManager.CreateSchema(core.DbContextCreator);
                }
                catch { }

                core.FeatureManager.Load(core.DbContextCreator);

                core.FeatureManager.Write(feature, string.Empty);
                this.ViewModel.Load(
                    ExceptionsDataProvider.GetTimePeriods,
                    ExceptionsDataProvider.GetVersions,
                    ExceptionsDataProvider.GetExceptions,
                    ExceptionsDataProvider.GetExceptionsCounts);
                s.Stop();
                Debug.WriteLine(s.ElapsedMilliseconds);
            }
            catch (Exception ex)
            {
                core.Log(ex.ToString(), LogLevel.Error);
                core.FeatureManager.Write(feature, ex);
            }
        }
Beispiel #9
0
        public void SetFeatureActivity(Feature feature, List<LabClient> selectedClients, bool active)
        {
            var exists = false;
            DataGridColumn column = null;
            switch (feature)
            {
                case Feature.WEB:
                    selectedClients.ForEach(i => i.Web = active);
                    exists = clients.Exists(i => i.Web);
                    column = dgrClients.Columns[8];
                    break;
                case Feature.SHARESCR:
                    selectedClients.ForEach(i => i.ShareScr = active);
                    exists = clients.Exists(i => i.ShareScr);
                    column = dgrClients.Columns[9];
                    break;
                case Feature.INPUT:
                    selectedClients.ForEach(i => i.Input = active);
                    exists = clients.Exists(i => i.Input);
                    column = dgrClients.Columns[10];
                    break;
                case Feature.NOTIFY:
                    selectedClients.ForEach(i => i.Notify = active);
                    exists = clients.Exists(i => i.Notify);
                    column = dgrClients.Columns[2];
                    break;
            }
            SetColumnVisibility(column, exists);

        }
Beispiel #10
0
        public void SetPropertyValue()
        {
            var ft = new Feature(Exp.SomeFeature);
            ft = ft.Set(Exp.SomeProperty, 10);

            Assert.Equal(10, ft.Get(Exp.SomeProperty));
        }
Beispiel #11
0
 public void DynamicEnabledFeatureIsEnabled()
 {
     var method = typeof(FeatureFacts)
         .GetMethod("Enabled");
     var feature = new Feature("DynamicDisabled", method);
     Assert.True(feature.IsEnabled);
 }
Beispiel #12
0
        /// <summary>
        /// Check if this device is supporting a feature.
        /// </summary>
        /// <param name="feature">The feature to check.</param>
        /// <returns>
        /// Returns true if this device supports this feature, otherwise false.
        /// </returns>
        public bool CheckFeatureSupport(Feature feature)
        {
            unsafe
            {
                switch (feature)
                {
                    case Feature.Doubles:
                        {
                            FeatureDataDoubles support;

                            if (CheckFeatureSupport(Feature.Doubles, new IntPtr(&support), Utilities.SizeOf<FeatureDataDoubles>()).Failure)
                                return false;
                            return support.DoublePrecisionFloatShaderOps;
                        }
                    case Feature.D3D10XHardwareOptions:
                        {
                            FeatureDataD3D10XHardwareOptions support;
                            if (CheckFeatureSupport(Feature.D3D10XHardwareOptions, new IntPtr(&support), Utilities.SizeOf<FeatureDataD3D10XHardwareOptions>()).Failure)
                                return false;
                            return support.ComputeShadersPlusRawAndStructuredBuffersViaShader4X;
                        }
                    default:
                        throw new SharpDXException("Unsupported Feature. Use specialized CheckXXX methods");
                }
            }
        }
Beispiel #13
0
 public FeatureNode(FileSystemInfoBase location, string relativePathFromRoot, Feature feature)
 {
     this.OriginalLocation = location;
     this.OriginalLocationUrl = location.ToUri();
     this.RelativePathFromRoot = relativePathFromRoot;
     this.Feature = feature;
 }
        public void ShouldRecordInstrumentationForIsEnabled([Values(true,false)] Boolean enabled)
        {
            var instrumenter = new MockInstrumenter();
            var feature = new Feature("Name", new MemoryAdapter(), instrumenter);

            if (enabled)
            {
                feature.Enable();
            } else
            {
                feature.Disable();
            }
            instrumenter.Events.Clear();

            feature.IsEnabled();

            var expectedPayload = new InstrumentationPayload {
                FeatureName = "Name",
                Operation = "enabled?",
                Thing = null,
                Result = enabled
            };
            var expectedEvent = new MockInstrumenter.Event {
                Type = InstrumentationType.FeatureOperation,
                Payload = expectedPayload,
            };

            Assert.That(instrumenter.Events, Has.Member(expectedEvent));
        }
        public IDictionary<string, object> Get(Feature feature)
        {
            var result = new Dictionary<string, object>();

            foreach (var gate in feature.Gates)
            {
                if (gate.DataType == typeof (bool))
                {
                    result[gate.Key] = ReadBool(Key(feature, gate));
                }
                else if (gate.DataType == typeof (int))
                {
                    result[gate.Key] = ReadInt(Key(feature, gate));
                }
                else if (gate.DataType == typeof (ISet<string>))
                {
                    result[gate.Key] = ReadSet(Key(feature, gate));
                }
                else
                {
                    UnsupportedDataType(gate);
                }
            }

            return result;
        }
 public void SetUp()
 {
     FlipperActor = MockActor("User:5");
     StatsdClient = MockRepository.GenerateStub<IStatsd>();
     Instrumenter = new StatsdInstrumenter(StatsdClient);
     Feature = new Feature("Name", new MemoryAdapter(), Instrumenter);
 }
 private string getFeatureLines(Feature ftr)
 {
     string retString = "";
     if (ftr.myChildren.Count > 0)
     {
         if (ftr.getPercentComplete() == 100)
         {
             retString += "<li title=\"" + ftr.getFeatureDescription() + "\"><table width=\"100%\"><tr><td align=\"left\">" + ftr.getFeatureName() + "&nbsp;&nbsp;<font color=\"green\"><i>" + ftr.getPercentComplete() + "%</i></font></td></tr></table><ul><hr style=\"height:1px; margin:2px;\" />";
         }
         else
         {
             retString += "<li title=\"" + ftr.getFeatureDescription() + "\"><table width=\"100%\"><tr><td align=\"left\">" + ftr.getFeatureName() + "&nbsp;&nbsp;<font color=\"red\"><i>" + ftr.getPercentComplete() + "%</i></font></td></tr></table><ul><hr style=\"height:1px; margin:2px;\" />";
         }
         foreach (Feature child in ftr.myChildren)
         {
             retString += getFeatureLines(child);
         }
         retString += "</ul></li>";
     }
     else
     {
         if (ftr.getPercentComplete() == 100)
         {
             retString += "<li title=\"" + ftr.getFeatureDescription() + "\"><table width=\"100%\"><tr><td align=\"left\">" + ftr.getFeatureName() + "&nbsp;&nbsp;<font color=\"green\"><i>" + ftr.getPercentComplete() + "%</i></font></td></tr></table><hr style=\"height:1px; margin:2px;\" />";
         }
         else
         {
             retString += "<li title=\"" + ftr.getFeatureDescription() + "\"><table width=\"100%\"><tr><td align=\"left\">" + ftr.getFeatureName() + "&nbsp;&nbsp;<font color=\"red\"><i>" + ftr.getPercentComplete() + "%</i></font></td></tr></table><hr style=\"height:1px; margin:2px;\" />";
         }
     }
     return retString;
 }
 public void Clear(Feature feature)
 {
     foreach (var gate in feature.Gates)
     {
         Delete(Key(feature, gate));
     }
 }
Beispiel #19
0
    public static void LogFeature(Feature feature)
    {
        System.Console.WriteLine("-----------------");
        System.Console.WriteLine("Feature : "+feature.Reference);
        System.Console.WriteLine("Feature is lifetime : "+feature.IsLifetime());

        if( !feature.IsLifetime() )
        {
            System.Console.WriteLine("Feature TTL : "+feature.Ttl);
        }

        System.Console.WriteLine("Feature has value : "+feature.HasValue());

        if( feature.HasValue() )
        {
            System.Console.WriteLine("Feature value : "+feature.Value);
        }

        System.Console.WriteLine("Feature is in bundle : "+feature.IsInBundle());

        if( feature.IsInBundle() )
        {
            System.Console.WriteLine("Feature bundle : "+feature.BundleReference);
        }

        System.Console.WriteLine("-----------------");
    }
 public override void BeforeFeature(Feature feature)
 {
     WriteLine(ConsoleColor.Cyan, 0, @"{0}
     Feature: {1}",
               feature.Tags.Select(t => string.Format(@"@{0}", t)).JoinToString(" "), feature.Headline);
     WriteLine(ConsoleColor.Cyan, 1, feature.Description);
 }
Beispiel #21
0
 public void Should_update_featureContext_with_feature_title()
 {
     const string featureTitle = "feature title";
     var f = new Feature(featureTitle);
     sut.OnFeatureStartedEvent(f);
     Assert.That(featureContext.FeatureTitle, Is.EqualTo(featureTitle));
 }
        private void btnBegin_Click(object sender, RoutedEventArgs e)
        {
            int pointsCount = Convert.ToInt32(((ComboBoxItem)cbxPointCount.SelectedItem).Content);
            LayerOverlay pointsOverlay = (LayerOverlay)wpfMap1.Overlays["PointsOverlay"];
            InMemoryFeatureLayer pointsLayer = (InMemoryFeatureLayer)pointsOverlay.Layers["PointsLayer"];

            pointsLayer.InternalFeatures.Clear();
            for (int i = 0; i < pointsCount; i++)
            {
                PointShape pointShape = GetRandomPoint(pointsBoundary);
                string id = GetRandomDirection().ToString();
                Feature feature = new Feature(pointShape.X, pointShape.Y, id);
                pointsLayer.InternalFeatures.Add(feature);
            }

            pointsOverlay.Refresh();

            // Starts the move points timer
            movePointsTimer.Change(0, Convert.ToInt32(((ComboBoxItem)cbxRedrawInterval.SelectedItem).Content));

            // Starts the color changing timer
            changeColorTimer.Change(0, Convert.ToInt32(((ComboBoxItem)cbxChangeColorInterval.SelectedItem).Content));

            btnBegin.IsEnabled = false;
            btnStop.IsEnabled = true;
        }
        public PopupUserControl(Feature feature)
        {
            InitializeComponent();

            string speed = feature.ColumnValues["Speed"];
            string name = feature.ColumnValues["VehicleName"];
            string latitude = feature.ColumnValues["Latitude"];
            string dateTime = feature.ColumnValues["DateTime"];
            string longitude = feature.ColumnValues["Longitude"];

            txtName.Text = name;
            double x, y;
            if (double.TryParse(longitude, out x) && double.TryParse(latitude, out y))
            {
                ManagedProj4Projection proj4 = new ManagedProj4Projection();
                proj4.InternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString();
                proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
                proj4.Open();

                Vertex vertex = proj4.ConvertToInternalProjection(x, y);
                txtLongitude.Text = vertex.X.ToString("N6", CultureInfo.InvariantCulture);
                txtLatitude.Text = vertex.Y.ToString("N6", CultureInfo.InvariantCulture);

                proj4.Close();
            }
            else
            {
                txtLongitude.Text = longitude;
                txtLatitude.Text = latitude;
            }

            txtSpeed.Text = speed + " mph";
            txtTime.Text = dateTime;
        }
        private void convertWkbToFeature_Click(object sender, RoutedEventArgs e)
        {
            byte[] wellKnownBinary = Convert.FromBase64String(wkbTextBox.Text);
            Feature feature = new Feature(wellKnownBinary);

            wktResultTextBox.Text = feature.GetWellKnownText();
        }
 public GenericHandler(string contentType, EndpointAttributes handlerAttributes, Feature usesFeature)
 {
     this.HandlerContentType = contentType;
     this.ContentTypeAttribute = ContentType.GetEndpointAttributes(contentType);
     this.HandlerAttributes = handlerAttributes;
     this.usesFeature = usesFeature;
 }
Beispiel #26
0
        public void Should_add_table_steps_to_scenario()
        {
            var gherkinEvents = MockRepository.GenerateStub<IGherkinParserEvents>();
            var stepBuilder = new StepBuilder(gherkinEvents);
            var feature = new Feature("title");
            var scenario = new Scenario("title", "source", feature);
            gherkinEvents.Raise(_ => _.FeatureEvent += null, this, new EventArgs<Feature>(feature));
            gherkinEvents.Raise(_ => _.ScenarioEvent += null, this, new EventArgs<Scenario>(scenario));
            gherkinEvents.Raise(_ => _.StepEvent += null, this, new EventArgs<StringStep>(new StringStep("step 1", "source")));
            gherkinEvents.Raise(_ => _.StepEvent += null, this, new EventArgs<StringStep>(new StringStep("step 2", "source")));
            gherkinEvents.Raise(_ => _.TableEvent += null, this,
                                new EventArgs<IList<IList<Token>>>(new List<IList<Token>>
                                                                       {
                                                                           new List<Token>
                                                                               {
                                                                                   new Token("A", new LineInFile(1)),
                                                                                   new Token("B", new LineInFile(1))
                                                                               },
                                                                           new List<Token>
                                                                               {
                                                                                   new Token("1", new LineInFile(2)),
                                                                                   new Token("2", new LineInFile(2))
                                                                               },

                                                                       }));
            gherkinEvents.Raise(_ => _.EofEvent += null, this, new EventArgs());

            Assert.That(scenario.Steps.Count(), Is.EqualTo(2));
            Assert.That(scenario.Steps.ToList()[0], Is.TypeOf<StringStep>());
            Assert.That(scenario.Steps.ToList()[1], Is.TypeOf<StringTableStep>());
        }
        private void convertFeatureToWkb_Click(object sender, RoutedEventArgs e)
        {
            Feature feature = new Feature(wktTextBox.Text);
            byte[] wellKnownBinary = feature.GetWellKnownBinary();

            wkbResultTextBox.Text = Convert.ToBase64String(wellKnownBinary);
        }
Beispiel #28
0
    public static void Main(string[] args)
    {
        var binaries = new Feature("MyApp Binaries", "Application binaries");
        var docs = new Feature("MyApp Documentation");
        var tuts = new Feature("MyApp Tutorial");

        docs.Add(tuts);
        binaries.Add(docs);

        var project =
            new Project("MyProduct",
                new Dir(@"%ProgramFiles%\My Company\My Product",
                    new File(binaries, @"Files\Bin\MyApp.exe"),
                    new Dir(@"Docs\Manual",
                        new File(docs, @"Files\Docs\Manual.txt"),
                        new File(tuts, @"Files\Docs\Tutorial.txt"))));

        project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");
        project.UI = WUI.WixUI_FeatureTree;

        project.DefaultFeature = binaries; //this line is optional

        project.PreserveTempFiles = true;

        project.BuildMsi();
    }
Beispiel #29
0
        public void FeaturesAreNotSame()
        {
            var feature1 = new Feature<Point>
            {
                Geometry = new Point { X = 50.342, Y = -2, SpatialReference = SpatialReference.WGS84 }
            };

            var feature2 = new Feature<Point>
            {
                Geometry = new Point { X = 50.342, Y = -30.331, SpatialReference = SpatialReference.WGS84 }
            };

            var feature3 = new Feature<Point>
            {
                Geometry = new Point { X = 50.342, Y = -30.331, SpatialReference = SpatialReference.WGS84 }
            };
            feature3.Attributes.Add("random", "rtcxbvbx");
            feature3.Attributes.Add("something", 45445);

            var feature4 = new Feature<Point>
            {
                Geometry = new Point { X = 50.342, Y = -30.331, SpatialReference = SpatialReference.WGS84 }
            };
            feature4.Attributes.Add("random", "rtcxbvbx");
            feature4.Attributes.Add("something", 4);

            Assert.NotEqual(feature1, feature2);
            Assert.NotEqual(feature3, feature4);
            Assert.NotEqual(feature1, feature3);
            Assert.NotEqual(feature1, feature4);
            Assert.NotEqual(feature2, feature3);
            Assert.NotEqual(feature2, feature4);
        }
Beispiel #30
0
 public void Should_set_tags_for_feature_event()
 {
     var feature = new Feature("featureTitle");
     feature.AddTags(new[] { "tag1", "tag2" });
     sut.OnFeatureStartedEvent(feature);
     CollectionAssert.AreEqual(new[] { "tag1", "tag2" }, featureContext.Tags);
 }
Beispiel #31
0
 public void Enabling(Feature feature)
 {
 }
Beispiel #32
0
        public void GenerateSeedData()
        {
            EntityManager entityManager = new EntityManager();

            try
            {


                #region create Entities

                // Entities
                Entity entity = entityManager.Entities.Where(e => e.Name.ToUpperInvariant() == "Event".ToUpperInvariant()).FirstOrDefault();

                if (entity == null)
                {
                    entity = new Entity();
                    entity.Name = "Event";
                    entity.EntityType = typeof(Event);
                    entity.EntityStoreType = typeof(EventStore);
                    entity.UseMetadata = true;
                    entity.Securable = true;

                    entityManager.Create(entity);
                }
                #endregion

                #region SECURITY

                OperationManager operationManager = new OperationManager();
                FeatureManager featureManager = new FeatureManager();

                try
                {
                    Feature rootEventManagementFeature = featureManager.FeatureRepository.Get().FirstOrDefault(f => f.Name.Equals("Event Management"));
                    if (rootEventManagementFeature == null) rootEventManagementFeature = featureManager.Create("Event Management", "Event Management");

                    Feature eventRegistrationFeature = featureManager.FeatureRepository.Get().FirstOrDefault(f => f.Name.Equals("Event Registration"));
                    if (eventRegistrationFeature == null) eventRegistrationFeature = featureManager.Create("Event Registration", "Event Registration", rootEventManagementFeature);

                    Feature eventAdministrationFeature = featureManager.FeatureRepository.Get().FirstOrDefault(f => f.Name.Equals("Event Administration"));
                    if (eventAdministrationFeature == null) eventAdministrationFeature = featureManager.Create("Event Administration", "Event Administration", rootEventManagementFeature);

                    Feature eventRegistrationResultFeature = featureManager.FeatureRepository.Get().FirstOrDefault(f => f.Name.Equals("Event Registration Result"));
                    if (eventRegistrationResultFeature == null) eventRegistrationResultFeature = featureManager.Create("Event Registration Result", "Event Registration Result", rootEventManagementFeature);

                    operationManager.Create("EMM", "EventRegistration", "*", eventRegistrationFeature);
                    operationManager.Create("EMM", "Event", "*", eventAdministrationFeature);
                    operationManager.Create("EMM", "EventRegistrationResult", "*", eventRegistrationResultFeature);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    featureManager.Dispose();
                    operationManager.Dispose();
                }

                #endregion

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                entityManager.Dispose();
            }
        }
Beispiel #33
0
 private static DependencyBlueprintItem BuildModule(Type type, Feature feature)
 {
     return(new DependencyBlueprintItem {
         Type = type, Feature = feature
     });
 }
 void IFeatureEventHandler.Uninstalled(Feature feature)
 {
 }
 void IFeatureEventHandler.Disabled(Feature feature)
 {
 }
 void IFeatureEventHandler.Enabled(Feature feature)
 {
 }
 void IFeatureEventHandler.Enabling(Feature feature)
 {
 }
 void IFeatureEventHandler.Installing(Feature feature)
 {
     AddDefaultRolesForFeature(feature);
 }
Beispiel #39
0
 public bool HasFeature(Feature feature)
 {
     return((feature & EndpointHost.Config.EnableFeatures) == feature);
 }
Beispiel #40
0
        private void ReadFromShapeFile()
        {
            var          featureCollection = new List <IFeature>();
            const string filename          = @"country";

            if (!File.Exists(filename + ".dbf"))
            {
                throw new FileNotFoundException(filename + " not found at " + Environment.CurrentDirectory);
            }
            var dataReader = new ShapefileDataReader(filename, new GeometryFactory());

            while (dataReader.Read())
            {
                var feature = new Feature {
                    Geometry = dataReader.Geometry
                };

                int      length = dataReader.DbaseHeader.NumFields;
                string[] keys   = new string[length];
                for (int i = 0; i < length; i++)
                {
                    keys[i] = dataReader.DbaseHeader.Fields[i].Name;
                }

                feature.Attributes = new AttributesTable();
                for (int i = 0; i < length; i++)
                {
                    object val = dataReader.GetValue(i);
                    feature.Attributes.AddAttribute(keys[i], val);
                }

                featureCollection.Add(feature);
            }

            int index = 0;

            Console.WriteLine("Elements = " + featureCollection.Count);
            foreach (var feature in featureCollection)
            {
                Console.WriteLine("Feature " + index++);
                var table = feature.Attributes as AttributesTable;
                foreach (string name in table.GetNames())
                {
                    Console.WriteLine(name + ": " + table[name]);
                }
            }

            //Directory
            string dir = CommonHelpers.TestShapefilesDirectory + Path.DirectorySeparatorChar;
            // Test write with stub header
            string file = dir + "testWriteStubHeader";

            if (File.Exists(file + ".shp"))
            {
                File.Delete(file + ".shp");
            }
            if (File.Exists(file + ".shx"))
            {
                File.Delete(file + ".shx");
            }
            if (File.Exists(file + ".dbf"))
            {
                File.Delete(file + ".dbf");
            }

            var dataWriter = new ShapefileDataWriter(file);

            dataWriter.Header = ShapefileDataWriter.GetHeader(featureCollection[0] as IFeature, featureCollection.Count);
            dataWriter.Write(featureCollection);

            // Test write with header from a existing shapefile
            file = dir + "testWriteShapefileHeader";
            if (File.Exists(file + ".shp"))
            {
                File.Delete(file + ".shp");
            }
            if (File.Exists(file + ".shx"))
            {
                File.Delete(file + ".shx");
            }
            if (File.Exists(file + ".dbf"))
            {
                File.Delete(file + ".dbf");
            }

            dataWriter = new ShapefileDataWriter(file)
            {
                Header =
                    ShapefileDataWriter.GetHeader(dir + "country.dbf")
            };
            dataWriter.Write(featureCollection);
        }
Beispiel #41
0
        public void TestGetField()
        {
            var area = new Feature(new GridRectangle(0, 0, 10, 10));

            Assert.Equal(5, area.GetFieldAt(5, 0).Coordinates.X);
        }
        async private Task Query()
        {
            _features.Clear();

            string where = String.IsNullOrEmpty(_where) ?
                           $"{ _featureClass.IDFieldName }>{ _lastOid }" :
                           $"{ _where } and { _featureClass.IDFieldName }>{ _lastOid }";

            var postData = $"{ _postData }&orderByFields={ _featureClass.IDFieldName }&where={ where.UrlEncodeWhereClause() }";

            var jsonFeatureResponse = await _dataset.TryPostAsync <JsonFeatureResponse>(_queryUrl, postData);

            #region Parse Field Types (eg. is Date?)

            List <string> dateColumns = new List <string>();
            if (_featureClass?.Fields != null)
            {
                foreach (var field in _featureClass.Fields.ToEnumerable())
                {
                    if (field.type == FieldType.Date)
                    {
                        dateColumns.Add(field.name);
                    }
                }
            }

            #endregion

            foreach (var jsonFeature in jsonFeatureResponse.Features)
            {
                Feature feature = new Feature();

                #region Geometry

                if (_featureClass.GeometryType == geometryType.Polyline && jsonFeature.Geometry?.Paths != null)
                {
                    Polyline polyline = new Polyline();
                    for (int p = 0, to = jsonFeature.Geometry.Paths.Length; p < to; p++)
                    {
                        Path path = new Path();

                        var pathsPointsArray       = jsonFeature.Geometry.Paths[p];
                        var dimension              = pathsPointsArray.GetLength(1); // 2D 3D 3D+M ?
                        int pathsPointsArrayLength = (pathsPointsArray.Length / dimension);

                        for (int multiArrayIndex = 0; multiArrayIndex < pathsPointsArrayLength; multiArrayIndex++)
                        {
                            path.AddPoint(ArrayToPoint(pathsPointsArray, multiArrayIndex, dimension));
                        }
                        polyline.AddPath(path);
                    }

                    feature.Shape = polyline;
                }
                else if (_featureClass.GeometryType == geometryType.Polygon && jsonFeature.Geometry?.Rings != null)
                {
                    Polygon polygon = new Polygon();
                    for (int r = 0, to = jsonFeature.Geometry.Rings.Length; r < to; r++)
                    {
                        Ring ring = new Ring();

                        var ringsPointsArray       = jsonFeature.Geometry.Rings[r];
                        var dimension              = ringsPointsArray.GetLength(1); // 2D 3D 3D+M ?
                        int ringsPointsArrayLength = (ringsPointsArray.Length / dimension);

                        for (int multiArrayIndex = 0; multiArrayIndex < ringsPointsArrayLength; multiArrayIndex++)
                        {
                            //Point point = new Point();
                            //point.X = ringsPointsArray[multiArrayIndex, 0];
                            //point.Y = ringsPointsArray[multiArrayIndex, 1];

                            ring.AddPoint(ArrayToPoint(ringsPointsArray, multiArrayIndex, dimension));
                        }
                        polygon.AddRing(ring);
                    }

                    feature.Shape = polygon;
                }
                else if (_featureClass.GeometryType == geometryType.Point &&
                         (jsonFeature.Geometry?.X != null) &&
                         (jsonFeature.Geometry?.Y != null)
                         )
                {
                    Point shape = _featureClass.HasM ? new PointM() : new Point();
                    shape.X = jsonFeature.Geometry.X.Value;
                    shape.Y = jsonFeature.Geometry.Y.Value;

                    if (_featureClass.HasZ && jsonFeature.Geometry.Z.HasValue)
                    {
                        shape.Z = jsonFeature.Geometry.Z.Value;
                    }

                    if (this._featureClass.HasM && jsonFeature.Geometry.M.HasValue)
                    {
                        ((PointM)shape).M = jsonFeature.Geometry.M.Value;
                    }

                    feature.Shape = shape;
                }
                else if (_featureClass.GeometryType == geometryType.Multipoint &&
                         jsonFeature.Geometry?.Points != null &&
                         jsonFeature.Geometry.Points.Length > 0)
                {
                    MultiPoint multiPoint = new MultiPoint();

                    for (int p = 0, pointCount = jsonFeature.Geometry.Points.Length; p < pointCount; p++)
                    {
                        var doubleArray = jsonFeature.Geometry.Points[p];
                        if (doubleArray.Length >= 2)
                        {
                            var point = new Point(doubleArray[0].Value, doubleArray[1].Value);

                            multiPoint.AddPoint(point);
                        }
                    }

                    feature.Shape = multiPoint;
                }
                else
                {
                }

                #endregion

                #region Properties

                if (jsonFeature.Attributes != null)
                {
                    var attribiutes = (IDictionary <string, object>)jsonFeature.Attributes;
                    foreach (var name in attribiutes.Keys)
                    {
                        object value = attribiutes[name];

                        if (dateColumns.Contains(name))
                        {
                            try
                            {
                                long     esriDate = Convert.ToInt64(value);
                                DateTime td       = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(esriDate);
                                feature.Fields.Add(new FieldValue(name, td));
                            }
                            catch // if date is not a long?!
                            {
                                feature.Fields.Add(new FieldValue(name, value?.ToString()));
                            }
                        }
                        else
                        {
                            //if (!filter.SuppressResolveAttributeDomains && _domains != null && _domains.ContainsKey(name))
                            //{
                            //    value = DomainValue(name, value?.ToString());
                            //}
                            feature.Fields.Add(new FieldValue(name, value?.ToString()));
                        }

                        if (name == _featureClass.IDFieldName)
                        {
                            feature.OID = int.Parse(value.ToString());
                            _lastOid    = Math.Max(_lastOid, feature.OID);
                        }
                    }
                }

                #endregion

                _features.Add(feature);
            }

            _hasMore = _lastOid > 0 && jsonFeatureResponse.ExceededTransferLimit;

            //_hasMore = false;
        }
Beispiel #43
0
        private void TestWriteZMValuesShapeFile(bool testM)
        {
            var points = new Coordinate[3];

            points[0] = new Coordinate(0, 0);
            points[1] = new Coordinate(1, 0);
            points[2] = new Coordinate(1, 1);

            var csFactory = DotSpatialAffineCoordinateSequenceFactory.Instance;
            var sequence  = csFactory.Create(3, Ordinates.XYZM);

            for (var i = 0; i < 3; i++)
            {
                sequence.SetOrdinate(i, Ordinate.X, points[i].X);
                sequence.SetOrdinate(i, Ordinate.Y, points[i].Y);
                sequence.SetOrdinate(i, Ordinate.Z, 1 + i);
                if (testM)
                {
                    sequence.SetOrdinate(i, Ordinate.M, 11 + i);
                }
            }
            var lineString = Factory.CreateLineString(sequence);

            var attributes = new AttributesTable();

            attributes.Add("FOO", "Trond");

            var feature  = new Feature(Factory.CreateMultiLineString(new[] { lineString }), attributes);
            var features = new Feature[1];

            features[0] = feature;

            var shpWriter = new ShapefileDataWriter("ZMtest", Factory)
            {
                Header = ShapefileDataWriter.GetHeader(features[0], features.Length)
            };

            shpWriter.Write(features);

            // Now let's read the file and verify that we got Z and M back
            var factory = new GeometryFactory(DotSpatialAffineCoordinateSequenceFactory.Instance);

            using (var reader = new ShapefileDataReader("ZMtest", factory))
            {
                reader.Read();
                var geom = reader.Geometry;

                for (var i = 0; i < 3; i++)
                {
                    var c = geom.Coordinates[i];
                    Assert.AreEqual(i + 1, c.Z);
                }

                if (testM)
                {
                    sequence = ((ILineString)geom).CoordinateSequence;
                    for (var i = 0; i < 3; i++)
                    {
                        Assert.AreEqual(sequence.GetOrdinate(i, Ordinate.M), 11 + i);
                    }
                }

                // Run a simple attribute test too
                var v = reader.GetString(1);
                Assert.AreEqual(v, "Trond");
            }
        }
Beispiel #44
0
        private void CreateFeature()
        {
            lock (_sync)
            {
                if (_feature == null)
                {
                    // Create a new one
                    _feature = new Feature
                    {
                        Geometry  = Position.ToMapsui(),
                        ["Label"] = Label,
                    };
                }
                // Check for bitmapId
                if (_bitmapId != -1)
                {
                    // There is already a registered bitmap, so delete it
                    BitmapRegistry.Instance.Unregister(_bitmapId);
                    // We don't have any bitmap up to now
                    _bitmapId = -1;
                }

                Stream stream = null;

                switch (Type)
                {
                case PinType.Svg:
                    // Load the SVG document
                    if (!string.IsNullOrEmpty(Svg))
                    {
                        stream = new MemoryStream(Encoding.UTF8.GetBytes(Svg));
                    }
                    if (stream == null)
                    {
                        return;
                    }
                    _bitmapId = BitmapRegistry.Instance.Register(stream);
                    break;

                case PinType.Pin:
                    // First we have to create a bitmap from Svg code
                    // Create a new SVG object
                    var svg = new SkiaSharp.Extended.Svg.SKSvg();
                    // Load the SVG document
                    stream = Utilities.EmbeddedResourceLoader.Load("Images.Pin.svg", typeof(Pin));
                    if (stream == null)
                    {
                        return;
                    }
                    svg.Load(stream);
                    Width  = svg.CanvasSize.Width * Scale;
                    Height = svg.CanvasSize.Height * Scale;
                    // Create bitmap to hold canvas
                    var info = new SKImageInfo((int)svg.CanvasSize.Width, (int)svg.CanvasSize.Height)
                    {
                        AlphaType = SKAlphaType.Premul
                    };
                    var bitmap = new SKBitmap(info);
                    var canvas = new SKCanvas(bitmap);
                    // Now draw Svg image to bitmap
                    using (var paint = new SKPaint())
                    {
                        // Replace color while drawing
                        paint.ColorFilter = SKColorFilter.CreateBlendMode(Color.ToSKColor(), SKBlendMode.SrcIn);     // use the source color
                        canvas.Clear();
                        canvas.DrawPicture(svg.Picture, paint);
                    }
                    // Now convert canvas to bitmap
                    using (var image = SKImage.FromBitmap(bitmap))
                        using (var data = image.Encode(SKEncodedImageFormat.Png, 100))
                        {
                            _bitmapData = data.ToArray();
                        }
                    _bitmapId = BitmapRegistry.Instance.Register(new MemoryStream(_bitmapData));
                    break;

                case PinType.Icon:
                    if (Icon != null)
                    {
                        using (var image = SKBitmap.Decode(Icon))
                        {
                            Width     = image.Width * Scale;
                            Height    = image.Height * Scale;
                            _bitmapId = BitmapRegistry.Instance.Register(new MemoryStream(Icon));
                        }
                    }
                    break;
                }

                // If we have a bitmapId (and we should have one), than draw bitmap, otherwise nothing
                if (_bitmapId != -1)
                {
                    // We only want to have one style
                    _feature.Styles.Clear();
                    _feature.Styles.Add(new SymbolStyle
                    {
                        BitmapId       = _bitmapId,
                        SymbolScale    = Scale,
                        SymbolRotation = Rotation,
                        SymbolOffset   = new Offset(Anchor.X, Anchor.Y),
                        Opacity        = 1 - Transparency,
                    });
                }
            }
        }
 public Feature(Feature feature)
 {
     element = feature.element;
     // Any code common to creating features from other features
 }
Beispiel #46
0
        private void testform_Load(object sender, EventArgs e)
        {
            NumberFormatInfo nfi = new NumberFormatInfo(); //English comma separator dot, e.g. for German systems

            nfi.NumberDecimalSeparator = ".";

            var o = new Order();

            var ohi = o.OrderHeader.OrderInfo;

            ohi.DeliveryDate.Type = DeliveryDateType.Fixed;
            ohi.DeliveryDate.DeliveryStartDate = DateTime.Now.Date.AddDays(3);
            ohi.DeliveryDate.DeliveryEndDate   = DateTime.Now.Date.AddDays(4);

            ohi.OrderId   = "123";
            ohi.OrderDate = DateTime.Now.Date;
            ohi.CustomerOrderReference.OrderDescr = "MyOrderNr";

            ohi.Remarks.Add("MyDeliveryRemark", "DELIVERY");
            ohi.Remarks.Add("AnyAdditionalNote");

            o.OrderHeader.ControlInfo.GeneratorInfo  = "DXSdata openTRANS Generator";
            o.OrderHeader.ControlInfo.GenerationDate = DateTime.Now;

            o.OrderHeader.SourcingInfo.Agreement.AgreementId = "TestAgreement123";


            var p1 = new Party();

            p1.PartyId.Value = "TestSupplier";
            p1.PartyId.Type  = PartyType.BuyerSpecific;
            p1.PartyRole     = PartyRole.Supplier;

            var p2 = new Party();

            p2.PartyId.Value = "MyCustomerNumberOfSupplier";
            p2.PartyId.Type  = PartyType.SupplierSpecific;
            p2.PartyRole     = PartyRole.Buyer;

            p2.Address.Name = "MyCompany";
            //p2.Address.Name2 = "MyCustomName2";
            p2.Address.ContactDetails.ContactName = "MyEmployee";
            p2.Address.Street       = "MyStreet";
            p2.Address.Zip          = "MyZipCode";
            p2.Address.City         = "MyCity";
            p2.Address.Country      = "Austria";
            p2.Address.CountryCoded = Common.GetCountryCode(p2.Address.Country);
            p2.Address.Phone.Value  = "+1234";
            p2.Address.Phone.Value  = PhoneType.Office;
            p2.Address.Fax.Value    = "+5678";
            p2.Address.Fax.Type     = PhoneType.Office;
            p2.Address.Email        = "*****@*****.**";

            var p3 = new Party();

            p3.PartyId.Value  = "MyCustomerNumberOfSupplier";
            p3.PartyId.Type   = PartyType.ERPlusSpecific;
            p3.PartyRole      = PartyRole.Delivery;
            p3.Address.Name   = "MyDeliveryAddress";
            p3.Address.Street = "MyDeliveryAddress";
            p3.Address.Zip    = "MyDeliveryAddress";
            p3.Address.City   = "MyDeliveryAddress";

            o.OrderHeader.OrderInfo.Parties.AddRange(new[] { p1, p2, p3 });

            o.OrderHeader.OrderInfo.OrderPartiesReference.BuyerIdRef.Value    = "MyCustomerNumberOfSupplier";
            o.OrderHeader.OrderInfo.OrderPartiesReference.BuyerIdRef.Type     = PartyType.SupplierSpecific;
            o.OrderHeader.OrderInfo.OrderPartiesReference.SupplierIdRef.Value = "TestSupplier";
            o.OrderHeader.OrderInfo.OrderPartiesReference.SupplierIdRef.Type  = PartyType.BuyerSpecific;
            o.OrderHeader.OrderInfo.OrderPartiesReference.ShipmentPartiesReference.DeliveryIdRef.Value = "MyCustomerNumberOfSupplier";
            o.OrderHeader.OrderInfo.OrderPartiesReference.ShipmentPartiesReference.DeliveryIdRef.Type  = PartyType.SupplierSpecific;

            //foreach (var pos in myOrderPositions)
            {
                var oi = new OrderItem();
                oi.LineItemId                 = "001";
                oi.ProductId.SupplierPid      = "testnr";
                oi.ProductId.BuyerPid.Value   = "testnr";
                oi.ProductId.DescriptionShort = "testdescription";

                var features = new List <(string fname, string fval, string funit)>();
                features.Add(("ColorCodeInside", "a", null));
                features.Add(("ColorCodeOutside", "b", null));
                features.Add(("Length", "3,12".ToString(nfi), "mm"));
                features.Add(("Width", "4", "mm"));
                features.Add(("Height", "6", "mm"));

                foreach (var feature in features)
                {
                    if (!string.IsNullOrWhiteSpace(feature.fval))
                    {
                        var f = new Feature();
                        f.FName  = feature.fname;
                        f.FValue = feature.fval;
                        f.FUnit  = feature.funit;
                        oi.ProductFeatures.Add(f);
                    }
                }

                oi.Quantity  = 13;
                oi.OrderUnit = "mm".
                               Replace("mm", OrderUnit.Millimeter).
                               Replace("stk", OrderUnit.Piece).
                               Replace("stg", OrderUnit.Piece);

                oi.ProductPriceFix.PriceAmount = 14;
                //oi.ProductPriceFix.AllowOrChargesFix.AllowOrCharge.Type = AllowOrChargeTypes.Allowance;

                oi.Remarks.Add("testItemRemark");

                o.OrderItemList.Add(oi);
            }

            var ot = new XmlCreator(o);

            textBox1.Text = ot.Result;
        }
 public static IPreparedFeature New(IDialogFactory dialogFactory)
 => Feature.Create(() => new MgiStartingActor(), dialogFactory);
Beispiel #48
0
        /// <summary>
        /// given a data table, create an in-memory point feature set.
        /// The feature set must have the 'Latitude' and 'Longitude' numeric
        /// columns
        /// </summary>
        /// <param name="themeTable">The table of distinct series</param>
        /// <param name="projection">The projection of the theme feature set</param>
        /// <returns>A point FeatureSet in the WGS-84 coordinate system
        /// All columns of the data table will be converted to atrribute fields</returns>
        private IFeatureSet TableToFeatureSet(DataTable themeTable, ProjectionInfo projection = null)
        {
            //index of the Latitude column
            int latColIndex = -1;

            //index of the Longitude column
            int lonColIndex = -1;

            //get the latitude and longitude column indices
            for (int col = 0; col < themeTable.Columns.Count; col++)
            {
                string colName = themeTable.Columns[col].ColumnName.ToLower();

                if (colName == "latitude")
                {
                    latColIndex = col;
                }

                if (colName == "longitude")
                {
                    lonColIndex = col;
                }
            }

            //check if the latitude column exists
            if (latColIndex == -1)
            {
                throw new ArgumentException("The table doesn't have a column 'Latitude'");
            }
            //check if the longitude column exists
            if (lonColIndex == -1)
            {
                throw new ArgumentException("The table doesn't have a column 'Longitude'");
            }

            //generate attribute table schema
            var fs             = new FeatureSet(FeatureType.Point);
            var attributeTable = fs.DataTable;

            foreach (DataColumn column in themeTable.Columns)
            {
                attributeTable.Columns.Add(column.DataType == typeof(DateTime)
                                               ? new Field(column.ColumnName, 'C', 16, 0)
                                               : new DataColumn(column.ColumnName, column.DataType));
            }

            //generate features
            foreach (DataRow row in themeTable.Rows)
            {
                double lat        = Convert.ToDouble(row[latColIndex]);
                double lon        = Convert.ToDouble(row[lonColIndex]);
                var    coord      = new Coordinate(lon, lat);
                var    newFeature = new Feature(FeatureType.Point, new[] { coord });
                fs.Features.Add(newFeature);

                var featureRow = newFeature.DataRow;
                for (int c = 0; c < attributeTable.Columns.Count; c++)
                {
                    featureRow[c] = themeTable.Columns[c].DataType == typeof(DateTime)
                                        ? ConvertTime((DateTime)row[c])
                                        : row[c];
                }
            }

            //to save the feature set to a file with unique name
            string uniqueID = DateTime.Now.ToString("yyyyMMdd_hhmmss");
            var    rnd      = new Random();

            uniqueID += rnd.Next(100).ToString("000");
            var filename = Path.Combine(Settings.Instance.CurrentProjectDirectory, "theme_" + uniqueID + ".shp");

            fs.Filename   = filename;
            fs.Projection = _wgs84Projection;
            fs.Save();
            fs.Dispose();

            var fs2 = FeatureSet.OpenFile(filename);

            //to reproject the feature set
            if (projection != null)
            {
                fs2.Reproject(projection);
            }

            return(fs2);
        }
Beispiel #49
0
        public void ThenCanParseFeatureWithMultipleScenariosSuccessfully()
        {
            string featureText =
                @"# ignore this comment
Feature: Test
    In order to do something
    As a user
    I want to run this scenario

	Scenario: A scenario
		Given some feature
		When it runs
		Then I should see that this thing happens	

    Scenario: Another scenario
		Given some other feature
		When it runs
		Then I should see that this other thing happens
        And something else";

            var     parser  = Kernel.Get <FeatureParser>();
            Feature feature = parser.Parse(new StringReader(featureText));

            Assert.AreNotEqual(null, feature);
            Assert.AreEqual("Test", feature.Name);
            Assert.AreEqual(@"  In order to do something
  As a user
  I want to run this scenario",
                            feature.Description);
            Assert.AreEqual(2, feature.FeatureElements.Count);
            Assert.AreEqual(0, feature.Tags.Count);

            IFeatureElement scenario = feature.FeatureElements[0];

            Assert.AreEqual("A scenario", scenario.Name);
            Assert.AreEqual(string.Empty, scenario.Description);
            Assert.AreEqual(3, scenario.Steps.Count);
            Assert.AreEqual(0, scenario.Tags.Count);

            Step givenStep = scenario.Steps[0];

            Assert.AreEqual(Keyword.Given, givenStep.Keyword);
            Assert.AreEqual("some feature", givenStep.Name);
            Assert.AreEqual(null, givenStep.DocStringArgument);
            Assert.AreEqual(null, givenStep.TableArgument);

            Step whenStep = scenario.Steps[1];

            Assert.AreEqual(Keyword.When, whenStep.Keyword);
            Assert.AreEqual("it runs", whenStep.Name);
            Assert.AreEqual(null, whenStep.DocStringArgument);
            Assert.AreEqual(null, whenStep.TableArgument);

            Step thenStep = scenario.Steps[2];

            Assert.AreEqual(Keyword.Then, thenStep.Keyword);
            Assert.AreEqual("I should see that this thing happens", thenStep.Name);
            Assert.AreEqual(null, thenStep.DocStringArgument);
            Assert.AreEqual(null, thenStep.TableArgument);

            IFeatureElement scenario2 = feature.FeatureElements[1];

            Assert.AreEqual("Another scenario", scenario2.Name);
            Assert.AreEqual(string.Empty, scenario2.Description);
            Assert.AreEqual(4, scenario2.Steps.Count);
            Assert.AreEqual(0, scenario2.Tags.Count);

            Step givenStep2 = scenario2.Steps[0];

            Assert.AreEqual(Keyword.Given, givenStep2.Keyword);
            Assert.AreEqual("some other feature", givenStep2.Name);
            Assert.AreEqual(null, givenStep2.DocStringArgument);
            Assert.AreEqual(null, givenStep2.TableArgument);

            Step whenStep2 = scenario2.Steps[1];

            Assert.AreEqual(Keyword.When, whenStep2.Keyword);
            Assert.AreEqual("it runs", whenStep2.Name);
            Assert.AreEqual(null, whenStep2.DocStringArgument);
            Assert.AreEqual(null, whenStep2.TableArgument);

            Step thenStep2 = scenario2.Steps[2];

            Assert.AreEqual(Keyword.Then, thenStep2.Keyword);
            Assert.AreEqual("I should see that this other thing happens", thenStep2.Name);
            Assert.AreEqual(null, thenStep2.DocStringArgument);
            Assert.AreEqual(null, thenStep2.TableArgument);

            Step thenStep3 = scenario2.Steps[3];

            Assert.AreEqual(Keyword.And, thenStep3.Keyword);
            Assert.AreEqual("something else", thenStep3.Name);
            Assert.AreEqual(null, thenStep3.DocStringArgument);
            Assert.AreEqual(null, thenStep3.TableArgument);
        }
Beispiel #50
0
        public void ThenCanParseScenarioOutlinesSuccessfully()
        {
            string featureText =
                @"# ignore this comment
Feature: Test
    In order to do something
    As a user
    I want to run this scenario

	Scenario Outline: A scenario outline
		Given some feature with <keyword1>
		When it runs
		Then I should see <keyword2>

    Examples:
    | keyword1 | keyword2 |
    | this     | that     |";

            var     parser  = Kernel.Get <FeatureParser>();
            Feature feature = parser.Parse(new StringReader(featureText));

            var scenarioOutline = feature.FeatureElements[0] as ScenarioOutline;

            Assert.AreNotEqual(null, scenarioOutline);
            Assert.AreEqual("A scenario outline", scenarioOutline.Name);
            Assert.AreEqual(string.Empty, scenarioOutline.Description);
            Assert.AreEqual(3, scenarioOutline.Steps.Count);

            Step givenStep = scenarioOutline.Steps[0];

            Assert.AreEqual(Keyword.Given, givenStep.Keyword);
            Assert.AreEqual("some feature with <keyword1>", givenStep.Name);
            Assert.AreEqual(null, givenStep.DocStringArgument);
            Assert.AreEqual(null, givenStep.TableArgument);

            Step whenStep = scenarioOutline.Steps[1];

            Assert.AreEqual(Keyword.When, whenStep.Keyword);
            Assert.AreEqual("it runs", whenStep.Name);
            Assert.AreEqual(null, whenStep.DocStringArgument);
            Assert.AreEqual(null, whenStep.TableArgument);

            Step thenStep = scenarioOutline.Steps[2];

            Assert.AreEqual(Keyword.Then, thenStep.Keyword);
            Assert.AreEqual("I should see <keyword2>", thenStep.Name);
            Assert.AreEqual(null, thenStep.DocStringArgument);
            Assert.AreEqual(null, thenStep.TableArgument);

            Example examples = scenarioOutline.Example;

            Assert.AreEqual(string.Empty, examples.Name);
            Assert.AreEqual(null, examples.Description);

            Table table = examples.TableArgument;

            Assert.AreEqual("keyword1", table.HeaderRow[0]);
            Assert.AreEqual("keyword2", table.HeaderRow[1]);
            Assert.AreEqual("this", table.DataRows[0][0]);
            Assert.AreEqual("that", table.DataRows[0][1]);
        }
Beispiel #51
0
 public void Uninstalling(Feature feature)
 {
 }
Beispiel #52
0
        private async void CreateNewFeatureCollection()
        {
            // Create the schema for a points table (one text field to contain a name attribute)
            List <Field> pointFields = new List <Field>();
            Field        placeField  = new Field(FieldType.Text, "Place", "Place Name", 50);

            pointFields.Add(placeField);

            // Create the schema for a lines table (one text field to contain a name attribute)
            List <Field> lineFields    = new List <Field>();
            Field        boundaryField = new Field(FieldType.Text, "Boundary", "Boundary Name", 50);

            lineFields.Add(boundaryField);

            // Create the schema for a polygon table (one text field to contain a name attribute)
            List <Field> polyFields = new List <Field>();
            Field        areaField  = new Field(FieldType.Text, "AreaName", "Area Name", 50);

            polyFields.Add(areaField);

            // Instantiate FeatureCollectionTables with schema and geometry type
            FeatureCollectionTable pointsTable = new FeatureCollectionTable(pointFields, GeometryType.Point, SpatialReferences.Wgs84);
            FeatureCollectionTable linesTable  = new FeatureCollectionTable(lineFields, GeometryType.Polyline, SpatialReferences.Wgs84);
            FeatureCollectionTable polysTable  = new FeatureCollectionTable(polyFields, GeometryType.Polygon, SpatialReferences.Wgs84);

            // Set rendering for each table
            pointsTable.Renderer = CreateRenderer(GeometryType.Point);
            linesTable.Renderer  = CreateRenderer(GeometryType.Polyline);
            polysTable.Renderer  = CreateRenderer(GeometryType.Polygon);

            // Create a new point feature, provide geometry and attribute values
            Feature pointFeature = pointsTable.CreateFeature();

            pointFeature.SetAttributeValue(placeField, "Current location");
            MapPoint point1 = new MapPoint(-79.497238, 8.849289, SpatialReferences.Wgs84);

            pointFeature.Geometry = point1;

            // Create a new line feature, provide geometry and attribute values
            Feature lineFeature = linesTable.CreateFeature();

            lineFeature.SetAttributeValue(boundaryField, "AManAPlanACanalPanama");
            MapPoint point2 = new MapPoint(-80.035568, 9.432302, SpatialReferences.Wgs84);
            Polyline line   = new Polyline(new MapPoint[] { point1, point2 });

            lineFeature.Geometry = line;

            // Create a new polygon feature, provide geometry and attribute values
            Feature polyFeature = polysTable.CreateFeature();

            polyFeature.SetAttributeValue(areaField, "Restricted area");
            MapPoint point3 = new MapPoint(-79.337936, 8.638903, SpatialReferences.Wgs84);
            MapPoint point4 = new MapPoint(-79.11409, 8.895422, SpatialReferences.Wgs84);
            Polygon  poly   = new Polygon(new MapPoint[] { point1, point3, point4 });

            polyFeature.Geometry = poly;

            // Add the new features to the appropriate feature collection table
            await pointsTable.AddFeatureAsync(pointFeature);

            await linesTable.AddFeatureAsync(lineFeature);

            await polysTable.AddFeatureAsync(polyFeature);

            // Create a feature collection and add the feature collection tables
            FeatureCollection featuresCollection = new FeatureCollection();

            featuresCollection.Tables.Add(pointsTable);
            featuresCollection.Tables.Add(linesTable);
            featuresCollection.Tables.Add(polysTable);

            // Create a FeatureCollectionLayer
            FeatureCollectionLayer collectionLayer = new FeatureCollectionLayer(featuresCollection);

            // When the layer loads, zoom the map view to the extent of the feature collection
            collectionLayer.Loaded += (s, e) => _myMapView.SetViewpointAsync(new Viewpoint(collectionLayer.FullExtent));

            // Add the layer to the Map's Operational Layers collection
            _myMapView.Map.OperationalLayers.Add(collectionLayer);
        }
Beispiel #53
0
 public void Disabling(Feature feature)
 {
 }
Beispiel #54
0
 public void Disabled(Feature feature)
 {
 }
Beispiel #55
0
    static public void Main()
    {
        var bin   = new Feature("MyApp Binaries");
        var tools = new Feature("MyApp Tools");

        var project =
            new ManagedProject("ManagedSetup",
                               //one of possible ways of setting custom INSTALLDIR (disabled for demo purposes)
                               new ManagedAction(Script.SetInstallDir,
                                                 Return.check,
                                                 When.Before,
                                                 Step.LaunchConditions,
                                                 Condition.NOT_Installed,
                                                 Sequence.InstallUISequence),
                               new Dir(@"%ProgramFiles%\My Company\My Product",
                                       new File(bin, @"..\Files\bin\MyApp.exe"),
                                       new Dir(bin, "Docs",
                                               new File(bin, "readme.txt"))),

                               new Dir(new Id("TOOLSDIR"), tools, "Tools",
                                       new File(tools, "setup.cs")),

                               //reading TOOLSDIR from registry; the alternative ways is project_UIInit
                               new RegValueProperty("TOOLSDIR",
                                                    RegistryHive.CurrentUser,
                                                    @"SOFTWARE\7-Zip",
                                                    "Path",
                                                    defaultValue: @"C:\My Company\tools")
                               );

        //project.ManagedUI = ManagedUI.Empty;
        project.ManagedUI = ManagedUI.Default; //Wix# ManagedUI
        //project.UI = WUI.WixUI_ProgressOnly; //native MSI UI

        project.UILoaded                  += project_UIInit;
        project.UIInitialized             += Project_UIInitialized;
        project.Load                      += project_Load;
        project.BeforeInstall             += project_BeforeInstall;
        project.AfterInstall              += project_AfterInstall;
        project.DefaultDeferredProperties += ",ADDLOCAL";

        project.BeforeInstall += session =>
        {
            if (!session.IsUninstalling)
            {
                Tasks.StopService("some_service", throwOnError: false);
            }
        };
        project.AfterInstall += session =>
        {
            if (!session.IsUninstalling)
            {
                Tasks.StartService("some_service", throwOnError: false);
            }
        };

        project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");
        // project.PreserveTempFiles = true;

        Compiler.BuildMsi(project);
    }
Beispiel #56
0
 public void Enabled(Feature feature)
 {
 }
Beispiel #57
0
        public void Installing(Feature feature)
        {
            var featureName = feature.Descriptor.Id;

            _dataMigrationManager.Update(featureName);
        }
Beispiel #58
0
        public void AutoDrawing(SldWorks swApp, ModuleTree tree, string projectPath)
        {
            //创建项目模型存放地址
            string itemPath = projectPath + @"\" + tree.Module + "-" + tree.CategoryName;

            if (!Directory.Exists(itemPath))
            {
                Directory.CreateDirectory(itemPath);
            }
            else
            {
                DialogResult result =
                    MessageBox.Show("模型文件夹" + itemPath + "存在,如果之前pack已经执行过,将不执行pack过程而是直接修改模型,如果要继续请点击YES,否请点击No中断作图", "提示信息",
                                    MessageBoxButtons.YesNo);
                if (result == DialogResult.No)
                {
                    return;
                }
            }
            //Pack的后缀
            string suffix = tree.Module + "-" + tree.ODPNo.Substring(tree.ODPNo.Length - 6);
            //判断文件是否存在,如果存在将不执行pack,如果不存在则执行pack
            //packango后需要接收打包完成的地址,参数为后缀
            string packedAssyPath = itemPath + @"\" + tree.CategoryName.ToLower() + "_" + suffix + ".sldasm";

            if (!File.Exists(packedAssyPath))
            {
                packedAssyPath = CommonFunc.PackAndGoFunc(suffix, swApp, tree.ModelPath, itemPath);
            }

            //查询参数
            SSPFLAT item = (SSPFLAT)objSSPFLATService.GetModelByModuleTreeId(tree.ModuleTreeId.ToString());

            swApp.CommandInProgress = true; //告诉SolidWorks,现在是用外部程序调用命令
            int warnings = 0;
            int errors   = 0;

            suffix = "_" + suffix;//后缀
            ModelDoc2         swModel = default(ModelDoc2);
            ModelDoc2         swPart  = default(ModelDoc2);
            AssemblyDoc       swAssy  = default(AssemblyDoc);
            Component2        swComp;
            Feature           swFeat        = default(Feature);
            object            configNames   = null;
            ModelDocExtension swModelDocExt = default(ModelDocExtension);
            bool   status     = false;
            string compReName = string.Empty;

            //打开Pack后的模型
            swModel = swApp.OpenDoc6(packedAssyPath, (int)swDocumentTypes_e.swDocASSEMBLY,
                                     (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings) as ModelDoc2;
            swAssy = swModel as AssemblyDoc;                                                  //装配体
            string assyName = swModel.GetTitle().Substring(0, swModel.GetTitle().Length - 7); //获取装配体名称

            swModelDocExt = (ModelDocExtension)swModel.Extension;
            //打开装配体后必须重建,使Pack后的零件名都更新到带后缀的状态,否则程序出错
            swModel.ForceRebuild3(true);
            //TopOnly参数设置成true,只重建顶层,不重建零件内部

            /*注意SolidWorks单位是m,计算是应当/1000m
             * 整形与整形运算得出的结果仍然时整形,1640 / 1000m结果为0,因此必须将其中一个转化成decimal型,使用后缀m就可以了
             * (int)不进行四舍五入,Convert.ToInt32会四舍五入
             */
            //-----------计算中间值,----------

            try
            {
                //----------Top Level----------


                //----------边缘Z板----------
                swModel.Parameter("D1@Distance3").SystemValue = (item.MPanelNo * 2m - 1m) * 500m / 1000m;
                //左边
                if (item.LeftType == "Z")
                {
                    //重命名装配体内部
                    compReName = "FNCM0006[SSPFZ-" + tree.Module + ".L]{" + (int)(item.Length - 10m) + "}(" + (int)item.LeftLength + ")";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCM0006-L[SSPFZ-]{}()-4") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    if (status)
                    {
                        swModelDocExt.RenameDocument(compReName);
                    }
                    swModel.ClearSelection2(true);
                    status = swModelDocExt.SelectByID2(compReName + "-4" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    swModel.ClearSelection2(true);
                    if (status)
                    {
                        swComp = swAssy.GetComponentByName(compReName + "-4");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        swPart.Parameter("D2@Skizze1").SystemValue = (item.Length - 10m) / 1000m;
                        swPart.Parameter("D1@Skizze1").SystemValue = item.LeftLength / 1000m;
                        swFeat = swComp.FeatureByName("LED");
                        if (item.LightType == "LED60")
                        {
                            swFeat.SetSuppression2(1, 2, configNames);                            //参数1:1解压,0压缩
                        }
                        else
                        {
                            swFeat.SetSuppression2(0, 2, configNames);  //参数1:1解压,0压缩
                        }
                    }
                    //重命名装配体内部
                    compReName = "FNCM0004[SSPFW-" + tree.Module + ".L]{" + (int)(item.Length - 10m) + "}(500)";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCM0004-L[SSPFW-]{}()-2") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    if (status)
                    {
                        swModelDocExt.RenameDocument(compReName);
                    }
                    swModel.ClearSelection2(true);
                    status = swModelDocExt.SelectByID2(compReName + "-2" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    swModel.ClearSelection2(true);
                    if (status)
                    {
                        swComp = swAssy.GetComponentByName(compReName + "-2");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        swPart.Parameter("D2@Skizze1").SystemValue = (item.Length - 10m) / 1000m;
                        swPart.Parameter("D1@Skizze1").SystemValue = 499.5m / 1000m;
                        swFeat = swComp.FeatureByName("LED");
                        if (item.LightType == "LED60")
                        {
                            swFeat.SetSuppression2(1, 2, configNames);                            //参数1:1解压,0压缩
                        }
                        else
                        {
                            swFeat.SetSuppression2(0, 2, configNames);  //参数1:1解压,0压缩
                        }
                    }
                }
                else
                {
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCM0006-L[SSPFZ-]{}()-4"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩.
                    //重命名装配体内部
                    compReName = "FNCM0004[SSPFW-" + tree.Module + ".L]{" + (int)(item.Length - 10m) + "}(" + (int)item.LeftLength + ")";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCM0004-L[SSPFW-]{}()-2") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    if (status)
                    {
                        swModelDocExt.RenameDocument(compReName);
                    }
                    swModel.ClearSelection2(true);
                    status = swModelDocExt.SelectByID2(compReName + "-2" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    swModel.ClearSelection2(true);
                    if (status)
                    {
                        swComp = swAssy.GetComponentByName(compReName + "-2");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        swPart.Parameter("D2@Skizze1").SystemValue = (item.Length - 10m) / 1000m;
                        swPart.Parameter("D1@Skizze1").SystemValue = item.LeftLength / 1000m;
                        swFeat = swComp.FeatureByName("LED");
                        if (item.LightType == "LED60")
                        {
                            swFeat.SetSuppression2(1, 2, configNames);                            //参数1:1解压,0压缩
                        }
                        else
                        {
                            swFeat.SetSuppression2(0, 2, configNames);  //参数1:1解压,0压缩
                        }
                    }
                }
                //右边
                if (item.RightType == "Z")
                {
                    //重命名装配体内部
                    compReName = "FNCM0006[SSPFZ-" + tree.Module + ".R]{" + (int)(item.Length - 10m) + "}(" + (int)item.RightLength + ")";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCM0006-R[SSPFZ-]{}()-3") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    if (status)
                    {
                        swModelDocExt.RenameDocument(compReName);
                    }
                    swModel.ClearSelection2(true);
                    status = swModelDocExt.SelectByID2(compReName + "-3" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    swModel.ClearSelection2(true);
                    if (status)
                    {
                        swComp = swAssy.GetComponentByName(compReName + "-3");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        swPart.Parameter("D2@Skizze1").SystemValue = (item.Length - 10m) / 1000m;
                        swPart.Parameter("D1@Skizze1").SystemValue = item.RightLength / 1000m;
                        swFeat = swComp.FeatureByName("LED");
                        if (item.LightType == "LED60")
                        {
                            swFeat.SetSuppression2(1, 2, configNames);                            //参数1:1解压,0压缩
                        }
                        else
                        {
                            swFeat.SetSuppression2(0, 2, configNames);  //参数1:1解压,0压缩
                        }
                    }
                    //重命名装配体内部
                    compReName = "FNCM0004[SSPFW-" + tree.Module + ".R]{" + (int)(item.Length - 10m) + "}(500)";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCM0004-R[SSPFW-]{}()-3") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    if (status)
                    {
                        swModelDocExt.RenameDocument(compReName);
                    }
                    swModel.ClearSelection2(true);
                    status = swModelDocExt.SelectByID2(compReName + "-3" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    swModel.ClearSelection2(true);
                    if (status)
                    {
                        swComp = swAssy.GetComponentByName(compReName + "-3");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        swPart.Parameter("D2@Skizze1").SystemValue = (item.Length - 10m) / 1000m;
                        swPart.Parameter("D1@Skizze1").SystemValue = 499.5m / 1000m;
                        swFeat = swComp.FeatureByName("LED");
                        if (item.LightType == "LED60")
                        {
                            swFeat.SetSuppression2(1, 2, configNames);                            //参数1:1解压,0压缩
                        }
                        else
                        {
                            swFeat.SetSuppression2(0, 2, configNames);  //参数1:1解压,0压缩
                        }
                    }
                }
                else
                {
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCM0006-R[SSPFZ-]{}()-3"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩.
                    //重命名装配体内部
                    compReName = "FNCM0004[SSPFW-" + tree.Module + ".R]{" + (int)(item.Length - 10m) + "}(" + (int)item.RightLength + ")";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCM0004-R[SSPFW-]{}()-3") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    if (status)
                    {
                        swModelDocExt.RenameDocument(compReName);
                    }
                    swModel.ClearSelection2(true);
                    status = swModelDocExt.SelectByID2(compReName + "-3" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    swModel.ClearSelection2(true);
                    if (status)
                    {
                        swComp = swAssy.GetComponentByName(compReName + "-3");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        swPart.Parameter("D2@Skizze1").SystemValue = (item.Length - 10m) / 1000m;
                        swPart.Parameter("D1@Skizze1").SystemValue = item.RightLength / 1000m;
                        swFeat = swComp.FeatureByName("LED");
                        if (item.LightType == "LED60")
                        {
                            swFeat.SetSuppression2(1, 2, configNames);                            //参数1:1解压,0压缩
                        }
                        else
                        {
                            swFeat.SetSuppression2(0, 2, configNames);  //参数1:1解压,0压缩
                        }
                    }
                }
                //----------标准M板----------
                //重命名装配体内部
                compReName = "FNCM0005[SSPFM-" + tree.Module + "]{" + (int)(item.Length - 10m) + "}(500)";
                status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCM0005[SSPFM-]{}-3") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                if (status)
                {
                    swModelDocExt.RenameDocument(compReName);
                }
                swModel.ClearSelection2(true);
                status = swModelDocExt.SelectByID2(compReName + "-3" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                swModel.ClearSelection2(true);
                if (status)
                {
                    swComp = swAssy.GetComponentByName(compReName + "-3");
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swPart = swComp.GetModelDoc2(); //打开零件
                    swPart.Parameter("D2@Skizze1").SystemValue = (item.Length - 10m) / 1000m;
                    swPart.Parameter("D1@Skizze1").SystemValue = 499.5m / 1000m;
                    swFeat = swComp.FeatureByName("LED");
                    if (item.LightType == "LED60")
                    {
                        swFeat.SetSuppression2(1, 2, configNames);                            //参数1:1解压,0压缩
                    }
                    else
                    {
                        swFeat.SetSuppression2(0, 2, configNames);  //参数1:1解压,0压缩
                    }
                }
                //----------标准W板----------
                if (item.MPanelNo == 1)
                {
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCM0004[SSPFW-]{}-2"));
                    swComp.SetSuppression2(0);                 //2解压缩,0压缩.
                    swFeat = swAssy.FeatureByName("LocalLPattern2");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    swFeat = swAssy.FeatureByName("LocalLPattern1");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                }
                else
                {
                    //重命名装配体内部
                    compReName = "FNCM0004[SSPFW-" + tree.Module + "]{" + (int)(item.Length - 10m) + "}(500)";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCM0004[SSPFW-]{}-2") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    if (status)
                    {
                        swModelDocExt.RenameDocument(compReName);
                    }
                    swModel.ClearSelection2(true);
                    status = swModelDocExt.SelectByID2(compReName + "-2" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    swModel.ClearSelection2(true);
                    if (status)
                    {
                        swComp = swAssy.GetComponentByName(compReName + "-2");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        swPart.Parameter("D2@Skizze1").SystemValue = (item.Length - 10m) / 1000m;
                        swPart.Parameter("D1@Skizze1").SystemValue = 499.5m / 1000m;
                        swFeat = swComp.FeatureByName("LED");
                        if (item.LightType == "LED60")
                        {
                            swFeat.SetSuppression2(1, 2, configNames);                            //参数1:1解压,0压缩
                        }
                        else
                        {
                            swFeat.SetSuppression2(0, 2, configNames);  //参数1:1解压,0压缩
                        }
                    }
                    swFeat = swAssy.FeatureByName("LocalLPattern2");
                    swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                    swFeat = swAssy.FeatureByName("LocalLPattern1");
                    swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                    swModel.Parameter("D1@LocalLPattern2").SystemValue = item.MPanelNo;
                    swModel.Parameter("D1@LocalLPattern1").SystemValue = item.MPanelNo - 1;
                }

                swModel.ForceRebuild3(true);    //设置成true,直接更新顶层,速度很快,设置成false,每个零件都会更新,很慢
                swModel.Save();                 //保存,很耗时间
                swApp.CloseDoc(packedAssyPath); //关闭,很快
            }
            catch (Exception ex)
            {
                throw new Exception(packedAssyPath + "作图过程发生异常,详细:" + ex.Message);
            }
            finally
            {
                swApp.CommandInProgress = false; //及时关闭外部命令调用,否则影响SolidWorks的使用
            }
        }
Beispiel #59
0
 public void RefreshSteps(Feature feature)
 {
     _steps[feature] = new CodeCompletionFeatureSteps(feature);
     Invalidate();
 }
Beispiel #60
0
 public void Installed(Feature feature)
 {
 }