Exemplo n.º 1
0
        public override void Execute()
        {
            new GetPricingModelDefaultRate(this.customerId, Model).Execute();

            VerificationModel = Model.Clone().ClearOutput();

            LogModel("with updated default rate");

            CalculateVerificationModel();

            Model.PricingSourceModels = new List <PricingSourceModel>();

            if (CalculateInterestRate())
            {
                CalculateFullModelAfterInterestRate();
            }

            LogModel("just after calculations");

            SetCustomerOriginID();

            CompareResults();

            if (!string.IsNullOrEmpty(Error) && ThrowExceptionOnError)
            {
                throw new StrategyWarning(this, Error);
            }
        }         // Execute
Exemplo n.º 2
0
        private List <Tuple <int, int, int> > GetPossibleBestPosOrderList(Model pModel, ChessType chessType)
        {
            const int FIND_COUNT = 10;

            List <Tuple <int, int, int> > posScoreList = new List <Tuple <int, int, int> >();

            for (int y = 0; y < GameDef.board_cell_length; y++)
            {
                for (int x = 0; x < GameDef.board_cell_length; x++)
                {
                    var board = pModel.GetBoardByCopy();
                    if (board[y][x] == ChessType.None)
                    {
                        Model cloneModel = pModel.Clone() as Model;

                        int score = onePointEvaluation.GetScore(cloneModel, y, x, chessType);

                        posScoreList.Add(new Tuple <int, int, int>(y, x, score));
                    }
                }
            }
            //         y,   x,  score                                   order score by Descending
            List <Tuple <int, int, int> > OrderPosScoreList = posScoreList.OrderByDescending(x => x.Item3).ToList();

            if (OrderPosScoreList.Count > FIND_COUNT)
            {
                OrderPosScoreList = OrderPosScoreList.GetRange(0, FIND_COUNT);
            }

            return(OrderPosScoreList);
        }
Exemplo n.º 3
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Model                  input    = null;
            List <Load>            loads    = new List <Load>();
            List <Guanaco.Support> supports = new List <Guanaco.Support>();

            DA.GetData(0, ref input);
            DA.GetDataList(1, loads);
            DA.GetDataList(2, supports);
            if (input.Mesh == null)
            {
                throw new Exception("The boundary conditions can be applied to a meshed model only.");
            }

            Model model = input.Clone() as Model;

            foreach (Load l in loads)
            {
                model.AddLoad(l.Clone() as Load);
            }
            foreach (Guanaco.Support s in supports)
            {
                model.AddSupport(s.Clone() as Guanaco.Support);
            }
            DA.SetData(0, model);
        }
Exemplo n.º 4
0
        protected async Task HandleValidSubmit()
        {
            if (!EditContext.Validate())
            {
                return;
            }

            var changes = HandleModificationState.Changes;

            if (!changes.Any())
            {
                await Notifier.NotifyAsync(new Models.Notification
                {
                    Header  = GetModelId(Model),
                    IsError = false,
                    Message = Localizer["No changes"]
                }).ConfigureAwait(false);

                return;
            }

            Id    = GetModelId(Model);
            IsNew = false;
            CreateEditContext(Model.Clone());

            var keys = changes.Keys
                       .OrderBy(k => k, this);

            try
            {
                foreach (var key in keys)
                {
                    await HandleMoficationList(key, changes[key])
                    .ConfigureAwait(false);
                }

                await Notifier.NotifyAsync(new Models.Notification
                {
                    Header  = Id,
                    Message = Localizer["Saved"]
                }).ConfigureAwait(false);
            }
            catch (AggregateException ae)
            {
                foreach (var e in ae.InnerExceptions)
                {
                    await HandleModificationErrorAsync(e).ConfigureAwait(false);
                }
            }
            catch (Exception e)
            {
                await HandleModificationErrorAsync(e).ConfigureAwait(false);
            }
            finally
            {
                changes.Clear();
            }

            await InvokeAsync(StateHasChanged).ConfigureAwait(false);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Caches a deep clone of the entity
        /// </summary>
        public void BeginEdit()
        {
            // Throw an exception if Entity not supplied
            if (Model == null)
            {
                throw new InvalidOperationException("Entity must be set");
            }

            // Return if we're already editing
            if (Copy != null)
            {
                return;
            }

            // Copy entity
            Original = Model;
            Copy     = Model.Clone();

            // Point entity to the copy
            Model = Copy;

            // Notify IsEditing, IsDirty
            BindingHelper.InternalNotifyPropertyChanged("IsEditing",
                                                        this, base.propertyChanged);
            BindingHelper.InternalNotifyPropertyChanged("IsDirty",
                                                        this, base.propertyChanged);

            // Post-processing
            OnBeginEdit();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            SetEntryExpenses();
            if (isEditMode && OldModel.Value != Model.Value)
            {
                OldModel.Value *= -1;
                controller.PerformTransaction(OldModel);
                controller.Remove(OldModel);
            }

            if (Model.PaymentMethod is Account)
            {
                controller.PerformTransaction(Model);
            }
            else if (!isEditMode)
            {
                if (ckRepeat.Enabled && ckRepeat.Checked)
                {
                    Model.CaptionRepeat = $"(1/{nupTimes.Value})";
                    controller.SplitAccount(Convert.ToInt32(nupTimes.Value), Model.Clone());
                }
                else
                {
                    controller.PerformTransaction(Model);
                }
            }

            controller.Save(Model);
            DialogResult = DialogResult.OK;
            this.Close();
        }
Exemplo n.º 7
0
        private Model GetScaledModel()
        {
            Model   result = model.Clone();
            Matrix3 matrix = Matrix3.CreateScale(scale);

            result.Transform(matrix);
            return(result);
        }
Exemplo n.º 8
0
        private void CloneRound_Executed(object arg)
        {
            var newRound          = Model.Clone() as Round;
            var newRoundViewModel = new RoundViewModel(newRound);

            OwnerPackage.Rounds.Add(newRoundViewModel);
            OwnerPackage.Document.Navigate.Execute(newRoundViewModel);
        }
Exemplo n.º 9
0
 public static void Main()
 {
     var mainModel = new Model
     {
         Data = 1
     };
     var copyModel = mainModel.Clone() as Model;
 }
Exemplo n.º 10
0
 internal void UpdateUnresolvedDataElements()
 {
     _unresolvedDataElements = Model.Clone() as Collection;
     foreach (KeyValuePair <string, int[]> kvp in _boundProperties)
     {
         SetBoundProperty(_unresolvedDataElements, kvp.Key, "#ElisyBound:" + kvp.Key);
     }
 }
Exemplo n.º 11
0
        public T Build()
        {
            T buildingBlocks = Model.Clone();

            new JsonPatchDocument <T>(ThisInterface.Patches, new DefaultContractResolver()).ApplyTo(buildingBlocks);

            return(buildingBlocks);
        }
Exemplo n.º 12
0
        private void CloneTheme_Executed(object arg)
        {
            var newTheme          = Model.Clone() as Theme;
            var newThemeViewModel = new ThemeViewModel(newTheme);

            OwnerRound.Themes.Add(newThemeViewModel);
            OwnerRound.OwnerPackage.Document.Navigate.Execute(newThemeViewModel);
        }
Exemplo n.º 13
0
        public NeuralNetwork Clone()
        {
            var clone = new NeuralNetwork(Name, Seed);

            clone.Model     = Model.Clone();
            clone.Optimizer = Optimizer;
            clone.LossFuncs = LossFuncs;
            return(clone);
        }
Exemplo n.º 14
0
 private void CloneQuestion_Executed(object arg)
 {
     if (OwnerTheme != null)
     {
         var quest = Model.Clone() as Question;
         var newQuestionViewModel = new QuestionViewModel(quest);
         OwnerTheme.Questions.Add(newQuestionViewModel);
         OwnerTheme.OwnerRound.OwnerPackage.Document.Navigate.Execute(newQuestionViewModel);
     }
 }
Exemplo n.º 15
0
 public void Show_Settings(ref Model ip)
 {
     view = new Model_View((Model)ip.Clone());
     propertyGrid_Settings.SelectedObject = view;
     DialogResult = DialogResult.Cancel;
     ShowDialog();
     if (DialogResult == DialogResult.OK)
     {
         ip = (Model)view.P.Clone();
     }
 }
Exemplo n.º 16
0
        public WhiskerPointViewModel Clone()
        {
            WhiskerPointViewModel viewModel = new WhiskerPointViewModel(Model.Clone(), Parent);

            viewModel.CanvasXPosition = CanvasXPosition;
            viewModel.CanvasYPosition = CanvasYPosition;
            viewModel.CanvasWidth     = CanvasWidth;
            viewModel.CanvasHeight    = CanvasHeight;

            return(viewModel);
        }
 /// <summary>
 /// Creates a clone of this instance
 /// </summary>
 /// <returns>A clone of this instance</returns>
 public object Clone()
 {
     return(new Heater
     {
         Current = Current,
         Name = (Name != null) ? string.Copy(Name) : null,
         State = State,
         Model = (HeaterModel)Model.Clone(),
         Max = Max,
         Sensor = Sensor
     });
 }
Exemplo n.º 18
0
        public int GetScore(Model model, int y, int x, ChessType chessType)
        {
            Model attackCloneModel  = model.Clone() as Model;
            Model defenseCloneModel = model.Clone() as Model;

            ChessType enemyChessType = Utility.GetOppositeChessType(chessType);

            attackCloneModel.PutChessToBoard(x, y, chessType);
            defenseCloneModel.PutChessToBoard(x, y, enemyChessType);


            //int posX = model.PrepareCheckedPOS_X;
            //int posY = model.PrepareCheckedPOS_Y;
            //ChessType posChessType = model.PrepareCheckedChessType;

            int attackScore  = GetOnePointScore(attackCloneModel, x, y, chessType);
            int defenseScore = GetOnePointScore(defenseCloneModel, x, y, enemyChessType);

            int totalScore = (int)(1.05 * attackScore) + defenseScore;

            return(totalScore);
        }
 public Ship Clone()
 {
     return(new Ship(Position, Model.Clone(), Uid)
     {
         Velocity = Velocity,
         Angle = Angle,
         RotationSpeed = RotationSpeed,
         Alive = Alive,
         _leftRunning = _leftRunning,
         _rightRunning = _rightRunning,
         ShotTimer = ShotTimer,
     });
 }
Exemplo n.º 20
0
        public ExtrudeState(Model m, FullScene scene)
        {
            this.modelClone = m.Clone();
            var s = new Slider()
            {
                Minimum     = -100,
                Maximum     = 100,
                Value       = 0,
                Orientation = Orientation.Vertical
            };

            s.ValueChanged += s_ValueChanged;
            this.Widgets.Add(s);
        }
Exemplo n.º 21
0
 public override CoreModel GetModelDuplicate()
 {
     if (Model == null)
     {
         Model = new CoreModel
         {
             StartPosition   = this.SpawningPosition + new ALVector2D(_rnd.Next(-100, 100) * 0.003, _rnd.Next(-100, 100) * 0.1, _rnd.Next(-100, 100) * 0.1),
             Size            = this.Size,
             Mass            = 200,
             ConnectionSlots = new []
             {
                 new ConnectionSlotModel
                 {
                     IsOccupied         = false,
                     Size               = 15,
                     MaxChildMass       = 15,
                     MaxChildSize       = 100,
                     DistanceFromCenter = this.Size + 10.0f,
                     Direction          = MathHelper.PiOver2 + 0.3f,
                     Orientation        = -0.6f
                 },
                 new ConnectionSlotModel
                 {
                     IsOccupied         = false,
                     Size               = 15,
                     MaxChildMass       = 15,
                     MaxChildSize       = 100,
                     DistanceFromCenter = this.Size + 10.0f,
                     Direction          = 0.0f,
                     Orientation        = 0.0f
                 },
                 new ConnectionSlotModel
                 {
                     IsOccupied         = false,
                     Size               = 15,
                     MaxChildMass       = 15,
                     MaxChildSize       = 100,
                     DistanceFromCenter = this.Size + 10.0f,
                     Direction          = -MathHelper.PiOver2 - 0.3f,
                     Orientation        = 0.6f
                 }
             }
         };
     }
     return((CoreModel)Model.Clone());
 }
Exemplo n.º 22
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            bool  run     = false;
            int   threads = 0;
            Model input   = null;

            DA.GetData(0, ref run);
            DA.GetData(1, ref input);
            DA.GetData(2, ref threads);

            if (run)
            {
                Model model = input.Clone() as Model;
                model.SolveFromFile(threads, GHUtil.CCXPath(this.OnPingDocument()));
                DA.SetData(0, model);
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            bool  run   = false;
            Model input = null;
            bool  reducedIntegration = false;

            DA.GetData(0, ref run);
            DA.GetData(1, ref input);
            DA.GetData(2, ref reducedIntegration);

            if (run)
            {
                Model model = input.Clone() as Model;
                model.MeshModelFromFile(GHUtil.GmshPath(this.OnPingDocument()), reducedIntegration);
                DA.SetData(0, model);
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            bool generate, nLinear;

            generate = nLinear = false;
            Model input = null;

            DA.GetData(0, ref generate);
            DA.GetData(1, ref input);
            DA.GetData(2, ref nLinear);

            if (generate)
            {
                Model model = input.Clone() as Model;
                model.BuildCCXFile(nLinear);
                DA.SetData(0, model);
                DA.SetData(1, model.Directory + "\\" + model.Name + ".inp");
            }
        }
Exemplo n.º 25
0
        protected override void Process()
        {
            if (IterationFlag)
            {
                if (SaveModel)
                {
                    ModelSaver.Pushback(Model.Clone());
                    ModelSaver.Request.Set();
                }
                switch (State)
                {
                case FlagState.Initial:
                    State = FlagState.Adjustment;
                    break;

                case FlagState.Adjustment:
                    State = FlagState.Update;
                    {
                        Model.UpdateState(true);
                    }
                    break;

                case FlagState.Update:
                    break;

                default:
                    break;
                }
            }

            Model.Learning(Input, Teacher, IterationFlag);

            var result  = Model.ShowResult(640, 480);
            var process = Model.ShowProcess(0.5);

            Components.Imaging.View.Show(result, "result");
            Components.Imaging.View.Show(process, "process");
            var span = (DateTime.Now - StartTime);

            Console.WriteLine(Model.Epoch + " / " + Model.Generation + " / " + Model.OutputLayer.Variable.Error[0] +
                              "  :" + span.Days + ":" + span.Hours + ":" + span.Minutes + ":" + span.Seconds + "'" + span.Milliseconds);
        }
Exemplo n.º 26
0
        public override void onMyTurn()
        {
            base.onMyTurn();

            int bestScore = int.MinValue;
            int bestX     = -1;
            int bestY     = -1;

            if (TotalTurn == 0)
            {
                System.Console.WriteLine($"AI Turn 1");
                bool isPutSuccessful = PutChess(GameDef.board_cell_length / 2, GameDef.board_cell_length / 2);
                RoleMgr.ChangeNextRole();
            }
            else
            {
                for (int y = 0; y < GameDef.board_cell_length; y++)
                {
                    for (int x = 0; x < GameDef.board_cell_length; x++)
                    {
                        var board = Model.GetBoardByCopy();
                        if (board[y][x] == ChessType.None)
                        {
                            Model cloneModel = Model.Clone() as Model;

                            int score = MyEvaluation.GetScore(cloneModel, y, x, MyChessType);

                            if (score > bestScore)
                            {
                                bestScore = score;
                                bestX     = x;
                                bestY     = y;
                            }
                        }
                    }
                }

                bool isPutSuccessful = PutChess(bestX, bestY);
                RoleMgr.ChangeNextRole();
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            bool  run   = false;
            Model input = null;

            MeshUtil.GmshParams gmshParams = null;

            DA.GetData(0, ref run);
            DA.GetData(1, ref input);
            DA.GetData(2, ref gmshParams);

            RhinoDoc    doc = RhinoDoc.ActiveDoc;
            GH_Document GrasshopperDocument = this.OnPingDocument();

            if (undoGH)
            {
                Rhino.RhinoApp.RunScript("_undo", false);
                undoGH = false;
                done   = true;
            }

            if (run && !done)
            {
                model = input.Clone() as Model;
                model.BuildGmshFile(doc, gmshParams);

                undoGH = true;
                GrasshopperDocument.ScheduleSolution(0, ScheduleCallback);
            }

            else if (!run)
            {
                done = false;
            }

            DA.SetData(0, model);
            if (model != null)
            {
                DA.SetData(1, model.GetModelFilePath(GuanacoUtil.FileType.geo));
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            bool  run   = false;
            Model input = null;

            MeshUtil.GmshParams gmshParams = null;
            bool reducedIntegration        = false;

            DA.GetData(0, ref run);
            DA.GetData(1, ref input);
            DA.GetData(2, ref gmshParams);
            DA.GetData(3, ref reducedIntegration);

            RhinoDoc    doc = RhinoDoc.ActiveDoc;
            GH_Document GrasshopperDocument = this.OnPingDocument();

            if (undoGH)
            {
                Rhino.RhinoApp.RunScript("_undo", false);
                undoGH = false;
                done   = true;
            }

            if (run && !done)
            {
                model = input.Clone() as Model;
                model.MeshModel(doc, gmshParams, GHUtil.GmshPath(GrasshopperDocument), reducedIntegration);

                undoGH = true;
                GrasshopperDocument.ScheduleSolution(0, ScheduleCallback);
            }

            else if (!run)
            {
                done = false;
            }

            DA.SetData(0, model);
        }
Exemplo n.º 29
0
 /// <summary>
 /// Create a new Booking based on an existing booking
 /// </summary>
 /// <param name="order">The order to attach the new Booking to</param>
 /// <param name="booking">The original Booking</param>
 /// <returns>new Booking</returns>
 private static Model.Booking.Booking CloneBooking(Model.Order.Order order, Model.Booking.Booking booking)
 {
     var newBooking = booking.Clone();
     newBooking.Id = null;
     newBooking.BookingReferenceNumber = null;
     newBooking.OrderId = order.Id.Value;
     newBooking.Order = order;
     return newBooking;
 }
Exemplo n.º 30
0
        void CreateScene()
        {
            var cache = ResourceCache;

            scene = new Scene();

            // Create the Octree component to the scene so that drawable objects can be rendered. Use default volume
            // (-1000, -1000, -1000) to (1000, 1000, 1000)
            scene.CreateComponent <Octree>();

            // Create a Zone for ambient light & fog control
            Node zoneNode = scene.CreateChild("Zone");
            Zone zone     = zoneNode.CreateComponent <Zone>();

            zone.SetBoundingBox(new BoundingBox(-1000.0f, 1000.0f));
            zone.FogColor = new Color(0.2f, 0.2f, 0.2f);
            zone.FogStart = 200.0f;
            zone.FogEnd   = 300.0f;

            // Create a directional light
            Node lightNode = scene.CreateChild("DirectionalLight");

            lightNode.SetDirection(new Vector3(-0.6f, -1.0f, -0.8f));             // The direction vector does not need to be normalized
            Light light = lightNode.CreateComponent <Light>();

            light.LightType         = LightType.Directional;
            light.Color             = new Color(0.4f, 1.0f, 0.4f);
            light.SpecularIntensity = (1.5f);

            // Get the original model and its unmodified vertices, which are used as source data for the animation
            Model originalModel = cache.GetModel("Models/Box.mdl");

            if (originalModel == null)
            {
                Log.Write(LogLevel.Error, "Model not found, cannot initialize example scene");
                return;
            }
            // Get the vertex buffer from the first geometry's first LOD level
            VertexBuffer buffer        = originalModel.GetGeometry(0, 0).GetVertexBuffer(0);
            IntPtr       vertexRawData = buffer.Lock(0, buffer.VertexCount, false);

            if (vertexRawData != IntPtr.Zero)
            {
                uint numVertices = buffer.VertexCount;
                uint vertexSize  = buffer.VertexSize;
                // Copy the original vertex positions
                for (int i = 0; i < numVertices; ++i)
                {
                    var src = (Vector3)Marshal.PtrToStructure(IntPtr.Add(vertexRawData, i * (int)vertexSize), typeof(Vector3));
                    originalVertices.Add(src);
                }
                buffer.Unlock();

                // Detect duplicate vertices to allow seamless animation
                vertexDuplicates = new uint[originalVertices.Count];
                for (int i = 0; i < originalVertices.Count; ++i)
                {
                    vertexDuplicates[i] = (uint)i;                     // Assume not a duplicate
                    for (int j = 0; j < i; ++j)
                    {
                        if (originalVertices[i].Equals(originalVertices[j]))
                        {
                            vertexDuplicates[i] = (uint)j;
                            break;
                        }
                    }
                }
            }
            else
            {
                Log.Write(LogLevel.Error, "Failed to lock the model vertex buffer to get original vertices");
                return;
            }

            // Create StaticModels in the scene. Clone the model for each so that we can modify the vertex data individually
            for (int y = -1; y <= 1; ++y)
            {
                for (int x = -1; x <= 1; ++x)
                {
                    Node node = scene.CreateChild("Object");
                    node.Position = (new Vector3(x * 2.0f, 0.0f, y * 2.0f));
                    StaticModel sm         = node.CreateComponent <StaticModel>();
                    Model       cloneModel = originalModel.Clone();
                    sm.Model = (cloneModel);
                    // Store the cloned vertex buffer that we will modify when animating
                    animatingBuffers.Add(cloneModel.GetGeometry(0, 0).GetVertexBuffer(0));
                }
            }

            // Finally create one model (pyramid shape) and a StaticModel to display it from scratch
            // Note: there are duplicated vertices to enable face normals. We will calculate normals programmatically
            {
                const uint numVertices = 18;
                float[]    vertexData  =
                {
                    // Position             Normal
                    0.0f,   0.5f,  0.0f, 0.0f, 0.0f, 0.0f,
                    0.5f,  -0.5f,  0.5f, 0.0f, 0.0f, 0.0f,
                    0.5f,  -0.5f, -0.5f, 0.0f, 0.0f, 0.0f,

                    0.0f,   0.5f,  0.0f, 0.0f, 0.0f, 0.0f,
                    -0.5f, -0.5f,  0.5f, 0.0f, 0.0f, 0.0f,
                    0.5f,  -0.5f,  0.5f, 0.0f, 0.0f, 0.0f,

                    0.0f,   0.5f,  0.0f, 0.0f, 0.0f, 0.0f,
                    -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, 0.0f,
                    -0.5f, -0.5f,  0.5f, 0.0f, 0.0f, 0.0f,

                    0.0f,   0.5f,  0.0f, 0.0f, 0.0f, 0.0f,
                    0.5f,  -0.5f, -0.5f, 0.0f, 0.0f, 0.0f,
                    -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, 0.0f,

                    0.5f,  -0.5f, -0.5f, 0.0f, 0.0f, 0.0f,
                    0.5f,  -0.5f,  0.5f, 0.0f, 0.0f, 0.0f,
                    -0.5f, -0.5f,  0.5f, 0.0f, 0.0f, 0.0f,

                    0.5f,  -0.5f, -0.5f, 0.0f, 0.0f, 0.0f,
                    -0.5f, -0.5f,  0.5f, 0.0f, 0.0f, 0.0f,
                    -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, 0.0f
                };

                short[] indexData =
                {
                    0,   1,  2,
                    3,   4,  5,
                    6,   7,  8,
                    9,  10, 11,
                    12, 13, 14,
                    15, 16, 17
                };

                Model        fromScratchModel = new Model();
                VertexBuffer vb   = new VertexBuffer(Context, false);
                IndexBuffer  ib   = new IndexBuffer(Context, false);
                Geometry     geom = new Geometry();

                // Shadowed buffer needed for raycasts to work, and so that data can be automatically restored on device loss
                vb.Shadowed = true;
                vb.SetSize(numVertices, ElementMask.Position | ElementMask.Normal, false);
                vb.SetData(vertexData);

                ib.Shadowed = true;
                ib.SetSize(numVertices, false, false);
                ib.SetData(indexData);

                geom.SetVertexBuffer(0, vb);
                geom.IndexBuffer = ib;
                geom.SetDrawRange(PrimitiveType.TriangleList, 0, numVertices, true);

                fromScratchModel.NumGeometries = 1;
                fromScratchModel.SetGeometry(0, 0, geom);
                fromScratchModel.BoundingBox = new BoundingBox(new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(0.5f, 0.5f, 0.5f));

                Node node = scene.CreateChild("FromScratchObject");
                node.Position = (new Vector3(0.0f, 3.0f, 0.0f));
                StaticModel sm = node.CreateComponent <StaticModel>();
                sm.Model = fromScratchModel;
            }

            // Create the camera
            CameraNode          = new Node();
            CameraNode.Position = (new Vector3(0.0f, 2.0f, -20.0f));
            Camera camera = CameraNode.CreateComponent <Camera>();

            camera.FarClip = 300.0f;
        }
Exemplo n.º 31
0
        public override WebElement Locale(string lang)
        {
            if (lang.Equals(Model.DefaultLanguage, StringComparison.OrdinalIgnoreCase) || string.IsNullOrEmpty(lang))
            {
                if (Model.Pages == null)
                {
                    Model.Pages = LoadPages();
                }

                if (Model.LogoImage != null && !string.IsNullOrEmpty(Model.LogoImage.Ref))
                {
                    Model.LogoImage.Ref = ResolveUri(Model.LogoImage.Ref);
                }

                if (Model.ShortcutIcon != null && !string.IsNullOrEmpty(Model.ShortcutIcon.Ref))
                {
                    Model.ShortcutIcon.Ref = ResolveUri(Model.ShortcutIcon.Ref);
                }

                return(Model);
            }

            var copy = Model.Clone();

            copy.DefaultLanguage = lang;

            var titleEle = GetLocalizableElement("title", lang);

            if (titleEle != null)
            {
                copy.Title = titleEle;
            }

            if (copy.Title != null)
            {
                copy.Title.Language = lang;
            }

            var descEle = GetLocalizableElement("description", lang);

            if (descEle != null)
            {
                copy.Description = descEle;
            }

            if (copy.Description != null)
            {
                copy.Description.Language = lang;
            }

            var logoNode = GetLocalizedNode("logo", lang);

            if (logoNode != null && logoNode.Attributes != null && logoNode.Attributes["src"] != null && !string.IsNullOrEmpty(logoNode.Attributes["src"].Value))
            {
                copy.LogoImage = new RefElement()
                {
                    Language = lang,
                    Ref      = ResolveUri(logoNode.Attributes["src"].Value, lang)
                };
            }

            var shotcutNode = GetLocalizedNode("title", lang);

            if (shotcutNode != null && shotcutNode.Attributes != null && shotcutNode.Attributes["src"] != null && !string.IsNullOrEmpty(shotcutNode.Attributes["src"].Value))
            {
                copy.ShortcutIcon = new RefElement()
                {
                    Language = lang,
                    Ref      = ResolveUri(shotcutNode.Attributes["src"].Value, lang)
                };
            }

            copy.Pages = LoadPages(lang);
            var cats = GetLocalizedNode("categories", lang);

            if (cats != null)
            {
                copy.Categories = new CategoriesElement()
                {
                    Locale = lang
                };
                if (cats.ChildNodes.Count > 0)
                {
                    copy.Categories.Categories = new List <CategoryElement>();
                    foreach (XmlNode c in cats.ChildNodes)
                    {
                        copy.Categories.Categories.Add(new CategoryElement()
                        {
                            ID       = c.Attributes != null && c.Attributes["id"] != null ? Convert.ToInt16(c.Attributes["id"].Value) : 0,
                            ParentID = c.Attributes != null && c.Attributes["parentId"] != null ? Convert.ToInt16(c.Attributes["parentId"].Value) : 0,
                            Name     = c.Attributes != null && c.Attributes["name"] != null ? c.Attributes["name"].Value : "",
                        });
                    }
                }
            }

            if (copy.ListRefs != null)
            {
                var _listRefs = copy.ListRefs.Where(r => r.Language.Equals(lang, StringComparison.OrdinalIgnoreCase)).ToList();
                copy.ListRefs = _listRefs;
            }

            //copy.PageRefs = new List<RefElement>();

            return(copy);
        }
Exemplo n.º 32
0
 /// <summary>
 /// Create a new (empty) Order based on an existing Order
 /// </summary>
 /// <param name="order">The original Order</param>
 /// <returns>new Order</returns>
 private static Model.Order.Order CloneOrder(Model.Order.Order order)
 {
     var neworder = order.Clone();
     neworder.Id = null;
     neworder.AmountPaid = 0;
     neworder.AmountRefunded = 0;
     neworder.OrderReference = null;
     return neworder;
 }