/// <summary>
            ///
            /// </summary>
            private void Start()
            {
                // create cell array
                _cells = new Cell[_countY, _countX];

                // instantiate cell prefabs and store in array
                for (int y = 0; y < _countY; y++)
                {
                    for (int x = 0; x < _countX; x++)
                    {
                        //instantiate a new cell using the cell prefab
                        Cell cell = Instantiate(_cellPrefab, transform);

                        //move the cell's position to correct location based on the index
                        cell.transform.localPosition = new Vector3(x, 0, y);

                        //store the newly created cell in the cells 2d array
                        _cells[y, x] = cell;
                    }
                }


                // create model using the rule attached to this component
                _rule  = GetComponent <ICARule2D>();
                _model = new CAModel2D(_rule, _countY, _countX);

                // initialize model
                _initializer.Initialize(_model.CurrentState);

                // create display
                _display = new ModelDisplay();
                _display.Initialize(_countX, _countY, _cells);
            }
            /// <summary>
            /// Resets the model
            /// </summary>
            public void ResetModel()
            {
                // initialize model
                _initializer.Initialize(_model.CurrentState);

                // create display
                _display = new ModelDisplay();
                _display.Initialize(_countX, _countY, _cells);
            }
Example #3
0
 public ActionResult Markdown()
 {
     if (Manager.EditMode && Module.IsAuthorized(ModuleDefinition.RoleDefinition.Edit))
     {
         ModelEdit model = new ModelEdit();
         ObjectSupport.CopyData(Module.Contents, model.Contents);
         return(View(model));
     }
     else
     {
         ModelDisplay model = new ModelDisplay();
         ObjectSupport.CopyData(Module.Contents, model.Contents);
         return(View("MarkdownDisplay", model));
     }
 }
Example #4
0
        private static void Process(Store store, string filename, AssemblyProcessor assemblyProcessor, TextFileProcessor textFileProcessor)
        {
            try
            {
                Cursor.Current          = Cursors.WaitCursor;
                ModelRoot.BatchUpdating = true;

                if (IsAssembly(filename))
                {
                    using (Transaction tx = store.TransactionManager.BeginTransaction("Process dropped assembly"))
                    {
                        if (assemblyProcessor.Process(filename))
                        {
                            StatusDisplay.Show("Creating diagram elements. This might take a while...");
                            tx.Commit();

                            ModelDisplay.LayoutDiagram(store.ModelRoot().GetActiveDiagram() as EFModelDiagram);
                        }
                    }
                }
                else
                {
                    using (Transaction tx = store.TransactionManager.BeginTransaction("Process dropped class"))
                    {
                        if (textFileProcessor.Process(filename))
                        {
                            StatusDisplay.Show("Creating diagram elements. This might take a while...");
                            tx.Commit();
                        }
                    }
                }
            }
            finally
            {
                Cursor.Current          = Cursors.Default;
                ModelRoot.BatchUpdating = false;

                StatusDisplay.Show("");
            }
        }
Example #5
0
    void Start()
    {
        VuforiaBehaviour.Instance.RegisterVuforiaStartedCallback(OnVuforiaStarted);
        VuforiaBehaviour.Instance.RegisterOnPauseCallback(OnPause);
        VuforiaBehaviour.Instance.RegisterTrackablesUpdatedCallback(OnTrackablesUpdated);
        if (mutex == null)
        {
            mutex = new Mutex(false);
        }
        setRecognitionStatus(RECOG_STATUS.FINISHED);
        country_code = -1;

        text          = GameObject.FindWithTag("DebugLog").GetComponent <UnityEngine.UI.Text>();
        audio         = GameObject.Find("Audios").GetComponent <Audio> ();
        model_display = GameObject.Find("ModelDisplayControl").GetComponent <ModelDisplay> ();

        path = Application.streamingAssetsPath + "/";
        multi_class_model_path = path + "multi_class.model";
        dict_path            = path + "dictionary.mat";
        one_class_model_path = path + "one_class.model";


        sw = new Stopwatch();
    }
        public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
        {
            base.ElementPropertyChanged(e);

            ModelRoot   element = (ModelRoot)e.ModelElement;
            Store       store   = element.Store;
            Transaction current = store.TransactionManager.CurrentTransaction;

            if (current.IsSerializing)
            {
                return;
            }

            if (Equals(e.NewValue, e.OldValue))
            {
                return;
            }

            List <string> errorMessages = EFCoreValidator.GetErrors(element).ToList();
            bool          redraw        = false;

            switch (e.DomainProperty.Name)
            {
            case "ConnectionString":

                if (e.NewValue != null)
                {
                    element.ConnectionStringName = null;
                }

                break;

            case "ConnectionStringName":

                if (e.NewValue != null)
                {
                    element.ConnectionString = null;
                }

                break;

            case "DatabaseSchema":

                if (string.IsNullOrEmpty((string)e.NewValue))
                {
                    element.DatabaseSchema = "dbo";
                }

                break;

            case "EntityFrameworkVersion":
                element.EntityFrameworkPackageVersion = "Latest";

                if (element.EntityFrameworkVersion == EFVersion.EFCore)
                {
                    element.InheritanceStrategy = CodeStrategy.TablePerHierarchy;
                }

                break;

            case "EnumOutputDirectory":

                if (string.IsNullOrEmpty((string)e.NewValue) && !string.IsNullOrEmpty(element.EntityOutputDirectory))
                {
                    element.EnumOutputDirectory = element.EntityOutputDirectory;
                }

                break;

            case "StructOutputDirectory":

                if (string.IsNullOrEmpty((string)e.NewValue) && !string.IsNullOrEmpty(element.EntityOutputDirectory))
                {
                    element.StructOutputDirectory = element.EntityOutputDirectory;
                }

                break;

            case "EntityOutputDirectory":

                if (string.IsNullOrEmpty(element.EnumOutputDirectory) || element.EnumOutputDirectory == (string)e.OldValue)
                {
                    element.EnumOutputDirectory = (string)e.NewValue;
                }

                if (string.IsNullOrEmpty(element.StructOutputDirectory) || element.StructOutputDirectory == (string)e.OldValue)
                {
                    element.StructOutputDirectory = (string)e.NewValue;
                }

                break;

            case "FileNameMarker":
                string newFileNameMarker = (string)e.NewValue;

                if (!Regex.Match($"a.{newFileNameMarker}.cs",
                                 @"^(?!^(PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\..*)(\..+)?$)[^\x00-\x1f\\?*:\"";|/]+$")
                    .Success)
                {
                    errorMessages.Add("Invalid value to make part of file name");
                }

                break;

            case "InheritanceStrategy":

                if ((element.EntityFrameworkVersion == EFVersion.EFCore) && (element.NuGetPackageVersion.MajorMinorVersionNum < 2.1))
                {
                    element.InheritanceStrategy = CodeStrategy.TablePerHierarchy;
                }

                break;

            case "LayoutAlgorithm":
                ModelDisplay.LayoutDiagram(element.Classes.FirstOrDefault()?.GetActiveDiagram() as EFModelDiagram);

                break;

            case "Namespace":
                errorMessages.Add(CommonRules.ValidateNamespace((string)e.NewValue, CodeGenerator.IsValidLanguageIndependentIdentifier));

                break;

            case "ShowCascadeDeletes":

                // need these change rules to fire even though nothing in Association has changed
                // so we need to set this early -- requires guarding against recursion.
                bool newShowCascadeDeletes = (bool)e.NewValue;

                if (element.ShowCascadeDeletes != newShowCascadeDeletes)
                {
                    element.ShowCascadeDeletes = newShowCascadeDeletes;

                    foreach (Association association in store.ElementDirectory.FindElements <Association>())
                    {
                        AssociationChangeRules.UpdateDisplayForCascadeDelete(association);
                    }
                }

                redraw = true;

                break;

            case "ShowWarningsInDesigner":
                redraw = true;

                break;

            case "WarnOnMissingDocumentation":

                if (element.ShowWarningsInDesigner)
                {
                    redraw = true;
                }

                ModelRoot.ExecuteValidator?.Invoke();

                break;
            }

            errorMessages = errorMessages.Where(m => m != null).ToList();

            if (errorMessages.Any())
            {
                current.Rollback();
                ErrorDisplay.Show(string.Join("\n", errorMessages));
            }

            if (redraw)
            {
                element.InvalidateDiagrams();
            }
        }