Example #1
0
        public static string GetDirectorySeparatorForPlatform(Platform platform)
        {
            switch (platform)
            {
            case Platform.NonWindows:
                return(DirectorySeparator.NonWindows);

            case Platform.Windows:
                return(DirectorySeparator.Windows);

            default:
                throw EnumerationHelper.UnexpectedEnumerationValueException(platform);
            }
        }
Example #2
0
        /// <summary>
        /// Returns the alternate platform given a platform. For example, if <see cref="Platform.Windows"/> is provided, <see cref="Platform.NonWindows"/> is returned, and vice-versa.
        /// </summary>
        public static Platform GetAlternatePlatform(Platform platform)
        {
            switch (platform)
            {
            case Platform.NonWindows:
                return(Platform.Windows);

            case Platform.Windows:
                return(Platform.NonWindows);

            default:
                throw EnumerationHelper.UnexpectedEnumerationValueException(platform);
            }
        }
Example #3
0
        private void InitializeDialog()
        {
            dpiComboBox.Items.Clear();
            dpiComboBox.Items.Add(72);
            dpiComboBox.Items.Add(150);
            dpiComboBox.Items.Add(300);
            dpiComboBox.Items.Add(600);

            Graphics infoGfx = _diagramPresenter.Diagram.DisplayService.InfoGraphics;

            for (int i = dpiComboBox.Items.Count - 1; i >= 0; --i)
            {
                System.Diagnostics.Debug.Assert(dpiComboBox.Items[i] is int);
                if ((int)dpiComboBox.Items[i] < infoGfx.DpiY)
                {
                    dpiComboBox.Items.Insert(i + 1, (int)infoGfx.DpiY);
                    dpiComboBox.SelectedIndex = i + 1;
                    break;
                }
                else if (i == 0)
                {
                    dpiComboBox.Items.Insert(i, (int)infoGfx.DpiY);
                    dpiComboBox.SelectedIndex = i;
                }
            }

            colorLabel.BackColor = Color.White;

            backColorCheckBox.Checked  = false;
            marginUpDown.Value         = 0;
            emfPlusRadioButton.Checked = true;
            toFileRadioButton.Checked  = true;
            if (_diagramPresenter.SelectedShapes.Count > 0)
            {
                exportSelectedRadioButton.Enabled     =
                    exportSelectedRadioButton.Checked = true;
            }
            else
            {
                exportSelectedRadioButton.Enabled = false;
                exportAllRadioButton.Checked      = true;
            }
            visibleLayersOnlyCheckBox.Checked = (!EnumerationHelper.IsEmpty(_diagramPresenter.HiddenLayerIds));

            EnableOkButton();
        }
Example #4
0
        public static string ToStringStandard(this ServiceLifetime serviceLifetime)
        {
            switch (serviceLifetime)
            {
            case ServiceLifetime.Scoped:
                return(ServiceLifetimeHelper.ScopedStandardRepresentation);

            case ServiceLifetime.Singleton:
                return(ServiceLifetimeHelper.SingletonStandardRepresentation);

            case ServiceLifetime.Transient:
                return(ServiceLifetimeHelper.TransientStandardRepresentation);

            default:
                throw EnumerationHelper.UnexpectedEnumerationValueException(serviceLifetime);
            }
        }
Example #5
0
        public ActionResult DetayList(int id)
        {
            PersonelRepository personelRepository = new PersonelRepository();
            PersonelViewModel  model         = new PersonelViewModel();
            Personell          personel      = personelRepository.FirstOrDefault(x => x.PersonellId == id);
            DepartmanEnum      departmanEnum = (DepartmanEnum)personel.Departman;

            model.DepartmanAd = EnumerationHelper.GetDescription <DepartmanEnum>(departmanEnum);

            model.Ad          = personel.Ad;
            model.Soyad       = personel.Soyad;
            model.Departman   = personel.Departman.Value;
            model.Ä°zinGunu    = personel.Ä°zinGunu.Value;
            model.PersonellId = id;

            return(View(model));
        }
Example #6
0
        public override IEnumerator <EventBean> GetEnumerator(Viewable parent)
        {
            if (_orderByProcessor != null)
            {
                // Pull all events, generate order keys
                var eventsPerStream = new EventBean[1];
                var events          = new List <EventBean>();
                var orderKeys       = new List <Object>();

                var parentEnumerator = parent.GetEnumerator();
                if (parentEnumerator.MoveNext() == false)
                {
                    return(CollectionUtil.NULL_EVENT_ITERATOR);
                }

                do
                {
                    var aParent = parentEnumerator.Current;
                    eventsPerStream[0] = aParent;
                    var orderKey = _orderByProcessor.GetSortKey(eventsPerStream, true, ExprEvaluatorContext);
                    var pair     = ProcessViewResultIterator(eventsPerStream);
                    var result   = pair.First;
                    if (result != null && result.Length != 0)
                    {
                        events.Add(result[0]);
                    }
                    orderKeys.Add(orderKey);
                } while (parentEnumerator.MoveNext());

                // sort
                var outgoingEvents = events.ToArray();
                var orderKeysArr   = orderKeys.ToArray();
                var orderedEvents  = _orderByProcessor.Sort(outgoingEvents, orderKeysArr, ExprEvaluatorContext);
                if (orderedEvents == null)
                {
                    return(EnumerationHelper <EventBean> .CreateEmptyEnumerator());
                }

                return(((IEnumerable <EventBean>)orderedEvents).GetEnumerator());
            }
            // Return an iterator that gives row-by-row a result

            var transform = new ResultSetProcessorSimpleTransform(this);

            return(parent.Select(transform.Transform).GetEnumerator());
        }
Example #7
0
        public static string GetFileExtensionNoUnknown(FileFormat fileFormat)
        {
            switch (fileFormat)
            {
            case FileFormat.Bitmap:
                return(FileExtensions.Bitmap);

            case FileFormat.Jpg:
                return(FileExtensions.Jpg);

            case FileFormat.Png:
                return(FileExtensions.Png);

            default:
                var message = EnumerationHelper.UnexpectedEnumerationValueMessage <FileFormat>(fileFormat);
                throw new Exception(message);
            }
        }
        public static ConnectionString GetConnectionString(this DatabaseConfiguration databaseConfiguration, DatabaseServerAuthentications databaseServerAuthentications)
        {
            ConnectionString connectionString;

            switch (databaseConfiguration.LocalOrRemote)
            {
            case LocalOrRemote.Local:
                connectionString = databaseConfiguration.GetLocalConnectionString();
                break;

            case LocalOrRemote.Remote:
                connectionString = databaseConfiguration.GetRemoteConnectionString(databaseServerAuthentications);
                break;

            default:
                throw new Exception(EnumerationHelper.UnexpectedEnumerationValueMessage(databaseConfiguration.LocalOrRemote));
            }

            return(connectionString);
        }
Example #9
0
        public async Task <IActionResult> Index(HotelFile model)
        {
            if (ModelState.IsValid)
            {
                if (model == null ||
                    model.FileToUpload == null || model.FileToUpload.Length == 0)
                {
                    return(Content("file not selected"));
                }

                var path = Path.Combine(
                    Directory.GetCurrentDirectory(), "wwwroot/uploadedfiles",
                    model.FileToUpload.GetFilename());

                using (var stream = new FileStream(path, FileMode.Create))
                {
                    await model.FileToUpload.CopyToAsync(stream);
                }

                var hotelList = _reader.ReadFile(path);

                var description   = EnumerationHelper.GetDescription((FileStorageType)model.SelectedFileStorageType);
                var sortingOption = EnumerationHelper.GetDescription((TransactionOptionType)model.SelectedSortGroup);

                var orderedHotelList = FileHelper.ToOrderedList(hotelList as IList <Hotel>, sortingOption);

                var writer      = FileWriterCreator.GetFileWriter(description);
                var newFilePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/uploadedfiles", $"{description.TrimStart('.')}File{description}");

                writer.WriteFile(hotelList, newFilePath);
            }
            else
            {
                if (model == null ||
                    model.FileToUpload == null || model.FileToUpload.Length == 0)
                {
                    return(Content("file not selected"));
                }
            }
            return(View());
        }
Example #10
0
        public ActionResult List(List <PersonelViewModel> list)
        {
            PersonelRepository       repository = new PersonelRepository();
            List <PersonelViewModel> _list      = new List <PersonelViewModel>();

            list = _list.ToList();

            IQueryable <Personell> personel = repository.GetAll();

            foreach (var item in personel)
            {
                DepartmanEnum     departmanEnum = (DepartmanEnum)item.Departman;
                PersonelViewModel model         = new PersonelViewModel()
                {
                    PersonellId = item.PersonellId,
                    Ad          = item.Ad,
                    Soyad       = item.Soyad,
                    Ä°zinGunu    = item.Ä°zinGunu.Value,
                    Departman   = item.Departman.Value,
                    DepartmanAd = EnumerationHelper.GetDescription <DepartmanEnum>(departmanEnum)
                }; list.Add(model);
            }
            return(View(list));
        }
		public void CorrectlyDeterminesAbsoluteDifference()
		{
			IEnumerationHelper helper = new EnumerationHelper();
			Assert.That(helper.DetermineAbsoluteDifference(PersistenceMode.Archive, PersistenceMode.Live), Is.EqualTo(1));
		}
 public override IEnumerator <KeyValuePair <string, int> > StagesIterate()
 {
     // no action
     return(EnumerationHelper.Empty <KeyValuePair <string, int> >());
 }
Example #13
0
 public IEnumerator<EventBean> GetEnumerator()
 {
     return EnumerationHelper.SingletonNullable(_eventReference.Get());
 }
Example #14
0
        public void Perform()
        {
            IPCClient pcClient = new PCClient(_pcModel, _fileLog);

            try
            {
                bool authenticated = pcClient.Login();
                int  runID;
                if (authenticated)
                {
                    runID = pcClient.StartRun();
                    if (runID == 0)
                    {
                        pcClient.Logout();
                        return;
                    }
                }
                else
                {
                    return;
                }

                string        testName      = pcClient.GetTestName();
                PCRunResponse pcRunResponse = null;
                if (runID > 0)
                {
                    pcRunResponse = pcClient.WaitForRunCompletion(runID);
                }

                if (pcRunResponse != null)
                {
                    //analysis report
                    string pcReportFile = (pcRunResponse.RunState == EnumerationHelper.GetEnumDescription(PCConstants.RunStates.Finished)) ? pcClient.PublishRunReport(runID, _workDirectory) : "";

                    // Adding the trend report section if ID has been set
                    if (_pcModel.GetAddRunToTrendReport.Equals("UseTrendReportID") && !string.IsNullOrWhiteSpace(_pcModel.TrendReportId) && pcRunResponse.RunState != EnumerationHelper.GetEnumDescription(PCConstants.RunStates.RunFailure))
                    {
                        bool addRunToTrendReportSuccess = pcClient.AddRunToTrendReport(runID, _pcModel.TrendReportId);
                        if (addRunToTrendReportSuccess)
                        {
                            pcClient.WaitForRunToPublishOnTrendReport(runID, _pcModel.TrendReportId);
                            pcClient.DownloadTrendReportAsPdf(_pcModel.TrendReportId, _workDirectory);
                        }
                    }

                    // Adding the trend report if the Associated Trend report is selected.
                    if (_pcModel.GetAddRunToTrendReport.Equals("AssociatedTrend") && pcRunResponse.RunState != EnumerationHelper.GetEnumDescription(PCConstants.RunStates.RunFailure))
                    {
                        bool addRunToTrendReportSuccess = pcClient.AddRunToTrendReport(runID, _pcModel.TrendReportId);
                        if (addRunToTrendReportSuccess)
                        {
                            pcClient.WaitForRunToPublishOnTrendReport(runID, _pcModel.TrendReportId);
                            pcClient.DownloadTrendReportAsPdf(_pcModel.TrendReportId, _workDirectory);
                        }
                    }
                    if (_statusBySLA && pcRunResponse.RunState == EnumerationHelper.GetEnumDescription(PCConstants.RunStates.Finished))
                    {
                        pcClient.verifySlaStatus(pcRunResponse.RunSLAStatus);
                    }
                }
                pcClient.Logout();
            }
            catch { }
            finally
            {
                //important ending to mark the end of the task for log report parsing!!
                pcClient.PCClientEnd();
            }
        }
Example #15
0
 public static IEnumerable <DayOfWeek> SortedByIndex() =>
 EnumerationHelper.ToEnumerations <DayOfWeek>()
 .OrderBy(dayOfWeek => dayOfWeek.ToIndex());
Example #16
0
 public override IEnumerator <EventBean> GetEnumerator()
 {
     return(EnumerationHelper <EventBean> .Empty());
 }
Example #17
0
        private static void CreateTemplatesFromShapeTypes(Project project, IList <String> shapeTypeNames, Int32 shapeSize, Boolean withModels, Boolean withTerminalMappings, Boolean withModelMappings, Int32 expectedShapeCount)
        {
            if (shapeTypeNames == null)
            {
                shapeTypeNames = new List <String>();
                shapeTypeNames.Add("Circle");
                shapeTypeNames.Add("PolyLine");
            }
            //
            foreach (String shapeTypeName in shapeTypeNames)
            {
                ShapeType shapeType = project.ShapeTypes[shapeTypeName];
                // Create a shape for the template
                Shape shape = shapeType.CreateInstance();
                shape.Fit(0, 0, shapeSize, shapeSize);
                // Create the template
                Template template = new Template(String.Format("{0} Template", shapeType.Name), shapeType.CreateInstance());
                if (shape is IPlanarShape)
                {
                    // Add optional data
                    if (withModels)
                    {
                        template.Shape.ModelObject = project.ModelObjectTypes["Core.GenericModelObject"].CreateInstance();
                        template.MapTerminal(TerminalId.Generic, ControlPointId.Reference);
                        if (withTerminalMappings)
                        {
                            foreach (ControlPointId id in template.Shape.GetControlPointIds(ControlPointCapabilities.Connect))
                            {
                                template.MapTerminal(TerminalId.Generic, id);
                            }
                        }
                        if (withModelMappings)
                        {
                            //
                            // Create ModelMappings
                            List <IModelMapping> modelMappings = new List <IModelMapping>(3);
                            // Create numeric- and format model mappings
                            NumericModelMapping numericMapping = new NumericModelMapping(2, 4, NumericModelMapping.MappingType.FloatInteger, 10, 0);
                            FormatModelMapping  formatMapping  = new FormatModelMapping(4, 2, FormatModelMapping.MappingType.StringString, "{0}");
                            // Create style model mapping
                            float             range             = expectedShapeCount / 15f;
                            StyleModelMapping styleModelMapping = new StyleModelMapping(1, 4, StyleModelMapping.MappingType.FloatStyle);
                            for (int i = 0; i < 15; ++i)
                            {
                                IStyle style = null;
                                switch (i)
                                {
                                case 0: style = project.Design.LineStyles.None; break;

                                case 1: style = project.Design.LineStyles.Dotted; break;

                                case 2: style = project.Design.LineStyles.Dashed; break;

                                case 3: style = project.Design.LineStyles.Special1; break;

                                case 4: style = project.Design.LineStyles.Special2; break;

                                case 5: style = project.Design.LineStyles.Normal; break;

                                case 6: style = project.Design.LineStyles.Blue; break;

                                case 7: style = project.Design.LineStyles.Green; break;

                                case 8: style = project.Design.LineStyles.Yellow; break;

                                case 9: style = project.Design.LineStyles.Red; break;

                                case 10: style = project.Design.LineStyles.HighlightDotted; break;

                                case 11: style = project.Design.LineStyles.HighlightDashed; break;

                                case 12: style = project.Design.LineStyles.Highlight; break;

                                case 13: style = project.Design.LineStyles.HighlightThick; break;

                                case 14: style = project.Design.LineStyles.Thick; break;

                                default: style = null; break;
                                }
                                if (style != null)
                                {
                                    styleModelMapping.AddValueRange(i * range, style);
                                }
                            }
                            modelMappings.Add(styleModelMapping);
                            //
                            foreach (IModelMapping modelMapping in modelMappings)
                            {
                                template.MapProperties(modelMapping);
                            }
                        }
                    }
                }
                else if (shape is ILinearShape)
                {
                    // Nothing else to do
                }
                else
                {
                    throw new NotImplementedException();
                }
                // Insert the template into the repository
                project.Repository.InsertAll(template);
            }
            Assert.AreEqual(EnumerationHelper.Count(project.Repository.GetTemplates()), shapeTypeNames.Count);
        }
		public void CorrectlyRetrievesAllEnumeratedValuesForAGivenEnumerationType()
		{
			IEnumerationHelper helper = new EnumerationHelper();
			IEnumerable<PersistenceMode> modes = helper.GetAll<PersistenceMode>();
			EnumerableAssert.That(modes, Is.EquivalentTo(new PersistenceMode[] { PersistenceMode.Live, PersistenceMode.Archive }));
		}
Example #19
0
 public IEnumerator <EventBean> GetEnumerator()
 {
     return(EnumerationHelper <EventBean> .CreateEmptyEnumerator());
 }
 public IEnumerator<KeyValuePair<string, DeploymentRecoveryEntry>> Deployments()
 {
     return EnumerationHelper.Empty<KeyValuePair<string, DeploymentRecoveryEntry>>();
 }
Example #21
0
        public static void CreateDiagram(Project project, string diagramName, int shapesPerRow, int shapesPerColumn, bool connectShapes, bool withModels, bool withTerminalMappings, bool withModelMappings, bool withLayers, IList <String> shapeTypeNames)
        {
            const int shapeSize  = 80;
            int       lineLength = shapeSize / 2;

            //
            // Create the templates
            CreateTemplatesFromShapeTypes(project, shapeTypeNames, shapeSize, withModels, withTerminalMappings, withModelMappings, shapesPerRow * shapesPerColumn);
            //
            // Prepare the connection points
            ControlPointId leftPoint   = withModels ? ControlPointId.Reference : 4;
            ControlPointId rightPoint  = withModels ? ControlPointId.Reference : 5;
            ControlPointId topPoint    = withModels ? ControlPointId.Reference : 2;
            ControlPointId bottomPoint = withModels ? ControlPointId.Reference : 7;
            //
            // Create the diagram
            Diagram diagram = new Diagram(diagramName);
            //
            // Create and add layers
            int planarLayerId = Layer.NoLayerId, linearLayerId = Layer.NoLayerId, oddRowLayerId = Layer.NoLayerId,
                evenRowLayerId = Layer.NoLayerId, oddColLayerId = Layer.NoLayerId, evenColLayerId = Layer.NoLayerId;

            if (withLayers)
            {
                const string planarLayerName   = "PlanarShapesLayer";
                const string linearLayerName   = "LinearShapesLayer";
                const string oddRowsLayerName  = "OddRowsLayer";
                const string evenRowsLayerName = "EvenRowsLayer";
                const string oddColsLayerName  = "OddColsLayer";
                const string evenColsLayerName = "EvenColsLayer";
                // Create Layers
                Layer planarShapesLayer = new Layer(planarLayerName);
                planarShapesLayer.Title = "Planar Shapes";
                planarShapesLayer.LowerZoomThreshold = 5;
                planarShapesLayer.UpperZoomThreshold = 750;
                diagram.Layers.Add(planarShapesLayer);
                Layer linearShapesLayer = new Layer(linearLayerName);
                linearShapesLayer.Title = "Linear Shapes";
                linearShapesLayer.LowerZoomThreshold = 10;
                linearShapesLayer.UpperZoomThreshold = 500;
                diagram.Layers.Add(linearShapesLayer);
                Layer oddRowsLayer = new Layer(oddRowsLayerName);
                oddRowsLayer.Title = "Odd Rows";
                oddRowsLayer.LowerZoomThreshold = 2;
                oddRowsLayer.UpperZoomThreshold = 1000;
                diagram.Layers.Add(oddRowsLayer);
                Layer evenRowsLayer = new Layer(evenRowsLayerName);
                evenRowsLayer.Title = "Even Rows";
                evenRowsLayer.LowerZoomThreshold = 2;
                evenRowsLayer.UpperZoomThreshold = 1000;
                diagram.Layers.Add(evenRowsLayer);
                Layer oddColsLayer = new Layer(oddColsLayerName);
                oddColsLayer.Title = "Odd Columns";
                oddColsLayer.LowerZoomThreshold = 2;
                oddColsLayer.UpperZoomThreshold = 1000;
                diagram.Layers.Add(oddColsLayer);
                Layer evenColsLayer = new Layer(evenColsLayerName);
                evenColsLayer.Title = "Even Columns";
                evenColsLayer.LowerZoomThreshold = 2;
                evenColsLayer.UpperZoomThreshold = 1000;
                diagram.Layers.Add(evenColsLayer);
                // Assign LayerIds
                planarLayerId  = diagram.Layers.FindLayer(planarLayerName).LayerId;
                linearLayerId  = diagram.Layers.FindLayer(linearLayerName).LayerId;
                oddRowLayerId  = diagram.Layers.FindLayer(oddRowsLayerName).LayerId;
                evenRowLayerId = diagram.Layers.FindLayer(evenRowsLayerName).LayerId;
                oddColLayerId  = diagram.Layers.FindLayer(oddColsLayerName).LayerId;
                evenColLayerId = diagram.Layers.FindLayer(evenColsLayerName).LayerId;
            }

            Template planarTemplate = null;
            Template linearTemplate = null;
            int      searchRange    = shapeSize / 2;

            for (int rowIdx = 0; rowIdx < shapesPerRow; ++rowIdx)
            {
                int rowLayerId = ((rowIdx + 1) % 2 == 0) ? evenRowLayerId : oddRowLayerId;
                for (int colIdx = 0; colIdx < shapesPerRow; ++colIdx)
                {
                    int colLayerId = ((colIdx + 1) % 2 == 0) ? evenColLayerId : oddColLayerId;
                    int shapePosX  = shapeSize + colIdx * (lineLength + shapeSize);
                    int shapePosY  = shapeSize + rowIdx * (lineLength + shapeSize);

                    planarTemplate = GetNextPlanarTemplate(project, planarTemplate);
                    Shape planarShape = planarTemplate.CreateShape();
                    // Apply shape specific property values
                    if (planarShape is PictureBase)
                    {
                        ((PictureBase)planarShape).Image = new NamedImage((System.Drawing.Bitmap)Properties.Resources.SamplePicture.Clone(), "Sample Picture");
                    }
                    if (planarShape is ICaptionedShape)
                    {
                        ((ICaptionedShape)planarShape).SetCaptionText(0, string.Format("{0} / {1}", rowIdx + 1, colIdx + 1));
                    }
                    planarShape.MoveTo(shapePosX, shapePosY);
                    if (withModels)
                    {
                        project.Repository.Insert(planarShape.ModelObject);
                        ((GenericModelObject)planarShape.ModelObject).IntegerValue = rowIdx;
                    }

                    diagram.Shapes.Add(planarShape, project.Repository.ObtainNewTopZOrder(diagram));
                    if (withLayers)
                    {
                        diagram.AddShapeToLayers(planarShape, planarLayerId, Layer.ConvertToLayerIds(EnumerationHelper.Enumerate(rowLayerId | colLayerId)));
                    }
                    if (connectShapes)
                    {
                        linearTemplate = GetNextLinearTemplate(project, linearTemplate);
                        if (rowIdx > 0)
                        {
                            Shape lineShape = linearTemplate.CreateShape();
                            if (planarShape.HasControlPointCapability(topPoint, ControlPointCapabilities.Connect))
                            {
                                lineShape.Connect(ControlPointId.FirstVertex, planarShape, topPoint);
                                Assert.AreNotEqual(ControlPointId.None, lineShape.IsConnected(ControlPointId.FirstVertex, planarShape));
                            }
                            Shape otherShape = diagram.Shapes.FindShape(shapePosX, shapePosY - shapeSize, ControlPointCapabilities.None, searchRange, null);
                            if (otherShape != null && otherShape.HasControlPointCapability(bottomPoint, ControlPointCapabilities.Connect))
                            {
                                lineShape.Connect(ControlPointId.LastVertex, otherShape, bottomPoint);
                                Assert.AreNotEqual(ControlPointId.None, lineShape.IsConnected(ControlPointId.LastVertex, otherShape));
                            }
                            // Add line shape if at least one connection was established.
                            if (lineShape.IsConnected(ControlPointId.FirstVertex, null) != ControlPointId.None && lineShape.IsConnected(ControlPointId.LastVertex, null) != ControlPointId.None)
                            {
                                diagram.Shapes.Add(lineShape, project.Repository.ObtainNewBottomZOrder(diagram));
                                if (withLayers)
                                {
                                    diagram.AddShapeToLayers(lineShape, linearLayerId);
                                }
                            }
                        }
                        if (colIdx > 0)
                        {
                            Shape lineShape = linearTemplate.CreateShape();
                            if (planarShape.HasControlPointCapability(leftPoint, ControlPointCapabilities.Connect))
                            {
                                lineShape.Connect(1, planarShape, leftPoint);
                                Assert.AreNotEqual(ControlPointId.None, lineShape.IsConnected(ControlPointId.FirstVertex, planarShape));
                            }
                            Shape otherShape = diagram.Shapes.FindShape(shapePosX - shapeSize, shapePosY, ControlPointCapabilities.None, searchRange, null);
                            if (otherShape != null && otherShape.HasControlPointCapability(rightPoint, ControlPointCapabilities.Connect))
                            {
                                lineShape.Connect(2, otherShape, rightPoint);
                                Assert.AreNotEqual(ControlPointId.None, lineShape.IsConnected(ControlPointId.LastVertex, otherShape));
                            }
                            // Add line shape if at least one connection was established.
                            if (lineShape.IsConnected(ControlPointId.FirstVertex, null) != ControlPointId.None && lineShape.IsConnected(ControlPointId.LastVertex, null) != ControlPointId.None)
                            {
                                diagram.Shapes.Add(lineShape, project.Repository.ObtainNewBottomZOrder(diagram));
                                if (withLayers)
                                {
                                    diagram.AddShapeToLayers(lineShape, linearLayerId);
                                }
                            }
                        }
                    }
                }
            }
            diagram.Width  = (lineLength + shapeSize) * shapesPerRow + 2 * shapeSize;
            diagram.Height = (lineLength + shapeSize) * shapesPerColumn + 2 * shapeSize;
            project.Repository.InsertAll(diagram);
        }
 public static ETimeInterval ToTimeInterval(EGrouppedTimeInterval grouppedInterval) => (grouppedInterval == EGrouppedTimeInterval.DayOfWeek) ? ETimeInterval.Day : EnumerationHelper.ToEnumerationByText <EGrouppedTimeInterval, ETimeInterval>(grouppedInterval);
Example #23
0
 public override IEnumerator<EventBean> GetEnumerator()
 {
     return EnumerationHelper.SingletonNullable(firstEvent);
 }
Example #24
0
        public static void CreateDiagram(Project project, string diagramName, int shapeSize, int shapesPerRow, int shapesPerColumn, bool connectShapes, bool withModels, bool withMappings, bool withLayers)
        {
            shapeSize = Math.Max(10, shapeSize);
            int lineLength = shapeSize / 2;
            //
            // Create ModelMappings
            NumericModelMapping numericModelMapping = null;
            FormatModelMapping  formatModelMapping  = null;
            StyleModelMapping   styleModelMapping   = null;

            if (withMappings)
            {
                // Create numeric- and format model mappings
                numericModelMapping = new NumericModelMapping(2, 4, NumericModelMapping.MappingType.FloatInteger, 10, 0);
                formatModelMapping  = new FormatModelMapping(4, 2, FormatModelMapping.MappingType.StringString, "{0}");
                // Create style model mapping
                float range = (shapesPerRow * shapesPerColumn) / 15f;
                styleModelMapping = new StyleModelMapping(1, 4, StyleModelMapping.MappingType.FloatStyle);
                for (int i = 0; i < 15; ++i)
                {
                    IStyle style = null;
                    switch (i)
                    {
                    case 0: style = project.Design.LineStyles.None; break;

                    case 1: style = project.Design.LineStyles.Dotted; break;

                    case 2: style = project.Design.LineStyles.Dashed; break;

                    case 3: style = project.Design.LineStyles.Special1; break;

                    case 4: style = project.Design.LineStyles.Special2; break;

                    case 5: style = project.Design.LineStyles.Normal; break;

                    case 6: style = project.Design.LineStyles.Blue; break;

                    case 7: style = project.Design.LineStyles.Green; break;

                    case 8: style = project.Design.LineStyles.Yellow; break;

                    case 9: style = project.Design.LineStyles.Red; break;

                    case 10: style = project.Design.LineStyles.HighlightDotted; break;

                    case 11: style = project.Design.LineStyles.HighlightDashed; break;

                    case 12: style = project.Design.LineStyles.Highlight; break;

                    case 13: style = project.Design.LineStyles.HighlightThick; break;

                    case 14: style = project.Design.LineStyles.Thick; break;

                    default: style = null; break;
                    }
                    if (style != null)
                    {
                        styleModelMapping.AddValueRange(i * range, style);
                    }
                }
            }
            //
            // Create model obejct for the planar shape's template
            IModelObject planarModel = null;

            if (withModels)
            {
                planarModel = project.ModelObjectTypes["Core.GenericModelObject"].CreateInstance();
            }
            //
            // Create a shape for the planar shape's template
            Shape planarShape = project.ShapeTypes["RoundedBox"].CreateInstance();

            planarShape.Fit(0, 0, shapeSize, shapeSize);
            //
            // Create a template for the planar shapes
            Template planarTemplate = new Template("PlanarShape Template", planarShape);

            if (withModels)
            {
                planarTemplate.Shape.ModelObject = planarModel;
                if (withMappings)
                {
                    foreach (ControlPointId id in planarTemplate.Shape.GetControlPointIds(ControlPointCapabilities.Connect))
                    {
                        planarTemplate.MapTerminal(TerminalId.Generic, id);
                    }
                    planarTemplate.MapProperties(numericModelMapping);
                    planarTemplate.MapProperties(formatModelMapping);
                    planarTemplate.MapProperties(styleModelMapping);
                }
            }
            //
            // Create a template for the linear shapes
            Template linearTemplate = null;

            if (connectShapes)
            {
                linearTemplate = new Template("LinearShape Template", project.ShapeTypes["Polyline"].CreateInstance());
            }
            //
            // Insert the created templates into the repository
            project.Repository.InsertAll(planarTemplate);
            if (connectShapes)
            {
                project.Repository.InsertAll(linearTemplate);
            }
            //
            // Prepare the connection points
            ControlPointId leftPoint   = withModels ? ControlPointId.Reference : 4;
            ControlPointId rightPoint  = withModels ? ControlPointId.Reference : 5;
            ControlPointId topPoint    = withModels ? ControlPointId.Reference : 2;
            ControlPointId bottomPoint = withModels ? ControlPointId.Reference : 7;
            //
            // Create the diagram
            Diagram diagram = new Diagram(diagramName);
            //
            // Create and add layers
            int planarLayerId = Layer.NoLayerId, linearLayerId = Layer.NoLayerId, oddRowLayerId = Layer.NoLayerId,
                evenRowLayerId = Layer.NoLayerId, oddColLayerId = Layer.NoLayerId, evenColLayerId = Layer.NoLayerId;

            if (withLayers)
            {
                const string planarLayerName   = "PlanarShapesLayer";
                const string linearLayerName   = "LinearShapesLayer";
                const string oddRowsLayerName  = "OddRowsLayer";
                const string evenRowsLayerName = "EvenRowsLayer";
                const string oddColsLayerName  = "OddColsLayer";
                const string evenColsLayerName = "EvenColsLayer";
                // Create Layers
                Layer planarShapesLayer = new Layer(planarLayerName);
                planarShapesLayer.Title = "Planar Shapes";
                planarShapesLayer.LowerZoomThreshold = 5;
                planarShapesLayer.UpperZoomThreshold = 750;
                diagram.Layers.Add(planarShapesLayer);
                Layer linearShapesLayer = new Layer(linearLayerName);
                linearShapesLayer.Title = "Linear Shapes";
                linearShapesLayer.LowerZoomThreshold = 10;
                linearShapesLayer.UpperZoomThreshold = 500;
                diagram.Layers.Add(linearShapesLayer);
                Layer oddRowsLayer = new Layer(oddRowsLayerName);
                oddRowsLayer.Title = "Odd Rows";
                oddRowsLayer.LowerZoomThreshold = 2;
                oddRowsLayer.UpperZoomThreshold = 1000;
                diagram.Layers.Add(oddRowsLayer);
                Layer evenRowsLayer = new Layer(evenRowsLayerName);
                evenRowsLayer.Title = "Even Rows";
                evenRowsLayer.LowerZoomThreshold = 2;
                evenRowsLayer.UpperZoomThreshold = 1000;
                diagram.Layers.Add(evenRowsLayer);
                Layer oddColsLayer = new Layer(oddColsLayerName);
                oddColsLayer.Title = "Odd Columns";
                oddColsLayer.LowerZoomThreshold = 2;
                oddColsLayer.UpperZoomThreshold = 1000;
                diagram.Layers.Add(oddColsLayer);
                Layer evenColsLayer = new Layer(evenColsLayerName);
                evenColsLayer.Title = "Even Columns";
                evenColsLayer.LowerZoomThreshold = 2;
                evenColsLayer.UpperZoomThreshold = 1000;
                diagram.Layers.Add(evenColsLayer);
                // Assign LayerIds
                planarLayerId  = diagram.Layers.FindLayer(planarLayerName).LayerId;
                linearLayerId  = diagram.Layers.FindLayer(linearLayerName).LayerId;
                oddRowLayerId  = diagram.Layers.FindLayer(oddRowsLayerName).LayerId;
                evenRowLayerId = diagram.Layers.FindLayer(evenRowsLayerName).LayerId;
                oddColLayerId  = diagram.Layers.FindLayer(oddColsLayerName).LayerId;
                evenColLayerId = diagram.Layers.FindLayer(evenColsLayerName).LayerId;
            }

            for (int rowIdx = 0; rowIdx < shapesPerColumn; ++rowIdx)
            {
                int rowLayerId = ((rowIdx + 1) % 2 == 0) ? evenRowLayerId : oddRowLayerId;
                for (int colIdx = 0; colIdx < shapesPerRow; ++colIdx)
                {
                    int colLayerId = ((colIdx + 1) % 2 == 0) ? evenColLayerId : oddColLayerId;
                    int shapePosX  = shapeSize + colIdx * (lineLength + shapeSize);
                    int shapePosY  = shapeSize + rowIdx * (lineLength + shapeSize);

                    planarShape = planarTemplate.CreateShape();
                    if (planarShape is ICaptionedShape)
                    {
                        ((ICaptionedShape)planarShape).SetCaptionText(0, string.Format("{0} / {1}", rowIdx + 1, colIdx + 1));
                    }

                    planarShape.MoveTo(shapePosX, shapePosY);
                    if (withModels)
                    {
                        project.Repository.Insert(planarShape.ModelObject);
                        ((GenericModelObject)planarShape.ModelObject).IntegerValue = rowIdx;
                    }

                    diagram.Shapes.Add(planarShape, project.Repository.ObtainNewTopZOrder(diagram));
                    if (withLayers)
                    {
                        diagram.AddShapeToLayers(planarShape, planarLayerId, Layer.ConvertToLayerIds(EnumerationHelper.Enumerate(rowLayerId, colLayerId)));
                    }
                    if (connectShapes)
                    {
                        if (rowIdx > 0)
                        {
                            Shape lineShape = linearTemplate.CreateShape();
                            lineShape.Connect(ControlPointId.FirstVertex, planarShape, topPoint);
                            Debug.Assert(ControlPointId.None != lineShape.IsConnected(ControlPointId.FirstVertex, planarShape));

                            Shape otherShape = diagram.Shapes.FindShape(shapePosX, shapePosY - (shapeSize + lineLength), ControlPointCapabilities.None, 0, null);
                            Debug.Assert(otherShape != null && otherShape != planarShape);
                            lineShape.Connect(ControlPointId.LastVertex, otherShape, bottomPoint);
                            diagram.Shapes.Add(lineShape, project.Repository.ObtainNewBottomZOrder(diagram));
                            if (withLayers)
                            {
                                diagram.AddShapeToLayers(lineShape, linearLayerId);
                            }
                            Debug.Assert(ControlPointId.None != lineShape.IsConnected(ControlPointId.LastVertex, otherShape));
                        }
                        if (colIdx > 0)
                        {
                            Shape lineShape = linearTemplate.CreateShape();
                            lineShape.Connect(1, planarShape, leftPoint);
                            Debug.Assert(ControlPointId.None != lineShape.IsConnected(ControlPointId.FirstVertex, planarShape));

                            Shape otherShape = diagram.Shapes.FindShape(shapePosX - (shapeSize + lineLength), shapePosY, ControlPointCapabilities.None, 0, null);
                            Debug.Assert(otherShape != null && otherShape != planarShape);
                            lineShape.Connect(2, otherShape, rightPoint);

                            diagram.Shapes.Add(lineShape, project.Repository.ObtainNewBottomZOrder(diagram));
                            if (withLayers)
                            {
                                diagram.AddShapeToLayers(lineShape, linearLayerId);
                            }
                            Debug.Assert(ControlPointId.None != lineShape.IsConnected(ControlPointId.LastVertex, otherShape));
                        }
                    }
                }
            }
            diagram.Width  = ((shapeSize + lineLength) * shapesPerRow) + lineLength;
            diagram.Height = ((shapeSize + lineLength) * shapesPerColumn) + lineLength;
            project.Repository.InsertAll(diagram);
        }
Example #25
0
 public static IEnumerable <string> GetMonthsTexts() => EnumerationHelper.ToStrings <MonthsOfYear>();
Example #26
0
 public LayerMouseEventArgs(Layer layer, LayerItem item,
                            MouseEventType eventType, MouseButtonsDg buttons, int clickCount, int wheelDelta,
                            Point position, KeysDg modifiers)
     : this(layer, item, EnumerationHelper.Enumerate(layer), eventType, buttons, clickCount, wheelDelta, position, modifiers)
 {
 }
Example #27
0
        private Parameter ReadParameter()
        {
            var parameter = new Parameter();

            parameter.Type = (ParameterType)reader.ReadInt32();

            switch (parameter.Type)
            {
            case ParameterType.Boolean:
                parameter.Value = reader.ReadBoolean();
                ReadNullBytes(9);
                break;

            case ParameterType.Integer:
                parameter.Value = reader.ReadInt32();
                ReadNullBytes(6);
                break;

            case ParameterType.Float:
            case ParameterType.Angle:
            case ParameterType.Percent:
                ReadNullBytes(4);
                parameter.Value = reader.ReadSingle();
                ReadNullBytes(2);
                break;

            case ParameterType.Location:
                parameter.Value = new float[]
                {
                    reader.ReadSingle(),
                        reader.ReadSingle(),
                        reader.ReadSingle()
                };
                break;

            case ParameterType.Color:
                parameter.Value = new byte[]
                {
                    reader.ReadByte(),     //B
                        reader.ReadByte(), //G
                        reader.ReadByte(), //R
                        reader.ReadByte()  //A
                };
                ReadNullBytes(6);
                break;

            case ParameterType.ComparisonOperator:
            case ParameterType.Surface:
            case ParameterType.ShakeIntensity:
            case ParameterType.Mood:
            case ParameterType.EvacuationSide:
            case ParameterType.RadarEvent:
            case ParameterType.Buildability:
            case ParameterType.Boundary:
                parameter.Value = EnumerationHelper.GetEnumerationValue((short)reader.ReadInt32(), parameter.Type);
                ReadNullBytes(6);
                break;

            case ParameterType.KindOf:
                parameter.Value = EnumerationHelper.GetEnumerationValue((short)reader.ReadInt32(), parameter.Type);
                ReadNullBytes(4);
                var kindOfAsString = ReadString();
                Assert(kindOfAsString == parameter.Value.ToString());
                break;

            default:
                ReadNullBytes(8);
                parameter.Value = ReadString();
                break;
            }
            Write(parameter.Type.ToString(), parameter.Value.ToString());
            return(parameter);
        }
Example #28
0
 public LayerMouseEventArgs(Layer layer, LayerItem item, MouseEventArgsDg mouseEventArgs)
     : this(layer, item, EnumerationHelper.Enumerate(layer), mouseEventArgs.EventType, mouseEventArgs.Buttons, mouseEventArgs.Clicks, mouseEventArgs.WheelDelta, mouseEventArgs.Position, mouseEventArgs.Modifiers)
 {
 }
Example #29
0
 public IEnumerator <EventBean> GetEnumerator()
 {
     return(EnumerationHelper.Empty <EventBean>());
     //return ((IEnumerable<EventBean>) null).GetEnumerator();
 }
        public void CorrectlyDeterminesAbsoluteDifference()
        {
            IEnumerationHelper helper = new EnumerationHelper();

            Assert.That(helper.DetermineAbsoluteDifference(PersistenceMode.Archive, PersistenceMode.Live), Is.EqualTo(1));
        }
 public IEnumerator <EventBean> GetEnumerator()
 {
     return(EnumerationHelper.Empty <EventBean>());
 }
Example #32
0
 public override IEnumerator<EventBean> GetEnumerator()
 {
     return EnumerationHelper.Empty<EventBean>();
 }