Example #1
0
 public void configure(int controllerID, ControllerBase controller, ModelBase model, ViewBase view)
 {
     addControllerRoute(new RouteBase(controllerID, controller));
     controller.configure(view, model);
     model.configure();
     view.configure(model);
 }
Example #2
0
        public AbstractModelLoader(string modelFileName)
        {
            m_Model = new ModelBase(modelFileName);

            m_ModelFileName = modelFileName;
            m_ModelPath = Path.GetDirectoryName(m_ModelFileName);
        }
		/// <summary>
		///   Serializes the <paramref name="model" />.
		/// </summary>
		private unsafe void SerializeModel(BinaryWriter writer, ModelBase model, Formula[] formulas)
		{
			// Collect all objects contained in the model
			var objectTable = CreateObjectTable(model, formulas);

			// Prepare the serialization of the model's initial state
			lock (_syncObject)
			{
				_stateVector = SerializationRegistry.Default.GetStateVectorLayout(model, objectTable, SerializationMode.Full);
				_deserializer = null;
			}

			var stateVectorSize = _stateVector.SizeInBytes;
			var serializer = _stateVector.CreateSerializer(objectTable);

			// Serialize the object table
			SerializeObjectTable(objectTable, writer);

			// Serialize the object identifier of the model itself and the formulas
			writer.Write(objectTable.GetObjectIdentifier(model));
			writer.Write(formulas.Length);
			foreach (var formula in formulas)
				writer.Write(objectTable.GetObjectIdentifier(formula));

			// Serialize the initial state
			var serializedState = stackalloc byte[stateVectorSize];
			serializer(serializedState);

			// Copy the serialized state to the stream
			writer.Write(stateVectorSize);
			for (var i = 0; i < stateVectorSize; ++i)
				writer.Write(serializedState[i]);
		}
Example #4
0
        public AbstractModelWriter(ModelBase model, string modelFileName)
        {
            m_Model = model;

            m_ModelFileName = modelFileName;
            m_ModelPath = Path.GetDirectoryName(m_ModelFileName);
        }
Example #5
0
        public override void Populate(ModelBase obj)
        {
            CodigoIso newProps = obj as CodigoIso;

            Codigo = newProps.Codigo;
            Nome = newProps.Nome;
        }
Example #6
0
 public DynamoNodeButton(ModelBase model, string eventName)
     : this()
 {
     this.model = model;
     this.eventName = eventName;
     Click += OnDynamoNodeButtonClick;
 }
		/// <param name="model">A copy of the original model the runtime model was generated from.</param>
		/// <param name="buffer">The buffer the model was deserialized from.</param>
		/// <param name="objectTable">The table of objects referenced by the model.</param>
		/// <param name="formulas">The formulas that are checked on the model.</param>
		internal SerializedRuntimeModel(ModelBase model, byte[] buffer, ObjectTable objectTable, Formula[] formulas)
		{
			Model = model;
			Buffer = buffer;
			ObjectTable = objectTable;
			Formulas = formulas;
		}
Example #8
0
		/// <summary>
		///   Initializes a new instance.
		/// </summary>
		/// <param name="model">The model that should be simulated.</param>
		/// <param name="formulas">The formulas that can be evaluated on the model.</param>
		public Simulator(ModelBase model, params Formula[] formulas)
		{
			Requires.NotNull(model, nameof(model));
			Requires.NotNull(formulas, nameof(formulas));

			_runtimeModel = RuntimeModel.Create(model, formulas);
			Reset();
		}
Example #9
0
		/// <summary>
		///   Initizializes the model that should be analyzed.
		/// </summary>
		/// <param name="configuration">The configuration that should be used for the analyses.</param>
		/// <param name="model">The model that should be analyzed.</param>
		/// <param name="hazard">The hazard that should be analyzed.</param>
		internal void InitializeModel(AnalysisConfiguration configuration, ModelBase model, Formula hazard)
		{
			Model = model;
			ForcedFaults = new FaultSet(Model.Faults.Where(fault => fault.Activation == Activation.Forced));
			SuppressedFaults = new FaultSet(Model.Faults.Where(fault => fault.Activation == Activation.Suppressed));

			InitializeModel(configuration, hazard);
		}
		/// <summary>
		///   Returns the serialized <paramref name="model" /> and the <paramref name="formulas" />.
		/// </summary>
		/// <param name="model">The model that should be serialized.</param>
		/// <param name="formulas">The formulas that should be serialized.</param>
		public static byte[] Save(ModelBase model, params Formula[] formulas)
		{
			var serializer = new RuntimeModelSerializer();
			serializer.Serialize(model, formulas);

			lock (serializer._syncObject)
				return serializer._serializedModel;
		}
		/// <summary>
		///   Initializes a new instance.
		/// </summary>
		/// <param name="model">The model the heuristic is created for.</param>
		/// <param name="cardinalityLevel">The cardinality level where the first suggestions should be made.</param>
		public MaximalSafeSetHeuristic(ModelBase model, uint cardinalityLevel = 3)
		{
			Requires.NotNull(model, nameof(model));

			_model = model;
			_cardinalityLevel = cardinalityLevel;
			_allFaults = new FaultSet(model.Faults.Where(fault => fault.Activation != Activation.Suppressed).ToArray());
		}
Example #12
0
        public BookingView(BookingViews type, ModelBase model = null, bool IsDuplicate = false)
        {
            InitializeComponent();
            if (model != null)
                this.Header = "Edit Booking";
            DataContext = ViewModel = new BookingViewModel(type, model,IsDuplicate);

            Owner = Application.Current.MainWindow;
        }
Example #13
0
        public BCA ConvertAnimatedDAEToBCA(ref NitroFile animationFile, string fileName, bool save = true)
        {
            if (m_LoadedModel == null)
                m_LoadedModel = new DAELoader(fileName).LoadModel();

            BCA importedAnimation = CallBCAWriter(ref animationFile, m_LoadedModel, save);

            return importedAnimation;
        }
		public void SetModel(ModelBase model, params Formula[] formulas)
		{
			_formulas = formulas;
			_model = model;

			foreach (var fault in _model.Faults)
				fault.Activation = Activation.Suppressed;

			SetSimulator(new Simulator(_model, formulas));
		}
Example #15
0
 protected static void ExportTextureToPNG(string destDir, ModelBase.TextureDefBase texture)
 {
     try
     {
         ExportTextureToPNG(destDir, texture.m_ID, texture.GetBitmap());
     }
     catch (IOException)
     {
         Console.Write("Cannot write image for texture: " + texture.m_ID);
     }
 }
		/// <summary>
		///   Initializes a new instance.
		/// </summary>
		/// <param name="model">The <see cref="Model" /> instance the safety analysis was conducted for.</param>
		/// <param name="hazard">The hazard the analysis was conducated for.</param>
		/// <param name="suppressedFaults">The faults whose activations have been completely suppressed during analysis.</param>
		/// <param name="forcedFaults">The faults whose activations have been forced during analysis.</param>
		/// <param name="heuristics">The heuristics that are used during the analysis.</param>
		/// <param name="activationBehavior">The fault acitvation behavior used during the analysis.</param>
		internal SafetyAnalysisResults(ModelBase model, Formula hazard, IEnumerable<Fault> suppressedFaults,
									  IEnumerable<Fault> forcedFaults, IEnumerable<IFaultSetHeuristic> heuristics,
									  FaultActivationBehavior activationBehavior)
		{
			Model = model;
			Hazard = hazard;
			SuppressedFaults = suppressedFaults;
			ForcedFaults = forcedFaults;
			Heuristics = heuristics.ToArray(); // make a copy so that later changes to the heuristics don't affect the results
			FaultActivationBehavior = activationBehavior;
		}
Example #17
0
        public KCL ConvertOBJToKCL(NitroFile modelFile, string fileName, float scale, float faceSizeThreshold,
            Dictionary<string, int> matColTypes, bool save = true)
        {
            KCL importedModel = new KCL(modelFile);

            if (m_LoadedModel == null)
                m_LoadedModel = new OBJLoader(fileName).LoadModel();

            importedModel = CallKCLWriter(modelFile, m_LoadedModel, fileName, scale, faceSizeThreshold, matColTypes, save);

            return importedModel;
        }
		/// <summary>
		///   Initializes a new instance.
		/// </summary>
		/// <param name="model">The model the heuristic is created for.</param>
		/// <param name="minimalCriticalFaultSets">The minimal critical fault sets known from a previous analysis.</param>
		public MaximalSafeSetHeuristic(ModelBase model, ISet<ISet<Fault>> minimalCriticalFaultSets)
		{
			Requires.NotNull(model, nameof(model));
			Requires.NotNull(minimalCriticalFaultSets, nameof(minimalCriticalFaultSets));

			_model = model;
			_hasNewMinimalCriticalSets = true;
			_allFaults = new FaultSet(model.Faults.Where(fault => fault.Activation != Activation.Suppressed).ToArray());

			foreach (var set in minimalCriticalFaultSets)
				_minimalCriticalSets.Add(set.Select(MapFault).ToArray());
		}
Example #19
0
        public ZoomValue(ListCollectionView view, ModelBase item)
        {
            _view = view;
            _item = item;

            InitializeComponent();

            this.DataContext = item;

            this.Loaded += OnEditTaskItemLoaded;
            this.Closed += new EventHandler(ZoomValue_Closed);
        }
Example #20
0
        public BMDWriter(ModelBase model, ref NitroFile modelFile, BMDImporter.BMDExtraImportOptions extraOptions)
            : base(model, modelFile.m_Name)
        {
            m_ModelFile = modelFile;
            m_ConvertToTriangleStrips = extraOptions.m_ConvertToTriangleStrips;
            m_KeepVertexOrderDuringStripping = extraOptions.m_KeepVertexOrderDuringStripping;
            m_AlwaysWriteFullVertexCmd23h = extraOptions.m_AlwaysWriteFullVertexCmd23h;

            if (m_ConvertToTriangleStrips)
            {
                Stripify();
            }
        }
		/// <summary>
		///   Serializes the <paramref name="model" /> and the <paramref name="formulas" />.
		/// </summary>
		/// <param name="model">The model that should be serialized.</param>
		/// <param name="formulas">The formulas that should be serialized.</param>
		public void Serialize(ModelBase model, params Formula[] formulas)
		{
			Requires.NotNull(model, nameof(model));
			Requires.NotNull(formulas, nameof(formulas));

			using (var buffer = new MemoryStream())
			using (var writer = new BinaryWriter(buffer, Encoding.UTF8, leaveOpen: true))
			{
				SerializeModel(writer, model, formulas);

				lock (_syncObject)
					_serializedModel = buffer.ToArray();
			}
		}
Example #22
0
        public TriangleStripper(ModelBase.FaceListDef faceList)
        {
            if (faceList.m_Type != ModelBase.PolyListType.Triangles)
            {
                bool tris = true;
                for (int i = 0; i < faceList.m_Faces.Count; i++)
                {
                    tris = (faceList.m_Faces[i].m_NumVertices == 3);
                    if (!tris)
                        throw new ArgumentException("The provided FaceListDef must be triangulated.");
                }
                faceList.m_Type = ModelBase.PolyListType.Triangles;
            }

            m_Vertices = new List<VertexLinked>();
            m_Triangles = new List<TriangleLinked>();
            m_TrianglesToProcess = new List<TriangleLinked>();

            for (int i = 0; i < faceList.m_Faces.Count; i++)
            {
                if (IsDegenerateFace(faceList.m_Faces[i]))
                {
                    faceList.m_Faces.RemoveAt(i);
                }
            }

            for (int i = 0; i < faceList.m_Faces.Count; i++)
            {
                m_Triangles.Add(new TriangleLinked(faceList.m_Faces[i]));
            }

            for (int i = 0; i < m_Triangles.Count; i++)
            {
                ModelBase.FaceDef triangle = m_Triangles[i].m_Triangle;

                for (int j = 0; j < triangle.m_NumVertices; j++)
                {
                    VertexLinked vertex = new VertexLinked(triangle.m_Vertices[j]);

                    int index = m_Vertices.IndexOf(vertex);
                    if (index == -1)
                    {
                        m_Vertices.Add(vertex);
                        index = m_Vertices.Count - 1;
                    }

                    m_Vertices[index].m_LinkedTriangles.Add(i);
                }
            }
        }
        public void AddScriptBrick(ModelBase scriptBrick, int firstViewIndex, int lastViewIndex)
        {
            //if (this.Count == lastViewIndex + 1 && GetAtIndex(lastViewIndex) is Script && )
            //{
            //  lastViewIndex++;
            //}

            if (scriptBrick is Brick) // Add brick at last visible end of a Script
            {
                var brick = scriptBrick as Brick;

                var scriptEndIndex = -1;
                Script lastFullScript = null;
                foreach (var script in Scripts)
                {
                    var scriptBeginIndex = scriptEndIndex + 1;
                    scriptEndIndex += script.Bricks.Count + 1;

                    // what does that do?
                    //if (scriptEndIndex > lastViewIndex && scriptBeginIndex >= firstViewIndex)
                    //{
                    //    break;
                    //}

                    lastFullScript = script;
                }

                if (lastFullScript == null)
                {
                    var startScript = new StartScript();
                    Scripts.Add(startScript);
                    lastFullScript = startScript;

                    OnScriptAdded(startScript, IndexOf(startScript));
                }

                lastFullScript.Bricks.Add(brick);

                //OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); // TODO: make faster and use method below instead
                OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, scriptBrick, IndexOf(scriptBrick)));
            }
            else if (scriptBrick is Script) // Add Script at end of all
            {
                var script = scriptBrick as Script;
                Scripts.Add(script);

                //OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); // TODO: make faster and use method below instead
                OnScriptAdded((Script) scriptBrick, IndexOf(scriptBrick));
            }
        }
Example #24
0
 static public void AddNew(ModelBase model, DataView v, int remarkTypeId, string remarks = null, string title = null, bool alert = false)
 {
   DataRowView r = v.AddNew();
   r["TableId"] = (model is SponsorModel) ? 9 : 10;
   r["FKRowGUID"] = model.GUID;
   r["RemarkTypeId"] = remarkTypeId;
   r["Remarks"] = remarks;
   r["Title"] = title;
   r["Alert"] = alert;
   r["CreateDate"] = r["LastUpdate"] = DateTime.Now;
   r["CreateAgentGUID"] = UserModel.Current.GUID;
   r["CreateTaxOfficeId"] = SettingsModel.TaxOfficeId;
   r.Row.Table.Rows.Add(r.Row);
 }
Example #25
0
        protected void AddTexture(ModelBase.TextureDefBase texture, ModelBase.MaterialDef matDef)
        {
            matDef.m_TextureDefID = texture.m_ID;

            IEnumerable<ModelBase.TextureDefBase> matchingHash = m_Model.m_Textures.Values.Where(
                tex0 => tex0.m_ImgHash.Equals(texture.m_ImgHash));
            if (matchingHash.Count() > 0)
            {
                matDef.m_TextureDefID = matchingHash.ElementAt(0).m_ID;
                return;
            }

            m_Model.m_Textures.Add(texture.m_ID, texture);
        }
        internal MainWindowViewModel()
        {
            r_Page = new InitializationPageViewModel(this);
            GameInformation = new GameInformationViewModel(this);

            ApiService.SubscribeOnce("api_start2", delegate
            {
                IsGameStarted = true;
                OnPropertyChanged(nameof(IsGameStarted));
            });

            ShowSessionToolCommand = new DelegatedCommand(() => WindowService.Instance.Show<SessionToolWindow>(r_SessionTool));

            ApiService.Subscribe("api_req_map/start", _ => ThemeManager.Instance.ChangeAccent(Accent.Brown));
            KanColleGame.Current.ReturnedFromSortie += _ => ThemeManager.Instance.ChangeAccent(Accent.Blue);

            Preference.Instance.Game.DisableHeavyDamageBlinkingWarning.Subscribe(rpValue =>
            {
                if (SortieInfo.Current == null)
                    return;

                if (!rpValue)
                    ThemeManager.Instance.ChangeAccent(Accent.Brown);
            });

            r_BlinkingBrownAccent = new Accent("BlinkingBrown", new Uri("pack://application:,,,/HeavenlyWind;component/Themes/Accents/BlinkingBrown.xaml"));

            PropertyChangedEventListener.FromSource(NotificationService.Instance)
                .Add(nameof(NotificationService.Instance.IsBlinking), delegate
                {
                    if (NotificationService.Instance.IsBlinking)
                        ThemeManager.Instance.ChangeAccent(r_BlinkingBrownAccent);
                });

            UISetZoomCommand = new DelegatedCommand<double>(SetZoom);
            UIZoomInCommand = new DelegatedCommand(() => SetZoom(Preference.Instance.UI.Zoom.Value + .05));
            UIZoomOutCommand = new DelegatedCommand(() => SetZoom(Preference.Instance.UI.Zoom.Value - .05));

            UIZoomFactors = new[] { .25, .5, .75, 1.0, 1.25, 1.5, 1.75, 2.0, 3.0, 4.0 }.Select(r => new UIZoomInfo(r, UISetZoomCommand)).ToArray();

            ShowConstructionHistoryCommand = new DelegatedCommand(() => WindowService.Instance.Show<ConstructionHistoryWindow>());
            ShowDevelopmentHistoryCommand = new DelegatedCommand(() => WindowService.Instance.Show<DevelopmentHistoryWindow>());
            ShowSortieHistoryCommand = new DelegatedCommand(() => WindowService.Instance.Show<SortieHistoryWindow>());
            ShowExpeditionHistoryCommand = new DelegatedCommand(() => WindowService.Instance.Show<ExpeditionHistoryWindow>());
            ShowScrappingHistoryCommand = new DelegatedCommand(() => WindowService.Instance.Show<ScrappingHistoryWindow>());
            ShowResourceHistoryCommand = new DelegatedCommand(() => WindowService.Instance.Show<ResourceHistoryWindow>());
            ShowSortieConsumptionHistoryCommand = new DelegatedCommand(() => WindowService.Instance.Show<SortieConsumptionHistoryWindow>());
            ShowSortieStatisticCommand = new DelegatedCommand(() => WindowService.Instance.Show<SortieStatisticWindow>());
        }
Example #27
0
		/// <summary>
		///   Checks whether the <paramref name="formula" /> holds in all states of the <paramref name="model" />.
		/// </summary>
		/// <param name="model">The model that should be checked.</param>
		/// <param name="formula">The formula that should be checked.</param>
		public AnalysisResult Check(ModelBase model, Formula formula)
		{
			Requires.NotNull(model, nameof(model));
			Requires.NotNull(formula, nameof(formula));

			var visitor = new IsLtlFormulaVisitor();
			visitor.Visit(formula);

			if (!visitor.IsLtlFormula)
				throw new NotSupportedException("CTL model checking is currently not supported with LtsMin.");

			var transformationVisitor = new LtsMinLtlTransformer();
			transformationVisitor.Visit(new UnaryFormula(formula, UnaryOperator.Next));

			return Check(model, formula, $"--ltl=\"{transformationVisitor.TransformedFormula}\"");
		}
Example #28
0
		/// <summary>
		///   Checks whether the <paramref name="invariant" /> holds in all states of the <paramref name="model" />.
		/// </summary>
		/// <param name="model">The model that should be checked.</param>
		/// <param name="invariant">The invariant that should be checked.</param>
		public AnalysisResult CheckInvariant(ModelBase model, Formula invariant)
		{
			Requires.NotNull(model, nameof(model));
			Requires.NotNull(invariant, nameof(invariant));

			var visitor = new IsStateFormulaVisitor();
			visitor.Visit(invariant);

			if (!visitor.IsStateFormula)
				throw new InvalidOperationException("Invariants must be non-temporal state formulas.");

			var transformationVisitor = new LtsMinLtlTransformer();
			transformationVisitor.Visit(invariant);

			return Check(model, invariant,
				$"--invariant=\"({RuntimeModel.ConstructionStateName} == 1) || ({transformationVisitor.TransformedFormula})\"");
		}
Example #29
0
        /// <summary>
        /// Auto generates select sql and params. If sqlStatement!=null then params are added to that statement
        /// </summary>
        public static void Load(SqlConnection cnn, string sqlStatement ,ModelBase instance, IDataStoreKey key, object[] extra)
        {
            var autoSql = string.IsNullOrEmpty(sqlStatement);

            var record = asSuitableRecordInstance(instance, autoSql);

            var select = new StringBuilder();

              if (autoSql)
              {
            foreach (var fld in record.Fields)
              if (fld.StoreFlag == StoreFlag.LoadAndStore || fld.StoreFlag == StoreFlag.OnlyLoad)
            select.AppendFormat(" T1.[{0}],", fld.FieldName);

            if (select.Length > 0)
             select.Remove(select.Length - 1, 1);// remove ","
            else throw new MsSQLDataAccessException(StringConsts.LOAD_NO_SELECT_COLUMNS_ERROR);

              }

              var pk = key ?? record.DataStoreKey;

              if (pk == null)
            throw new MsSQLDataAccessException(StringConsts.KEY_UNAVAILABLE_ERROR);

              using (var cmd = cnn.CreateCommand())
              {

            var where = keyToWhere(pk, cmd.Parameters);

            if (autoSql)
              cmd.CommandText = string.Format("SELECT {0} FROM [{1}] T1 WHERE {2}", select, record.TableName, where);
            else
              cmd.CommandText =  string.Format(sqlStatement, where);

            using (var reader = cmd.ExecuteReader())
            {
              if (reader.Read())
            reader.CopyFieldsToRecordFields(record);
              else
            throw new MsSQLDataAccessException(string.Format(StringConsts.LOADING_ENTITY_NOT_FOUND_ERROR, pk));
            }//using reader

              }//using command
        }
Example #30
0
        public static ConvertedTexture ConvertTexture(ModelBase.TextureDefBase texture)
        {
            if (!texture.IsNitro())
            {
                return ConvertTexture(texture.m_ID, texture.GetTexName(), texture.GetPalName(), texture.GetBitmap());
            }
            else
            {
                int textype = (int)texture.m_Format;
                int dswidth = 0, dsheight = 0, widthPowerOfTwo = 8, heightPowerOfTwo = 8;
                GetDSWidthAndHeight((int)texture.GetWidth(), (int)texture.GetHeight(), out dswidth, out dsheight,
                    out widthPowerOfTwo, out heightPowerOfTwo);
                uint dstp = GetDSTextureParamsPart1(dswidth, dsheight, textype, texture.GetColor0Mode());

                return new ConvertedTexture(dstp, texture.GetNitroTexData(), texture.GetNitroPalette(), texture.GetTexName(),
                    texture.GetPalName());
            }
        }
Example #31
0
        private ModelBase m_Model;        /// モデル

        /// コンストラクタ
        protected ViewModelBase(ModelBase model)
        {
            m_Model = model;
            Model.PropertyChanged += Model_PropertyChanged;
        }
 public ModelNotFoundAfterRefresh(ModelBase model)
 {
     this.Model = model;
 }
        /// <summary>
        /// Updates the group boundary based on the nodes / notes selection.
        /// </summary>
        internal void UpdateBoundaryFromSelection()
        {
            var selectedModelsList = selectedModels.ToList();

            if (selectedModelsList.Any())
            {
                var groupModels = selectedModelsList.OrderBy(x => x.X).ToList();

                //Shifting x by 10 and y to the height of textblock
                var regionX = groupModels.Min(x => x.X) - ExtendSize;
                //Increase the Y value by 10. This provides the extra space between
                // a model and textbox. Otherwise there will be some overlap
                var regionY = groupModels.Min(y => y.Y) - ExtendSize - (TextBlockHeight == 0.0 ? MinTextHeight : TextBlockHeight);

                //calculates the distance between the nodes
                var xDistance = groupModels.Max(x => x.X) - regionX;
                var yDistance = groupModels.Max(x => x.Y) - regionY;

                var widthandheight = CalculateWidthAndHeight();

                var maxWidth  = widthandheight.Item1;
                var maxHeight = widthandheight.Item2;

                // InitialTop is to store the Y value without the Textblock height
                this.InitialTop = groupModels.Min(y => y.Y);

                var region = new Rect2D
                {
                    X      = regionX,
                    Y      = regionY,
                    Width  = xDistance + maxWidth + ExtendSize,
                    Height = yDistance + maxHeight + ExtendSize
                };

                this.X      = region.X;
                this.Y      = region.Y;
                this.Width  = region.Width;
                this.Height = region.Height;

                //Calculate the boundary if there is any overlap
                ModelBase overlap = null;
                foreach (var nodes in SelectedModels)
                {
                    if (!region.Contains(nodes.Rect))
                    {
                        overlap = nodes;
                        if (overlap.Rect.Top < this.X ||
                            overlap.Rect.Bottom > region.Bottom)         //Overlap in height - increase the region height
                        {
                            if (overlap.Rect.Bottom - region.Bottom > 0)
                            {
                                this.Height += overlap.Rect.Bottom - region.Bottom + ExtendSize + ExtendYHeight;
                            }
                            region.Height = this.Height;
                        }
                        if (overlap.Rect.Left < this.Y ||
                            overlap.Rect.Right > region.Right)     //Overlap in width - increase the region width
                        {
                            if (overlap.Rect.Right - region.Right > 0)
                            {
                                this.Width += overlap.Rect.Right - region.Right + ExtendSize;
                            }
                            region.Width = this.Width;
                        }
                    }
                }

                //Initial Height is to store the Actual height of the group.
                //that is the height should be the initial height without the textblock height.
                if (this.InitialHeight <= 0.0)
                {
                    this.InitialHeight = region.Height;
                }
            }
            else
            {
                this.Width  = 0;
                this.height = 0;
            }
        }
Example #34
0
        public static ExecutableModelCreator <SafetySharpRuntimeModel> CreateExecutedModelFromFormulasCreator(ModelBase model)
        {
            Requires.NotNull(model, nameof(model));

            Func <Formula[], CoupledExecutableModelCreator <SafetySharpRuntimeModel> > creator = formulasToCheckInBaseModel =>
            {
                Requires.NotNull(formulasToCheckInBaseModel, nameof(formulasToCheckInBaseModel));
                return(CreateExecutedModelCreator(model, formulasToCheckInBaseModel));
            };

            return(new ExecutableModelCreator <SafetySharpRuntimeModel>(creator, model));
        }
Example #35
0
 /// <summary>
 /// Binds the ViewModel to a source model.
 /// </summary>
 /// <param name="source">Model to bind to.</param>
 /// <param name="property">Property on model to bind to.</param>
 /// <param name="mode">How to bind to the source model.</param>
 public void BindSelection(ModelBase source, ModelProperty property, ModelBindingMode mode = ModelBindingMode.Committed)
 {
     SetBinding(SelectedIdProperty, new ModelBinding(source, property, mode));
 }
Example #36
0
 public IActionResult World()
 {
     return(View(ModelBase.EnumerateWorldDbs()));
 }
Example #37
0
 private void Initialize(XElement element, ModelBase model)
 {
     Element = element;
     Model   = model;
 }
Example #38
0
 private void Initialize(string xmlContent, ModelBase model)
 {
     Initialize(XElement.Parse(xmlContent), model);
 }
Example #39
0
 /// <summary>
 /// Add a creation action.
 /// </summary>
 /// <param name="model"></param>
 public void RecordCreation(ModelBase model)
 {
     recordedActions.Add(Tuple.Create(model, UndoRedoRecorder.UserAction.Creation));
 }
Example #40
0
 public FormUpdate(ModelBase model)
 {
     InitializeComponent();
     modelUpdate = model;
 }
Example #41
0
 public OBJWriter(ModelBase model, string modelFileName) :
     base(model, modelFileName)
 {
 }
Example #42
0
        /// <summary>
        /// Gets the serializable members for the specified model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="membersToIgnore">The members to ignore.</param>
        /// <returns>The list of members to serialize.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="model"/> is <c>null</c>.</exception>
        public virtual List <MemberValue> GetSerializableMembers(ModelBase model, params string[] membersToIgnore)
        {
            Argument.IsNotNull("model", model);

            var membersToIgnoreHashSet = new HashSet <string>(membersToIgnore);

            var modelType     = model.GetType();
            var catelTypeInfo = PropertyDataManager.Default.GetCatelTypeInfo(modelType);

            var catelPropertyNames    = SerializationManager.GetCatelPropertyNames(modelType);
            var fieldsToSerialize     = SerializationManager.GetFieldsToSerialize(modelType);
            var propertiesToSerialize = SerializationManager.GetPropertiesToSerialize(modelType);

            var listToSerialize    = new List <MemberValue>();
            var checkedMemberNames = new List <string>();

            foreach (var fieldToSerialize in fieldsToSerialize)
            {
                checkedMemberNames.Add(fieldToSerialize);

                if (membersToIgnoreHashSet.Contains(fieldToSerialize) || ShouldIgnoreMember(model, fieldToSerialize))
                {
                    Log.Debug("Field '{0}' is being ignored for serialization", fieldToSerialize);
                    continue;
                }

                try
                {
                    Log.Debug("Adding field '{0}' to list of objects to serialize", fieldToSerialize);

                    var fieldInfo  = modelType.GetFieldEx(fieldToSerialize);
                    var fieldValue = new MemberValue(SerializationMemberGroup.Field, modelType, fieldInfo.FieldType, fieldInfo.Name, fieldInfo.GetValue(model));

                    listToSerialize.Add(fieldValue);
                }
                catch (Exception ex)
                {
                    Log.Warning(ex, "Failed to get value of member '{0}.{1}', skipping item during serialization", modelType.GetSafeFullName(), fieldToSerialize);
                }
            }

            foreach (var propertyToSerialize in propertiesToSerialize)
            {
                checkedMemberNames.Add(propertyToSerialize);

                if (membersToIgnoreHashSet.Contains(propertyToSerialize) || ShouldIgnoreMember(model, propertyToSerialize))
                {
                    Log.Debug("Property '{0}' is being ignored for serialization", propertyToSerialize);
                    continue;
                }

                try
                {
                    Log.Debug("Adding property '{0}' to list of objects to serialize", propertyToSerialize);

                    if (catelPropertyNames.Contains(propertyToSerialize))
                    {
                        var propertyData        = catelTypeInfo.GetPropertyData(propertyToSerialize);
                        var actualPropertyValue = model.GetValueFast(propertyToSerialize);
                        var propertyValue       = new MemberValue(SerializationMemberGroup.CatelProperty, modelType, propertyData.Type, propertyData.Name, actualPropertyValue);

                        listToSerialize.Add(propertyValue);
                    }
                    else
                    {
                        var propertyInfo  = modelType.GetPropertyEx(propertyToSerialize);
                        var propertyValue = new MemberValue(SerializationMemberGroup.RegularProperty, modelType, propertyInfo.PropertyType, propertyInfo.Name, propertyInfo.GetValue(model, null));

                        listToSerialize.Add(propertyValue);
                    }
                }
                catch (Exception ex)
                {
                    Log.Warning(ex, "Failed to get value of member '{0}.{1}', skipping item during serialization", modelType.GetSafeFullName(), propertyToSerialize);
                }
            }

            return(listToSerialize);
        }
 public static bool TestIt(ref ModelBase BaseModel)
 {
     BaseModel.UserID = 10;
     BaseModel.UserName = "******";
     return true;
 }
Example #44
0
        /// <summary>
        /// Updates <see cref="ModelBase"/> object with given xml data
        /// </summary>
        /// <param name="modelData">Xml data to update model</param>
        public void ReloadModel(XmlElement modelData)
        {
            ModelBase model = GetModelForElement(modelData);

            model.Deserialize(modelData, SaveContext.Undo);
        }
Example #45
0
        void vm_RequestNodeCentered(object sender, EventArgs e)
        {
            ModelEventArgs args = e as ModelEventArgs;
            ModelBase      node = args.Model;

            double x = outerCanvas.ActualWidth / 2.0;
            double y = outerCanvas.ActualHeight / 2.0;

            // apply small perturbation
            // so node isn't right on top of last placed node
            if (currentNodeCascadeOffset > 96.0)
            {
                currentNodeCascadeOffset = 0.0;
            }

            x += currentNodeCascadeOffset;
            y += currentNodeCascadeOffset;

            currentNodeCascadeOffset += 24.0;

            if (args.PositionSpecified)
            {
                x = args.X;
                y = args.Y;
            }

            Point dropPt = new Point(x, y);

            // Transform dropPt from outerCanvas space into zoomCanvas space
            if (args.TransformCoordinates)
            {
                if (WorkBench != null)
                {
                    var a = outerCanvas.TransformToDescendant(WorkBench);
                    dropPt = a.Transform(dropPt);
                }
            }

            // center the node at the drop point
            if (!Double.IsNaN(node.Width))
            {
                dropPt.X -= (node.Width / 2.0);
            }

            if (!Double.IsNaN(node.Height))
            {
                dropPt.Y -= (node.Height / 2.0);
            }

            if (!Double.IsNaN(node.Width))
            {
                dropPt.X -= (node.Height / 2.0);
            }

            if (!Double.IsNaN(node.Height))
            {
                dropPt.Y -= (node.Height / 2.0);
            }

            node.X = dropPt.X;
            node.Y = dropPt.Y;
            node.ReportPosition();
        }
Example #46
0
 public Download(ModelBase childModel, Dictionary <string, DefConfigurationSectionRequest> param, string batchNumber)
     : base(childModel)
 {
     _paramList       = param;
     this.batchNumber = batchNumber;
 }
Example #47
0
        public static CoupledExecutableModelCreator <SafetySharpRuntimeModel> CreateExecutedModelCreator(ModelBase model, params Formula[] formulasToCheckInBaseModel)
        {
            Requires.NotNull(model, nameof(model));
            Requires.NotNull(formulasToCheckInBaseModel, nameof(formulasToCheckInBaseModel));

            Func <int, SafetySharpRuntimeModel> creatorFunc;
            Action <TextWriter> writeFullStateVectorLayout;

            // serializer.Serialize has potentially a side effect: Model binding. The model gets bound when it isn't
            // bound already. The lock ensures that this binding is only made by one thread because model.EnsureIsBound
            // is not reentrant.
            lock (model)
            {
                var serializer = new RuntimeModelSerializer();
                model.EnsureIsBound();                 // Bind the model explicitly. Otherwise serialize.Serializer makes it implicitly.
                serializer.Serialize(model, formulasToCheckInBaseModel);

                creatorFunc = serializer.Load;
                writeFullStateVectorLayout = textWriter => textWriter.WriteLine(serializer.StateVector);
            }
            var faults = model.Faults;

            return(new CoupledExecutableModelCreator <SafetySharpRuntimeModel>(creatorFunc, writeFullStateVectorLayout, model, formulasToCheckInBaseModel, faults));
        }
Example #48
0
        }                                                                                                                               // 0x00BB0EF0-0x00BB0F00

        public void ShowBossOverDriveGauge(int hp, int maxhp, int damage, int effect, int rest_turn, Vector3 arg_pos, ModelBase target)
        {
        }                                                                                                                                          // 0x00BB0F00-0x00BB0F10
 private void ReceiveBroadcastObjectAction(GenericMessage <ModelBase> message)
 {
     _broadcastObject = message.Content;
 }
Example #50
0
        internal static ModelCreateResult TryCreate(XmlNode node, XmlNode log4NetNode, out ModelBase model)
        {
            model = null;

            switch (node.Name)
            {
            case Log4NetXmlConstants.Root:
                model = new RootLoggerModel(node, false, LoggerDescriptor.Root);
                return(ModelCreateResult.Success);

            case Log4NetXmlConstants.Logger:
                model = new LoggerModel(node, false, LoggerDescriptor.Logger);
                return(ModelCreateResult.Success);

            case Log4NetXmlConstants.Appender:
                if (AppenderModel.TryCreate(node, log4NetNode, out AppenderModel appenderModel))
                {
                    model = appenderModel;
                    return(ModelCreateResult.Success);
                }

                return(ModelCreateResult.UnknownAppender);

            case Log4NetXmlConstants.Renderer:
                model = new RendererModel(node);
                return(ModelCreateResult.Success);

            case Log4NetXmlConstants.Param:
                model = new ParamModel(node);
                return(ModelCreateResult.Success);

            default:
                return(ModelCreateResult.UnknownElement);
            }
        }
        /// <summary>
        ///   Creates the object table for the <paramref name="model" /> and <paramref name="formulas" />.
        /// </summary>
        private static ObjectTable CreateObjectTable(ModelBase model, Formula[] formulas)
        {
            var objects = model.Roots.Cast <object>().Concat(formulas).Concat(new[] { model });

            return(new ObjectTable(SerializationRegistry.Default.GetReferencedObjects(objects.ToArray(), SerializationMode.Full)));
        }
Example #52
0
 public void SetModel(ModelBase model)
 {
     modelUpdate = model;
 }
Example #53
0
        }                                       // 0x00BB0EE0-0x00BB0EF0

        public void ShowBossHPGauge(int hp, int maxhp, int damage, int effect, Vector3 arg_pos, ModelBase target, int[] pin)
        {
        }                                                                                                                               // 0x00BB0EF0-0x00BB0F00
Example #54
0
 public override bool ProcessFileModelBase(PictureMetaData pmd, ModelBase model)
 {
     return(ProcessFile(pmd, model as MODEL));
 }
Example #55
0
        public bool IsAutoLocked() => default;         // 0x00BB0EC0-0x00BB0ED0

        public void CreatePopupHPGauge(float src_amount, float dst_amount, Vector3 arg_pos, ModelBase target)
        {
        }                                                                                                                // 0x00BB0ED0-0x00BB0EE0
Example #56
0
 public string Validate(ModelBase model, object value)
 {
     throw new NotImplementedException();
 }
Example #57
0
 public void AddModel(ModelBase model)
 {
     _entityModels.Add(model.Id, model);
 }
Example #58
0
 /// <summary>
 /// Determines whether the specified member on the specified model should be ignored by the serialization engine.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="propertyName">Name of the member.</param>
 /// <returns><c>true</c> if the member should be ignored, <c>false</c> otherwise.</returns>
 protected virtual bool ShouldIgnoreMember(ModelBase model, string propertyName)
 {
     return(false);
 }
 public RenderWolf(ModelBase par1ModelBase, float par2) : base(par1ModelBase, par2)
 {
 }
Example #60
0
 /// <summary>
 /// Gets the context.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="stream">The stream.</param>
 /// <param name="contextMode">The context mode.</param>
 /// <returns>The serialization context.</returns>
 /// <exception cref="ArgumentNullException">The <paramref name="model" /> is <c>null</c>.</exception>
 /// <exception cref="ArgumentNullException">The <paramref name="stream" /> is <c>null</c>.</exception>
 protected abstract ISerializationContext <TSerializationContext> GetContext(ModelBase model, Stream stream, SerializationContextMode contextMode);