public static Image GetPngFromExtension(string ext, IconSizes size) { ext = ext.Replace("*", "").Replace(".", ""); //clean the param up. var hIcon = GetIcon(GetIconIndex("*." + ext), size); Image result = null; // from native to managed try { using var ico = (Icon)Icon.FromHandle(hIcon).Clone(); // save to stream to convert to png, then back. using var stream = new MemoryStream(); ico.ToBitmap().Save(stream, ImageFormat.Png); result = Image.FromStream(stream); } catch (Exception e) { Globals.WriteToLog("Failed to get PNG from extension", e); return(null); } finally { NativeMethods.DestroyIcon(hIcon); // don't forget to cleanup } return(result); }
static IntPtr GetIcon(int iImage, IconSizes size) { IImageList spiml = null; var guil = new Guid(IID_IImageList2);//or IID_IImageList NativeMethods.SHGetImageList((int)size, ref guil, ref spiml); var hIcon = IntPtr.Zero; spiml.GetIcon(iImage, NativeMethods.ILD_TRANSPARENT | NativeMethods.ILD_IMAGE, ref hIcon); return(hIcon); }
public int getIcon(IconSizes size, object item) { if (item == null) return 0; Type type = item.GetType(); if (type == typeof(Type)) { type = item as Type; } if (type.IsSubclassOf(typeof(ExplorerItem))) { if (item is ItemLibrary) return 0; if (item is ItemCategory) return 1; if (item is ItemPuzzle) return 0; } if (item is SokoSolve.Core.Model.Library) return 0; if (item is SokoSolve.Core.Model.Category) return 1; if (item is SokoSolve.Core.Model.Solution) return 3; if (item is SokoSolve.Core.Model.PuzzleMap) return 2; if (item is SokoSolve.Core.Model.Puzzle) { return 2; //if (size == IconSizes.Small) return 2; //Puzzle puz = item as Puzzle; //if (puz.MasterMap != null) //{ // if (cache.ContainsKey(puz.MasterMap.Map)) // { // return cache[puz.MasterMap.Map]; // } // else // { // // Create // thumbnail.Images.Add(this.images.DrawColours(puz.MasterMap.Map)); // int idx = thumbnail.Images.Count - 1; // cache.Add(puz.MasterMap.Map, idx); // return idx; // } //} } return 0; }
/// <summary> /// Returns a Image from a file system path /// </summary> /// <param name="path">The path can be a fully qualified path name, non-existent file, or file extension</param> /// <param name="size">The size of the bitmap to return</param> /// <param name="style">The style of the bitmap to retrieve</param> /// <param name="attributes">Extra attributes to specify for the path</param> /// <returns></returns> public static Image GetImageFromPath(string path, IconSizes size, IconStyles style, FileAttributes attributes) { SHFILEINFO shfi = new SHFILEINFO(); uint uFlags = SHGFI_ICON; uFlags |= (uint)size; uFlags |= (uint)style; if (attributes != 0) { uFlags |= SHGFI_USEFILEATTRIBUTES; } SHGetFileInfo(path, (int)attributes, ref shfi, (uint)Marshal.SizeOf(shfi), uFlags); Image image = (Image)Bitmap.FromHicon(shfi.hIcon).Clone(); DeleteObject(shfi.hIcon); return(image); }
protected override void Context() { base.Context(); _availbleIconSizes = IconSizes.All(); }
public static void SetIconSize(DependencyObject o, IconSizes value) { Contract.Requires(o != null); o.SetValue(IconSizeProperty, value); }
private void btnSave_Click(object sender, EventArgs ergs) { if ( Utility.IsNetworkAvailable && (ComboBoxAutoShortUrlFirst.SelectedIndex == (int)UrlConvertorKind.Bitly || ComboBoxAutoShortUrlFirst.SelectedIndex == (int)UrlConvertorKind.Jmp) && ( !string.IsNullOrEmpty( TextBitlyId.Text ) || !string.IsNullOrEmpty( TextBitlyPw.Text ) ) ) { if ( !BitlyValidation( TextBitlyId.Text, TextBitlyPw.Text ) ) { MessageBox.Show( Tween.Properties.Resources.SettingSave_ClickText1, "" ); this.validation_error_ = true; this.TreeViewSetting.SelectedNode.Name = "TweetActNode"; // 動作タブを選択します。 TextBitlyId.Focus(); return ; } else this.validation_error_ = false; } else this.validation_error_ = false; this.user_accounts_.Clear(); foreach ( object item in AuthUserCombo.Items ) { this.user_accounts_.Add( item as UserAccount ); } if ( AuthUserCombo.SelectedIndex > -1 ) { foreach ( UserAccount account in this.user_accounts_ ) { if ( account.Username.ToLower() == ((UserAccount)AuthUserCombo.SelectedItem).Username.ToLower() ) { //this.twitter_analysis_.Initialize( account.Token, account.TokenSecret, account.Username, accoun.UserId ); this.twitter_analysis_ = new Twitter( account.Token, account.TokenSecret, account.Username, account.UserId ); if ( account.UserId == 0 ) { this.twitter_analysis_.VerifyCredentiials(); account.UserId = this.twitter_analysis_.UserId; } Google.GASender.Instance.SessionFirst = account.GAFirst; Google.GASender.Instance.SessionLast = account.GaLast; } } } else { this.twitter_analysis_.ClearAuthInfo(); this.twitter_analysis_ = new Twitter( string.Empty, string.Empty, string.Empty, 0 ); } #if UA == true if ( FollowCheckBox.Checked ) { ProxyType proxy_type; if ( proxyNoneRadioButton.Checked ) proxy_type = ProxyType.None; else if ( proxyIERadioButton.Checked ) proxy_type = ProxyType.IE; else proxy_type = ProxyType.Specified; string proxy_address = proxyAddressEntry.Text.Trim(); int proxy_port = int.Parse( proxyPortEntry.Text.Trim() ); string proxy_username = proxyUserEntry.Text.Trim(); string proxy_password = proxyPasswordEntry.Text.Trim(); HttpConnection.InitializeConnection( 20, proxy_type, proxy_address, proxy_port, proxy_username, proxy_password ); string ret = this.twitter_analysis_.PostFollowCommand( "Tween4csApp" ); } #endif IntervalChangedEventArgs arg; bool is_interval_changed = false; try { this.userstream_startup_ = this.startupUserstreamCheckBox.Checked; if ( this.userstream_period_ != Convert.ToInt32( UserstreamPeriod.Text ) ) { this.userstream_period_ = Convert.ToInt32( UserstreamPeriod.Text ); arg.UserStream = true; is_interval_changed = true; } if ( this.timeline_period_ != Convert.ToInt32( timelinePeriodEntry.Text ) ) { this.timeline_period_ = Convert.ToInt32( timelinePeriodEntry.Text ); arg.Timeline = true; is_interval_changed = true; } if ( this.directmessage_period_ != Convert.ToInt32( directMessagePeriodEntry.Text ) ) { this.directmessage_period_ = Convert.ToInt32( directMessagePeriodEntry.Text ); arg.DirectMessage = true; is_interval_changed = true; } if ( this.pulic_search_period_ != Convert.ToInt32( pubSearchPeriodEntry.Text ) ) { this.pulic_search_period_ = Convert.ToInt32( pubSearchPeriodEntry.Text ); arg.PublicSearch = true; is_interval_changed = true; } if ( this.lists_period_ != Convert.ToInt32( ListsPeriod.Text ) ) { this.lists_period_ = Convert.ToInt32( ListsPeriod.Text ); arg.Lists = true; is_interval_changed = true; } if ( this.user_timeline_period_ != Convert.ToInt32( UserTimelinePeriod ) ) { this.user_timeline_period_ = Convert.ToInt32( UserTimelinePeriod ); arg.UserTimeline = true; is_interval_changed = true; } if ( is_interval_changed ) IntervalChanged( this, arg ); this.readed_ = StartupUserstreamCheck.Checked; switch ( IconSize.SelectedIndex ) { case 0: this.icon_size_ = IconSizes.IconNone; break; case 1: this.icon_size_ = IconSizes.Icon16; break; case 2: this.icon_size_ = IconSizes.Icon24; break; case 3: this.icon_size_ = IconSizes.Icon48; break; case 4: this.icon_size_ = IconSizes.Icon48_2; break; } this.status_text_ = statusEntry.Text; this.play_sound_ = playSndCheckBox.Checked; this.unread_manage_ = unreadMngCheckBox.Checked; this.one_way_love_ = oneWayLvCheckBox.Checked; if ( this.font_book_ == null ) this.font_book_ = new Dictionary<string, Font>(); if ( this.color_book_ == null ) this.color_book_ = new Dictionary<string, Color>(); this.font_book_.Add( "unread", unreadLabel.Font ); // 未使用です。 this.color_book_.Add( "unread", unreadLabel.ForeColor ); this.font_book_.Add( "readed", listFontButton.Font ); this.color_book_.Add( "readed", listFontButton.ForeColor ); this.color_book_.Add( "retweet", lblReTweet.ForeColor ); this.color_book_.Add( "favorite", favoriteLabel.ForeColor ); this.color_book_.Add( "owl", lblOwl.ForeColor ); this.font_book_.Add( "detail", detailLabel.Font ); this.color_book_.Add( "detail_back", detailBackcolorLabel.BackColor ); this.color_book_.Add( "detail_link", detailLinkLabel.ForeColor ); this.color_book_.Add( "self", lblSelf.BackColor ); this.color_book_.Add( "at_self", lblAtSelf.BackColor ); this.color_book_.Add( "at_from_target", lblAtFromTarget.backColor ); this.color_book_.Add( "at_to", lblAtTo.BackColor ); this.color_book_.Add( "list_back", lblListBackcolor.BackColor ); this.font_book_.Add( "input_font", lblInputFont.ForeColor ); this.color_book_.Add( "input_back", lblInputBackcolor.BackColor ); this.color_book_.Add( "input_font", lblInputFont.ForeColor ); switch ( nameBalloonComboBox.SelectedIndex ) { case 0: this.name_balloon_ = NameBalloons.None; break; case 1: this.name_balloon_ = NameBalloons.UserID; break; case 2: this.name_balloon_ = NameBalloons.NickName; break; } switch ( postKeySelectComboBox.SelectedIndex ) { case 2: this.post_shift_enter_ = true; this.post_ctrl_enter_ = false; break; case 1: this.post_shift_enter_ = false; this.post_ctrl_enter_ = true; break; case 0: this.post_shift_enter_ = false; this.post_ctrl_enter_ = false; break; } this.use_post_method_ = false; this.count_api_ = Convert.ToInt32( countApiEntry.Text ); this.count_api_reply_ = Convert.ToInt32( countApiEntry.Text ); this.browser_path_ = browserPathEntry.Text.Trim(); this.post_and_get_ = postAndGetCheckBox.Checked; this.use_recommend_status_ = useRecommendStatusCheckBox.Checked; this.display_user_name_ = dispUsernameCheckBox.Checked; this.close_to_exit_ = closeToExitCheckBox.Checked; this.minimize_to_tray_ = minimizeToTrayCheckBox.Checked; switch ( ComboDispTile.SelectedIndex ) { case 0: this.display_latest_post_ = DisplayTitleKind.None; break; case 1: this.display_latest_post_ = DisplayTitleKind.Version; break; case 2: this.display_latest_post_ = DisplayTitleKind.Post; break; case 3: this.display_latest_post_ = DisplayTitleKind.UnreadReplyCount; break; case 4: this.display_latest_post_ = DisplayTitleKind.UnreadAllCount; break; case 5: this.display_latest_post_ = DisplayTitleKind.UnreadAllReplyCount; break; case 6: this.display_latest_post_ = DisplayTitleKind.UnreadAllCount; break; case 7: this.display_latest_post_ = DisplayTitleKind.OwnStatus; break; } this.sort_order_lock_ = sortOrderLockCheckBox.Checked; this.tiny_url_resolve_ = tinyUrlCheckBox.Checked; this.short_url_force_resolve_ = this.tiny_url_resolve_; ShortUrl.IsResolve = this.tiny_url_resolve_; ShortUrl.IsForceResolve = this.short_url_force_resolve_; if ( RadioProcyNone.Checked ) this.proxy_type_ = ProxyType.None; else if ( proxyIERadioButton.Checked ) this.proxy_type_ = ProxyType.IE; else this.proxy_type_ = ProxyType.Specified; this.proxy_address_ = proxyAddressEntry.Text.Trim(); this.proxy_port_ = int.Parse( proxyPortEntry.Text.Trim() ); this.proxy_user_ = proxyUserEntry.Text.Trim(); this.proxy_password_ = proxyPasswordEntry.Text.Trim(); this.period_adjust_ = CheeckPeriodAdjust.Checked; this.startup_version_ = startupVersionCheckBox.Checked; this.startup_followers_ = startupFollowersCheckBox.Checked; this.restrict_favorite_check_ = favRestrictCheckBox.Checked; this.always_top_ = alwaysTopCheckBox.Checked; this.url_convert_auto_ = autoConvertUrlCheckBox.Checked; this.shorten_tco_ = ShortenTcoCheck.Checked; this.outputz_ = CheckeOutputz.Checked; this.outputz_key = outputzKeyEntry.Text.Trim(); switch ( outputzUrlmodeComboBox.SelectedIndex ) { case 0: this.outputz_url_mode_ = OutputzUrlMode.TwitterCom; break; case 1: this.outputz_url_mode_ = OutputzUrlMode.TwitterComWithUsername; break; } this.nicoms_ = nicomsCheckBox.Checked; this.unread_style_ = unreadStyleCheckBox.Checked; this.datetime_format_ = dateTimeFormatComboBox.Text; this.default_timeout_ = Convert.ToInt32( connectionTimeOutEntry.Text ); this.retweet_no_confirm_ = retweetNoConfirmCheckBox.Checked; this.limit_balloon_ = balloonLimitCheckBox.Checked; this.event_notify_enabled_ = eventNotifyCheckBox.Checked; GetEventNotifyFlag( this.event_notify_flag_, this.is_event_notify_flag_ ); this.force_event_unread_ = favEventUnreadCheckBox.Checked; this.translate_language_ = new Bing.GetLanguageEnumFromIndex( translateLanguageComboBox.SelectedIndex ); this.event_sound_file_ = eventNotifySoundComboBox.SelectedItem.ToString(); this.auto_short_url_first_ = ComboBoxAutoShortUrlFirst.SelectedIndex as UrlConvertorKind; this.tab_icon_display_ = tabIconDispCheckBox.Checked; this.read_own_post_ = readOwnPostCheckBox.Checked; this.get_favorite_ = getFavoriteCheckBox.Checked; this.mono_space_ = monospaceCheckBox.Checked; this.read_old_posts_ = readOldPostsCheckBox.Checked; this.use_ssl_ = useSslCheckBox.Checked; this.bitly_id_ = TextBitlyId.Text; this.bitly_password_ = TextBitlyPw.Text; this.show_grid_ = showGridCheckBox.Checked; this.use_at_id_supplement_ = atIdSuppleCheckBox.Checked; this.use_hash_supplement_ = hashSuppleCheckBox.Checked; this.preview_enable_ = previewEnableCheckBox.Checked; this.twitter_api_url_ = TwitterApiUrl.Text.Trim(); this.twitter_search_api_url_ = TwitterSearchApiUrl.Text.Trim(); switch ( ComboReplyIconState.SelectedIndex ) { case 0: this.reply_icon_state_ = ReplyIconState.None; break; case 1: this.reply_icon_state_ = ReplyIconState.StaticIcon; break; case 2: this.reply_icon_state_ = ReplyIconState.BlinkIcon; break; } switch ( LanguageComboSelectedIndex ) { case 0: this.language_ = "OS"; break; case 1: this.language_ = "ja"; break; case 2: this.language_ = "en"; break; case 3: this.language_ = "zh-CN"; break; default: this.language_ = "en"; break; } this.hotkey_enabled_ = CheckHotKey.Checked; this.hotkey_mod_ = Keys.None; if ( hotkeyAltCheckBox.Checked ) this.hotkey_mod_ = this.hotkey_mod_ | Keys.Alt; if ( hotkeyShiftCheckBox.Checked ) this.hotkey_mod_ = this.hotkey_mod_ | Keys.Shift; if ( hotkeyCtrlCheckBox.Checked ) this.hotkey_mod_ = this.hotkey_mod_ | Keys.Control; if ( hotkeyWinCheckBox.Checked ) this.hotkey_mod_ = this.hotkey_mod_ | Keys.LWin; int temp = 0; if ( int.TryParse( hotkeyCodeLabel.Text ) ) this.hotkey_value_ = Convert.ToInt32( hotkeyCodeLabel.Text ); this.hotkey_key_ = (Keys)HotkeyEntry.Tag; this.blink_new_mentions_ = CheckNewMentionsBlink.Checked; this.use_additonal_count_ = useChangeGetCountCheckBox.Checked; this.more_count_api_ = Convert.ToInt32( getMoreTextCountApiEntry.Text ); this.first_count_api_ = Convert.ToInt32( firstTextCountApiEntry.Text ); this.search_count_api_ = Convert.ToInt32( SearchTextCuntApi.Text ); this.favorites_count_api_ = Convert.ToInt32( favoritesTextCountApiEntry.Text ); this.user_timelinee_count_api_ = Convert.ToInt32( UserTimeelineTextCountApi.Text ); this.list_count_api_ = Convert.ToInt32( ListOpenuserTimeline.Checked ); this.open_user_timeline_ = CheckOpenu8serTimeline.Checked; this.double_click_action_ = listDoubleClickActionComboBox.SelectedIndex; this.user_appoint_url_ = UserAppointUrlText.Text; this.HideDuplicatedRetweets = HideDuplicatedRetweetsCheck.Checked; this.is_preview_foursquare_ = IsPreviewFoursquareCheckBox.Checked; this.FoursquarePreviewWidth = Convert.ToInt32( FoursquarePreviewWidthTextBox.Text ); this.FoursquarePreviewHeight = Convert.ToInt32( FoursquarePreviewHeightTextBox.Text ); this.FoursquarePreviewZoom = Convert.ToInt32( FoursquarePreviewZoomTextBox.Text ); this.is_list_statuses_include_retweets_ = IsListsIncludeRtsCheckBox.Checked; this.TabMouseLock = TabMouseLockCheck.Checked; this.is_remove_same_event_ = IsRemoveSameFavEventCheckBox.Checked; this.is_notify_use_growl_ = IsNotigyUseGrowlCheckBox.Checked; } catch ( Exception e ) { MessageBox.Show( Resurces["Save_ClickText3"] ); base.DialogResult = DialogResult.Cancel; return ; } }
public override object ConvertFrom(string attributeValue, SerializationContext context) { return(IconSizes.ById(attributeValue)); }
public static void SetIconSize(DependencyObject o, IconSizes value) { Contract.Requires(o != null); o.SetValue(IconSizeProperty, value); }
/// <summary> /// Initializes a new instance of the ShellImageListManager class /// </summary> public ShellImageListManager() { _extensions = new Hashtable(); _size = IconSizes.ShellIconSize; _style = IconStyles.NormalIconStyle; }
/// <summary> /// Returns a Image from a file system path /// </summary> /// <param name="path">The path can be a fully qualified path name, non-existent file, or file extension</param> /// <param name="size">The size of the bitmap to return</param> /// <param name="style">The style of the bitmap to retrieve</param> /// <param name="attributes">Extra attributes to specify for the path</param> /// <returns></returns> public static Image GetImageFromPath(string path, IconSizes size, IconStyles style, FileAttributes attributes) { SHFILEINFO shfi = new SHFILEINFO(); uint uFlags = SHGFI_ICON; uFlags |= (uint)size; uFlags |= (uint)style; if (attributes != 0) uFlags |= SHGFI_USEFILEATTRIBUTES; SHGetFileInfo(path, (int)attributes, ref shfi, (uint)Marshal.SizeOf(shfi), uFlags); Image image = (Image)Bitmap.FromHicon(shfi.hIcon).Clone(); DeleteObject(shfi.hIcon); return image; }
public ImageList GetImageList(IconSizes size) { switch(size) { case (IconSizes.Small): return small; case (IconSizes.Icon): return icon; case (IconSizes.Thumbnail): return thumbnail; } return null; }
public void SetImageList(IconSizes size, ImageList list) { switch (size) { case (IconSizes.Small): small = list; return; case (IconSizes.Icon): icon = list; return; case (IconSizes.Thumbnail): thumbnail = list; return; } }
/// <summary> /// Initializes a new instance of the ShellImageListManager class /// </summary> protected ShellImageListManager() { _extensions = new Hashtable(); _size = IconSizes.ShellIconSize; _style = IconStyles.NormalIconStyle; }