コード例 #1
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            string source = this.ServerProperties["Source"].ToString();

            if (String.IsNullOrEmpty(this.ItemID) ||
                String.IsNullOrEmpty(source) ||
                !source.StartsWith(ImageSourceHelper.SITE_SOURCE_PREFIX))
            {
                return;
            }

            this.SetSource(String.Empty);
            Sitecore.Data.Items.Item current = Sitecore.Context.ContentDatabase.GetItem(this.ItemID);

            if (current == null)
            {
                return;
            }

            source = ImageSourceHelper.GetSiteMediaPath(current);

            if (source == null)
            {
                return;
            }

            this.SetSource(source);
        }
コード例 #2
0
 private static MainMenuItem GenerateSettingsItem()
 {
     return(new MainMenuItem()
     {
         Title = "Settings",
         Page = new SettingsPage(),
         IconImageSource = ImageSourceHelper.GenerateFontImageSource("FontAwesomeSolid", ""),
     });
 }
コード例 #3
0
        private void SubmitPokemonName_Click(object sender, RoutedEventArgs e)
        {
            var pokeApi           = new PokemonApiCaller();
            var imageSourceHelper = new ImageSourceHelper();

            var pokemonJson       = pokeApi.GetPokemonJson(pokemonNameTxtBox.Text);
            var bitmap            = pokeApi.GetPokemonPic(pokemonJson);
            var bitmapImageSource = imageSourceHelper.BitmapToImageSource(bitmap);

            var pokemonDescription = pokeApi.GetPokemonDescription(pokemonJson);

            pokemonFrontImage.Source = bitmapImageSource;
            pokemonNameLabel.Content = pokemonDescription;
        }
コード例 #4
0
        private void HyperlinkBrowse_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog()
            {
                Filter = "가능한 모든 파일(*.jpg;*.png)|*.jpg;*.png"
            };

            if (ofd.ShowDialog() == false)
            {
                return;
            }

            BitmapSource bitmapSource = ImageSourceHelper.GetImageFromFile(ofd.FileName);

            SetThumbnailImage((sender as Hyperlink).DataContext as UploadQueueItem, bitmapSource);
        }
コード例 #5
0
 private static List <MainMenuItem> GenerateMenuItems()
 {
     return(new List <MainMenuItem>()
     {
         new MainMenuItem()
         {
             Title = "Uploads",
             Page = new UploadPage(),
             IconImageSource = ImageSourceHelper.GenerateFontImageSource("FontAwesomeSolid", ""),
         },
         new MainMenuItem()
         {
             Title = "Gallery",
             Page = new ImageGalleryPage(),
             IconImageSource = ImageSourceHelper.GenerateFontImageSource("FontAwesomeSolid", ""),
         },
     });
 }
コード例 #6
0
 public TaskbarServicesViewModel()
 {
     OverlayIcons = new NamedIcon[] {
         new NamedIcon()
         {
             Caption = "Moon",
             Icon    = ImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(TaskbarServices).Assembly, "Images/Moon.png"))
         },
         new NamedIcon()
         {
             Caption = "Sun",
             Icon    = ImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(TaskbarServices).Assembly, "Images/Sun.png"))
         }
     };
     ProgressStatesNames = Enum.GetNames(typeof(TaskbarItemProgressState));
     ButtonProperties    = new ObservableCollection <bool> {
         true, true, true, false, true
     };
     ButtonProperties.CollectionChanged += ButtonPropertyChanged;
 }
コード例 #7
0
 public NewJumpTaskWindowViewModel()
 {
     Icons = new NamedIcon[] {
         new NamedIcon()
         {
             Caption = "Moon",
             Icon    = ImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(NewJumpTaskWindowViewModel).Assembly, "Images/Moon.png"))
         },
         new NamedIcon()
         {
             Caption = "Sun",
             Icon    = ImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(NewJumpTaskWindowViewModel).Assembly, "Images/Sun.png"))
         }
     };
     CustomCategory = "";
     Title          = "Title";
     Description    = "";
     MessageText    = "Message";
     Icon           = Icons.ElementAt(0);
 }
コード例 #8
0
 protected virtual void OnThumbButtonsCreateChanged()
 {
     if (ThumbButtonsCreate)
     {
         TaskbarButtonService.ThumbButtonInfos.Add(new TaskbarThumbButtonInfo {
             Description = "Zoom out",
             ImageSource = ImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(TaskbarServices).Assembly, "/Images/TaskbarScreenshots/ZoomOut_32x32.png")),
             Action      = () => DecreaseThumbnailClipMarginMultipliyer()
         });
         TaskbarButtonService.ThumbButtonInfos.Add(new TaskbarThumbButtonInfo {
             Description = "Zoom in",
             ImageSource = ImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(TaskbarServices).Assembly, "/Images/TaskbarScreenshots/ZoomIn_32x32.png")),
             Action      = () => IncreaseThumbnailClipMarginMultipliyer()
         });
         SetButtonsProperties();
     }
     else
     {
         TaskbarButtonService.ThumbButtonInfos.Clear();
     }
 }
コード例 #9
0
        public object Convert(object value, Type targetType,
                              object parameter, CultureInfo culture)
        {
            var v = value.ToString();
            var l = LocaleHelper.GetLangForCountry2(v);

            //Langs l = (Langs)Enum.Parse(typeof(Langs), lang);

            if (l.HasValue)
            {
                Bitmap bmp = null;

                switch (l.Value)
                {
                case Langs.cs:
                    bmp = Resources.cz;
                    break;

                case Langs.en:
                    bmp = Resources.gb;
                    break;

                default:
                    break;
                }

                if (bmp != null)
                {
                    return(ImageSourceHelper.ImageSourceFromBitmap2(bmp));
                }
            }

            ThrowExceptions.NotImplementedCase(Exc.GetStackTrace(), type, Exc.CallingMethod(), SH.NullToStringOrDefault(l));
            return(null);

            //string urImage = AppDomain.CurrentDomain.BaseDirectory + "Images\\Countries\\"+ value.ToString() + ".png";
            //return urImage;
        }
コード例 #10
0
        public WeightPageForCombinationViewModel(string combination)
        {
            NumberOfAxles = combination.Split(',')
                            .Select((a) => Convert.ToInt32(a))
                            .ToList();

            string imageFile = combination.Replace(',', '_') + ".png";

            ImageSource = ImageSourceHelper.GetFromResource(imageFile);

            PsiTableTruck          = DictionaryToList(_psiTableTruckBase);
            PsiTableTrailerGeneric = DictionaryToList(_psiTableTrailerGenericBase);

            SelectedIndexA = ApplicationPropertiesHelper.GetProperty(nameof(SelectedIndexA), -1);
            SelectedIndexB = ApplicationPropertiesHelper.GetProperty(nameof(SelectedIndexB), -1);
            SelectedIndexC = ApplicationPropertiesHelper.GetProperty(nameof(SelectedIndexC), -1);
            SelectedIndexD = ApplicationPropertiesHelper.GetProperty(nameof(SelectedIndexD), -1);

            HelpCommand = new Command(async() => {
                await Commons.DisplayAlert(AppResources.WeightHelpTitle, AppResources.WeightHelpMessage, "Ok");
            });

            MaxLegalWeight = (NumberOfAxles[2] > 0) ? 67500 : 5500 + GetMaxWeightForAxle(NumberOfAxles[0]) + GetMaxWeightForAxle(NumberOfAxles[1]);
        }
コード例 #11
0
        protected new static void Run(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Item itemNotNull = Client.GetItemNotNull(args.Parameters["itemid"]);

            itemNotNull.Fields.ReadAll();
            Field field = itemNotNull.Fields[args.Parameters["fieldid"]];

            Assert.IsNotNull(field, "field");
            ImageField imageField = new ImageField(field, field.Value);
            string     controlid  = args.Parameters["controlid"];

            if (args.IsPostBack)
            {
                if (args.Result != "undefined")
                {
                    string rawValue;

                    if (!string.IsNullOrEmpty(args.Result))
                    {
                        MediaItem item = Client.ContentDatabase.Items[args.Result];

                        if (item != null)
                        {
                            MediaUrlOptions mediaOptions = new MediaUrlOptions();
                            string          mediaUrl     = MediaManager.GetMediaUrl(item, mediaOptions);
                            imageField.SetAttribute("mediaid", item.ID.ToString());
                            imageField.SetAttribute("mediapath", item.MediaPath);
                            imageField.SetAttribute("src", mediaUrl);

                            if (!string.IsNullOrEmpty(args.Parameters["fieldValue"]))
                            {
                                XmlValue xmlValue = new XmlValue(args.Parameters["fieldValue"], "image");
                                string   height   = xmlValue.GetAttribute("height");

                                if (!String.IsNullOrEmpty(height))
                                {
                                    imageField.Height = height;
                                }

                                string width = xmlValue.GetAttribute("width");

                                if (!String.IsNullOrEmpty(width))
                                {
                                    imageField.Width = width;
                                }
                            }
                        }
                        else
                        {
                            SheerResponse.Alert("Item not found.", new string[0]);
                        }

                        rawValue = imageField.Value;
                    }
                    else
                    {
                        rawValue = string.Empty;
                    }

                    string markup = WebEditImageCommand.RenderImage(args, rawValue);
                    SheerResponse.SetAttribute("scHtmlValue", "value", markup);
                    SheerResponse.SetAttribute("scPlainValue", "value", rawValue);
                    SheerResponse.Eval("scSetHtmlValue('" + rawValue + "')");
                }
            }
            else
            {
                string text = StringUtil.GetString(new string[] { field.Source, ImageSourceHelper.MEDIA_ROOT });

                if (text.StartsWith(ImageSourceHelper.SITE_SOURCE_PREFIX))
                {
                    string path = ImageSourceHelper.GetSiteMediaPath(itemNotNull);

                    if (path != null)
                    {
                        text = path;
                    }
                }

                string mediaid = imageField.GetAttribute("mediaid");

                if (text.StartsWith("~"))
                {
                    if (string.IsNullOrEmpty(mediaid))
                    {
                        mediaid = StringUtil.Mid(text, 1);
                    }

                    text = ImageSourceHelper.MEDIA_ROOT;
                }

                Language            language     = itemNotNull.Language;
                MediaBrowserOptions mediaOptions = new MediaBrowserOptions();
                Item item3 = Client.ContentDatabase.GetItem(text, language);

                if (item3 == null)
                {
                    throw new ClientAlertException("The source of this Image field points to an item that does not exist.");
                }

                mediaOptions.Root       = item3;
                mediaOptions.AllowEmpty = true;

                if (!string.IsNullOrEmpty(mediaid))
                {
                    Item selected = Client.ContentDatabase.GetItem(mediaid, language);

                    if (selected != null)
                    {
                        mediaOptions.SelectedItem = selected;
                    }
                }

                SheerResponse.ShowModalDialog(mediaOptions.ToUrlString().ToString(), true);
                args.WaitForPostBack();
            }
        }
コード例 #12
0
ファイル: Helpers.cs プロジェクト: jannisk/VideoRent
        static ImageSource GetImageSource(string imageName)
        {
            Assembly assembly = typeof(DevExpress.VideoRent.Resources.ImagesHelper).Assembly;

            return(ImageSourceHelper.CreateImageFromEmbeddedResource(assembly, string.Format("AboutPage/{0}.png", imageName), true));
        }
コード例 #13
0
 public void SetIcon(string icon)
 {
     //一定要把image文件加入到工程中
     Icon = ImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(ModuleMenu).Assembly, string.Format("Images/{0}", icon)));
 }
コード例 #14
0
        private void HyperlinkClipboard_Click(object sender, RoutedEventArgs e)
        {
            BitmapSource bitmapSource = ImageSourceHelper.GetClipboardImage();

            SetThumbnailImage((sender as Hyperlink).DataContext as UploadQueueItem, bitmapSource);
        }