internal BlackboardTestController(
            EditorWindow associatedEditorWindow,
            GraphData model,
            BlackboardViewModel inViewModel,
            DataStore <GraphData> graphDataStore)
            : base(model, inViewModel, graphDataStore)
        {
            m_AddButton = blackboard.Q <Button>("addButton");
            Assert.IsNotNull(m_AddButton);

            m_AddBlackboardItemsMenu = blackboard.addBlackboardItemMenu;
            Assert.IsNotNull(m_AddBlackboardItemsMenu);

            m_EditorWindow = associatedEditorWindow;
        }
예제 #2
0
        public UnitViewModel(Unit model)
        {
            Model = model;
            Model.PropertyChanged += Model_PropertyChanged;

            modelVisual3D.Model      = geometryModel3D;
            modelVisual3D.MouseDown += OnMouseDown;
            modelVisual3D.MouseUp   += OnMouseUp;
            geometryModel3D.Geometry = Helper.FindResource("cubeMesh") as Geometry3D;
            if (Model.Behavior != null)
            {
                behaviortree = new BehaviortreeViewModel(Model.Behavior);
            }
            blackboard = new BlackboardViewModel(Model.Blackboard);
        }
예제 #3
0
        public ActionResult BlackboardView()
        {
            BlackboardViewModel vm = new BlackboardViewModel();

            // populate Blackboard
            Blackboard       blackboard = vm.Blackboard ?? new Blackboard();
            List <BoardPost> boardposts = blackboard.BoardPosts ?? new List <BoardPost>();

            using (DataModel dm = new DataModel())
            {
                var bp = dm.BoardPosts;

                foreach (BoardPost b in bp)
                {
                    boardposts.Add(b);
                }

                if (blackboard.BoardPosts == null)
                {
                    blackboard.BoardPosts = boardposts;
                }
                else
                {
                    blackboard.BoardPosts.AddRange(boardposts);
                }

                vm.Blackboard = blackboard;
            }

            vm.Encryption = new List <SelectListItem>
            {
                new SelectListItem {
                    Value = "", Text = "Select encryption algorithm", Selected = false
                },
                new SelectListItem {
                    Value = "aes128", Text = "AES-128", Selected = false
                },
                new SelectListItem {
                    Value = "aes192", Text = "AES-192", Selected = false
                },
                new SelectListItem {
                    Value = "aes256", Text = "AES-256", Selected = false
                }
            };
            ViewData["EncryptionAlgos"] = vm.Encryption;

            return(View(vm));
        }
예제 #4
0
        public void LoadGraph()
        {
            List <PropertyCollector.TextureInfo> lti;
            var assetCollection = new AssetCollection();

            ShaderGraphImporter.GetShaderText(kGraphName, out lti, assetCollection, out m_Graph);
            Assert.NotNull(m_Graph, $"Invalid graph data found for {kGraphName}");

            m_Graph.ValidateGraph();

            m_Collector = new PropertyCollector();
            m_Graph.CollectShaderProperties(m_Collector, GenerationMode.ForReals);

            // Open up the window
            if (!ShaderGraphImporterEditor.ShowGraphEditWindow(kGraphName))
            {
                Assert.Fail("ShaderGraphImporterEditor.ShowGraphEditWindow could not open " + kGraphName);
            }

            m_Window = EditorWindow.GetWindow <MaterialGraphEditWindow>();
            if (m_Window == null)
            {
                Assert.Fail("Could not open window");
            }

            // EditorWindow.GetWindow will return a new window if one is not found. A new window will have graphObject == null.
            if (m_Window.graphObject == null)
            {
                Assert.Fail("Existing Shader Graph window of " + kGraphName + " not found.");
            }

            m_GraphEditorView = m_Window.graphEditorView;

            // Create the blackboard test controller
            var blackboardViewModel = new BlackboardViewModel()
            {
                parentView = m_Window.graphEditorView.graphView, model = m_Window.graphObject.graph, title = m_Window.assetName
            };

            m_BlackboardTestController = new BlackboardTestController(m_Window, m_Graph, blackboardViewModel, m_Window.graphObject.graphDataStore);

            // Remove the normal blackboard
            m_GraphEditorView.blackboardController.blackboard.RemoveFromHierarchy();

            // And override reference to the blackboard controller to point at the test controller
            m_GraphEditorView.blackboardController = m_BlackboardTestController;
        }
예제 #5
0
        public ActionResult BlackboardView(BlackboardViewModel vm)
        {
            vm.PostTime   = DateTime.Now;
            vm.Encryption = new List <SelectListItem>
            {
                new SelectListItem {
                    Value = "", Text = "Select encryption algorithm", Selected = false
                },
                new SelectListItem {
                    Value = "aes128", Text = "AES-128", Selected = false
                },
                new SelectListItem {
                    Value = "aes192", Text = "AES-192", Selected = false
                },
                new SelectListItem {
                    Value = "aes256", Text = "AES-256", Selected = false
                }
            };
            ViewData["EncryptionAlgos"] = vm.Encryption;

            // populate Blackboard (copied from GET)
            Blackboard       blackboard = vm.Blackboard ?? new Blackboard();
            List <BoardPost> boardposts = blackboard.BoardPosts ?? new List <BoardPost>();

            using (DataModel dm = new DataModel())
            {
                var bp = dm.BoardPosts;

                foreach (BoardPost b in bp)
                {
                    boardposts.Add(b);
                }

                if (blackboard.BoardPosts == null)
                {
                    blackboard.BoardPosts = boardposts;
                }
                else
                {
                    blackboard.BoardPosts.AddRange(boardposts);
                }

                vm.Blackboard = blackboard;
            }

            // Server-side validation
            if (vm.UserHandle.Length < 1 || vm.UserHandle.Length > 256)
            {
                ModelState.AddModelError(nameof(vm.UserHandle), "User handle is invalid.");
            }

            if (vm.EncryptionChoice == null || vm.EncryptionChoice == "")
            {
                ModelState.AddModelError(nameof(vm.EncryptionChoice), "Please select an encryption algorithm.");
            }

            if (vm.Message.Length < 1 || vm.Message.Length > 256)
            {
                ModelState.AddModelError(nameof(vm.Message), "Message content is too long.");
            }

            if (vm.EncryptionKey.Length < 8 || vm.EncryptionKey.Length > 256)
            {
                ModelState.AddModelError(nameof(vm.EncryptionKey), "Password must be between 8 - 256 characters.");
            }

            if (ModelState.IsValid)
            {
                Crypto Crypto   = new Crypto();
                string plaintxt = vm.Message;
                string key      = vm.EncryptionKey;
                string ciphertxt;

                switch (vm.EncryptionChoice)
                {
                case ("aes128"):
                    ciphertxt = (string)Crypto.Crypt(CryptType.Encrypt, CryptAlgo.AES128, plaintxt, key);
                    ViewData["encryptedMsg"] = ciphertxt;
                    break;

                case ("aes192"):
                    ciphertxt = (string)Crypto.Crypt(CryptType.Encrypt, CryptAlgo.AES192, plaintxt, key);
                    ViewData["encryptedMsg"] = ciphertxt;
                    break;

                case ("aes256"):
                    ciphertxt = (string)Crypto.Crypt(CryptType.Encrypt, CryptAlgo.AES256, plaintxt, key);
                    ViewData["encryptedMsg"] = ciphertxt;
                    break;

                default:
                    throw new Exception("Something went very wrong.");
                }

                // collect data from form
                BoardPost bp = new BoardPost();
                bp.Content             = ciphertxt; // write encrypted content to BoardPost, not original Content
                bp.PostTime            = vm.PostTime;
                bp.Poster              = vm.UserHandle;
                bp.TimeToLive          = 600000; // 600000 ms = 10 minutes
                bp.EncryptionAlgorithm = vm.EncryptionChoice;
                bp.Salt = Crypto.Salt;
                bp.IV   = Crypto.IV;

                vm.Blackboard.BoardPosts.Add(bp); // add post to view model

                // package BoardPost object to be written to database
                using (DataModel dm = new DataModel())
                {
                    dm.BoardPosts.Add(bp);
                    dm.SaveChanges();
                }

                return(RedirectToAction("BlackboardView", "Blackboard"));
            }
            return(View(vm));
        }