protected Block(Vector2f _pos, Vector2f _size, string _filename, BlockName _name, TypeBlock _blocktype = TypeBlock.solid) : base(_pos, _size, _filename, Type.block, _name.ToString()) { blockType = _blocktype; Pos = new Vector2f(BlockWidth * ((int)PosX / BlockWidth) + BlockWidth / 2, BlockHeight * ((int)PosY / BlockHeight) + BlockHeight / 2); Sprite.Scale = new Vector2f((float)BlockWidth / (float)Sprite.TextureRect.Width, (float)BlockHeight / (float)Sprite.TextureRect.Height); }
public XElement Serialize(string name) { return(new XElement(UblNames.Cac + name, ID.Serialize(nameof(ID)), AddressTypeCode.Serialize(nameof(AddressTypeCode)), AddressFormatCode.Serialize(nameof(AddressFormatCode)), Postbox.Serialize(nameof(Postbox)), Floor.Serialize(nameof(Floor)), Room.Serialize(nameof(Room)), StreetName.Serialize(nameof(StreetName)), AdditionalStreetName.Serialize(nameof(AdditionalStreetName)), BlockName.Serialize(nameof(BlockName)), BuildingName.Serialize(nameof(BuildingName)), BuildingNumber.Serialize(nameof(BuildingNumber)), InhouseMail.Serialize(nameof(InhouseMail)), Department.Serialize(nameof(Department)), MarkAttention.Serialize(nameof(MarkAttention)), MarkCare.Serialize(nameof(MarkCare)), PlotIdentification.Serialize(nameof(PlotIdentification)), CitySubdivisionName.Serialize(nameof(CitySubdivisionName)), CityName.Serialize(nameof(CityName)), PostalZone.Serialize(nameof(PostalZone)), CountrySubentity.Serialize(nameof(CountrySubentity)), CountrySubentityCode.Serialize(nameof(CountrySubentityCode)), Region.Serialize(nameof(Region)), District.Serialize(nameof(District)), TimezoneOffset.Serialize(nameof(TimezoneOffset)), AddressLines?.Select(line => new XElement(UblNames.Cac + "AddressLine", line.Serialize("Line"))), Country?.Serialize(), LocationCoordinates?.Select(lc => lc.Serialize()) )); }
public bool GetForegroundAt(int X, int Y, out BlockName Foreground) { Foreground = BlockName.NONE; if (HasForegroundAt(X, Y)) { Foreground = SelectableTile.GetBlockNameByString(TileDB.Tiles[X, Y].blName); return(true); } return(false); }
public void SetType(BlockName type) { ClearAnimationStates(); AddAnimationState(new SpriteState("Idle", _tileSpriteMap[type], 0)); SetCurrentAnimationState("Idle"); _name = type; _type = _tileBlockTypes[type]; switch (_type) { case BlockType.Solid: _depth = SpriteHelper.GetDefaultDepth(SpriteHelper.SpriteDepth.High); _health = 2; break; case BlockType.WalkableCovering: _depth = SpriteHelper.GetDefaultDepth(SpriteHelper.SpriteDepth.High); break; case BlockType.Walkable: _depth = SpriteHelper.GetDefaultDepth(SpriteHelper.SpriteDepth.Low); break; } }
// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (Page.IsPostBack) { return; } var rockContext = new RockContext(); var dvService = new DefinedValueService(rockContext); LoadSourceGuids(); // Output variables direct to the ascx metricBlockNumber.Value = BlockId.ToString(); metricBlockId.Value = BlockName.Replace(" ", "").ToString(); metricTitle.Value = BlockName; metricWidth.Value = GetAttributeValue("NumberofColumns"); DisplayTextValue(); }
/// <summary> /// Get charactericstic of block (Name || Filename || Path) /// </summary> /// <param name="btr"></param> /// <returns></returns> private string GetBlockChar(Document doc) { string n = null; BlockName nType = BlockName.Name; if (m_rdoFileName.Checked) { nType = BlockName.FileName; } if (m_rdoPath.Checked) { nType = BlockName.Path; } switch (nType) { case BlockName.Name: n = FrameBlock.Name; break; case BlockName.FileName: n = Path.GetFileName(FrameBlock.PathName); break; case BlockName.Path: string p = FrameBlock.PathName; if (!(Path.IsPathRooted(p))) { HostApplicationServices hs = HostApplicationServices.Current; string acPath = hs.FindFile( doc.Name, doc.Database, FindFileHint.Default); p = Path.Combine(acPath, p); n = Path.GetFullPath(p); } break; } return(n); }
protected void Page_Load(object sender, EventArgs e) { SendOptionsControl.ApplyEditAttributes <ScheduledEmailBlock>(p => p.EmailSendOptions); BlockName.ApplyEditAttributes <ScheduledEmailBlock>(p => (p as IContent).Name); SendOnStatusControl.ApplyEditAttributes <ScheduledEmailBlock>(p => p.SendOnStatus); ScheduledRelativeAmountControl.ApplyEditAttributes <ScheduledEmailBlock>(p => p.ScheduledRelativeAmount); ScheduledRelativeToControl.ApplyEditAttributes <ScheduledEmailBlock>(p => p.ScheduledRelativeTo); ScheduledRelativeUnitControl.ApplyEditAttributes <ScheduledEmailBlock>(p => p.ScheduledRelativeUnit); (this as PageBase).EditHints.Add("ScheduledRelativeTo"); (this as PageBase).EditHints.Add("ScheduledRelativeAmount"); (this as PageBase).EditHints.Add("ScheduledRelativeUnit"); (this as PageBase).EditHints.Add("SendOnStatus"); (this as PageBase).EditHints.Add("EmailSendOptions"); (this as PageBase).EditHints.Add("SendOptions"); (this as PageBase).EditHints.Add("EmailTemplateContentReference"); if ((CurrentData as ScheduledEmailBlock).EmailTemplateContentReference != null && (CurrentData as ScheduledEmailBlock).EmailTemplateContentReference != ContentReference.EmptyReference) { SetupPreviewPropertyControl(MailTemplateBlockPreview, new[] { Locate.ContentRepository() .Get <IContent>((CurrentData as ScheduledEmailBlock).EmailTemplateContentReference) }, "MailPreview"); } else { ConfirmMailTemplateBlockPreviewPlaceHolder.Visible = false; } MailTemplateBlockPreview.RenderSettings.Tag = "edit"; MailTemplateBlockPreview.DataBind(); this.DataBind(); }
//World Load private void LoadWorld_Click(object sender, RoutedEventArgs e) { if (firstPlaced && MessageBox.Show("Are you sure to load a new world? You may lose all your unsaved progress!", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { return; } isLoading = true; OpenFileDialog dialog = new OpenFileDialog() { Filter = "Pixel Worlds World (*.pww)|*.pww", DefaultExt = "pww", RestoreDirectory = true }; Nullable <bool> Selected = dialog.ShowDialog(); string path = dialog.FileName; if (Selected == true) { MainCanvas.Children.Clear(); TileDB = (TileData)DataHandler.LoadWorld(path); DrawGrid(TileDB.Height, TileDB.Width); if (!TileDB.hasMainBackground) { MainCanvas.Background = new SolidColorBrush(Utils.IntToARGBColor(TileDB.ARGBBackgroundColor)); } else { MainCanvas.Background = BackgroundData.GetBackground(TileDB.MainBackground); } SortedList <string, int> invalids = new SortedList <string, int>(); for (int i = 0; i < TileDB.Tiles.GetLength(0); i++) { for (int j = 0; j < TileDB.Tiles.GetLength(1); j++) { if (TileDB.Tiles[i, j] != null) { if (TileDB.Tiles[i, j].Type == TileType.Background || TileDB.Tiles[i, j].Type == TileType.Both) { Image image = new Image() { Height = 32, Width = 32 }; string dataName = TileDB.Tiles[i, j].bgName; BackgroundName name = SelectableTile.GetBackgroundNameByString(TileDB.Tiles[i, j].bgName); //If the sprite does not exist. bool exists = backgroundMap.TryGetValue(name, out BitmapImage src); if (!exists && dataName != null) { if (invalids.ContainsKey(dataName)) { invalids[dataName]++; } else { invalids.Add(dataName, 0); } TileDB.Tiles[i, j] = null; } else { image.Source = src; Canvas.SetTop(image, TileDB.Tiles[i, j].Positions.BackgroundY.Value * 32); Canvas.SetLeft(image, TileDB.Tiles[i, j].Positions.BackgroundX.Value * 32); image.SetValue(Canvas.ZIndexProperty, 10); MainCanvas.Children.Add(image); TileDB.Tiles[i, j].Background = image; } } if (TileDB.Tiles[i, j].Type == TileType.Foreground || TileDB.Tiles[i, j].Type == TileType.Both) { Image image = new Image() { Height = 32, Width = 32 }; string dataName = TileDB.Tiles[i, j].blName; BlockName name = SelectableTile.GetBlockNameByString(TileDB.Tiles[i, j].blName); bool exists = blockMap.TryGetValue(name, out BitmapImage src); if (!exists && dataName != null) { if (invalids.ContainsKey(dataName)) { invalids[dataName]++; } else { invalids.Add(dataName, 0); } TileDB.Tiles[i, j] = null; } else { image.Source = src; Canvas.SetTop(image, TileDB.Tiles[i, j].Positions.ForegroundY.Value * 32); Canvas.SetLeft(image, TileDB.Tiles[i, j].Positions.ForegroundX.Value * 32); image.SetValue(Canvas.ZIndexProperty, 20); MainCanvas.Children.Add(image); TileDB.Tiles[i, j].Foreground = image; } } } } ColorSelector.SelectedColor = Utils.IntToARGBColor(TileDB.ARGBBackgroundColor); firstPlaced = false; SaveButton.IsEnabled = false; SavedPath = String.Empty; } if (invalids.Count > 0) { StringBuilder sb = new StringBuilder(); sb.AppendLine($"Could not load {invalids.Count} tiles (Using an older version?)"); foreach (KeyValuePair <string, int> entry in invalids) { sb.AppendLine($"-{entry.Key} [x{entry.Value}]"); } MessageBox.Show(sb.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } isLoading = false; }
public Tile(BlockName type, int xPos, int yPos) : base("Sprites", xPos, yPos, 32, 32, true, 0) { SetType(type); }
private void Run() { try { // System - call method if (Application.IsSystem) { string typeName = BlockName; string[] splitted = Executor.Split('/'); /// Post/string:ahoj;int:4/string:aho string methodName = splitted[0]; object[] objectArguments = splitted.Length < 2 ? new object[0] : getArguments(splitted[1]); object[] callArguments = splitted.Length < 3 ? new object[0] : getArguments(splitted[2]); Type type = Assembly.GetCallingAssembly().GetType(typeName); MethodInfo method = type.GetMethod(methodName); if (method.IsStatic) { method.Invoke(null, callArguments); } else { method.Invoke(Activator.CreateInstance(type, objectArguments), callArguments); } return; } var core = COREobject.i; core.User = core.Context.Users.Single(u => u.UserName == "system"); core.Application = core.Context.Applications.Find(ApplicationId); var block = core.Context.Blocks.Single(b => b.WorkFlow.ApplicationId == ApplicationId && b.Name.ToLower() == BlockName.ToLower()); var tapestry = new Modules.Tapestry.Tapestry(core); var result = tapestry.innerRun(block, Executor ?? "INIT", ModelId ?? -1, null, -1); if (result.Item1.Type != MessageType.Error) { LastEndTask = DateTime.UtcNow; COREobject.i.Context.SaveChanges(); } } catch (Exception ex) { Modules.Watchtower.OmniusException.Log(ex, source: Modules.Watchtower.OmniusLogSource.Cortex, application: Application); } }
public override int GetHashCode() { return(BlockName.GetHashCode()); }
// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!Page.IsPostBack) { // check the page context bool pageScope = GetAttributeValue("ContextScope") == "Page"; // If the blocks respect page context let's set those vars if (pageScope) { // Get Current Campus Context CampusContext = RockPage.GetCurrentContext(EntityTypeCache.Read(typeof(Campus))); // Get Current Schedule Context ScheduleContext = RockPage.GetCurrentContext(EntityTypeCache.Read(typeof(Schedule))); // Get Current Group Context GroupContext = RockPage.GetCurrentContext(EntityTypeCache.Read(typeof(Group))); // Get Current GroupType Context GroupTypeContext = RockPage.GetCurrentContext(EntityTypeCache.Read(typeof(GroupType))); } // Output variables direct to the ascx metricBlockNumber.Value = BlockId.ToString(); metricBlockId.Value = BlockName.Replace(" ", "").ToString(); metricTitle.Value = BlockName; metricDisplay.Value = GetAttributeValue("MetricDisplayType"); metricWidth.Value = GetAttributeValue("NumberofColumns"); PrimaryMetricKey = GetAttributeValue("PrimaryMetricKey"); ComparisonMetricKey = GetAttributeValue("ComparisonMetricKey"); var churchMetricPeriod = GetAttributeValue("MetricPeriod"); var metricComparison = GetAttributeValue("MetricComparison"); var metricDisplayType = GetAttributeValue("MetricDisplayType"); var rockContext = new RockContext(); var metricService = new MetricService(rockContext); var primarySourceGuids = GetAttributeValue("PrimaryMetricSource") .SplitDelimitedValues() .AsGuidList(); var comparisonSourceGuids = GetAttributeValue("ComparisonMetricSource") .SplitDelimitedValues() .AsGuidList(); // lookup the metric sources List <int> primaryMetricSource = metricService.GetByGuids(primarySourceGuids) .Select(a => a.Id).ToList(); List <int> comparisonMetricSource = metricService.GetByGuids(comparisonSourceGuids) .Select(a => a.Id).ToList(); DateRange dateRange = new DateRange(DateTime.Now.AddMonths(-6), DateTime.Now); // Show data if metric source is selected if (primaryMetricSource.Any() || !string.IsNullOrEmpty(PrimaryMetricKey)) { if (metricDisplayType.Equals("Text")) { DisplayTextValue(dateRange, primaryMetricSource, comparisonMetricSource); } else if (metricDisplayType.Equals("Line")) { DisplayLineValue(dateRange, primaryMetricSource); } else if (metricDisplayType.Equals("Donut")) { DisplayDonutValue(dateRange, primaryMetricSource); } } else { // nothing selected, display an error message churchMetricWarning.Visible = true; } } // unused variables // var metricCustomDates = GetAttributeValue( "CustomDates" ); // MetricCompareLastYear = GetAttributeValue( "CompareAgainstLastYear" ).ToString(); // var dateRange = SlidingDateRangePicker.CalculateDateRangeFromDelimitedValues( this.GetAttributeValue( "SlidingDateRange" ) ?? string.Empty ); }