public void SetCurrentCell(Point location) { if (!TemplateImage.IsOnBoundary(location)) { CurrentCell = TemplateImage.GetCorrespondingCellId(location); } }
private void UploadVhd(TemplateImage image) { UploadScriptResult response = null; Collection <PSObject> scriptResult = null; string command = null; task.SetStatus(Commands_RemoteApp.TemplateImageUploadingStatusMessage); response = CallClient_ThrowOnError(() => Client.TemplateImages.GetUploadScript()); if (response != null && response.Script != null) { string uploadFilePath = string.Concat(Environment.GetEnvironmentVariable("temp"), "\\uploadScript.ps1"); try { File.WriteAllText(uploadFilePath, response.Script); } catch (Exception ex) { task.SetState(JobState.Failed, new Exception(string.Format(Commands_RemoteApp.FailedToWriteToFileErrorFormat, uploadFilePath, ex.Message))); return; } command = String.Format("{0} -Uri \"{1}\" -Sas \"{2}\" -VhdPath \"{3}\"", uploadFilePath, image.Uri, image.Sas, Path); scriptResult = CallPowershell(command); } }
private void SetupForConfiguration(Bitmap template = null) { MinimumSize = new Size(500, 560); MainLayoutPanel.RowStyles[1].SizeType = SizeType.Absolute; MainLayoutPanel.RowStyles[1].Height = 115; for (int i = 0; i < configureStatesPanel.RowCount; i++) { configureStatesPanel.RowStyles[i].SizeType = SizeType.Percent; configureStatesPanel.RowStyles[i].Height = i == 0 ? 0 : i == 1 ? 0 : i == 2 ? 50 : i == 3 ? 50 : 0; } if (!curConfigureStatePanel.Controls.Contains(statePanelsPanel)) { curConfigureStatePanel.Controls.Add(statePanelsPanel, 1, 0); } statePanelsPanel.Dock = DockStyle.Fill; statePanelsPanel.Visible = true; configureStatesPanel.Visible = true; TemplateImage = template == null ? TemplateImage : new Image <Gray, byte>(template).Mat; templateImageCopy = TemplateImage.Clone(); imageBox.Image = TemplateImage.Bitmap; StartWalkthrough(); }
public Dictionary <uint, Color> ClearAllCells() { var oldCache = (TemplateImage as ColoringBookBitmapLibraryImage).CellColorCache; TemplateImage.EraseAllCells(); return(oldCache); }
internal List <IDirective> getImageResponseIfUrlLeadsToImage(String url, String title) { TemplateImage ti = new TemplateImage(); if (supportsDisplay) { if (url.EndsWith(".png") || url.EndsWith(".jpg") || url.EndsWith(".jpeg")) { ImageSource imageSource = new ImageSource(); imageSource.Url = url; log.LogLine($"Image detected: ImageURL = {url}"); ti.ContentDescription = title; List <ImageSource> imageSources = new List <ImageSource>(); imageSources.Add(imageSource); ti.Sources = imageSources; var bodytemplate = new BodyTemplate7(); bodytemplate.Title = title; bodytemplate.Image = ti; DisplayRenderTemplateDirective directive = new DisplayRenderTemplateDirective(); directive.Template = bodytemplate; List <IDirective> directives = new List <IDirective>(); directives.Add(directive); return(directives); } } return(null); }
static UnityProjectScopeCategoryUIProvider() { // UnityCSharp requires its own icon rather than the generic C# icon because it's used as the group icon // for the UITag "Unity Class" menu item TemplateImage.Register("UnityCSharp", UnityFileTypeThemedIcons.FileUnity.Id); TemplateImage.Register("UnityShaderLab", ShaderFileTypeThemedIcons.FileShader.Id); TemplateImage.Register("UnityAsmDef", PsiJavaScriptThemedIcons.Json.Id); }
private void SetupForConfigured(Template.AnchorAlignmentMethod anchorAlignmentMethod, Bitmap templateImage) { referenceAnchorAlignmentMethod = anchorAlignmentMethod; MinimumSize = new Size(500, 600); MainLayoutPanel.RowStyles[1].SizeType = SizeType.Absolute; MainLayoutPanel.RowStyles[1].Height = 58; statePanelsPanel.Controls.Remove(SizeValueStatePanel); for (int i = 0; i < configureStatesPanel.RowCount; i++) { configureStatesPanel.RowStyles[i].SizeType = SizeType.Percent; configureStatesPanel.RowStyles[i].Height = i == 0 ? 100 : i == 1 ? 0 : i == 2 ? 0 : i == 3 ? 0 : 0; } var list = EnumHelper.ToList(typeof(ConfigurationState)); list.RemoveAt(0); selectStateComboBox.DataSource = list; selectStateComboBox.DisplayMember = "Value"; selectStateComboBox.ValueMember = "Key"; if (!curConfigureStatePanel.Controls.Contains(statePanelsPanel)) { curConfigureStatePanel.Controls.Add(statePanelsPanel, 1, 0); } statePanelsPanel.Dock = DockStyle.Fill; statePanelsPanel.Visible = true; configureStatesPanel.Visible = true; resizedImage = new Image <Gray, byte>(templateImage).Resize(anchorAlignmentMethod.GetDownscaleSize.Width, anchorAlignmentMethod.GetDownscaleSize.Height, Emgu.CV.CvEnum.Inter.Cubic); TemplateImage = templateImage == null ? TemplateImage : resizedImage; templateImageCopy = TemplateImage.Clone(); imageBox.Image = TemplateImage.Bitmap; var refAnchors = anchorAlignmentMethod.GetAnchors; for (int i = 0; i < refAnchors.Count; i++) { AnchorPlaceholderControl anchorPlaceholder = anchorPlaceholderControls[i]; anchorPlaceholder.Initialize(refAnchors[i].GetAnchorRegion, (Mat)refAnchors[i].GetAnchorImage, DeleteAnchorAction); anchorPlaceholder.IsCurrent = false; anchors.Add(anchorPlaceholder.GetAnchor); if (!anchorPlaceholderControls.Exists(x => x.IsInitialized == false)) { continue; } curAnchorIndex = anchorPlaceholderControls.Find(x => x.IsInitialized == false).Index; anchorPlaceholderControls[curAnchorIndex].IsCurrent = true; } testPointPlaceholderControl.Initialize(anchorAlignmentMethod.GetTestAnchor.GetAnchorRegion, (Mat)anchorAlignmentMethod.GetTestAnchor.GetAnchorImage, DeleteAnchorAction); }
static UnityProjectScopeCategoryUIProvider() { // These get added to a static dictionary, so they can be referenced by name from templates // We're using Unity_CSharp instead of just CSharp, because that's set up to use the C# // template scope icon instead of the C# file icon - see RIDER-9903 TemplateImage.Register("UnityCSharp", PsiCSharpThemedIcons.Csharp.Id); TemplateImage.Register("UnityShaderLab", ShaderFileTypeThemedIcons.FileShader.Id); TemplateImage.Register("UnityAsmDef", PsiJavaScriptThemedIcons.Json.Id); }
public override void ExecuteCmdlet() { // register the subscription for this service if it has not been before // sebsequent call to register is redundent RegisterSubscriptionWithRdfeForRemoteApp(); switch (DetermineParameterSetName()) { case UploadLocalVhd: { string scriptBlock = "Test-Path -Path " + Path; Collection <bool> pathValid = CallPowershellWithReturnType <bool>(scriptBlock); TemplateImage image = null; if (pathValid[0] == false) { throw new RemoteAppServiceException(Commands_RemoteApp.FailedToValidateVhdPathError, ErrorCategory.ObjectNotFound); } task = new LongRunningTask <NewAzureRemoteAppTemplateImage>(this, "RemoteAppTemplateImageUpload", Commands_RemoteApp.UploadTemplateImageJobDescriptionMessage); task.ProcessJob(() => { image = VerifyPreconditions(); image = StartTemplateUpload(image); UploadVhd(image); task.SetStatus(Commands_RemoteApp.JobCompletionStatusMessage); }); WriteObject(task); break; } case AzureVmUpload: { if (IsFeatureEnabled(EnabledFeatures.goldImageImport)) { ImportTemplateImage(); } else { ErrorRecord er = RemoteAppCollectionErrorState.CreateErrorRecordFromString( string.Format(Commands_RemoteApp.ImportImageFeatureNotEnabledError), String.Empty, Client.Account, ErrorCategory.InvalidOperation ); ThrowTerminatingError(er); } break; } } }
private void CropTemplateImage() { preCroppedImage = TemplateImage.Clone(); cropRegion = imageBox.SelectionRegion; croppedImage = cropRegion == RectangleF.Empty? TemplateImage : new Mat(TemplateImage, Rectangle.Round(cropRegion)); imageBox.Invalidate(); }
public override void ExecuteCmdlet() { AzureOperationResponse response = null; TemplateImage matchingTemplate = null; matchingTemplate = FilterTemplateImage(ImageName, Operation.Remove); if (ShouldProcess(ImageName, "Remove image")) { response = CallClient(() => Client.TemplateImages.Delete(matchingTemplate.Name), Client.TemplateImages); } }
private void AddSelectedAnchor() { if (imageBox.SelectionRegion != RectangleF.Empty && imageBox.SelectionRegion.Width != 0 && imageBox.SelectionRegion.Height != 0 && (anchorPlaceholderControls.Exists(x => x.IsCurrent == true) || testPointPlaceholderControl.IsCurrent == true)) { RectangleF selectionRegion = imageBox.SelectionRegion; if (originalImageToggle.ToggleState == Syncfusion.Windows.Forms.Tools.ToggleButtonState.Active && resizedImage != null) { selectionRegion = Functions.ResizeRegion(selectionRegion, templateImage.Size, resizedImage.Size); } if (curAnchorIndex == testPointPlaceholderControl.Index) { testPointPlaceholderControl.Initialize(selectionRegion, TemplateImage.Copy(selectionRegion).Mat, DeleteAnchorAction); testPointPlaceholderControl.IsCurrent = false; } else { AnchorPlaceholderControl anchorPlaceholder = anchorPlaceholderControls[curAnchorIndex]; anchorPlaceholder.Initialize(selectionRegion, TemplateImage.Copy(selectionRegion).Mat, DeleteAnchorAction); anchorPlaceholderControls.ForEach(x => x.IsCurrent = false); testPointPlaceholderControl.IsCurrent = false; if (!anchorPlaceholderControls.Exists(x => x.IsInitialized == false)) { if (!testPointPlaceholderControl.IsInitialized) { curAnchorIndex = testPointPlaceholderControl.Index; testPointPlaceholderControl.IsCurrent = true; } } else { curAnchorIndex = anchorPlaceholderControls.Find(x => x.IsInitialized == false).Index; anchorPlaceholderControls[curAnchorIndex].IsCurrent = true; } anchors.Add(anchorPlaceholder.GetAnchor); } } if (curAnchorIndex != testPointPlaceholderControl.Index) { anchorsStatePanelLabel.Text = anchorPlaceholderControls[curAnchorIndex].IsInitialized? "Anchors:" : (curAnchorIndex == 0 ? "Top Left:" : curAnchorIndex == 1 ? "Top Right:" : curAnchorIndex == 2 ? "Bottom Right:" : curAnchorIndex == 3 ? "Bottom Left:" : "Anchors:"); } else { anchorsStatePanelLabel.Text = testPointPlaceholderControl.IsInitialized? "Anchors:" : "Test Region:"; } imageBox.Invalidate(); }
public void Create_Basic_Image() { var actual = new TemplateImage { ContentDescription = ImageDescription, Sources = new List <ImageSource> { new ImageSource { Url = ImageSource } } }; Assert.True(CompareJson(actual, "TemplateImageBasic.json")); }
/// <summary> /// Creates the metosat response. /// </summary> /// <param name="infrared">if set to <c>true</c> [infrared].</param> /// <returns></returns> private static SkillResponse CreateResponse(bool infrared) { string text = infrared ? "Ecco le ultime immagini all' infraross dal satellite meteosàt" : "Ecco le ultime immagini dal satellite meteosàt"; SkillResponse response = ResponseBuilder.Tell(text); DisplayRenderTemplateDirective display = new DisplayRenderTemplateDirective(); var bodyTemplate = new ListTemplate2 { Title = "Immagini meteosat", BackButton = "HIDDEN" }; foreach (KeyValuePair <string, string> info in infos) { var image = new TemplateImage() { ContentDescription = $"Vista {info.Key}" }; string url = infrared ? $"https://api.sat24.com/mostrecent/{info.Value}/infraPolair" : $"https://api.sat24.com/mostrecent/{info.Value}/visual5hdcomplete"; image.Sources.Add(new ImageSource() { Url = url, Height = 615, Width = 845, }); ListItem item = new ListItem { Image = image, Content = new TemplateContent { Primary = new TemplateText() { Text = $"{info.Key}", Type = "PlainText" } } }; bodyTemplate.Items.Add(item); } display.Template = bodyTemplate; response.Response.Directives.Add(display); response.Response.ShouldEndSession = false; return(response); }
public void Create_Image() { var actual = new TemplateImage { ContentDescription = ImageDescription, Sources = new List <ImageSource> { new ImageSource { Url = ImageSource, Size = ImageSize.Small, Height = 480, Width = 640 } } }; Assert.True(CompareJson(actual, "TemplateImage.json")); }
private void SetupForConfigured(Template template, Mat tmpImg = null) { //Size = new Size(450, 456); MinimumSize = new Size(500, 456); MainLayoutPanel.RowStyles[1].SizeType = SizeType.Absolute; MainLayoutPanel.RowStyles[1].Height = 58; for (int i = 0; i < configureStatesPanel.RowCount; i++) { configureStatesPanel.RowStyles[i].SizeType = SizeType.Percent; configureStatesPanel.RowStyles[i].Height = i == 0 ? 100 : i == 1 ? 0 : i == 2 ? 0 : i == 3 ? 0 : 0; } if (!curConfigureStatePanel.Controls.Contains(statePanelsPanel)) { curConfigureStatePanel.Controls.Add(statePanelsPanel, 1, 0); } statePanelsPanel.Dock = DockStyle.Fill; statePanelsPanel.Visible = true; var configStatesList = EnumHelper.ToList(typeof(ConfigurationState)); configStatesList.RemoveAt(0); configStatesList.RemoveAt(0); configStatesList.RemoveAt(0); selectStateComboBox.DataSource = configStatesList; selectStateComboBox.DisplayMember = "Value"; selectStateComboBox.ValueMember = "Key"; configureStatesPanel.Visible = true; CurrentStatePanel = LabelStatePanel; TemplateImage = tmpImg == null ? new Image <Gray, byte>(template.GetTemplateImage.GetBitmap ?? SynapseMain.GetSynapseMain.GetCurrentImage()).Mat : tmpImg.ToImage <Gray, byte>().Mat; templateImageCopy = TemplateImage.Clone(); imageBox.Image = TemplateImage.Bitmap; selectedSize = template.GetTemplateImage.Size; selectedScale = template.GetTemplateImage.TemplateScale; selectedDeskewAngle = template.GetTemplateImage.DeskewAngle; referenceTemplate = template; alignmentMethods = new List <Template.AlignmentMethod>(template.TemplateData.GetAlignmentPipeline); }
private TemplateImage VerifyPreconditions() { TemplateImage matchingTemplate = null; Operation op = Operation.Create; if (Resume) { op = Operation.Resume; } if (ParameterSetName == UploadLocalVhd) { VerifySessionIsElevated(); } matchingTemplate = FilterTemplateImage(ImageName, op); return(matchingTemplate); }
public async Task <ActionResult> CreateEmptyTemplate(product product) { const double pixelSize = 37.938105; double width = double.Parse(product.Width) * pixelSize;; double height = double.Parse(product.Height) * pixelSize;; TemplateSerializer TemplateJson = new TemplateSerializer { Width = width, Height = height, Images = new List <TemplateImage>(), TextBlocks = new List <TemplateText>() }; TemplateImage main_image = new TemplateImage { Name = "MainImage", Src = product.PicturePath, Width = width, Height = height, Top = 0, Left = 0, }; TemplateJson.Images.Add(main_image); Template NewTemplate = new Template { ProductId = product.Id, Name = product.Name, UserId = 1, JsonTemplate = JsonSerializer.Serialize <TemplateSerializer>(TemplateJson), DateCreated = DateTime.Now.ToShortDateString(), }; await db.Template.AddAsync(NewTemplate); await db.SaveChangesAsync(); product.TemplateId = NewTemplate.Id; db.product.Update(product); await db.SaveChangesAsync(); return(RedirectToAction("Editor", "Editor", new { templateId = NewTemplate.Id })); }
private void CreateTemplete(object sender, EventArgs e) { HTuple CenterRow = ObjectRoi.GetDrawingObjectParams("row"); HTuple CenterColumn = ObjectRoi.GetDrawingObjectParams("column"); HTuple Phi = ObjectRoi.GetDrawingObjectParams("phi"); HTuple Lenght1 = ObjectRoi.GetDrawingObjectParams("length1"); HTuple Lenght2 = ObjectRoi.GetDrawingObjectParams("length2"); HObject ModelRegion; HOperatorSet.GenEmptyObj(out ModelRegion); HOperatorSet.GenRectangle2(out ModelRegion, CenterRow, CenterColumn, Phi, Lenght1, Lenght2); HObject TemplateImage; HOperatorSet.GenEmptyObj(out TemplateImage); HOperatorSet.ReduceDomain(ho_Image, ModelRegion, out TemplateImage); HTuple hv_ParameterValue = null, hv_ParameterName = null; HOperatorSet.DetermineShapeModelParams(TemplateImage, "auto", 0, (new HTuple(360)).TupleRad(), 0.9, 1.1, "auto", "use_polarity", "auto", "auto", "all", out hv_ParameterName, out hv_ParameterValue); HTuple MinContrast = hv_ParameterValue[7].I.ToString(); HTuple Location_MaxContrast = hv_ParameterValue[5].I.ToString(); HOperatorSet.CreateShapeModel(TemplateImage, 0, 0, (new HTuple(360)).TupleRad(), "auto", "auto", "use_polarity", int.Parse(Location_MaxContrast), int.Parse(MinContrast), out hv_ModelID); if (File.Exists(Directory.GetCurrentDirectory() + @"/Templete.shm")) { File.Delete(Directory.GetCurrentDirectory() + @"/Templete.shm"); HOperatorSet.WriteShapeModel(hv_ModelID, Directory.GetCurrentDirectory() + @"/Templete.shm"); } else { HOperatorSet.WriteShapeModel(hv_ModelID, Directory.GetCurrentDirectory() + @"/Templete.shm"); } ModelRegion.Dispose(); TemplateImage.Dispose(); }
public override void ExecuteCmdlet() { TemplateImageResult response = null; TemplateImageDetails details = null; TemplateImage matchingTemplate = null; matchingTemplate = FilterTemplateImage(ImageName, Operation.Update); details = new TemplateImageDetails() { Id = matchingTemplate.Id, Region = matchingTemplate.RegionList[0], Name = NewName }; response = CallClient(() => Client.TemplateImages.Set(details), Client.TemplateImages); if (response != null) { WriteObject(response.TemplateImage); } }
public static bool ContainsExpectedTemplate(IList <TemplateImage> expectedResult, IList <TemplateImage> templateList) { bool isIdentical = false; IList <TemplateImage> actualResult = new List <TemplateImage>(templateList); foreach (TemplateImage expected in expectedResult) { int i = 0; while (i < actualResult.Count) { bool found = false; TemplateImage actual = actualResult[i]; found = expected.Name == actual.Name; found &= expected.Status == actual.Status; found &= expected.Id == actual.Id; found &= expected.NumberOfLinkedCollections == actual.NumberOfLinkedCollections; found &= expected.Type == actual.Type; if (found) { isIdentical = found; break; } i++; } if (isIdentical && actualResult.Count > 0) { actualResult.RemoveAt(i); } else { return(false); } } return(isIdentical); }
private TemplateImage StartTemplateUpload(TemplateImage image) { TemplateImageResult response = null; TemplateImageDetails details = null; TemplateImage templateImage = null; EnsureStorageInRegion(Location); if (Resume) { templateImage = image; } else { details = new TemplateImageDetails() { Name = ImageName, Region = Location }; response = CallClient_ThrowOnError(() => Client.TemplateImages.Set(details)); templateImage = response.TemplateImage; if (templateImage == null) { throw new RemoteAppServiceException(String.Format( System.Globalization.CultureInfo.InvariantCulture, Commands_RemoteApp.TemplateImageCreationFailedErrorFormat, ImageName, Location) , ErrorCategory.InvalidResult); } } return(templateImage); }
public void CanCreateTemplateImagesSuccessfully() { using (UndoContext context = UndoContext.Current) { context.Start(); string imageName = "my_unit_test_created_templateimage"; string returnedImageName = null; HttpRecorderMode mode = HttpMockServer.GetCurrentMode(); RemoteAppManagementClient client = GetRemoteAppManagementClient(); TemplateImageResult setResponse; AzureOperationResponse deleteResponse; TemplateImageListResult listResponse = null; IList <TemplateImage> imageList; TemplateImage myImage = null; bool foundTestImage = false; string newName = "renamed_my_test_image"; TemplateImageDetails renameDetails = null; TemplateImageDetails newImageDetails = new TemplateImageDetails() { Name = imageName, Region = "West US" }; Assert.DoesNotThrow(() => { setResponse = client.TemplateImages.Set(newImageDetails); }); // now check the list Assert.DoesNotThrow(() => { listResponse = client.TemplateImages.List(); imageList = listResponse.RemoteAppTemplateImageList; foreach (TemplateImage image in imageList) { if ((image.Name == imageName)) { foreach (string region in image.RegionList) { if (region == newImageDetails.Region) { foundTestImage = true; // cleanup returnedImageName = image.Name; myImage = image; break; } } } } }); Assert.True(foundTestImage); Assert.False(string.IsNullOrEmpty(returnedImageName)); Assert.NotNull(myImage); // rename the image renameDetails = new TemplateImageDetails() { Id = myImage.Id, Name = newName, Region = "West US" }; setResponse = null; Assert.DoesNotThrow(() => { setResponse = client.TemplateImages.Set(renameDetails); }); Assert.NotNull(setResponse); Assert.NotNull(setResponse.TemplateImage); Assert.Equal(System.Net.HttpStatusCode.OK, setResponse.StatusCode); // verify that we have an image with the new name TemplateImageResult imageResponse = null; Assert.DoesNotThrow(() => { imageResponse = client.TemplateImages.Get(newName); }); Assert.NotNull(imageResponse); Assert.NotNull(imageResponse.TemplateImage); Assert.Equal(newName, imageResponse.TemplateImage.Name); Assert.True(imageResponse.TemplateImage.RegionList.Contains("West US"), "Unexpected region of the renamed image: " + String.Join(", ", imageResponse.TemplateImage.RegionList)); Assert.DoesNotThrow(() => { deleteResponse = client.TemplateImages.Delete(newName); }); } }
static GodotProjectScopeCategoryUIProvider() { // These get added to a static dictionary, so they can be referenced by name from templates TemplateImage.Register("GodotCSharp", PsiCSharpThemedIcons.Csharp.Id); }
//private Sprite GetSprite(YuLegoDropdownOptionMeta optionMeta) //{ // var spriteId = optionMeta.SpriteId; // if (spriteDict.ContainsKey(spriteId)) // { // return spriteDict[spriteId].GetAsset(); // } // var spRef = AssetModule.GetSprite(spriteId); // spriteDict.Add(spriteId, spRef); // return spRef.GetAsset(); //} #endregion public override void Metamorphose(LegoUIMeta uiMeta) { if (MetamorphoseStage == LegoMetamorphoseStage.Completed) { MetamorphoseStage = LegoMetamorphoseStage.Metamorphosing; } if (dropdownMeta == null) { dropdownMeta = uiMeta.NextDropdown; dropdownRectMeta = uiMeta.CurrentRect; } switch (metamorphoseStatus) { case MetamorphoseStatus.Dropdown: MetamorphoseRect(dropdownRectMeta); // 输入框自身附带Image控件变形 SelfImage.Metamorphose(dropdownMeta.DropdownImageMeta); if (dropdownMeta.Transition == LegoTransition.ColorTint) { var colorTintMeta = dropdownMeta.ColorTintMeta; colors = new ColorBlock { normalColor = colorTintMeta.NormalLegoColor.ToColor(), highlightedColor = colorTintMeta.HighlightedLegoColor.ToColor(), pressedColor = colorTintMeta.PressedLegoColor.ToColor(), disabledColor = colorTintMeta.DisabledLegoColor.ToColor(), colorMultiplier = colorTintMeta.ColorMultiplier, fadeDuration = colorTintMeta.FadeDuration }; } // 选项 if (dropdownMeta.OptionMetas != null && dropdownMeta.OptionMetas.Count > 0) { options.Clear(); foreach (var optionMeta in dropdownMeta.OptionMetas) { var optionData = new OptionData(); optionData.text = optionMeta.Text; // todo 下拉框菜单精灵 //optionData.image = SpriteRouter.GetSprite(optionMeta.SpriteId); options.Add(optionData); } } metamorphoseStatus = MetamorphoseStatus.Label; break; case MetamorphoseStatus.Label: Label.Metamorphose(dropdownMeta.LabelRectMeta, dropdownMeta.LabelTextMeta); metamorphoseStatus = MetamorphoseStatus.Arrow; break; case MetamorphoseStatus.Arrow: Arrow.Metamorphose(dropdownMeta.ArrowRectMeta, dropdownMeta.ArrowImageMeta); metamorphoseStatus = MetamorphoseStatus.Template; break; case MetamorphoseStatus.Template: TemplateImage.Metamorphose(dropdownMeta.TemplateRectMeta, dropdownMeta.TemplateImageMeta); metamorphoseStatus = MetamorphoseStatus.Viewport; break; case MetamorphoseStatus.Viewport: ViewportImage.Metamorphose(dropdownMeta.ViewPortRectMeta, dropdownMeta.ViewPortImageMeta); metamorphoseStatus = MetamorphoseStatus.Content; break; case MetamorphoseStatus.Content: YuLegoUtility.MetamorphoseRect(Content, dropdownMeta.ContentRectMeta); metamorphoseStatus = MetamorphoseStatus.Item; break; case MetamorphoseStatus.Item: if (dropdownMeta.ItemTransition == LegoTransition.ColorTint) { var colorTintMeta = dropdownMeta.ItemRootColorTintMeta; Item.colors = new ColorBlock { normalColor = colorTintMeta.NormalLegoColor.ToColor(), highlightedColor = colorTintMeta.HighlightedLegoColor.ToColor(), pressedColor = colorTintMeta.PressedLegoColor.ToColor(), disabledColor = colorTintMeta.DisabledLegoColor.ToColor(), colorMultiplier = colorTintMeta.ColorMultiplier, fadeDuration = colorTintMeta.FadeDuration }; } YuLegoUtility.MetamorphoseRect(Item.RectTransform, dropdownMeta.ItemRootRectMeta); metamorphoseStatus = MetamorphoseStatus.ItemBackground; break; case MetamorphoseStatus.ItemBackground: ItemBackground.Metamorphose(dropdownMeta.ItemBackgroundRectMeta, dropdownMeta.ItemBackgroundImageMeta); metamorphoseStatus = MetamorphoseStatus.ItemCheckmark; break; case MetamorphoseStatus.ItemCheckmark: ItemCheckmark.Metamorphose(dropdownMeta.ItemCheckmarkRectMeta, dropdownMeta.ItemCheckmarkImageMeta); metamorphoseStatus = MetamorphoseStatus.ItemLabel; break; case MetamorphoseStatus.ItemLabel: ItemLabel.Metamorphose(dropdownMeta.ItemLabelRectMeta, dropdownMeta.ItemLabelTextMeta); metamorphoseStatus = MetamorphoseStatus.Scrollbar; break; case MetamorphoseStatus.Scrollbar: ScrollbarImage.Metamorphose(dropdownMeta.ScrollbarRectMeta, dropdownMeta.ScrollbarImageMeta); metamorphoseStatus = MetamorphoseStatus.SlidingArea; break; case MetamorphoseStatus.SlidingArea: YuLegoUtility.MetamorphoseRect(SlidingArea, dropdownMeta.SlidingAreaRectMeta); metamorphoseStatus = MetamorphoseStatus.Handle; break; case MetamorphoseStatus.Handle: HandleImage.Metamorphose(dropdownMeta.ScrollbarHandleRectMeta, dropdownMeta.ScrollbarHandleImageMeta); dropdownMeta = null; dropdownRectMeta = null; metamorphoseStatus = MetamorphoseStatus.Dropdown; MetamorphoseStage = LegoMetamorphoseStage.Completed; break; default: throw new ArgumentOutOfRangeException(); } }
public static bool ContainsExpectedTemplate(List <TemplateImage> expectedResult, TemplateImage operationResult) { bool isIdentical = false; foreach (TemplateImage expected in expectedResult) { isIdentical = expected.Name == operationResult.Name; isIdentical &= expected.Status == operationResult.Status; isIdentical &= expected.Id == operationResult.Id; isIdentical &= expected.NumberOfLinkedCollections == operationResult.NumberOfLinkedCollections; isIdentical &= expected.Type == operationResult.Type; if (isIdentical) { break; } } return(isIdentical); }
public static int SetUpDefaultRemoteAppTemplates(Mock <IRemoteAppManagementClient> clientMock, string imageName, string id) { TemplateImageListResult response = new TemplateImageListResult() { RequestId = "122-13342", StatusCode = System.Net.HttpStatusCode.Accepted, }; response.RemoteAppTemplateImageList = new List <TemplateImage>() { new TemplateImage() { Name = imageName, Status = TemplateImageStatus.Ready, Id = id, NumberOfLinkedCollections = 2, Type = TemplateImageType.PlatformImage, RegionList = new List <string>() { "West US" } }, new TemplateImage() { Name = "a", Status = TemplateImageStatus.Ready, Id = "2222", NumberOfLinkedCollections = 2, Type = TemplateImageType.PlatformImage, RegionList = new List <string>() { "West US" } }, new TemplateImage() { Name = "ztestImage", Status = TemplateImageStatus.Ready, Id = "4444", NumberOfLinkedCollections = 2, Type = TemplateImageType.CustomerImage, RegionList = new List <string>() { "West US" } }, new TemplateImage() { Name = "atestImage", Status = TemplateImageStatus.Ready, Id = "3333", NumberOfLinkedCollections = 1, Type = TemplateImageType.CustomerImage, RegionList = new List <string>() { "West US" } } }; mockTemplates = new List <TemplateImage>(); foreach (TemplateImage image in response.RemoteAppTemplateImageList) { TemplateImage mockImage = new TemplateImage() { Name = image.Name, Status = image.Status, Id = image.Id, NumberOfLinkedCollections = image.NumberOfLinkedCollections, Type = image.Type, RegionList = image.RegionList }; mockTemplates.Add(mockImage); } ISetup <IRemoteAppManagementClient, Task <TemplateImageListResult> > Setup = clientMock.Setup(c => c.TemplateImages.ListAsync(It.IsAny <CancellationToken>())); Setup.Returns(Task.Factory.StartNew(() => response)); return(mockTemplates.Count); }
public void TestTemplateImage() { var homeShareTemplate = new TemplateImage( "F:\\Projects\\StockForecast\\StockForecast\\StockForecast.Web\\uploads\\share\\homeshare.png"); var t = homeShareTemplate.Generate(new TemplateItemBase[] { new StringTemplateItem() //日期 { Location = new Point(136, 191), Font = new Font("Songti SC", 27, FontStyle.Bold, GraphicsUnit.Pixel), Color = Color.FromArgb(0x8e, 0x1a, 0x22), Value = DateTime.Now.ToString("yyyy.MM.dd") }, new StringTemplateItem() //农历 { Location = new Point(276, 287), MaxWidth = 15, Font = new Font("Songti SC", 16, FontStyle.Bold, GraphicsUnit.Pixel), Color = Color.FromArgb(0x8e, 0x1a, 0x22), Value = "九月初六" }, new StringTemplateItem() //星期 { Location = new Point(300, 293), MaxWidth = 15, Font = new Font("Songti SC", 12, FontStyle.Bold, GraphicsUnit.Pixel), Color = Color.FromArgb(0x8e, 0x1a, 0x22), Value = "星期一" }, new ImageTemplateItem() //图片 { Image = (Bitmap)Bitmap.FromFile( "F:\\Projects\\StockForecast\\StockForecast\\StockForecast.Web\\uploads\\weather\\202012\\202012130334171296129.png"), Location = new Point(122, 229), Size = new Size(132, 133) }, new StringTemplateItem() { Location = new Point(129, 378), MaxWidth = 125, Font = new Font("Kaiti SC", 14, FontStyle.Bold, GraphicsUnit.Pixel), Color = Color.FromArgb(0x17, 0x14, 0x0e), Value = "sdflsdjfslfjsldfjslfjsldf" }, new StringTemplateItem() //宜 { Location = new Point(82, 415), Color = Color.FromArgb(0x8f, 0x1A, 0x22), Font = new Font("Songti SC", 20, FontStyle.Bold, GraphicsUnit.Pixel), MaxWidth = 14, Value = "满仓" }, new StringTemplateItem() //忌 { Location = new Point(274, 415), Color = Color.FromArgb(0x8f, 0x1A, 0x22), Font = new Font("Songti SC", 20, FontStyle.Bold, GraphicsUnit.Pixel), MaxWidth = 14, Value = "不购入" }, new QrCodeTemplateItem() //二维码 { Location = new Point(229, 542), Size = new Size(73, 72), QrCode = "http://ssssss.com/sdfsdfsdfs/sss" } }); }
protected TemplateImage FilterTemplateImage(string TemplateImageName, Operation op) { TemplateImageListResult response = null; TemplateImage matchingTemplate = null; string errorMessage = null; ErrorCategory category = ErrorCategory.NotSpecified; response = CallClient_ThrowOnError(() => Client.TemplateImages.List()); foreach (TemplateImage template in response.RemoteAppTemplateImageList) { if (String.Equals(template.Name, TemplateImageName, StringComparison.OrdinalIgnoreCase)) { matchingTemplate = template; break; } } switch (op) { case Operation.Remove: case Operation.Update: { if (matchingTemplate == null) { errorMessage = String.Format("Template {0} does not exist.", TemplateImageName); category = ErrorCategory.ObjectNotFound; } break; } case Operation.Create: { if (matchingTemplate != null) { errorMessage = String.Format("There is an existing template named {0}.", TemplateImageName); category = ErrorCategory.ResourceExists; } break; } case Operation.Resume: { if (matchingTemplate == null) { errorMessage = String.Format("Template {0} does not exist.", TemplateImageName); category = ErrorCategory.ObjectNotFound; } else if (matchingTemplate.Status != TemplateImageStatus.UploadPending && matchingTemplate.Status != TemplateImageStatus.UploadInProgress) { errorMessage = String.Format( "Unable to resume uploading this template {0}." + "It is in the wrong state {1}, it should be either UploadPending or UploadInProgress", matchingTemplate.Name, matchingTemplate.Status.ToString()); category = ErrorCategory.InvalidOperation; } else if (DateTime.UtcNow >= matchingTemplate.SasExpiry) { errorMessage = String.Format( "Unable to resume uploading this template {0}. The time limit has expired at {1}", matchingTemplate.Name, matchingTemplate.SasExpiry.ToString()); category = ErrorCategory.InvalidOperation; } break; } } if (errorMessage != null) { throw new RemoteAppServiceException(errorMessage, category); } return(matchingTemplate); }
public bool IsWithinUserCurrentCell(Point location) => CurrentCell == 0 ? false : CurrentCell == TemplateImage.GetCorrespondingCellId(location);