Click here to Skip to main content
13,705,837 members
Click here to Skip to main content

Stats

146.6K views
18.1K downloads
227 bookmarked
Posted 1 Jan 2010
Licenced CPOL

Task Manager

, 1 Jan 2010
Manage your daily tasks and To-Do list using some exciting features of Windows 7.
TaskManager
Core
AppRestartRecovery
Dialogs
Common
TaskDialogs
Interop
AppRestartRecovery
Dialogs
NetworkList
PowerManagement
TaskDialogs
NetworkList
PowerManagement
Properties
PropertySystem
SafeHandles
Shell
Common
CommonFileDialogs
Controls
Design
ShellObjects.cd
ShellThumbnailClassDiagram.cd
DesktopWindowManager
ExplorerBrowser
ExplorerBrowserDiagram.cd
Interop
Common
Dialogs
ExplorerBrowser
KnownFolders
PropertySystem
StockIcons
Taskbar
KnownFolders
Properties
PropertySystem
StockIcons
Taskbar
TaskManager
Common
Controls
Database
SqlTaskManager.edmx
TaskManager.mdf
TaskManager_log.LDF
Properties
Resources
Add.png
AddCategory.png
AddResource.png
AddTask.png
Back.ico
backcolor.bmp
BlueCat.png
Blue_Category.ico
bold.bmp
Category.png
Category_Icon.ico
Close.bmp
Close.png
color.bmp
Delete.png
Delete_01.png
Delete_Icon.ico
edit.png
edit_Icon.ico
Empty.png
Forward.ico
GanttChart.png
GreenCat.png
Green_Category.ico
High_Priority.png
High_Priority_Icon.ico
indent.bmp
italic.bmp
Low_Priority.png
Low_Priority_Icon.ico
Medium_Priority.png
Medium_Priority_Icon.ico
NextWeek_Flag.png
NextWeek_Flag_Icon.ico
NoDate_Flag.png
NoDate_Flag_Icon.ico
ol.bmp
OrangeCat.png
Orange_Category.ico
outdent.bmp
PurpleCat.png
Purple_Category.ico
Question.ico
Question_Icon.ico
RedCat.png
Red_Category.ico
Resource.png
Resource_Icon.ico
Save.bmp
Save.png
Task manager.ico
Task.png
TaskSetting.png
Task_Icon.ico
ThisWeek_Flag.png
ThisWeek_Flag_Icon.ico
Today_Flag.png
Today_Flag_Icon.ico
Tomorrow_Flag.png
Tomorrow_Flag_Icon.ico
underscore.bmp
uol.bmp
YellowCat.png
Yellow_Category.ico
TaskManager.csproj.user
Window7
TaskManagerSimple
TaskManagerSimple
Common
Controls
Database
SqlTaskManager.edmx
TaskManager.mdf
TaskManager_log.LDF
Properties
Resources
Add.png
AddCategory.png
AddResource.png
AddTask.png
Back.ico
backcolor.bmp
BlueCat.png
Blue_Category.ico
bold.bmp
Category.png
Category_Icon.ico
Close.bmp
Close.png
color.bmp
Delete.png
Delete_01.png
Delete_Icon.ico
edit.png
edit_Icon.ico
Empty.png
Forward.ico
GanttChart.png
GreenCat.png
Green_Category.ico
High_Priority.png
High_Priority_Icon.ico
indent.bmp
italic.bmp
Low_Priority.png
Low_Priority_Icon.ico
Medium_Priority.png
Medium_Priority_Icon.ico
NextWeek_Flag.png
NextWeek_Flag_Icon.ico
NoDate_Flag.png
NoDate_Flag_Icon.ico
ol.bmp
OrangeCat.png
Orange_Category.ico
outdent.bmp
PurpleCat.png
Purple_Category.ico
Question.ico
Question_Icon.ico
RedCat.png
Red_Category.ico
Resource.png
Resource_Icon.ico
Save.bmp
Save.png
Task manager.ico
Task.png
TaskSetting.png
Task_Icon.ico
ThisWeek_Flag.png
ThisWeek_Flag_Icon.ico
Today_Flag.png
Today_Flag_Icon.ico
Tomorrow_Flag.png
Tomorrow_Flag_Icon.ico
underscore.bmp
uol.bmp
YellowCat.png
Yellow_Category.ico
TaskManager.csproj.user
//Copyright (c) Microsoft Corporation.  All rights reserved.

using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
using MS.WindowsAPICodePack.Internal;
using Microsoft.WindowsAPICodePack.Controls.WindowsForms;

namespace Microsoft.WindowsAPICodePack.Controls
{
    /// <summary>
    /// These options control how the content of the Explorer Browser 
    /// is rendered.
    /// </summary>
    public class ExplorerBrowserContentOptions
    {
        #region construction
        ExplorerBrowser eb;
        internal ExplorerBrowserContentOptions( ExplorerBrowser eb )
        {
            this.eb = eb;
        }
        #endregion

        #region ViewMode property
        // This is a one-way property of the explorer browser. 
        // Keeping it around for the get implementations.
        internal FOLDERSETTINGS folderSettings = new FOLDERSETTINGS( );

        /// <summary>
        /// The viewing mode of the Explorer Browser
        /// </summary>
        public ExplorerBrowserViewMode ViewMode
        {
            get
            {
                return (ExplorerBrowserViewMode)folderSettings.ViewMode;
            }
            set
            {
                folderSettings.ViewMode = (FOLDERVIEWMODE)value;
                HRESULT hr = HRESULT.S_OK;
                if( eb.explorerBrowserControl != null )
                    hr = eb.explorerBrowserControl.SetFolderSettings( folderSettings );
            }
        }
        #endregion

        #region Flags property
        /// <summary>
        /// The binary representation of the ExplorerBrowser content flags
        /// </summary>
        public ExplorerBrowserContentFlags Flags
        {
            get
            {
                return (ExplorerBrowserContentFlags)folderSettings.fFlags;
            }
            set
            {
                folderSettings.fFlags = (FOLDERFLAGS)value | FOLDERFLAGS.FWF_USESEARCHFOLDER | FOLDERFLAGS.FWF_NOWEBVIEW;
                if( eb.explorerBrowserControl != null )
                    eb.explorerBrowserControl.SetFolderSettings( folderSettings );
            }
        }
        #endregion

        #region content flags to properties mapping
        /// <summary>
        /// The view should be left-aligned. 
        /// </summary>
        public bool AlignLeft
        {
            get
            {
                return IsFlagSet( ExplorerBrowserContentFlags.AlignLeft );
            }
            set
            {
                SetFlag( ExplorerBrowserContentFlags.AlignLeft, value );
            }
        }
        /// <summary>
        /// Automatically arrange the elements in the view. 
        /// </summary>
        public bool AutoArrange
        {
            get
            {
                return IsFlagSet( ExplorerBrowserContentFlags.AutoArrange );
            }
            set
            {
                SetFlag( ExplorerBrowserContentFlags.AutoArrange, value );
            }
        }
        /// <summary>
        /// Turns on check mode for the view
        /// </summary>
        public bool CheckSelect
        {
            get
            {
                return IsFlagSet( ExplorerBrowserContentFlags.CheckSelect );
            }
            set
            {
                SetFlag( ExplorerBrowserContentFlags.CheckSelect, value );
            }
        }
        /// <summary>
        /// When the view is in "tile view mode" the layout of a single item should be extended to the width of the view.
        /// </summary>
        public bool ExtendedTiles
        {
            get
            {
                return IsFlagSet( ExplorerBrowserContentFlags.ExtendedTiles );
            }
            set
            {
                SetFlag( ExplorerBrowserContentFlags.ExtendedTiles, value );
            }
        }
        /// <summary>
        /// When an item is selected, the item and all its sub-items are highlighted.
        /// </summary>
        public bool FullRowSelect
        {
            get
            {
                return IsFlagSet( ExplorerBrowserContentFlags.FullRowSelect );
            }
            set
            {
                SetFlag( ExplorerBrowserContentFlags.FullRowSelect, value );
            }
        }
        /// <summary>
        /// The view should not display file names
        /// </summary>
        public bool HideFileNames
        {
            get
            {
                return IsFlagSet( ExplorerBrowserContentFlags.HideFileNames );
            }
            set
            {
                SetFlag( ExplorerBrowserContentFlags.HideFileNames, value );
            }
        }
        /// <summary>
        /// The view should not save view state in the browser.
        /// </summary>
        public bool NoBrowserViewState
        {
            get
            {
                return IsFlagSet( ExplorerBrowserContentFlags.NoBrowserViewState );
            }
            set
            {
                SetFlag( ExplorerBrowserContentFlags.NoBrowserViewState, value );
            }
        }
        /// <summary>
        /// Do not display a column header in the view in any view mode.
        /// </summary>
        public bool NoColumnHeader
        {
            get
            {
                return IsFlagSet( ExplorerBrowserContentFlags.NoColumnHeader );
            }
            set
            {
                SetFlag( ExplorerBrowserContentFlags.NoColumnHeader, value );
            }
        }
        /// <summary>
        /// Only show the column header in details view mode.
        /// </summary>
        public bool NoHeaderInAllViews
        {
            get
            {
                return IsFlagSet( ExplorerBrowserContentFlags.NoHeaderInAllViews );
            }
            set
            {
                SetFlag( ExplorerBrowserContentFlags.NoHeaderInAllViews, value );
            }
        }
        /// <summary>
        /// The view should not display icons. 
        /// </summary>
        public bool NoIcons
        {
            get
            {
                return IsFlagSet( ExplorerBrowserContentFlags.NoIcons );
            }
            set
            {
                SetFlag( ExplorerBrowserContentFlags.NoIcons, value );
            }
        }
        /// <summary>
        /// Do not show subfolders. 
        /// </summary>
        public bool NoSubfolders
        {
            get
            {
                return IsFlagSet( ExplorerBrowserContentFlags.NoSubfolders );
            }
            set
            {
                SetFlag( ExplorerBrowserContentFlags.NoSubfolders, value );
            }
        }
        /// <summary>
        /// Navigate with a single click
        /// </summary>
        public bool SingleClickActivate
        {
            get
            {
                return IsFlagSet( ExplorerBrowserContentFlags.SingleClickActivate );
            }
            set
            {
                SetFlag( ExplorerBrowserContentFlags.SingleClickActivate, value );
            }
        }
        /// <summary>
        /// Do not allow more than a single item to be selected.
        /// </summary>
        public bool SingleSelection
        {
            get
            {
                return IsFlagSet( ExplorerBrowserContentFlags.SingleSelection );
            }
            set
            {
                SetFlag( ExplorerBrowserContentFlags.SingleSelection, value );
            }
        }

        private bool IsFlagSet( ExplorerBrowserContentFlags flag )
        {
            return ( folderSettings.fFlags & (FOLDERFLAGS)flag ) != 0;
        }

        private void SetFlag( ExplorerBrowserContentFlags flag, bool value )
        {
            if( value )
                folderSettings.fFlags |= (FOLDERFLAGS)flag;
            else
                folderSettings.fFlags = folderSettings.fFlags & ~(FOLDERFLAGS)flag;

            if( eb.explorerBrowserControl != null )
                eb.explorerBrowserControl.SetFolderSettings( folderSettings );
        }

        #endregion

        #region thumbnail size
        /// <summary>
        /// The size of the thumbnails in pixels
        /// </summary>
        public int ThumbnailSize
        {
            get
            {
                int iconSize = 0;
                IFolderView2 iFV2 = eb.GetFolderView2( );
                if( iFV2 != null )
                {
                    try
                    {
                        int fvm = 0;
                        HRESULT hr = iFV2.GetViewModeAndIconSize( out fvm, out iconSize );
                        if( hr != HRESULT.S_OK )
                            throw new COMException("unable to get icon size", (int)hr );
                    }
                    finally
                    {
                        Marshal.ReleaseComObject( iFV2 );
                        iFV2 = null;
                    }
                }

                return iconSize;
            }
            set
            {
                IFolderView2 iFV2 = eb.GetFolderView2( );
                if( iFV2 != null )
                {
                    try
                    {
                        int fvm = 0;
                        int iconSize = 0;
                        HRESULT hr = iFV2.GetViewModeAndIconSize( out fvm, out iconSize );
                        if( hr != HRESULT.S_OK )
                            throw new COMException( "unable to get icon size", (int)hr );
                        hr = iFV2.SetViewModeAndIconSize( fvm, value );
                        if( hr != HRESULT.S_OK )
                            throw new COMException( "unable to set icon size", (int)hr );
                    }
                    finally
                    {
                        Marshal.ReleaseComObject( iFV2 );
                        iFV2 = null;
                    }
                }
            }
        }
        #endregion
    }

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Shakeel Iqbal
Software Developer (Senior) TEO
Pakistan Pakistan
Passion and positive dedication is essential part of success. I believe on hardworking and sharing knowledge with others. I always try to be a better than I am and think positive for positive result.

My Blogs

My Linked-In Profile

You may also be interested in...

Pro
Pro
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04-2016 | 2.8.180920.1 | Last Updated 2 Jan 2010
Article Copyright 2010 by Shakeel Iqbal
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid