Exemplo n.º 1
0
        protected void CreateImageUrl(imageType itemType)
        {
            this.ImageUrl = null;

            if (ImageId == null)
            {
                ImageUrl = null;
                return;
            }

            switch (itemType)
            {
            case imageType.product:
                ImageUrl = "Products/" + ImageId.ToString() + ".jpg";
                break;

            case imageType.category:
                ImageUrl = "Categories/" + ImageId.ToString() + ".jpg";
                break;

            case imageType.item:
                ImageUrl = "Items/" + ImageId.ToString() + ".jpg";
                break;

            default:
                ImageUrl = null;
                break;
            }
        }
Exemplo n.º 2
0
        public ImageModel()
        {
            ImageId = Guid.NewGuid();
            var FileName = ImageId.ToString();

            Image = new ImageInfo(FileName);
        }
Exemplo n.º 3
0
        public Uri GetImage(ImageId id)
        {
            var fileNameAttributes = typeof(ImageId).GetField(id.ToString()).GetCustomAttributes(typeof(FileTitleAttribute), false);
            var fileTitle          = fileNameAttributes.Length > 0 ? ((FileTitleAttribute)fileNameAttributes[0]).FileTitle : id.ToString();

            return(new Uri(string.Format("Images/{0}.png", fileTitle), UriKind.Relative));
        }
Exemplo n.º 4
0
        /// <summary>
        ///     The process record method.
        /// </summary>
        protected override void ProcessRecord()
        {
            try
            {
                ResponseType response =
                    Connection.ApiClient.ServerManagement.ServerImage.EditCustomerImageMetadata(new EditImageMetadataType
                {
                    id                = ImageId.ToString(),
                    description       = Description,
                    cpuSpeed          = CpuSpeed,
                    operatingSystemId = OperatingSystemId,
                    disk              = DiskSpeeds
                }).Result;

                if (response != null)
                {
                    WriteDebug(
                        string.Format(
                            "{0} resulted in {1} :{2}",
                            response.operation,
                            response.responseCode,
                            response.message));
                }

                WriteObject(response);
            }
            catch (AggregateException ae)
            {
                ae.Handle(
                    e =>
                {
                    if (e is ComputeApiException)
                    {
                        WriteError(new ErrorRecord(e, "-2", ErrorCategory.InvalidOperation, Connection));
                    }
                    else
                    {
                        // if (e is HttpRequestException)
                        ThrowTerminatingError(new ErrorRecord(e, "-1", ErrorCategory.ConnectionError, Connection));
                    }

                    return(true);
                });
            }

            base.ProcessRecord();
        }
Exemplo n.º 5
0
        public override void Select(MainForm frm)
        {
            if (frm.grpItem.Text == ToString() && frm.MainTab.SelectedTab == frm.tabItem)
            {
                return;
            }
            Program.MakeSelected(frm.tabItem, frm.lstItem, this);

            frm.grpItem.Text = ToString();
            frm.grpItem.Show();
#if DEBUG
            frm.grpItem.Text += $" - ID: {Id}";
#endif
            frm.lblItemDescription.Text      = Description;
            frm.lblItemCoords.Text           = Coords.IsEmpty ? "Off Map" : Coords.ToString();
            frm.lblItemMaker.Data            = Maker;
            frm.lblItemMasterpieceEvent.Data = MasterpieceEvent;
            frm.lblItemMat.Text     = Mat.HasValue ? Materials[Mat.Value].ToTitleCase() : "";
            frm.lblItemType.Text    = ItemTypeId.HasValue ? ItemTypes[ItemTypeId.Value].ToTitleCase() : "";
            frm.lblItemSubType.Text = ItemSubTypeId.HasValue ? ItemSubTypes[ItemSubTypeId.Value].ToTitleCase() : "";
            frm.lblItemName.Text    = Name;
            frm.lblItemQuality.Text = Quality.ToString();
            frm.lblItemWeight.Text  = Weight.ToString();
            frm.lblItemSkill.Text   = SkillUsed.ToString();
            var AgeTime = new WorldTime(0, Age).ToString().Split('.').Select(x => Convert.ToInt32(x)).ToArray();

            if (AgeTime[2] > 0)
            {
                frm.lblItemAge.Text = AgeTime[2] + @" year" + (AgeTime[2] > 0 ? "s" : "");
            }
            else if (AgeTime[1] > 1)
            {
                frm.lblItemAge.Text = AgeTime[1] - 1 + @" month" + (AgeTime[1] > 1 ? "s" : "");
            }
            else if (AgeTime[0] > 1)
            {
                frm.lblItemAge.Text = AgeTime[0] - 1 + @" day" + (AgeTime[0] > 1 ? "s" : "");
            }
            else if (Age.HasValue)
            {
                frm.lblItemAge.Text = Age + @" seconds";
            }
            else
            {
                frm.lblItemAge.Text = "";
            }

            frm.lblItemWear.Text   = Wear.ToString();
            frm.lblItemHand.Text   = Handedness.ToString();
            frm.lblItemShape.Text  = Shape.ToString();
            frm.lblItemDyeMat.Text = DyeMat.HasValue ? Materials[DyeMat.Value] : "";
            frm.lblItemUnit.Data   = UnitId.HasValue && World.Units.ContainsKey(UnitId.Value)
                ? World.Units[UnitId.Value]
                : null;
            frm.lblItemHF.Data = HistFigureId.HasValue && World.HistoricalFigures.ContainsKey(HistFigureId.Value)
                ? World.HistoricalFigures[HistFigureId.Value]
                : null;
            frm.lblItemBoneMat.Text = BoneMat.HasValue ? Materials[BoneMat.Value] : "";

            frm.lblItemStockpile.Text       = StockpileId.ToString();
            frm.lblItemStockpileCoords.Text = StockpileCoords.IsEmpty ? "" : StockpileCoords.ToString();

            frm.grpItemImage.Visible = ImageId.HasValue;
            if (ImageId.HasValue)
            {
                frm.lblItemImageID.Text    = ImageId.ToString();
                frm.lblItemImageSubID.Text = ImageSubId.ToString();
                frm.lblItemImageCiv.Data   = ImageCivId.HasValue && World.Entities.ContainsKey(ImageCivId.Value)
                    ? World.Entities[ImageCivId.Value]
                    : null;
                frm.lblItemImageSIte.Data = ImageSiteId.HasValue && World.Sites.ContainsKey(ImageSiteId.Value)
                    ? World.Sites[ImageSiteId.Value]
                    : null;
            }

            frm.grpItemIngredient.FillListboxWith(frm.lstItemIngredient, Ingredients);
            frm.grpItemImprovement.FillListboxWith(frm.lstItemImprovement, Improvements);
            frm.grpItemReferences.FillListboxWith(frm.lstItemReferences, References);
        }
Exemplo n.º 6
0
        /// <summary>
        ///     The process record method.
        /// </summary>
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            try
            {
                if (Mcp1.IsPresent)
                {
                    if (Network != null && string.IsNullOrEmpty(DataCenterId))
                    {
                        DataCenterId = Network.location;
                    }

                    IEnumerable <ImagesWithDiskSpeedImage> resultlist =
                        Connection.ApiClient.GetCustomerServerImages(ImageId == Guid.Empty ? null : ImageId.ToString(), Name, DataCenterId, OperatingSystemId,
                                                                     OperatingSystemFamily).Result;
                    WriteObject(resultlist, true);
                    return;
                }

                ServerCustomerImageListOptions options = new ServerCustomerImageListOptions
                {
                    Id                    = ImageId == Guid.Empty ? (Guid?)null : ImageId,
                    DatacenterId          = DataCenterId,
                    Name                  = Name,
                    OperatingSystemId     = OperatingSystemId,
                    OperatingSystemFamily = OperatingSystemFamily
                };

                this.WritePagedObject(Connection.ApiClient.ServerManagement.ServerImage.GetCustomerImages(options, PageableRequest).Result);
            }
            catch (AggregateException ae)
            {
                ae.Handle(
                    e =>
                {
                    if (e is ComputeApiException)
                    {
                        WriteError(new ErrorRecord(e, "-2", ErrorCategory.InvalidOperation, Connection));
                    }
                    else
                    {
                        ThrowTerminatingError(new ErrorRecord(e, "-1", ErrorCategory.ConnectionError, Connection));
                    }

                    return(true);
                });
            }
        }