initial oogynize check in _ this actually used to work!

This commit is contained in:
2016-02-14 21:16:31 -08:00
parent b183af5d55
commit 532ea133bc
337 changed files with 30692 additions and 0 deletions

156
.gitignore vendored Normal file
View File

@@ -0,0 +1,156 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
!packages/*/build/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
# =========================
# Windows detritus
# =========================
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac desktop service store files
.DS_Store

View File

@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D32C4454-9334-47AA-9A3F-456B8B12220A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Foo.AddIn.Common</RootNamespace>
<AssemblyName>Foo.AddIn.Common</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Target\Debug\AddIns\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Target\Release\AddIns\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CommonTypes.cs" />
<Compile Include="CommonValidations.cs" />
<Compile Include="IDynResolve.cs" />
<Compile Include="IAddIn.cs" />
<Compile Include="IWorkspace.cs" />
<Compile Include="CommonFunctions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,399 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Runtime.InteropServices.ComTypes;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Diagnostics;
namespace Foo.AddIn.Common
{
#region Structs
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
public Rectangle AsRectangle
{
get
{
return new Rectangle(this.left, this.top, this.right - this.left, this.bottom - this.top);
}
}
public static RECT FromXYWH(int x, int y, int width, int height)
{
RECT rect = new RECT();
rect.left = x;
rect.top = y;
rect.right = x + width;
rect.bottom = y + height;
return rect;
}
public static RECT FromRectangle(Rectangle rectangle)
{
RECT rect = new RECT();
rect.left = rectangle.Left;
rect.top = rectangle.Top;
rect.right = rectangle.Right;
rect.bottom = rectangle.Bottom;
return rect;
}
}
#endregion
public static class Functions
{
#region Enums
public static class FuncEnum
{
public enum WindowAction : int
{
SW_HIDE = 0,
SW_SHOWNORMAL = 1,
SW_NORMAL = 1,
SW_SHOWMINIMIZED = 2,
SW_SHOWMAXIMIZED = 3,
SW_MAXIMIZE = 3,
SW_SHOWNOACTIVATE = 4,
SW_SHOW = 5,
SW_MINIMIZE = 6,
SW_SHOWMINNOACTIVE = 7,
SW_SHOWNA = 8,
SW_RESTORE = 9,
SW_SHOWDEFAULT = 10,
SW_FORCEMINIMIZE = 11,
SW_MAX = 11
}
public enum WindowMessage : int
{
WM_NULL = 0x0000,
WM_CREATE = 0x0001,
WM_DESTROY = 0x0002,
WM_MOVE = 0x0003,
WM_SIZE = 0x0005,
WM_ACTIVATE = 0x0006,
WM_SETFOCUS = 0x0007,
WM_KILLFOCUS = 0x0008,
WM_ENABLE = 0x000A,
WM_SETREDRAW = 0x000B,
WM_SETTEXT = 0x000C,
WM_GETTEXT = 0x000D,
WM_GETTEXTLENGTH = 0x000E,
WM_PAINT = 0x000F,
WM_CLOSE = 0x0010,
WM_QUERYENDSESSION = 0x0011,
WM_QUIT = 0x0012,
WM_QUERYOPEN = 0x0013,
WM_ERASEBKGND = 0x0014,
WM_SYSCOLORCHANGE = 0x0015,
WM_ENDSESSION = 0x0016,
WM_SHOWWINDOW = 0x0018,
WM_CTLCOLOR = 0x0019,
WM_WININICHANGE = 0x001A,
WM_SETTINGCHANGE = 0x001A,
WM_DEVMODECHANGE = 0x001B,
WM_ACTIVATEAPP = 0x001C,
WM_FONTCHANGE = 0x001D,
WM_TIMECHANGE = 0x001E,
WM_CANCELMODE = 0x001F,
WM_SETCURSOR = 0x0020,
WM_MOUSEACTIVATE = 0x0021,
WM_CHILDACTIVATE = 0x0022,
WM_QUEUESYNC = 0x0023,
WM_GETMINMAXINFO = 0x0024,
WM_PAINTICON = 0x0026,
WM_ICONERASEBKGND = 0x0027,
WM_NEXTDLGCTL = 0x0028,
WM_SPOOLERSTATUS = 0x002A,
WM_DRAWITEM = 0x002B,
WM_MEASUREITEM = 0x002C,
WM_DELETEITEM = 0x002D,
WM_VKEYTOITEM = 0x002E,
WM_CHARTOITEM = 0x002F,
WM_SETFONT = 0x0030,
WM_GETFONT = 0x0031,
WM_SETHOTKEY = 0x0032,
WM_GETHOTKEY = 0x0033,
WM_QUERYDRAGICON = 0x0037,
WM_COMPAREITEM = 0x0039,
WM_GETOBJECT = 0x003D,
WM_COMPACTING = 0x0041,
WM_COMMNOTIFY = 0x0044,
WM_WINDOWPOSCHANGING = 0x0046,
WM_WINDOWPOSCHANGED = 0x0047,
WM_POWER = 0x0048,
WM_COPYDATA = 0x004A,
WM_CANCELJOURNAL = 0x004B,
WM_NOTIFY = 0x004E,
WM_INPUTLANGCHANGEREQUEST = 0x0050,
WM_INPUTLANGCHANGE = 0x0051,
WM_TCARD = 0x0052,
WM_HELP = 0x0053,
WM_USERCHANGED = 0x0054,
WM_NOTIFYFORMAT = 0x0055,
WM_CONTEXTMENU = 0x007B,
WM_STYLECHANGING = 0x007C,
WM_STYLECHANGED = 0x007D,
WM_DISPLAYCHANGE = 0x007E,
WM_GETICON = 0x007F,
WM_SETICON = 0x0080,
WM_NCCREATE = 0x0081,
WM_NCDESTROY = 0x0082,
WM_NCCALCSIZE = 0x0083,
WM_NCHITTEST = 0x0084,
WM_NCPAINT = 0x0085,
WM_NCACTIVATE = 0x0086,
WM_GETDLGCODE = 0x0087,
WM_SYNCPAINT = 0x0088,
WM_NCMOUSEMOVE = 0x00A0,
WM_NCLBUTTONDOWN = 0x00A1,
WM_NCLBUTTONUP = 0x00A2,
WM_NCLBUTTONDBLCLK = 0x00A3,
WM_NCRBUTTONDOWN = 0x00A4,
WM_NCRBUTTONUP = 0x00A5,
WM_NCRBUTTONDBLCLK = 0x00A6,
WM_NCMBUTTONDOWN = 0x00A7,
WM_NCMBUTTONUP = 0x00A8,
WM_NCMBUTTONDBLCLK = 0x00A9,
WM_KEYDOWN = 0x0100,
WM_KEYUP = 0x0101,
WM_CHAR = 0x0102,
WM_DEADCHAR = 0x0103,
WM_SYSKEYDOWN = 0x0104,
WM_SYSKEYUP = 0x0105,
WM_SYSCHAR = 0x0106,
WM_SYSDEADCHAR = 0x0107,
WM_KEYLAST = 0x0108,
WM_IME_STARTCOMPOSITION = 0x010D,
WM_IME_ENDCOMPOSITION = 0x010E,
WM_IME_COMPOSITION = 0x010F,
WM_IME_KEYLAST = 0x010F,
WM_INITDIALOG = 0x0110,
WM_COMMAND = 0x0111,
WM_SYSCOMMAND = 0x0112,
WM_TIMER = 0x0113,
WM_HSCROLL = 0x0114,
WM_VSCROLL = 0x0115,
WM_INITMENU = 0x0116,
WM_INITMENUPOPUP = 0x0117,
WM_MENUSELECT = 0x011F,
WM_MENUCHAR = 0x0120,
WM_ENTERIDLE = 0x0121,
WM_MENURBUTTONUP = 0x0122,
WM_MENUDRAG = 0x0123,
WM_MENUGETOBJECT = 0x0124,
WM_UNINITMENUPOPUP = 0x0125,
WM_MENUCOMMAND = 0x0126,
WM_CTLCOLORMSGBOX = 0x0132,
WM_CTLCOLOREDIT = 0x0133,
WM_CTLCOLORLISTBOX = 0x0134,
WM_CTLCOLORBTN = 0x0135,
WM_CTLCOLORDLG = 0x0136,
WM_CTLCOLORSCROLLBAR = 0x0137,
WM_CTLCOLORSTATIC = 0x0138,
WM_MOUSEMOVE = 0x0200,
WM_LBUTTONDOWN = 0x0201,
WM_LBUTTONUP = 0x0202,
WM_LBUTTONDBLCLK = 0x0203,
WM_RBUTTONDOWN = 0x0204,
WM_RBUTTONUP = 0x0205,
WM_RBUTTONDBLCLK = 0x0206,
WM_MBUTTONDOWN = 0x0207,
WM_MBUTTONUP = 0x0208,
WM_MBUTTONDBLCLK = 0x0209,
WM_MOUSEWHEEL = 0x020A,
WM_PARENTNOTIFY = 0x0210,
WM_ENTERMENULOOP = 0x0211,
WM_EXITMENULOOP = 0x0212,
WM_NEXTMENU = 0x0213,
WM_SIZING = 0x0214,
WM_CAPTURECHANGED = 0x0215,
WM_MOVING = 0x0216,
WM_DEVICECHANGE = 0x0219,
WM_MDICREATE = 0x0220,
WM_MDIDESTROY = 0x0221,
WM_MDIACTIVATE = 0x0222,
WM_MDIRESTORE = 0x0223,
WM_MDINEXT = 0x0224,
WM_MDIMAXIMIZE = 0x0225,
WM_MDITILE = 0x0226,
WM_MDICASCADE = 0x0227,
WM_MDIICONARRANGE = 0x0228,
WM_MDIGETACTIVE = 0x0229,
WM_MDISETMENU = 0x0230,
WM_ENTERSIZEMOVE = 0x0231,
WM_EXITSIZEMOVE = 0x0232,
WM_DROPFILES = 0x0233,
WM_MDIREFRESHMENU = 0x0234,
WM_IME_SETCONTEXT = 0x0281,
WM_IME_NOTIFY = 0x0282,
WM_IME_CONTROL = 0x0283,
WM_IME_COMPOSITIONFULL = 0x0284,
WM_IME_SELECT = 0x0285,
WM_IME_CHAR = 0x0286,
WM_IME_REQUEST = 0x0288,
WM_IME_KEYDOWN = 0x0290,
WM_IME_KEYUP = 0x0291,
WM_MOUSEHOVER = 0x02A1,
WM_MOUSELEAVE = 0x02A3,
WM_CUT = 0x0300,
WM_COPY = 0x0301,
WM_PASTE = 0x0302,
WM_CLEAR = 0x0303,
WM_UNDO = 0x0304,
WM_RENDERFORMAT = 0x0305,
WM_RENDERALLFORMATS = 0x0306,
WM_DESTROYCLIPBOARD = 0x0307,
WM_DRAWCLIPBOARD = 0x0308,
WM_PAINTCLIPBOARD = 0x0309,
WM_VSCROLLCLIPBOARD = 0x030A,
WM_SIZECLIPBOARD = 0x030B,
WM_ASKCBFORMATNAME = 0x030C,
WM_CHANGECBCHAIN = 0x030D,
WM_HSCROLLCLIPBOARD = 0x030E,
WM_QUERYNEWPALETTE = 0x030F,
WM_PALETTEISCHANGING = 0x0310,
WM_PALETTECHANGED = 0x0311,
WM_HOTKEY = 0x0312,
WM_PRINT = 0x0317,
WM_PRINTCLIENT = 0x0318,
WM_HANDHELDFIRST = 0x0358,
WM_HANDHELDLAST = 0x035F,
WM_AFXFIRST = 0x0360,
WM_AFXLAST = 0x037F,
WM_PENWINFIRST = 0x0380,
WM_PENWINLAST = 0x038F,
WM_APP = 0x8000,
WM_USER = 0x0400,
WM_REFLECT = WM_USER + 0x1c00,
WM_CHANGEUISTATE = 0x0127,
WM_UPDATEUISTATE = 0x0128,
WM_QUERYUISTATE = 0x0129
}
}
#endregion
#region DLLImports
[DllImport("ole32.dll")]
public static extern int CreateBindCtx(int reserved, out IBindCtx ppbc);
[DllImport("user32.dll")]
extern public static bool GetWindowRect(IntPtr hWnd, out RECT rect);
[DllImport("user32.dll")]
extern public static bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
[DllImport("User32.dll")]
extern public static bool IsWindow(IntPtr hwnd);
[DllImport("User32.dll")]
extern public static bool IsWindowVisible(IntPtr hwnd);
[DllImport("user32.dll")]
extern public static int ShowWindow(IntPtr hwnd, FuncEnum.WindowAction nCmdShow);
[DllImport("User32.dll")]
extern public static int GetWindowThreadProcessId(IntPtr hWnd, ref int lpdwProcessId);
[DllImport("User32.dll")]
extern public static int SendMessage(IntPtr hWnd, FuncEnum.WindowMessage Msg, IntPtr wParam, IntPtr lParam);
#endregion
#region Functions
/// <summary>
/// Returns the .Net Process Object that owns the passed in hWnd
/// </summary>
public static Process GetProcessFromHandle(IntPtr hWnd)
{
int currentPid = 0;
GetWindowThreadProcessId(hWnd, ref currentPid);
Process process;
process = Process.GetProcessById(currentPid);
return process;
}
/// <summary>
/// Attaches to instance of COM object matching progid
/// and returns an object. Client must cast and know
/// expected type.
/// </summary>
public static Object GetCOMObject(string progId)
{
Object app = null;
try
{
app = Marshal.GetActiveObject(progId);
}
catch (SystemException) { /* ignore */ }
return app;
}
/// <summary>
/// Use this to Get A specific type of Object from the ROT
/// </summary>
public static List<T> GetRunningObjectsOfType<T>()
{
// Get the table.
var res = new List<T>();
IBindCtx bc;
CreateBindCtx(0, out bc);
IRunningObjectTable runningObjectTable;
bc.GetRunningObjectTable(out runningObjectTable);
IEnumMoniker monikerEnumerator;
runningObjectTable.EnumRunning(out monikerEnumerator);
monikerEnumerator.Reset();
// Enumerate and fill our nice dictionary.
IMoniker[] monikers = new IMoniker[1];
IntPtr numFetched = IntPtr.Zero;
while (monikerEnumerator.Next(1, monikers, numFetched) == 0)
{
object o;
runningObjectTable.GetObject(monikers[0], out o);
if (o is T)
{
res.Add((T)o);
}
o = null;
}
return res;
}
/// <summary>
/// Get a windows rectangle in a .NET structure
/// </summary>
/// <param name="hwnd">The window handle to look up</param>
/// <returns>The rectangle</returns>
public static Rectangle GetWindowRect(IntPtr hwnd)
{
RECT rect = new RECT();
GetWindowRect(hwnd, out rect);
return rect.AsRectangle;
}
#endregion
}
}

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Foo.AddIn.Common
{
/// <summary>
/// Common Return Value for Addins
/// </summary>
public class FuncRetVal
{
public FuncRetValEnum Type { get; set; }
public string Message { get; set; }
}
/// <summary>
/// Useful for Returns where we
/// need more information on failures
/// </summary>
public enum FuncRetValEnum
{
Action_Succeeded,
Action_Failed,
NoAction_Needed,
ParameterInvalid,
ArtifactUnavailable,
FunctionallityNotSupported,
ErrorThrown
}
}

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Foo.AddIn.Common
{
public static class Validate
{
/// <summary>
/// Validate ArtifactLocation * We could later do much more work here *
/// </summary>
/// <returns></returns>
public static bool IsValidArtifactLocation(string strArtifactLocation, ref FuncRetVal retVal)
{
// All URLs should contain that character (Files aren't allowed to contain it)
bool bIsUrl = strArtifactLocation.Contains('/');
if (String.IsNullOrEmpty(strArtifactLocation))
{
retVal.Type = FuncRetValEnum.ParameterInvalid;
return false;
}
else if (!bIsUrl && !File.Exists(strArtifactLocation))
{
// Check File existence (if it doesn't return false)
return false;
}
else
{
return true;
}
}
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Foo.AddIn.Common
{
public interface IAddIn
{
// I
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Foo.AddIn.Common
{
public interface IDynResolve
{
// I
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Foo.AddIn.Common
{
public interface IWorkspace
{
// Launchers
FuncRetVal Launch(string strArtifactLocation, int WindowHeight, int WindowWidth, int WindowTop, int WindowLeft);
FuncRetVal Launch(string strArtifactLocation);
// ShowNHiders
FuncRetVal Show(string strArtifactLocation);
FuncRetVal Hide(string strArtifactLocation);
// Closers
FuncRetVal QueryClose(string strArtifactLocation);
FuncRetVal Close(string strArtifactLocation, bool bAutoSaveArtifact, out int WindowHeight, out int WindowWidth, out int WindowTop, out int WindowLeft);
FuncRetVal Close(string strArtifactLocation, bool bAutoSaveArtifact);
FuncRetVal Close(string strArtifactLocation);
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AddIn.Common")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AddIn.Common")]
[assembly: AssemblyCopyright("Copyright © 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("39d7351f-149f-4d32-a3ae-d07ec27515af")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,324 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Foo.AddIn.Common;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Drawing;
// Ignore 'Ambiguity' warning message, seems like no way around those
#pragma warning disable 0467
namespace Foo.Addin.Office
{
public class Access_Workspace : IWorkspace
{
public const string Access_ProgId = "Access.Application";
public FuncRetVal Launch(string strArtifactLocation, int WindowHeight, int WindowWidth, int WindowTop, int WindowLeft)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
Microsoft.Office.Interop.Access.Application app = new Microsoft.Office.Interop.Access.Application();
app.Visible = true;
// Must test the following here:
// - open both .mdb and .adp (access project files with this)
// - how does this behave when db is password protected?
app.OpenCurrentDatabase(strArtifactLocation, true, "");
// ToDo: Check if a new process got created? / or if hWnd exists???
// - Also PERFORM Window Positioning
retVal.Type = FuncRetValEnum.Action_Succeeded;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Launch(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
Microsoft.Office.Interop.Access.Application app = new Microsoft.Office.Interop.Access.Application();
app.Visible = true;
// Must test the following here:
// - open both .mdb and .adp (access project files with this)
// - how does this behave when db is password protected?
app.OpenCurrentDatabase(strArtifactLocation, true, "");
// ToDo: Check if a new process got created? / or if hWnd exists???
retVal.Type = FuncRetValEnum.Action_Succeeded;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Show(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningAccessApps = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Access.Application>();
foreach (Microsoft.Office.Interop.Access.Application app in RunningAccessApps)
{
if (app.CurrentProject.FullName.ToLower() == strArtifactLocation.ToLower())
{
IntPtr hWnd = (IntPtr)app.hWndAccessApp();
if (!Functions.IsWindowVisible(hWnd))
{
Functions.ShowWindow(hWnd, Functions.FuncEnum.WindowAction.SW_SHOW);
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
else
{
retVal.Type = FuncRetValEnum.NoAction_Needed;
return retVal;
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Hide(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningAccessApps = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Access.Application>();
foreach (Microsoft.Office.Interop.Access.Application app in RunningAccessApps)
{
if (app.CurrentProject.FullName.ToLower() == strArtifactLocation.ToLower())
{
IntPtr hWnd = (IntPtr)app.hWndAccessApp();
if (Functions.IsWindowVisible(hWnd))
{
Functions.ShowWindow(hWnd, Functions.FuncEnum.WindowAction.SW_HIDE);
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
else
{
retVal.Type = FuncRetValEnum.NoAction_Needed;
return retVal;
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal QueryClose(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningAccessApps = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Access.Application>();
foreach (Microsoft.Office.Interop.Access.Application app in RunningAccessApps)
{
if (app.CurrentProject.FullName.ToLower() == strArtifactLocation.ToLower())
{
IntPtr hWnd = (IntPtr) app.hWndAccessApp();
if (Functions.SendMessage(hWnd, Functions.FuncEnum.WindowMessage.WM_QUERYENDSESSION, IntPtr.Zero, IntPtr.Zero) != 0)
{
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
else
{
retVal.Type = FuncRetValEnum.Action_Failed;
return retVal;
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Close(string strArtifactLocation, bool bAutoSaveArtifact, out int WindowHeight, out int WindowWidth, out int WindowTop, out int WindowLeft)
{
FuncRetVal retVal = new FuncRetVal();
WindowTop = 0;
WindowLeft = 0;
WindowWidth = 0;
WindowHeight = 0;
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningAccessApps = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Access.Application>();
foreach (Microsoft.Office.Interop.Access.Application app in RunningAccessApps)
{
if (app.CurrentProject.FullName.ToLower() == strArtifactLocation.ToLower())
{
// Get Handle and Process
IntPtr hWnd = (IntPtr)app.hWndAccessApp();
Process process = Functions.GetProcessFromHandle((IntPtr)hWnd);
// Get the Window properties
Rectangle rect = Functions.GetWindowRect(hWnd);
WindowHeight = rect.Height;
WindowWidth = rect.Width;
WindowLeft = rect.Left;
WindowTop = rect.Top;
// Close the database
//app.CloseCurrentDatabase();
if (bAutoSaveArtifact)
app.Quit(Microsoft.Office.Interop.Access.AcQuitOption.acQuitSaveAll);
else
app.Quit(Microsoft.Office.Interop.Access.AcQuitOption.acQuitSaveNone);
Marshal.FinalReleaseComObject(app); // force clean-up
// Kill the process
process.Kill();
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Close(string strArtifactLocation, bool bAutoSaveArtifact)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningAccessApps = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Access.Application>();
foreach (Microsoft.Office.Interop.Access.Application app in RunningAccessApps)
{
if (app.CurrentProject.FullName.ToLower() == strArtifactLocation.ToLower())
{
// Get Handle and Process
IntPtr hWnd = (IntPtr)app.hWndAccessApp();
Process process = Functions.GetProcessFromHandle((IntPtr)hWnd);
// Close the database
//app.CloseCurrentDatabase();
if(bAutoSaveArtifact)
app.Quit(Microsoft.Office.Interop.Access.AcQuitOption.acQuitSaveAll);
else
app.Quit(Microsoft.Office.Interop.Access.AcQuitOption.acQuitSaveNone);
Marshal.FinalReleaseComObject(app); // force clean-up
// Kill the process
process.Kill();
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Close(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningAccessApps = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Access.Application>();
foreach (Microsoft.Office.Interop.Access.Application app in RunningAccessApps)
{
if (app.CurrentProject.FullName.ToLower() == strArtifactLocation.ToLower())
{
// Get Handle and Process
IntPtr hWnd = (IntPtr)app.hWndAccessApp();
Process process = Functions.GetProcessFromHandle((IntPtr)hWnd);
// Close the database
//app.CloseCurrentDatabase();
app.Quit(Microsoft.Office.Interop.Access.AcQuitOption.acQuitSaveAll);
Marshal.FinalReleaseComObject(app); // force clean-up
// Kill the process
process.Kill();
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Foo.AddIn.Common;
namespace Foo.Addin.Office
{
public class AddIn : IAddIn
{
}
}

View File

@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0CA1DD2E-2752-4587-ADB4-77194411648B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Foo.Addin.Office</RootNamespace>
<AssemblyName>Foo.Addin.Office</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Target\Debug\AddIns\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Target\Release\AddIns\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Office.Interop.Access, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Office.Interop.PowerPoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Office.Interop.Publisher, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Office.Interop.Visio, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Office.Interop.Word, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Access.cs" />
<Compile Include="AddIn.cs" />
<Compile Include="Excel.cs" />
<Compile Include="PowerPoint.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Publisher.cs" />
<Compile Include="Visio.cs" />
<Compile Include="Word.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AddIn.Common\AddIn.Common.csproj">
<Project>{D32C4454-9334-47AA-9A3F-456B8B12220A}</Project>
<Name>AddIn.Common</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<COMReference Include="Microsoft.Office.Core">
<Guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>3</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,383 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Reflection;
using Foo.AddIn.Common;
using System.Drawing;
// Ignore 'Ambiguity' warning message, seems like no way around those
#pragma warning disable 0467
namespace Foo.Addin.Office
{
public class Excel_Workspace : IWorkspace
{
public const string Excel_ProgId = "Excel.Application";
public FuncRetVal Launch(string strArtifactLocation, int WindowHeight, int WindowWidth, int WindowTop, int WindowLeft)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
Microsoft.Office.Interop.Excel.Application app = null;
app = new Microsoft.Office.Interop.Excel.Application();
// Mark the Application as visible
app.Visible = true;
// Position the Window
IntPtr hWnd = (IntPtr)app.Hwnd;
Functions.SetWindowPos(hWnd, IntPtr.Zero, WindowLeft, WindowTop, WindowHeight, WindowWidth, 0);
// Open/Load the Document
Microsoft.Office.Interop.Excel.Workbook workbook = app.Workbooks.Open(strArtifactLocation, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
if (workbook != null)
{
retVal.Type = FuncRetValEnum.Action_Succeeded;
}
else
{
retVal.Type = FuncRetValEnum.Action_Failed;
}
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Launch(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
Microsoft.Office.Interop.Excel.Application app = null;
app = new Microsoft.Office.Interop.Excel.Application();
// Mark the Application as visible
app.Visible = true;
Microsoft.Office.Interop.Excel.Workbook workbook = app.Workbooks.Open(strArtifactLocation, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
if (workbook != null)
{
retVal.Type = FuncRetValEnum.Action_Succeeded;
}
else
{
retVal.Type = FuncRetValEnum.Action_Failed;
}
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Show(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningExcelWorkbooks = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Excel.Workbook>();
foreach (Microsoft.Office.Interop.Excel.Workbook book in RunningExcelWorkbooks)
{
if (book.FullName.ToLower() == strArtifactLocation.ToLower())
{
var app = book.Application;
bool bIsTheOnlyDocumentInApp = (app.Workbooks.Count == 1);
// If For some reason the App is visible
if (app.Visible)
{
// Make Sure that this Workbook is activated
if (!bIsTheOnlyDocumentInApp)
{
book.Activate();
retVal.Type = FuncRetValEnum.Action_Succeeded;
}
else
{
retVal.Type = FuncRetValEnum.NoAction_Needed;
}
return retVal;
}
app.Visible = true;
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Hide(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningExcelWorkbooks = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Excel.Workbook>();
foreach (Microsoft.Office.Interop.Excel.Workbook book in RunningExcelWorkbooks)
{
if (book.FullName.ToLower() == strArtifactLocation.ToLower())
{
var app = book.Application;
bool bIsTheOnlyDocumentInApp = (app.Workbooks.Count == 1);
if (!app.Visible)
{
retVal.Type = FuncRetValEnum.NoAction_Needed;
return retVal;
}
// If this is NOT the Only open workbook in this App
// ~Activate the other workbook
if (!bIsTheOnlyDocumentInApp)
{
foreach (Microsoft.Office.Interop.Excel.Workbook book2 in app.Workbooks)
{
if (book2.FullName.ToLower() != strArtifactLocation.ToLower())
{
book2.Activate();
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
}
}
else
{
app.Visible = false;
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal QueryClose(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningExcelWorkbooks = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Excel.Workbook>();
foreach (Microsoft.Office.Interop.Excel.Workbook book in RunningExcelWorkbooks)
{
if (book.FullName.ToLower() == strArtifactLocation.ToLower())
{
if (book.Saved)
{
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
else
{
retVal.Type = FuncRetValEnum.Action_Failed;
return retVal;
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Close(string strArtifactLocation, bool bAutoSaveArtifact, out int WindowHeight, out int WindowWidth, out int WindowTop, out int WindowLeft)
{
FuncRetVal retVal = new FuncRetVal();
WindowTop = 0;
WindowLeft = 0;
WindowWidth = 0;
WindowHeight = 0;
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningExcelWorkbooks = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Excel.Workbook>();
foreach (Microsoft.Office.Interop.Excel.Workbook book in RunningExcelWorkbooks)
{
if (book.FullName.ToLower() == strArtifactLocation.ToLower())
{
// In case there is a running rogue excel process left open,
// we can always force it to close by closing the process
// int hWnd = app.Hwnd;
// Process process = Win32Functions.GetProcessFromHandle((IntPtr) hWnd);
var app = book.Application;
// Get the Window properties
IntPtr hWnd = (IntPtr)app.Hwnd;
Rectangle rect = Functions.GetWindowRect(hWnd);
WindowHeight = rect.Height;
WindowWidth = rect.Width;
WindowLeft = rect.Left;
WindowTop = rect.Top;
// Close the Workbook
book.Close(bAutoSaveArtifact, strArtifactLocation, false);
Marshal.FinalReleaseComObject(book); // force clean-up
// Close Excel if this is the last Workbook
if (app.Workbooks.Count == 0)
{
app.Quit();
Marshal.FinalReleaseComObject(app); // force clean-up, should clean up excel process
//process.Close();
}
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Close(string strArtifactLocation, bool bAutoSaveArtifact)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningExcelWorkbooks = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Excel.Workbook>();
foreach (Microsoft.Office.Interop.Excel.Workbook book in RunningExcelWorkbooks)
{
if (book.FullName.ToLower() == strArtifactLocation.ToLower())
{
// In case there is a running rogue excel process left open,
// we can always force it to close by closing the process
// int hWnd = app.Hwnd;
// Process process = Win32Functions.GetProcessFromHandle((IntPtr) hWnd);
var app = book.Application;
// Close the Workbook
book.Close(bAutoSaveArtifact, strArtifactLocation, false);
Marshal.FinalReleaseComObject(book); // force clean-up
// Close Excel if this is the last Workbook
if (app.Workbooks.Count == 0)
{
app.Quit();
Marshal.FinalReleaseComObject(app); // force clean-up, should clean up excel process
//process.Close();
}
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Close(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningExcelWorkbooks = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Excel.Workbook>();
foreach (Microsoft.Office.Interop.Excel.Workbook book in RunningExcelWorkbooks)
{
if (book.FullName.ToLower() == strArtifactLocation.ToLower())
{
// In case there is a running rogue excel process left open,
// we can always force it to close by closing the process
// int hWnd = app.Hwnd;
// Process process = Win32Functions.GetProcessFromHandle((IntPtr) hWnd);
var app = book.Application;
// Close the Workbook
book.Close(true, strArtifactLocation, false);
Marshal.FinalReleaseComObject(book); // force clean-up
// Close Excel if this is the last Workbook
if (app.Workbooks.Count == 0)
{
app.Quit();
Marshal.FinalReleaseComObject(app); // force clean-up, should clean up excel process
//process.Close();
}
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
}
}

View File

@@ -0,0 +1,379 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Foo.AddIn.Common;
using System.Runtime.InteropServices;
// Ignore 'Ambiguity' warning message, seems like no way around those
#pragma warning disable 0467
namespace Foo.Addin.Office
{
public class PowerPoint_Workspace : IWorkspace
{
public const string PowerPoint_ProgId = "PowerPoint.Application";
public FuncRetVal Launch(string strArtifactLocation, int WindowHeight, int WindowWidth, int WindowTop, int WindowLeft)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
Microsoft.Office.Interop.PowerPoint.Application app = null;
app = Functions.GetCOMObject(PowerPoint_ProgId) as Microsoft.Office.Interop.PowerPoint.Application;
// If no existing PowerPoint App is open, open a new one
if (app == null)
{
app = new Microsoft.Office.Interop.PowerPoint.Application();
app.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
}
// If there is an existing presentation, don't position the window
bool bThereIsAnExistingPresentation = (app.Presentations.Count > 0);
// Open the PowerPoint Presentation
Microsoft.Office.Interop.PowerPoint.Presentation presentation = null;
presentation = app.Presentations.Open(strArtifactLocation, Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoCTrue);
if (presentation != null)
{
// Position the Window
if (!bThereIsAnExistingPresentation)
{
IntPtr hWnd = (IntPtr) app.HWND;
Functions.SetWindowPos(hWnd, IntPtr.Zero, WindowLeft, WindowTop, WindowHeight, WindowWidth, 0);
}
retVal.Type = FuncRetValEnum.Action_Succeeded;
}
else
{
retVal.Type = FuncRetValEnum.Action_Failed;
}
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Launch(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
Microsoft.Office.Interop.PowerPoint.Application app = null;
app = Functions.GetCOMObject(PowerPoint_ProgId) as Microsoft.Office.Interop.PowerPoint.Application;
// If no existing PowerPoint App is open, open a new one
if (app == null)
{
app = new Microsoft.Office.Interop.PowerPoint.Application();
app.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
}
// Open the PowerPoint Presentation
Microsoft.Office.Interop.PowerPoint.Presentation presentation = null;
presentation = app.Presentations.Open(strArtifactLocation, Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoCTrue);
if (presentation != null)
{
retVal.Type = FuncRetValEnum.Action_Succeeded;
}
else
{
retVal.Type = FuncRetValEnum.Action_Failed;
}
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Show(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningPowerPoints = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.PowerPoint.Presentation>();
foreach (Microsoft.Office.Interop.PowerPoint.Presentation presentation in RunningPowerPoints)
{
if (presentation.FullName.ToLower() == strArtifactLocation.ToLower())
{
switch (presentation.Application.Visible)
{
case Microsoft.Office.Core.MsoTriState.msoTrue:
{
retVal.Type = FuncRetValEnum.NoAction_Needed;
return retVal;
}
case Microsoft.Office.Core.MsoTriState.msoFalse:
{
presentation.Application.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
//Functions.ShowWindow((IntPtr)presentation.Application.HWND, (int)Functions.WindowAction.SW_SHOW);
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Hide(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningPowerPoints = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.PowerPoint.Presentation>();
foreach (Microsoft.Office.Interop.PowerPoint.Presentation presentation in RunningPowerPoints)
{
if (presentation.FullName.ToLower() == strArtifactLocation.ToLower())
{
switch (presentation.Application.Visible)
{
case Microsoft.Office.Core.MsoTriState.msoTrue:
{
presentation.Application.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;
//Functions.ShowWindow((IntPtr)presentation.Application.HWND, (int)Functions.WindowAction.SW_HIDE);
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
case Microsoft.Office.Core.MsoTriState.msoFalse:
{
retVal.Type = FuncRetValEnum.NoAction_Needed;
return retVal;
}
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal QueryClose(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningPowerPoints = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.PowerPoint.Presentation>();
foreach (Microsoft.Office.Interop.PowerPoint.Presentation presentation in RunningPowerPoints)
{
if (presentation.FullName.ToLower() == strArtifactLocation.ToLower())
{
switch (presentation.Saved)
{
case Microsoft.Office.Core.MsoTriState.msoTrue:
{
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
case Microsoft.Office.Core.MsoTriState.msoFalse:
{
retVal.Type = FuncRetValEnum.Action_Failed;
return retVal;
}
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Close(string strArtifactLocation, bool bAutoSaveArtifact, out int WindowHeight, out int WindowWidth, out int WindowTop, out int WindowLeft)
{
FuncRetVal retVal = new FuncRetVal();
WindowTop = 0;
WindowLeft = 0;
WindowWidth = 0;
WindowHeight = 0;
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningPowerPoints = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.PowerPoint.Presentation>();
foreach (Microsoft.Office.Interop.PowerPoint.Presentation presentation in RunningPowerPoints)
{
if (presentation.FullName.ToLower() == strArtifactLocation.ToLower())
{
var app = presentation.Application;
// Save this Presentation
if (bAutoSaveArtifact)
presentation.Save();
// Pass out the Window Information
WindowTop = (int) presentation.Application.Top;
WindowLeft = (int) presentation.Application.Left;
WindowHeight = (int) presentation.Application.Height;
WindowWidth = (int)presentation.Application.Width;
// Close this Presentation
presentation.Close();
Marshal.FinalReleaseComObject(presentation); // force clean-up
// Close PowerPoint if there are no more Presentations
if (app.Presentations.Count == 0)
{
app.Quit();
Marshal.FinalReleaseComObject(app); // force clean-up, kill application for sure
}
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Close(string strArtifactLocation, bool bAutoSaveArtifact)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningPowerPoints = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.PowerPoint.Presentation>();
foreach (Microsoft.Office.Interop.PowerPoint.Presentation presentation in RunningPowerPoints)
{
if (presentation.FullName.ToLower() == strArtifactLocation.ToLower())
{
var app = presentation.Application;
// Save this Presentation
if(bAutoSaveArtifact)
presentation.Save();
// Close this Presentation
presentation.Close();
Marshal.FinalReleaseComObject(presentation); // force clean-up
// Close PowerPoint if there are no more Presentations
if (app.Presentations.Count == 0)
{
app.Quit();
Marshal.FinalReleaseComObject(app); // force clean-up, kill application for sure
}
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Close(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningPowerPoints = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.PowerPoint.Presentation>();
foreach (Microsoft.Office.Interop.PowerPoint.Presentation presentation in RunningPowerPoints)
{
if (presentation.FullName.ToLower() == strArtifactLocation.ToLower())
{
var app = presentation.Application;
// Save this Presentation
presentation.Save();
// Close this Presentation
presentation.Close();
Marshal.FinalReleaseComObject(presentation); // force clean-up
// Close PowerPoint if there are no more Presentations
if (app.Presentations.Count == 0)
{
app.Quit();
Marshal.FinalReleaseComObject(app); // force clean-up, kill application for sure
}
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Addin.Office")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Addin.Office")]
[assembly: AssemblyCopyright("Copyright © 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("79a22796-d344-456e-90a3-9e28c0f31d31")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,361 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Foo.AddIn.Common;
using System.Diagnostics;
// Ignore 'Ambiguity' warning message, seems like no way around those
#pragma warning disable 0467
namespace Foo.Addin.Office
{
public class Publisher_Workspace : IWorkspace
{
public const string Publisher_ProgId = "Publisher.Application";
public FuncRetVal Launch(string strArtifactLocation, int WindowHeight, int WindowWidth, int WindowTop, int WindowLeft)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
Microsoft.Office.Interop.Publisher.Application app = new Microsoft.Office.Interop.Publisher.Application();
// Opens Publisher
Microsoft.Office.Interop.Publisher.Document doc = null;
doc = app.Open(strArtifactLocation, false, false, Microsoft.Office.Interop.Publisher.PbSaveOptions.pbSaveChanges);
// Position the Window
IntPtr hWnd = (IntPtr)doc.ActiveWindow.Hwnd;
Functions.SetWindowPos(hWnd, IntPtr.Zero, WindowLeft, WindowTop, WindowHeight, WindowWidth, 0);
if (doc != null)
{
retVal.Type = FuncRetValEnum.Action_Succeeded;
}
else
{
retVal.Type = FuncRetValEnum.Action_Failed;
}
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Launch(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
Microsoft.Office.Interop.Publisher.Application app = new Microsoft.Office.Interop.Publisher.Application();
// Opens Publisher
Microsoft.Office.Interop.Publisher.Document doc = null;
doc = app.Open(strArtifactLocation, false, false, Microsoft.Office.Interop.Publisher.PbSaveOptions.pbSaveChanges);
if (doc != null)
{
retVal.Type = FuncRetValEnum.Action_Succeeded;
}
else
{
retVal.Type = FuncRetValEnum.Action_Failed;
}
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Show(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningPublisherApps = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Publisher.Application>();
foreach (Microsoft.Office.Interop.Publisher.Application app in RunningPublisherApps)
{
foreach (Microsoft.Office.Interop.Publisher.Document pubDoc in app.Documents)
{
if (pubDoc.FullName.ToLower() == strArtifactLocation.ToLower())
{
if (pubDoc.ActiveWindow.Visible)
{
retVal.Type = FuncRetValEnum.NoAction_Needed;
return retVal;
}
else
{
pubDoc.ActiveWindow.Visible = true;
retVal.Type = FuncRetValEnum.Action_Succeeded;
}
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Hide(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningPublisherApps = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Publisher.Application>();
foreach (Microsoft.Office.Interop.Publisher.Application app in RunningPublisherApps)
{
foreach (Microsoft.Office.Interop.Publisher.Document pubDoc in app.Documents)
{
if (pubDoc.FullName.ToLower() == strArtifactLocation.ToLower())
{
if (!pubDoc.ActiveWindow.Visible)
{
retVal.Type = FuncRetValEnum.NoAction_Needed;
return retVal;
}
else
{
pubDoc.ActiveWindow.Visible = false;
retVal.Type = FuncRetValEnum.Action_Succeeded;
}
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal QueryClose(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningPublisherApps = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Publisher.Application>();
foreach (Microsoft.Office.Interop.Publisher.Application app in RunningPublisherApps)
{
foreach (Microsoft.Office.Interop.Publisher.Document pubDoc in app.Documents)
{
if (pubDoc.FullName.ToLower() == strArtifactLocation.ToLower())
{
if (pubDoc.Saved)
{
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
else
{
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Close(string strArtifactLocation, bool bAutoSaveArtifact, out int WindowHeight, out int WindowWidth, out int WindowTop, out int WindowLeft)
{
FuncRetVal retVal = new FuncRetVal();
WindowTop = 0;
WindowLeft = 0;
WindowWidth = 0;
WindowHeight = 0;
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningPublisherApps = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Publisher.Application>();
foreach (Microsoft.Office.Interop.Publisher.Application app in RunningPublisherApps)
{
foreach (Microsoft.Office.Interop.Publisher.Document pubDoc in app.Documents)
{
if (pubDoc.FullName.ToLower() == strArtifactLocation.ToLower())
{
// Save the Document
if (bAutoSaveArtifact)
pubDoc.Save();
// Get the Window properties
WindowTop = pubDoc.ActiveWindow.Top;
WindowLeft = pubDoc.ActiveWindow.Left;
WindowWidth = pubDoc.ActiveWindow.Width;
WindowHeight = pubDoc.ActiveWindow.Height;
// Get the Handle
IntPtr hWnd = (IntPtr)pubDoc.ActiveWindow.Hwnd;
Process process = Functions.GetProcessFromHandle(hWnd);
// Send Close Message
if (Functions.SendMessage((IntPtr)hWnd, Functions.FuncEnum.WindowMessage.WM_CLOSE, IntPtr.Zero, IntPtr.Zero) == 0)
{
process.Kill();
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
else
{
retVal.Type = FuncRetValEnum.Action_Failed;
return retVal;
}
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Close(string strArtifactLocation, bool bAutoSaveArtifact)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningPublisherApps = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Publisher.Application>();
foreach (Microsoft.Office.Interop.Publisher.Application app in RunningPublisherApps)
{
foreach (Microsoft.Office.Interop.Publisher.Document pubDoc in app.Documents)
{
if (pubDoc.FullName.ToLower() == strArtifactLocation.ToLower())
{
// Save the Document
if(bAutoSaveArtifact)
pubDoc.Save();
// Get the Handle
IntPtr hWnd = (IntPtr)pubDoc.ActiveWindow.Hwnd;
Process process = Functions.GetProcessFromHandle(hWnd);
// Send Close Message
if (Functions.SendMessage((IntPtr)hWnd, Functions.FuncEnum.WindowMessage.WM_CLOSE, IntPtr.Zero, IntPtr.Zero) == 0)
{
process.Kill();
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
else
{
retVal.Type = FuncRetValEnum.Action_Failed;
return retVal;
}
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Close(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningPublisherApps = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Publisher.Application>();
foreach (Microsoft.Office.Interop.Publisher.Application app in RunningPublisherApps)
{
foreach (Microsoft.Office.Interop.Publisher.Document pubDoc in app.Documents)
{
if (pubDoc.FullName.ToLower() == strArtifactLocation.ToLower())
{
// Save the Document
pubDoc.Save();
// Get the Handle
IntPtr hWnd = (IntPtr)pubDoc.ActiveWindow.Hwnd;
Process process = Functions.GetProcessFromHandle(hWnd);
// Send Close Message
if (Functions.SendMessage((IntPtr)hWnd, Functions.FuncEnum.WindowMessage.WM_CLOSE, IntPtr.Zero, IntPtr.Zero) == 0)
{
process.Kill();
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
else
{
retVal.Type = FuncRetValEnum.Action_Failed;
return retVal;
}
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
}
}

View File

@@ -0,0 +1,320 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Foo.AddIn.Common;
using System.Runtime.InteropServices;
// Ignore 'Ambiguity' warning message, seems like no way around those
#pragma warning disable 0467
namespace Foo.Addin.Office
{
public class Visio_Workspace : IWorkspace
{
public const string Visio_ProgId = "Visio.Application";
public FuncRetVal Launch(string strArtifactLocation, int WindowHeight, int WindowWidth, int WindowTop, int WindowLeft)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
Microsoft.Office.Interop.Visio.Application app = null;
app = new Microsoft.Office.Interop.Visio.Application();
// Mark the Application as visible
app.Visible = true;
app.Documents.Open(strArtifactLocation);
// ToDo: Check if a new process got created? / or if hWnd exists???
// - Also PERFORM Window Positioning
app.ActiveWindow.SetWindowRect(WindowLeft, WindowTop, WindowWidth, WindowHeight);
retVal.Type = FuncRetValEnum.Action_Succeeded;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Launch(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
Microsoft.Office.Interop.Visio.Application app = null;
app = new Microsoft.Office.Interop.Visio.Application();
// Mark the Application as visible
app.Visible = true;
app.Documents.Open(strArtifactLocation);
// Keep Track of all our Excel Instances -- not needed in visio?
///WorkspaceState.Launched_ExcelInstances.Add(app);
retVal.Type = FuncRetValEnum.Action_Succeeded;
//if (!String.IsNullOrEmpty(strArtifactLocation) && (strArtifactLocation.Length > 3))
//{
// Process.Start(strArtifactLocation);
//}
//return FuncDepBoolType.ParametersInvalid;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Show(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningVisioDocs = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Visio.Document>();
foreach (Microsoft.Office.Interop.Visio.Document doc in RunningVisioDocs)
{
if (doc.FullName.ToLower() == strArtifactLocation.ToLower())
{
// TO DO - (doc.Application.Documents.Count == 1); not working, why?!?!? odd
bool bIsTrue = (doc.Application.Documents.Count == 1); // not working, why?!?!? odd
//bool bIsTheOnlyDocumentInApp = true;
if (!doc.Application.Visible) // && bIsTheOnlyDocumentInApp)
{
doc.Application.Visible = true;
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
else
{
retVal.Type = FuncRetValEnum.NoAction_Needed;
return retVal;
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Hide(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningVisioDocs = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Visio.Document>();
foreach (Microsoft.Office.Interop.Visio.Document doc in RunningVisioDocs)
{
if (doc.FullName.ToLower() == strArtifactLocation.ToLower())
{
// TO DO - (doc.Application.Documents.Count == 1); not working, why?!?!? odd
bool bIsTrue = (doc.Application.Documents.Count == 1); // not working, why?!?!? odd
//bool bIsTheOnlyDocumentInApp = true;
if (doc.Application.Visible) // && bIsTheOnlyDocumentInApp)
{
doc.Application.Visible = false;
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
else
{
retVal.Type = FuncRetValEnum.NoAction_Needed;
return retVal;
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal QueryClose(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningVisioDocs = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Visio.Document>();
foreach (Microsoft.Office.Interop.Visio.Document doc in RunningVisioDocs)
{
if (doc.FullName.ToLower() == strArtifactLocation.ToLower())
{
if (doc.Saved)
{
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
else
{
retVal.Type = FuncRetValEnum.Action_Failed;
return retVal;
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Close(string strArtifactLocation, bool bAutoSaveArtifact, out int WindowHeight, out int WindowWidth, out int WindowTop, out int WindowLeft)
{
FuncRetVal retVal = new FuncRetVal();
WindowTop = 0;
WindowLeft = 0;
WindowWidth = 0;
WindowHeight = 0;
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningVisioDocs = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Visio.Document>();
foreach (Microsoft.Office.Interop.Visio.Document doc in RunningVisioDocs)
{
if (doc.FullName.ToLower() == strArtifactLocation.ToLower())
{
if (bAutoSaveArtifact)
doc.Save();
var app = doc.Application;
// Get the Window properties
app.ActiveWindow.GetWindowRect(out WindowLeft, out WindowTop, out WindowWidth, out WindowHeight);
doc.Close();
Marshal.FinalReleaseComObject(doc); // Force Clean-up
if (app.Documents.Count == 0)
{
app.Quit();
Marshal.FinalReleaseComObject(app); // force clean-up
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Close(string strArtifactLocation, bool bAutoSaveArtifact)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningVisioDocs = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Visio.Document>();
foreach (Microsoft.Office.Interop.Visio.Document doc in RunningVisioDocs)
{
if (doc.FullName.ToLower() == strArtifactLocation.ToLower())
{
if(bAutoSaveArtifact)
doc.Save();
var app = doc.Application;
doc.Close();
Marshal.FinalReleaseComObject(doc); // Force Clean-up
if (app.Documents.Count == 0)
{
app.Quit();
Marshal.FinalReleaseComObject(app); // force clean-up
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Close(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningVisioDocs = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Visio.Document>();
foreach (Microsoft.Office.Interop.Visio.Document doc in RunningVisioDocs)
{
if (doc.FullName.ToLower() == strArtifactLocation.ToLower())
{
doc.Save();
var app = doc.Application;
doc.Close();
Marshal.FinalReleaseComObject(doc); // Force Clean-up
if (app.Documents.Count == 0)
{
app.Quit();
Marshal.FinalReleaseComObject(app); // force clean-up
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
}
}

424
AddIns/Addin.Office/Word.cs Normal file
View File

@@ -0,0 +1,424 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Foo.AddIn.Common;
using System.Runtime.InteropServices;
using System.Reflection;
// Ignore 'Ambiguity' warning message, seems like no way around those
#pragma warning disable 0467
namespace Foo.Addin.Office
{
public class Word_Workspace : IWorkspace
{
public const string Word_ProgId = "Word.Application";
public FuncRetVal Launch(string strArtifactLocation, int WindowHeight, int WindowWidth, int WindowTop, int WindowLeft)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
Microsoft.Office.Interop.Word.Application app = null;
app = Functions.GetCOMObject(Word_ProgId) as Microsoft.Office.Interop.Word.Application;
// If no existing Word App is open, open a new one
if (app == null)
{
app = new Microsoft.Office.Interop.Word.Application();
app.Visible = true;
}
object fileName = strArtifactLocation;
object missing = Missing.Value;
Microsoft.Office.Interop.Word.Document doc = null;
doc = app.Documents.Open(ref fileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
if (doc != null)
{
// Find the correct Window and position it
foreach (Microsoft.Office.Interop.Word.Window window in doc.Windows)
{
if (window.Document.FullName.ToLower() == strArtifactLocation.ToLower())
{
window.Top = WindowTop;
window.Left = WindowLeft;
window.Height = WindowHeight;
window.Width = WindowWidth;
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
}
retVal.Type = FuncRetValEnum.Action_Succeeded;
}
else
{
retVal.Type = FuncRetValEnum.Action_Failed;
}
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Launch(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
Microsoft.Office.Interop.Word.Application app = null;
app = Functions.GetCOMObject(Word_ProgId) as Microsoft.Office.Interop.Word.Application;
// If no existing Word App is open, open a new one
if (app == null)
{
app = new Microsoft.Office.Interop.Word.Application();
app.Visible = true;
}
object fileName = strArtifactLocation;
object missing = Missing.Value;
Microsoft.Office.Interop.Word.Document doc = null;
doc = app.Documents.Open(ref fileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
if (doc != null)
{
retVal.Type = FuncRetValEnum.Action_Succeeded;
}
else
{
retVal.Type = FuncRetValEnum.Action_Failed;
}
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Show(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningWordDocuments = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Word.Document>();
foreach (Microsoft.Office.Interop.Word.Document doc in RunningWordDocuments)
{
foreach (Microsoft.Office.Interop.Word.Window window in doc.Windows)
{
if (window.Document.FullName.ToLower() == strArtifactLocation.ToLower())
{
if (!window.Visible)
{
window.Visible = true;
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
else
{
retVal.Type = FuncRetValEnum.NoAction_Needed;
return retVal;
}
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Hide(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningWordDocuments = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Word.Document>();
foreach (Microsoft.Office.Interop.Word.Document doc in RunningWordDocuments)
{
foreach (Microsoft.Office.Interop.Word.Window window in doc.Windows)
{
if (window.Document.FullName.ToLower() == strArtifactLocation.ToLower())
{
if (window.Visible)
{
window.Visible = false;
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
else
{
retVal.Type = FuncRetValEnum.NoAction_Needed;
return retVal;
}
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal QueryClose(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningWordDocuments = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Word.Document>();
foreach (Microsoft.Office.Interop.Word.Document doc in RunningWordDocuments)
{
if (doc.FullName.ToLower() == strArtifactLocation.ToLower())
{
if (doc.Saved)
{
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
else
{
retVal.Type = FuncRetValEnum.Action_Failed;
return retVal;
}
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Close(string strArtifactLocation, bool bAutoSaveArtifact, out int WindowHeight, out int WindowWidth, out int WindowTop, out int WindowLeft)
{
FuncRetVal retVal = new FuncRetVal();
WindowTop = 0;
WindowLeft = 0;
WindowWidth = 0;
WindowHeight = 0;
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningWordDocuments = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Word.Document>();
foreach (Microsoft.Office.Interop.Word.Document doc in RunningWordDocuments)
{
if (doc.FullName.ToLower() == strArtifactLocation.ToLower())
{
// Found the document to close * Close it Without Prompting *
object saveOption = null;
if (bAutoSaveArtifact)
saveOption = Microsoft.Office.Interop.Word.WdSaveOptions.wdSaveChanges;
else
saveOption = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;
object originalFormat = Microsoft.Office.Interop.Word.WdOriginalFormat.wdOriginalDocumentFormat;
object routeDocument = false;
var app = doc.Application;
// Let's get the Window that belongs to this document
Microsoft.Office.Interop.Word.Window docWindow = null;
foreach (Microsoft.Office.Interop.Word.Window window in doc.Windows)
{
if (window.Document.FullName.ToLower() == strArtifactLocation.ToLower())
docWindow = window;
}
// Get the Window properties
WindowTop = docWindow.Top;
WindowLeft = docWindow.Left;
WindowWidth = docWindow.Width;
WindowHeight = docWindow.Height;
//Object missing = Missing.Value;
doc.Close(ref saveOption, ref originalFormat, ref routeDocument);
Marshal.FinalReleaseComObject(doc); // force clean-up
// Close the Window
if (docWindow != null)
docWindow.Close(ref saveOption, ref routeDocument);
// Close Word if this is the Last Document Instance
if (app.Documents.Count == 0)
{
app.Quit(ref saveOption, ref originalFormat, ref routeDocument);
Marshal.FinalReleaseComObject(docWindow);
Marshal.FinalReleaseComObject(app); // force clean-up, closes Process for sure
}
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Close(string strArtifactLocation, bool bAutoSaveArtifact)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningWordDocuments = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Word.Document>();
foreach (Microsoft.Office.Interop.Word.Document doc in RunningWordDocuments)
{
if (doc.FullName.ToLower() == strArtifactLocation.ToLower())
{
// Found the document to close * Close it Without Prompting *
object saveOption = null;
if (bAutoSaveArtifact)
saveOption = Microsoft.Office.Interop.Word.WdSaveOptions.wdSaveChanges;
else
saveOption = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;
object originalFormat = Microsoft.Office.Interop.Word.WdOriginalFormat.wdOriginalDocumentFormat;
object routeDocument = false;
var app = doc.Application;
// Let's get the Window that belongs to this document
Microsoft.Office.Interop.Word.Window docWindow = null;
foreach (Microsoft.Office.Interop.Word.Window window in doc.Windows)
{
if (window.Document.FullName.ToLower() == strArtifactLocation.ToLower())
docWindow = window;
}
//Object missing = Missing.Value;
doc.Close(ref saveOption, ref originalFormat, ref routeDocument);
Marshal.FinalReleaseComObject(doc); // force clean-up
// Close the Window
if (docWindow != null)
docWindow.Close(ref saveOption, ref routeDocument);
// Close Word if this is the Last Document Instance
if (app.Documents.Count == 0)
{
app.Quit(ref saveOption, ref originalFormat, ref routeDocument);
Marshal.FinalReleaseComObject(docWindow);
Marshal.FinalReleaseComObject(app); // force clean-up, closes Process for sure
}
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
public FuncRetVal Close(string strArtifactLocation)
{
FuncRetVal retVal = new FuncRetVal();
if (!Validate.IsValidArtifactLocation(strArtifactLocation, ref retVal))
return retVal;
try
{
var RunningWordDocuments = Functions.GetRunningObjectsOfType<Microsoft.Office.Interop.Word.Document>();
foreach (Microsoft.Office.Interop.Word.Document doc in RunningWordDocuments)
{
if (doc.FullName.ToLower() == strArtifactLocation.ToLower())
{
// Found the document to close * Close it Without Prompting *
object saveOption = Microsoft.Office.Interop.Word.WdSaveOptions.wdSaveChanges;
object originalFormat = Microsoft.Office.Interop.Word.WdOriginalFormat.wdOriginalDocumentFormat;
object routeDocument = false;
var app = doc.Application;
// Let's get the Window that belongs to this document
Microsoft.Office.Interop.Word.Window docWindow = null;
foreach (Microsoft.Office.Interop.Word.Window window in doc.Windows)
{
if (window.Document.FullName.ToLower() == strArtifactLocation.ToLower())
docWindow = window;
}
//Object missing = Missing.Value;
doc.Close(ref saveOption, ref originalFormat, ref routeDocument);
Marshal.FinalReleaseComObject(doc); // force clean-up
// Close the Window
if (docWindow != null)
docWindow.Close(ref saveOption, ref routeDocument);
// Close Word if this is the Last Document Instance
if (app.Documents.Count == 0)
{
app.Quit(ref saveOption, ref originalFormat, ref routeDocument);
Marshal.FinalReleaseComObject(docWindow);
Marshal.FinalReleaseComObject(app); // force clean-up, closes Process for sure
}
retVal.Type = FuncRetValEnum.Action_Succeeded;
return retVal;
}
}
retVal.Type = FuncRetValEnum.ArtifactUnavailable;
}
catch (Exception e)
{
retVal.Message = e.Message;
retVal.Type = FuncRetValEnum.ErrorThrown;
}
return retVal;
}
}
}

View File

@@ -0,0 +1,19 @@
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Class="Foo.ClientServices.ButtonWPForm.ButtonForm"
Title="ButtonForm" Closed="Window_Closed" Height="419" Width="538" WindowStyle="None" AllowsTransparency="True" Background="Transparent" ShowInTaskbar="False" Loaded="OnLoad" ResizeMode="NoResize" ShowActivated="False" mc:Ignorable="d">
<Grid>
<Rectangle x:Name="recGradiant" Stroke="Black" RadiusY="7.5" RadiusX="7.5" >
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" Opacity="1.0">
<GradientStop Color="#FF000000" Offset="0.238"/>
<GradientStop Color="#FE333333" Offset="0.778"/>
<GradientStop Color="#FE202020" Offset="0.613"/>
<GradientStop Color="#FE333333" Offset="0.87"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Frame x:Name="frmButtonForm" Margin="0,40,0,0" VerticalAlignment="Top" Height="371" />
</Grid>
</Window>

View File

@@ -0,0 +1,211 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Reflection;
using SnapshotImage = System.Drawing.Image;
// Ooganizer namespaces
using Foo.ClientServices.ButtonWPForm.ButtonFormPages;
using Foo.Platform;
using Foo.Platform.Win32;
using Foo.Platform.ErrorReporting;
using Foo.Platform.Interacters;
using System.Windows.Interop;
namespace Foo.ClientServices.ButtonWPForm
{
/// <summary>
/// Interaction logic for ButtonWindow Form
/// </summary>
[ComVisible(false)]
public partial class ButtonForm : Window
{
////
// Public Properties
////
public IntPtr HookedWindow { get { return _hHookedWnd; } set { _hHookedWnd = value; } } // Passed in by FormMgr
public System.Drawing.Image SnapShot { get { return _SnapShot; } set { _SnapShot = value; } } // Passed in by FormMgr
//public Artifact Artifact { get { return _Artifact; } }
//public string ArtifactTitle { get { return _ArtifactTitle; } }
//public string ArtifactLocation { get { return _ArtifactLocation; } }
//public string CurrentWorkspaceName { get { return _CurrentWorkspaceName; } }
////
// Private Member Variables
////
private IntPtr _hHookedWnd = IntPtr.Zero;
private System.Drawing.Image _SnapShot = null;
private bool _PerformanceCache = false;
private static ButtonForm s_PerfCacheButtonFormObj = null;
private bool _PerfCacheLoadedHidden = false;
//private Artifact _Artifact;
//private string _ArtifactTitle;
//private string _ArtifactLocation;
//private string _CurrentWorkspaceName;
////
// ButtonFormPages
////
IButtonFormPage[] m_ButtonFormPages = new IButtonFormPage[1];
// Declare the Log4net Variable
private static log4net.ILog Log = Logger.GetLog4NetInterface(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Construct WPF ButtonForm :)
/// </summary>
public ButtonForm()
{
InitializeComponent();
}
/// <summary>
/// Construct WPF ButtonForm (Performance Cache)
/// </summary>
public ButtonForm(bool bPerformanceCache)
{
if (bPerformanceCache && (s_PerfCacheButtonFormObj == null))
{
_PerformanceCache = bPerformanceCache;
s_PerfCacheButtonFormObj = this;
}
InitializeComponent();
}
/// <summary>
/// As part of Performance Caching (load one instance of this form
/// hidden and not visible to the user (called by FormMgr) ~also
/// allows to hide and existing one
/// ~Should only be called by FormMgr when creating the first object
/// </summary>
public void LoadHideButtonFormPerfCache()
{
if (!_PerfCacheLoadedHidden && _PerformanceCache && (s_PerfCacheButtonFormObj != null))
{
s_PerfCacheButtonFormObj.Opacity = 0;
s_PerfCacheButtonFormObj.WindowState = WindowState.Minimized;
s_PerfCacheButtonFormObj.ShowInTaskbar = false;
s_PerfCacheButtonFormObj.Show();
s_PerfCacheButtonFormObj.Hide();
_PerfCacheLoadedHidden = true;
}
}
/// <summary>
/// Window Load Event. We want all object loading to happen in the Load Event,
/// because we construct the WPFForm and show it right away, so this is called right at
/// start up, so put all the object loading in here to be cleaner and simplify FormObject Creator
/// </summary>
private void OnLoad(object sender, RoutedEventArgs args)
{
try
{
if (_PerformanceCache && (this == s_PerfCacheButtonFormObj)) // Preload child pages
{
PreloadAllChildPages();
// Add Message Hook for performance WPForm * To make sure it is always invisible *
HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
source.AddHook(new HwndSourceHook(MessageHook));
}
else if (!_PerformanceCache && (HookedWindow != IntPtr.Zero) && (this != s_PerfCacheButtonFormObj))
{
////
// Resolve the Window and set the properties accordingly,
// our child pages depend on this information
////
//ResolverDispatch resolver = new ResolverDispatch();
//ArtifactGroup artifacts = resolver.GetArtifacts(HookedWindow);
//if (artifacts.Length > 0)
//{
// _Artifact = artifacts.GetPrimary;
// _ArtifactTitle = _Artifact.Name;
// _ArtifactLocation = _Artifact.Location;
// // Workspace
// _CurrentWorkspaceName = SrvrCommon.GetCurrentWorkspaceName();
// // Now Load the Page
// LoadPageAccordingToState();
//}
//else
//{
// // Somemething went wrong Resolving
// UserError.Show("Document not Found", "Failed to accurately find the document for the Window");
// Close(); //~imp, we must close this Form
//}
}
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - A fatal error occured loading ButtonForm", MethodBase.GetCurrentMethod().Name), e);
Close(); //~imp, we must close this Form
}
}
/// <summary>
/// This Message Hook is for the Hidden WPForm that we use for better performance,
/// We want to make sure that it is never displayed *It can occur that explore can show it, without this*
/// </summary>
private IntPtr MessageHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
// force opacity at all times
if (Opacity == 1.0)
Opacity = 0.0;
// force minimized at all times
if (WindowState != WindowState.Minimized)
WindowState = WindowState.Minimized;
// force Not to be seen in taskbar
if (ShowInTaskbar == true)
ShowInTaskbar = false;
return System.IntPtr.Zero;
}
/// <summary>
/// For Performance, we need to preload all Child Pages
/// </summary>
private void PreloadAllChildPages()
{
m_ButtonFormPages[0] = (IButtonFormPage) new Page_AddEdit();
m_ButtonFormPages[0].ParentWPFContainer = this;
}
/// <summary>
/// Show different pages depending on the state we are in. (Currently only 1 state)
/// </summary>
private void LoadPageAccordingToState()
{
m_ButtonFormPages[0] = (IButtonFormPage) new Page_AddEdit();
m_ButtonFormPages[0].ParentWPFContainer = this;
if (!frmButtonForm.Navigate((Page) m_ButtonFormPages[0]))
Log.Info(string.Format("{0}() - ButtonForm could not navigate to Page_AddEdit", MethodBase.GetCurrentMethod().Name));
}
/// <summary>
/// When this window closes position the Hooked Window back to it's original position
/// </summary>
private void Window_Closed(object sender, EventArgs e)
{
// GUICommon.PositionWindowBackToWhereItWas(HookedWindow, true);
BHInteracter.SetAsActiveWindow(HookedWindow);
}
}
}

View File

@@ -0,0 +1,324 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Drawing;
using System.Threading;
using System.Windows.Interop;
using System.EnterpriseServices;
using System.Windows;
using System.IO;
using System.Windows.Threading;
using System.Collections;
using System.Reflection;
// Ooganizer Namespaces
using Foo.Platform;
using Foo.Platform.Win32;
namespace Foo.ClientServices.ButtonWPForm
{
/// <summary>
/// This class manages the creation/deletion and actions of (1 - n) ButtonForms
/// </summary>
[ComVisible(false)]
internal class ButtonFormMgr
{
private const int INITIAL_OBJECT_CAPACITY = 30;
private Hashtable m_ObjectList = null;
private Dispatcher m_Dispatcher = null;
// we have one btnForm loaded (hidden) always, as a performance cache
private ButtonForm m_btnForm = null;
private bool m_IsBtnFormCached = false;
// Imp! - allows external caller to run any action on a ButtonForm
public delegate void _Action(ButtonForm btnForm);
//custom private delegates
private delegate void delegate_Create(int hParentWND, Image snapshot);
private delegate void delegate_Delete(int hParentWND);
private delegate int delegate_CreateWindow(int hParentWND);
private delegate void delegate_Action(int hParentWND, _Action action);
// Declare the Log4net Variable
private static log4net.ILog Log = Logger.GetLog4NetInterface(MethodBase.GetCurrentMethod().DeclaringType);
public ButtonFormMgr(Dispatcher disp)
{
m_ObjectList = new Hashtable();
m_Dispatcher = disp;
if (!m_IsBtnFormCached)
BetterPerformance();
}
/// <summary>
/// Calls Create_ButtonForm via Dispatcher if neccessary
/// </summary>
/// <param name="hParentWND">handle to Parent/Owner Window</param>
public void Create_ButtonFormDISP(int hParentWND, Image snapshot)
{
if (hParentWND != 0)
{
if (m_Dispatcher.Thread == Thread.CurrentThread)
{
Create_ButtonForm(hParentWND, snapshot);
}
else
{
object[] parameters = new object[] { hParentWND, snapshot };
m_Dispatcher.Invoke((delegate_Create)Create_ButtonFormDISP, System.Windows.Threading.DispatcherPriority.Normal, parameters);
}
}
}
/// <summary>
/// Calls Create_ButtonFormWindow via Dispatcher if neccessary
/// </summary>
/// <param name="hParentWND">handle to Parent/Owner Window</param>
public int Create_ButtonFormWindowDISP(int hParentWND)
{
if (hParentWND != 0)
{
if (m_Dispatcher.Thread == Thread.CurrentThread)
{
return Create_ButtonFormWindow(hParentWND);
}
else
{
object[] parameters = new object[] { hParentWND };
return (int)m_Dispatcher.Invoke((delegate_CreateWindow)Create_ButtonFormWindowDISP, System.Windows.Threading.DispatcherPriority.Normal, parameters);
}
}
return 0;
}
/// <summary>
/// Calls Delete_ButtonForm via Dispatcher if neccessary
/// </summary>
/// <param name="hParentWND">handle to Parent/Owner Window</param>
public void Delete_ButtonFormDISP(int hParentWND)
{
if (hParentWND != 0)
{
if (m_Dispatcher.Thread == Thread.CurrentThread)
{
Delete_ButtonForm(hParentWND);
}
else
{
object[] parameters = new object[] { hParentWND };
m_Dispatcher.Invoke((delegate_Delete)Delete_ButtonFormDISP, System.Windows.Threading.DispatcherPriority.Normal, parameters);
}
}
}
/// <summary>
/// Use this Dispatching Action Function to run any _Action on the ButtonForm
/// </summary>
/// <param name="hParentWND">handle to Parent/Owner Window</param>
public void RunAction_ButtonFormDISP(int hParentWND, _Action action)
{
if (hParentWND != 0)
{
if (m_Dispatcher.Thread == Thread.CurrentThread)
{
RunAction_ButtonForm(hParentWND, action);
}
else
{
object[] parameters = new object[] { hParentWND, action };
m_Dispatcher.Invoke((delegate_Action)RunAction_ButtonFormDISP, System.Windows.Threading.DispatcherPriority.Normal, parameters);
}
}
}
/// <summary>
/// Calls Terminate via Dispatcher if neccessary
/// </summary>
/// <param name="hParentWND">handle to Parent/Owner Window</param>
public void TerminateDISP()
{
if (m_Dispatcher.Thread == Thread.CurrentThread)
{
Terminate();
}
else
{
m_Dispatcher.Invoke((Action)TerminateDISP, System.Windows.Threading.DispatcherPriority.Normal, null);
}
}
/// <summary>
/// Creates a new ButtonForm object into the ObjectList
/// </summary>
/// <param name="hParentWND">handle to Parent/Owner Window</param>
private void Create_ButtonForm(int hParentWND, Image snapshot)
{
try
{
if (!m_IsBtnFormCached)
BetterPerformance();
m_ObjectList[hParentWND] = new ButtonForm();
ButtonForm btnForm = (ButtonForm)m_ObjectList[hParentWND];
if (btnForm != null)
{
// We use the InteropHelper to set the Owner Property
WindowInteropHelper InteropHelper = new WindowInteropHelper(btnForm);
InteropHelper.Owner = (IntPtr)hParentWND;
// Set the important Fields into the Button Form
btnForm.HookedWindow = (IntPtr)hParentWND; // give it the handle to the hooked window
btnForm.SnapShot = snapshot; // give it the snapshot of the window
RECT ParentWndRect = new RECT();
Win32Functions.GetWindowRect((IntPtr)hParentWND, out ParentWndRect);
// Get Initial Location for the form
btnForm.Top = ParentWndRect.top;
btnForm.Left = ParentWndRect.left;
// Get Initial Height and Width of the form
btnForm.Height = (ParentWndRect.bottom - ParentWndRect.top);
btnForm.Width = (ParentWndRect.right - ParentWndRect.left);
}
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - error thrown", MethodBase.GetCurrentMethod().Name), e);
}
}
/// <summary>
/// Use this function to delete the ButtonForm Object
/// </summary>
/// <param name="hParentWND">handle to Parent/Owner Window</param>
private void Delete_ButtonForm(int hParentWND)
{
try
{
if (m_ObjectList.ContainsKey(hParentWND))
{
ButtonForm btnForm = (ButtonForm)m_ObjectList[hParentWND];
if (btnForm != null)
{
m_ObjectList.Remove(hParentWND);
btnForm.Close();
}
}
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - error thrown", MethodBase.GetCurrentMethod().Name), e);
}
}
/// <summary>
/// Use this to run void() function actions on the specified buttonform
/// </summary>
/// <param name="hParentWND">handle to Parent/Owner Window</param>
/// <param name="action">a pointer to a delegate (action function) to run</param>
private void RunAction_ButtonForm(int hParentWND, _Action action)
{
try
{
if (m_ObjectList.ContainsKey(hParentWND))
{
ButtonForm btnForm = (ButtonForm)m_ObjectList[hParentWND];
if (btnForm != null)
action(btnForm);
}
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - error thrown", MethodBase.GetCurrentMethod().Name), e);
}
}
/// <summary>
/// Use this to actually create the Window, call this after calling Create_ButtonForm
/// This will create the window by calling Show(), this will also show the window
/// </summary>
/// <param name="hParentWND">handle to Parent/Owner Window</param>
/// <returns>the Handle to the newly created window object</returns>
private int Create_ButtonFormWindow(int hParentWND)
{
try
{
if (m_ObjectList.ContainsKey(hParentWND))
{
ButtonForm btnForm = (ButtonForm)m_ObjectList[hParentWND];
// We use the InteropHelper to see if this WPFForm has been created previously
WindowInteropHelper InteropHelper = new WindowInteropHelper(btnForm);
if (InteropHelper.Handle == IntPtr.Zero)
{
btnForm.Show();
}
return (int)InteropHelper.Handle;
}
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - error thrown", MethodBase.GetCurrentMethod().Name), e);
}
return 0;
}
/// <summary>
/// Kills all ButtonForm Instances (STOPS ALL)
/// </summary>
private void Terminate()
{
try
{
foreach (object o in m_ObjectList)
{
if ((o != null) && (o is ButtonForm))
{
ButtonForm btnForm = (ButtonForm)o;
btnForm.Close();
}
}
m_ObjectList.Clear();
if (m_IsBtnFormCached)
{
m_btnForm.Close();
m_IsBtnFormCached = false;
}
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - error thrown", MethodBase.GetCurrentMethod().Name), e);
}
}
/// <summary>
/// In order to improve first WPForm performance we have one
/// WPForm ButtonForm loaded at all times. (opacity set to 0).
/// ~it has no parent setting so it is just a form of the desktop
/// </summary>
private void BetterPerformance()
{
if (!m_IsBtnFormCached)
{
try
{
// Performance Cache (keeps a window loaded always)
m_btnForm = new ButtonForm(true);
m_btnForm.LoadHideButtonFormPerfCache();
m_IsBtnFormCached = true;
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - error thrown", MethodBase.GetCurrentMethod().Name), e);
}
}
}
}
}

View File

@@ -0,0 +1,18 @@
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Class="Foo.ClientServices.ButtonWPForm.ButtonFormPages.Page_AddEdit"
Title="Page_AddEdit" Loaded="Page_Loaded" mc:Ignorable="d" Height="255" Width="550">
<Grid d:LayoutOverrides="VerticalMargin">
<Border CornerRadius="6" Background="Gray" Opacity="0.325" HorizontalAlignment="Left" Width="550"/>
<TextBox Margin="90,33,39,0" x:Name="txtTitle" Height="22" VerticalAlignment="Top" />
<Label Height="28" HorizontalAlignment="Left" Margin="48,30.667,0,0" x:Name="lblTitle" VerticalAlignment="Top" Width="36" Foreground="White" Content="Title" RenderTransformOrigin="-1.028,1.036"/>
<TextBox TextAlignment="Left" VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" Margin="90,0,39,77.671" x:Name="txtLocation" Background="Transparent" Foreground="White" BorderBrush="{x:Null}" Focusable="False" IsTabStop="False" VerticalAlignment="Bottom" Height="40" />
<ComboBox Margin="90,85,39,0" x:Name="comboWorkspaces" Height="24" VerticalAlignment="Top" d:LayoutOverrides="VerticalAlignment" />
<Label HorizontalAlignment="Left" Margin="12,83.334,0,0" x:Name="label1" Width="74" Foreground="White" Height="27" VerticalAlignment="Top" Content="Workspace" d:LayoutOverrides="VerticalAlignment"/>
<Label Height="24" HorizontalAlignment="Right" Margin="0,55,29,0" x:Name="lblRequired" VerticalAlignment="Top" Width="54" Foreground="White" FontSize="10" FontStyle="Italic" Content="Required" RenderTransformOrigin="1.963,0.542"/>
<Label FontSize="10" FontStyle="Italic" Foreground="White" Height="24" HorizontalAlignment="Right" Margin="0,108.331,29,0" x:Name="lblRequired3" VerticalAlignment="Top" Width="54" Content="Required"/>
<Button HorizontalAlignment="Left" Margin="90,201.649,0,0" x:Name="btnCancel" Width="75" Click="btnCancel_Click" Content="Cancel" VerticalAlignment="Top" Height="23"/>
<Button HorizontalAlignment="Right" Margin="0,201.649,39,0" x:Name="btnAdd" Width="75" Click="btnAdd_Click" Content="Add" VerticalAlignment="Top" Height="23"/>
</Grid>
</Page>

View File

@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Reflection;
// Ooganizer Namespaces
using Foo.Platform;
using Foo.Platform.Interacters;
namespace Foo.ClientServices.ButtonWPForm.ButtonFormPages
{
/// <summary>
/// Interaction logic for ButtonFormPage_AddEdit.xaml
/// </summary>
public partial class Page_AddEdit : Page, IButtonFormPage
{
#region IButtonFormPage
public ButtonForm ParentWPFContainer { get { return _ButtonForm; } set { _ButtonForm = value; } }
private ButtonForm _ButtonForm = null;
#endregion
// Declare the Log4net Variable
private static log4net.ILog Log = Logger.GetLog4NetInterface(MethodBase.GetCurrentMethod().DeclaringType);
public Page_AddEdit()
{
InitializeComponent();
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
if (ParentWPFContainer == null)
{
Log.Debug(string.Format("{0}() - ParentWPFContainer is null this should never happen", MethodBase.GetCurrentMethod().Name));
return;
}
// Set the Artifact Properties
//txtTitle.Text = ParentWPFContainer.ArtifactTitle;
// se
//txtLocation.Text = ParentWPFContainer.ArtifactLocation;
//txtLocation.ScrollToEnd();
// Add all workspaces to the combo selection
//foreach (Ooganizer.API.Workspace wspace in SrvrCommon.Workspaces)
// comboWorkspaces.Items.Add(wspace.Name);
////
// Default to the current Workspace or 0 if none are loaded
////
//if (ParentWPFContainer.CurrentWorkspaceName == "")
// comboWorkspaces.SelectedIndex = 0;
//else
// comboWorkspaces.SelectedValue = ParentWPFContainer.CurrentWorkspaceName;
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
BHInteracter.SetW32ButtonToNewState(ParentWPFContainer.HookedWindow, BHInteracter.BUTTON_HOOK_STATE.BUTTON_ADD);
ParentWPFContainer.Close();
}
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
//SrvrCommon.AddArtifactToWorkspace(txtTitle.Text, txtLocation.Text, ParentWPFContainer.SnapShot, ParentWPFContainer.CurrentWorkspaceName);
//BHInteracter.SetW32ButtonToNewState(ParentWPFContainer.HookedWindow, BHInteracter.BUTTON_HOOK_STATE.BUTTON_DELETE);
ParentWPFContainer.Close();
}
}
}

View File

@@ -0,0 +1,156 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E179DF39-539A-407F-94DE-C21F690E02C4}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Foo.ClientServices.ButtonWPForm</RootNamespace>
<AssemblyName>ButtonWPForm</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<StartupObject>
</StartupObject>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>MyKeyFile.SNK</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Target\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Target\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Components\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Page Include="ButtonForm.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="ButtonFormPages\Page_AddEdit.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Compile Include="ButtonForm.xaml.cs">
<DependentUpon>ButtonForm.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="ButtonFormMgr.cs" />
<Compile Include="ButtonFormPages\Page_AddEdit.xaml.cs">
<DependentUpon>Page_AddEdit.xaml</DependentUpon>
</Compile>
<Compile Include="ButtonWPFormCCW.cs" />
<Compile Include="CaptionButtonStarter.cs" />
<Compile Include="IButtonFormPage.cs" />
<Compile Include="IClientEvents.cs" />
<Compile Include="ComponentState.cs" />
<Compile Include="DispatcherThread.cs" />
<Compile Include="IButtonForm.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="MyKeyFile.SNK" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\DataAccessLayer\DataAccessLayer.csproj">
<Project>{C7E4B4C1-64D4-45FF-AAFD-C4B9AE216618}</Project>
<Name>DataAccessLayer</Name>
</ProjectReference>
<ProjectReference Include="..\..\GUILib\GUILib.csproj">
<Project>{C1282050-455B-44F4-8520-1C005E38EFB2}</Project>
<Name>GUILib</Name>
</ProjectReference>
<ProjectReference Include="..\..\Platform\Platform.csproj">
<Project>{F6929AFC-BF61-43A0-BABD-F807B65FFFA1}</Project>
<Name>Platform</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PostBuildEvent>$(FrameworkDir)\regasm.exe "$(SolutionDir)target\$(ConfigurationName)\$(TargetFileName)" /unregister
$(FrameworkDir)\regasm.exe "$(SolutionDir)target\$(ConfigurationName)\$(TargetFileName)" /tlb:$(TargetName).tlb /codebase
REM $(FrameworkDir)\regsvcs.exe /reconfig "$(SolutionDir)target\$(ConfigurationName)\$(TargetFileName)" /appdir:"$(SolutionDir)target\$(ConfigurationName)"</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,249 @@
// For GUIDebugStepExe Debugging Only - Uncomment this #define
#define GUIDEBUGSTEPEXE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Drawing;
using System.Threading;
using System.Windows.Interop;
using System.EnterpriseServices;
using System.Windows;
using System.IO;
using System.Windows.Threading;
using System.Collections;
using System.Reflection;
// Ooganizer Namespaces
using Foo.GUILib;
using Foo.Platform;
using Foo.Platform.Win32;
using Foo.Platform.Interacters;
using Foo.Platform.ErrorReporting;
namespace Foo.ClientServices.ButtonWPForm
{
/// <summary>
/// ButtonWPFormCCW - Com Callable Wrapper Class exposed to ButtonHook.
/// This class is responsible for creating the ButtonWPForm (a form created in response to a ButtonHook W32 Click)
/// </summary>
[Guid("6F108F0B-9CEB-4d3d-B1D9-7685F9F39E50")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("Foo.ClientServices.ButtonWPFormCCW")]
[ComVisible(true)]
[ObjectPooling(Enabled = true, MinPoolSize = 1, MaxPoolSize = 2500, CreationTimeout = 5000)]
#if GUIDEBUGSTEPEXE
public class ButtonWPFormCCW : IButtonForm, IClientEvents
#else
public class ButtonWPFormCCW : ServicedComponent, IButtonForm, IClientEvents, IProcessInitializer
#endif
{
////
// Member Variables
////
private IntPtr m_hWnd = IntPtr.Zero;
private IntPtr m_hWndParent = IntPtr.Zero;
private IntPtr m_hWndButton = IntPtr.Zero;
BHInteracter.BUTTON_HOOK_STATE m_ButtonState = BHInteracter.BUTTON_HOOK_STATE.BUTTON_NONE;
// Declare the Log4net Variable
private static log4net.ILog Log = Logger.GetLog4NetInterface(MethodBase.GetCurrentMethod().DeclaringType);
#region Construction / Destruction
public ButtonWPFormCCW() {}
~ButtonWPFormCCW() {}
#endregion
#if GUIDEBUGSTEPEXE
#region GuiDebugStepCustomStarterStopers
public void Start()
{
Log.Info(string.Format("{0}() - ComponentState Application Is being started", MethodBase.GetCurrentMethod().Name));
ComponentState.ApplicationIsRunning = true;
}
public void Stop()
{
Log.Info(string.Format("{0}() - ComponentState Application Is being stopped", MethodBase.GetCurrentMethod().Name));
ComponentState.ApplicationIsRunning = false;
}
#endregion
#else
#region IProcessInitializer Members
public void Startup(object punkProcessControl)
{
Log.Info(string.Format("{0}() - ComponentState Application Is being started", MethodBase.GetCurrentMethod().Name));
ComponentState.ApplicationIsRunning = true;
}
public void Shutdown()
{
Log.Info(string.Format("{0}() - ComponentState Application Is being stopped", MethodBase.GetCurrentMethod().Name));
ComponentState.ApplicationIsRunning = false;
}
#endregion
#endif
#region ButtonHook Activation/Deactivation
/// <summary>
/// This is called first time when the buttonhook is attaching into a Window. It passes us
/// important handle information that we need or may need to communicate back state information.
/// </summary>
/// <param name="hParentWND">the handle to the window the buttonhook is hooked into</param>
/// <param name="hButtonWND">the handle to the button Window (we need it if we want to communicat with it)</param>
public void WPFThreadProc_ButtonWPForm_Activated(int hParentWND, int hButtonWND)
{
// Store the handle information for later use
m_hWndParent = (IntPtr)hParentWND;
m_hWndButton = (IntPtr)hButtonWND;
}
/// <summary>
/// Called when the buttonhook is unattaching itself from a Window.
/// Here, we can do any cleanup that we may have to do.
/// </summary>
public void WPFThreadProc_ButtonWPForm_Deactivated()
{
try
{
if ((m_hWndParent != IntPtr.Zero) && (ComponentState.ButtonFormMgr != null))
ComponentState.ButtonFormMgr.Delete_ButtonFormDISP((int)m_hWndParent);
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - error thrown", MethodBase.GetCurrentMethod().Name), e);
}
}
#endregion
#region Custom Events
/// <summary>
/// This function is called when the Win32 button is clicked. This function should
/// handle the creation of the wpfform and display it over the window
/// </summary>
/// <returns>the window handle to the newly created wpfform to be stored by the caller</returns>
public int W32BUTTONCLICKED()
{
try
{
// Let's Position the Window and snapshot it...
Image snapshot = null;
try
{
BHInteracter.SetW32ButtonToNewState(m_hWndParent, BHInteracter.BUTTON_HOOK_STATE.BUTTON_NONE);
System.Threading.Thread.Sleep(100);
snapshot = GUICommon.PositionWindowToGoldenPosAndTakeSnapshot(m_hWndParent, true);
}
catch (Exception e)
{
UserError.Show("Snapshot Failed", "Obtaining a Snaphot for the Window Failed.");
Log.Error(string.Format("{0}() - error thrown", MethodBase.GetCurrentMethod().Name), e);
return 0;
}
if (snapshot != null)
{
// Create the WpfForm object and then create the wpfform window and show it.
ComponentState.ButtonFormMgr.Create_ButtonFormDISP((int)m_hWndParent, snapshot);
m_hWnd = (IntPtr) ComponentState.ButtonFormMgr.Create_ButtonFormWindowDISP((int)m_hWndParent);
return (int)m_hWnd;
}
else
{
UserError.Show("Snapshot Failed", "Obtaining a Snaphot for the Window Failed.");
Log.Error(string.Format("{0}() - UserError.Show() - Obtaining a Snapshot Failed", MethodBase.GetCurrentMethod().Name));
return 0;
}
}
catch (Exception e)
{
UserError.Show("Snapshot Failed", "Obtaining a Snaphot for the Window Failed.");
Log.Error(string.Format("{0}() - error thrown", MethodBase.GetCurrentMethod().Name), e);
return 0;
}
}
#endregion
#region Window Events we can extend on
public void WindowEvent_MaximizeOccured(int nHeight, int nWidth)
{
}
public void WindowEvent_MinimizeOccured()
{
}
public void WindowEvent_WindowActivated()
{
}
public void WindowEvent_WindowDeactivated()
{
}
#endregion
#region Resolver Client Events
public void ReResolve(int pid, IntPtr hWnd)
{
Log.Debug(string.Format("{0}() - Debug - ReResolve is called for {0} and {1}", pid, hWnd));
}
public void hWndInitialActivate(int pid, IntPtr hWnd, string ProcessStartUpPrms)
{
try
{
m_ButtonState = BHInteracter.SetW32ButtonToNewState(m_hWndParent, BHInteracter.BUTTON_HOOK_STATE.BUTTON_ADD);
Log.Debug(string.Format("{0}() - --- TEST --- ProcessStartUpPrms", ProcessStartUpPrms));
//// We need to resolve the window here
//ResolverDispatch resolver = new Resolver.ResolverDispatch();
//ArtifactGroup artifacts = resolver.GetArtifacts((IntPtr)hWnd);
//// If we can resolve this window then we want to be checking
//if (artifacts.Length >= 1)
//{
// Artifact curArtifact = artifacts.GetPrimary;
// bool bFound = SrvrCommon.IsArtifactInCurrentWorkspace(curArtifact);
// if (bFound)
// m_ButtonState = BHInteracter.SetW32ButtonToNewState(m_hWndParent, BHInteracter.BUTTON_HOOK_STATE.BUTTON_DELETE);
// else
// m_ButtonState = BHInteracter.SetW32ButtonToNewState(m_hWndParent, BHInteracter.BUTTON_HOOK_STATE.BUTTON_ADD);
//}
//else
//{
// Log.Error(string.Format("{0}() - WPForm could not resolve this Window - disabling the Caption Button", MethodBase.GetCurrentMethod().Name));
// m_ButtonState = BHInteracter.SetW32ButtonToNewState(m_hWndParent, BHInteracter.BUTTON_HOOK_STATE.BUTTON_NONE);
//}
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - WPForm could not resolve this Window - disabling the Caption Button", MethodBase.GetCurrentMethod().Name), e);
}
}
public void hWndLastDeactivate(int pid, IntPtr hWnd)
{
Log.Debug(string.Format("{0}() - Debug - hWndLastDeactivate is called for {0} and {1}", pid, hWnd));
}
public void DragNDropOccured(int pid, IntPtr hWnd, int nFiles, string SemiColonSepFileNames)
{
Log.Debug(string.Format("{0}() - Debug - DragNDropOccured is called with {0} and {1} and {2}", pid, hWnd, nFiles, SemiColonSepFileNames));
}
public void OpenOrSaveFileDialogOccured(int pid, IntPtr hWnd, string possibleLocAndFileName, string FileTypes)
{
Log.Debug(string.Format("{0}() - Debug - DragNDropOccured is called with {0} and {1} and {2}", pid, hWnd, possibleLocAndFileName, FileTypes));
}
#endregion
}
}

View File

@@ -0,0 +1,131 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Threading;
using System.Reflection;
// Ooganizer Namespaces
using Foo.Platform;
using Foo.Platform.Interacters;
namespace Foo.ClientServices.ButtonWPForm
{
/// <summary>
/// This class manages the creation/deletion of a Oogy CaptionButton Instance Exe.
/// A CaptionButton Instance hosts the ButtonHook.dll
/// </summary>
[ComVisible(false)]
internal class CaptionButtonStarter
{
// CaptionButton (ButtonHook.dll) Startup Delay
private const int CAPTIONBUTTON_STARTUP_DELAY_MILISECONDS = 4000;
// Member Variables
private static Thread s_ButtonHookKeepAliveThread = null;
private static bool s_ButtonHookKeepAliveThreadIsInitialized = false;
// Declare the Log4net Variable
private static log4net.ILog Log = Logger.GetLog4NetInterface(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Constructor by default will launch the thread if needed
/// </summary>
static CaptionButtonStarter()
{
StartButtonHookKeepAliveThreadIfNeeded();
}
/// <summary>
/// Use this property to set the CaptionButton to running / not running
/// </summary>
public static bool Run
{
get { return s_ButtonHookKeepAliveThreadIsInitialized; }
set
{
if (!value)
TerminateButtonHookKeepAliveThreadIfNeeded();
s_ButtonHookKeepAliveThreadIsInitialized = value;
}
}
/// <summary>
/// ButtonHookKeepAliveThread Thread for ButtonHook.dll - handled internally
/// </summary>
private static void ButtonHookKeepAliveThreadProc()
{
Thread.Sleep(CAPTIONBUTTON_STARTUP_DELAY_MILISECONDS);
while (true) // Make Sure ButtonHook stays alive (No User kills it for any reason)
{
if (!BHInteracter.IsCaptionButtonRunning())
{
Log.Info(string.Format("{0}() - ButtonHookKeepAliveThread - About to call StartCaptionButton()", MethodBase.GetCurrentMethod().Name));
// Launch OogyCaptionButton Process EXE
BHInteracter.StartCaptionButton();
// wait a little before checking again...
Thread.Sleep(100);
if (BHInteracter.IsCaptionButtonRunning())
Log.Info(string.Format("{0}() - StartCaptionButton() Succeeded", MethodBase.GetCurrentMethod().Name));
else
Log.Error(string.Format("{0}() - StartCaptionButton() Failed", MethodBase.GetCurrentMethod().Name));
}
if (!s_ButtonHookKeepAliveThreadIsInitialized)
{
s_ButtonHookKeepAliveThreadIsInitialized = true;
Log.Info(string.Format("{0}() - ButtonWPForm ButtonHookKeepAliveThread is initialized s_ButtonHookKeepAliveThreadIsInitialized is True", MethodBase.GetCurrentMethod().Name));
}
// Checking every 30 seconds (quickly) should be more than enough
Thread.Sleep(30000);
}
}
/// <summary>
/// Use this function to start ThreadProc(above) if needed. COM+ can shutdown the thread anytime,
/// we need to make sure that the thread is alive BEFORE calling ButtonForms
/// </summary>
private static void StartButtonHookKeepAliveThreadIfNeeded()
{
if (s_ButtonHookKeepAliveThread != null && s_ButtonHookKeepAliveThread.IsAlive)
{
return;
}
else
{
s_ButtonHookKeepAliveThreadIsInitialized = false;
// Start a new Thread so it can become the Message Loop
s_ButtonHookKeepAliveThread = new Thread(new ThreadStart(CaptionButtonStarter.ButtonHookKeepAliveThreadProc));
// GUI components require the thread to be STA; otherwise throws an error
s_ButtonHookKeepAliveThread.SetApartmentState(ApartmentState.STA);
s_ButtonHookKeepAliveThread.Start();
}
}
/// <summary>
/// Terminate the ButtonHook.dll by killing the Process
/// </summary>
private static void TerminateButtonHookKeepAliveThreadIfNeeded()
{
if (s_ButtonHookKeepAliveThreadIsInitialized)
{
s_ButtonHookKeepAliveThread.Abort();
s_ButtonHookKeepAliveThreadIsInitialized = false;
Log.Info(string.Format("{0}() - ButtonWPForm is ButtonHookKeepAliveThread shutdown s_ButtonHookKeepAliveThreadIsInitialized is False", MethodBase.GetCurrentMethod().Name));
// Kill the OogyCaptionButton Process EXE
BHInteracter.StopCaptionButton();
}
}
}
}

View File

@@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Threading;
// Ooganizer Namespaces
using Foo.Platform;
using Foo.DataAccessLayer;
using Foo.DataAccessLayer.DataTypes;
using System.Runtime.InteropServices;
namespace Foo.ClientServices.ButtonWPForm
{
/// <summary>
/// This class is responsible for launch all secondary threads required for this application as
/// well as hold any variables that are needed by all classes
/// created.
/// </summary>
[ComVisible(false)]
internal class ComponentState
{
// Declare the Log4net Variable
private static log4net.ILog Log = Logger.GetLog4NetInterface(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// This class manages the state / main variables of the COM+ that maybe needed by multiple classes.
/// It is responsible for starting and stopping any secondary threads.
/// </summary>
static ComponentState()
{
// We must subscribe to assembly resolver
Log.Info(string.Format("{0}() - ButtonWPFormCCW ComponentState() called. Application is starting...", MethodBase.GetCurrentMethod().Name));
// Let's Preload the Database *Right here, right now* that should be good for all of us
Data.Artifacts.DoesArtifactExistInSystem(DataTypeHelpers.CreateLocationOnlyArtifact("C:\\Dummy.file"));
// Start Dispatcher Thread
Log.Info(string.Format("{0}() - ButtonWPFormCCW ComponentState() called. Activating DispatcherThread", MethodBase.GetCurrentMethod().Name));
DispatcherThread.Run = true;
// Start ButtonHookKeepAlive Thread
if (!DebugSpec.SkipCaptionButtonStarter)
{
Log.Info(string.Format("{0}() - ButtonWPFormCCW ComponentState() called. Calling CaptionButtonStarter", MethodBase.GetCurrentMethod().Name));
CaptionButtonStarter.Run = true;
}
else
{
Log.Info(string.Format("{0}() - ButtonWPFormCCW ComponentState() called. Skipping CaptionButtonStarter due to DebugSpec Settings", MethodBase.GetCurrentMethod().Name));
}
}
/// <summary>
/// Private Variables
/// </summary>
private static bool s_bApplicationIsRunning = false;
/// <summary>
/// Use this to enable/disable all threads and variables for
/// the component states
/// </summary>
public static bool ApplicationIsRunning
{
get { return s_bApplicationIsRunning; }
set
{
if (!value)
{
Log.Info(string.Format("{0}() - ComponentState() sApplicationRunning set to False", MethodBase.GetCurrentMethod().Name));
DispatcherThread.Run = false;
CaptionButtonStarter.Run = false;
}
s_bApplicationIsRunning = value;
}
}
/// <summary>
/// Use this to access the ButtonFormMgr Object in order to
/// communicate to ButtonForms (Setter should only be called by
/// DispatcherThread)
/// </summary>
public static ButtonFormMgr ButtonFormMgr
{
get { return DispatcherThread.s_ButtonFormMgr; }
}
}
}

View File

@@ -0,0 +1,131 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Threading;
using System.Reflection;
// Ooganizer Namespaces
using Foo.Platform;
using System.Windows.Threading;
namespace Foo.ClientServices.ButtonWPForm
{
/// <summary>
/// This class is responsible for creation and deltion of ButtonFormMgr.cs on a
/// Dispatcher Thread. ~The Dispatcher is responsible for all the messages being passed
/// for the Form Objects, it must be running at all times and created before any forms get
/// created.
/// </summary>
[ComVisible(false)]
class DispatcherThread
{
// Member Variables
private static Thread s_DispatcherThread = null;
private static bool s_DispatcherThreadIsInitialized = false;
internal static ButtonFormMgr s_ButtonFormMgr = null;
// Declare the Log4net Variable
private static log4net.ILog Log = Logger.GetLog4NetInterface(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Constructor by default will launch the thread if needed
/// </summary>
static DispatcherThread()
{
Log.Info(string.Format("{0}() - DispatcherThread() called", MethodBase.GetCurrentMethod().Name));
StartDispatcherThreadIfNeeded();
}
/// <summary>
/// Use this property to set the Dispatcher to running / not running
/// </summary>
public static bool Run
{
get { return s_DispatcherThreadIsInitialized; }
set
{
if (!value)
TerminateDispatcherThreadIfNeeded();
s_DispatcherThreadIsInitialized = value;
}
}
/// <summary>
/// Message Loop Thread for ButtonForm
/// </summary>
private static void DispatcherThreadProc()
{
// Create ButtonFormMgr Object on this thread *Allow global access to the object*
Log.Info(string.Format("{0}() - About to new ButtonFormMgr via DispatcherThread", MethodBase.GetCurrentMethod().Name));
s_ButtonFormMgr = new ButtonFormMgr(Dispatcher.CurrentDispatcher);
Log.Info(string.Format("{0}() - ButtonWPForm DispatcherThread is initialized s_DispatcherThreadIsInitialized is True", MethodBase.GetCurrentMethod().Name));
s_DispatcherThreadIsInitialized = true; // always set to true to allow caller to exit out
if (s_ButtonFormMgr != null)
{
Log.Info(string.Format("{0}() - ButtonFormMgr Launched via DispatcherThread", MethodBase.GetCurrentMethod().Name));
//Enter Dispatcher Message Loop
System.Windows.Threading.Dispatcher.Run();
}
else
{
Log.Error(string.Format("{0}() - ButtonFormMgr Launch Failed! Exiting Thread - Major Error must have occured", MethodBase.GetCurrentMethod().Name));
// exit thread - no need to stay here
}
}
/// <summary>
/// Use this function to start ThreadProc(above) if needed. COM+ can shutdown the thread anytime,
/// we need to make sure that the thread is alive BEFORE calling ButtonForms
/// </summary>
private static void StartDispatcherThreadIfNeeded()
{
if (s_DispatcherThread != null && s_DispatcherThread.IsAlive)
{
return;
}
else
{
s_DispatcherThreadIsInitialized = false;
// Start a new Thread so it can become the Message Loop
s_DispatcherThread = new Thread(new ThreadStart(DispatcherThread.DispatcherThreadProc));
// GUI components require the thread to be STA; otherwise throws an error
s_DispatcherThread.SetApartmentState(ApartmentState.STA);
Log.Info(string.Format("{0}() - Starting DispatcherThread...", MethodBase.GetCurrentMethod().Name));
s_DispatcherThread.Start();
Log.Info(string.Format("{0}() - DispatcherThread Started.", MethodBase.GetCurrentMethod().Name));
// Make sure the Application Object is running
// (COM will eventually just time out otherwise)
//while (!s_DispatcherThreadIsInitialized)
// System.Threading.Thread.Sleep(20); // Syncronous call
}
}
/// <summary>
/// Terminates all ButtonForm Objects and the Message Dispatcher Thread *do this only on shutdown*
/// </summary>
private static void TerminateDispatcherThreadIfNeeded()
{
if (s_DispatcherThreadIsInitialized)
{
// Delete ButtonFormMgr and all ButtonForms from this thread
s_ButtonFormMgr.TerminateDISP();
s_ButtonFormMgr = null;
s_DispatcherThread.Abort();
s_DispatcherThreadIsInitialized = false;
Log.Info(string.Format("{0}() - ButtonWPForm is DispatcherThread shutdown s_DispatcherThreadIsInitialized is False", MethodBase.GetCurrentMethod().Name));
}
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace Foo.ClientServices.ButtonWPForm
{
/// <summary>
/// Button Hook uses the IButtonForm Interface to call into ButtonFormCCW.
/// This allows ButtonHook to communicate to us the state ButtonFormCCW should take.
/// ButtonForm will handle the methods/Events below and respond as needed.
/// ~We use the hParentWND to track which ButtonForm Instance we are talking with
/// (this is why all calls below have it in the method call ~it works better that way in COM+)
/// </summary>
[Guid("2CF9E641-57B7-436f-80E1-EF3127CB5C0A")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[ComVisible(true)]
public interface IButtonForm
{
// Custom Events
int W32BUTTONCLICKED();
// Called when ButtonHook activates/deactivates the COM Object
void WPFThreadProc_ButtonWPForm_Activated(int hParentWND, int hButtonWND);
void WPFThreadProc_ButtonWPForm_Deactivated();
// Hooked Window Events
void WindowEvent_MaximizeOccured(int nHeight, int nWidth);
void WindowEvent_MinimizeOccured();
void WindowEvent_WindowActivated();
void WindowEvent_WindowDeactivated();
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace Foo.ClientServices.ButtonWPForm
{
/// <summary>
/// This interface defines the communication from ButtonForm to
/// it's ButtonFormPage Client
/// </summary>
[ComVisible(false)]
public interface IButtonFormPage
{
ButtonForm ParentWPFContainer { get; set; }
}
}

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace Foo.ClientServices.ButtonWPForm
{
/// <summary>
/// Button Hook uses the IClientEvents Interface to let us know of certain events
/// which may require us to re-resolve the Window.
/// ~This is an important feature we need to do be accurate with all our artifacts.
/// We are piggy-backing on ButtonWPForm in order to have less components
/// </summary>
[Guid("F1AF5CAD-B9AB-4a20-80F1-EB68C577ABC4")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[ComVisible(true)]
public interface IClientEvents
{
// An Event occured that could potentially have made artifact changes
void ReResolve(int pid, IntPtr hWnd);
// First and Last Activation Events
void hWndInitialActivate(int pid, IntPtr hWnd, string ProcessStartUpPrms);
void hWndLastDeactivate(int pid, IntPtr hWnd);
// User File Events
void DragNDropOccured(int pid, IntPtr hWnd, int nFiles, string SemiColonSepFileNames);
void OpenOrSaveFileDialogOccured(int pid, IntPtr hWnd, string possibleLocAndFileName, string FileTypes);
}
}

Binary file not shown.

View File

@@ -0,0 +1,62 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
using System.EnterpriseServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ButtonWPForm")]
[assembly: AssemblyDescription("Performance Caching for ButtonWPForm")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Ooganizer Corporation")]
[assembly: AssemblyProduct("ButtonWPForm")]
[assembly: AssemblyCopyright("Copyright © Ooganizer Corporation 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(true)]
[assembly: ApplicationID("E6A84616-5ED1-4679-B26D-64F80A5E41CD")]
[assembly: ApplicationActivation(ActivationOption.Server)]
[assembly: ApplicationAccessControl(Value = false, Authentication = AuthenticationOption.None)]
[assembly: ApplicationName("Foo.ClientServices")]
[assembly: Description("Provides Data Access and Performance Caching for Ooganizer Components")]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4200
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Foo.ClientServices.ButtonWPForm.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Foo.ClientServices.ButtonWPForm.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4200
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Foo.ClientServices.ButtonWPForm.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@@ -0,0 +1,8 @@
<Application x:Class="Foo.ClientServices.GUIDebugStepExe.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="GUIDebugStepTestForm.xaml">
<Application.Resources>
</Application.Resources>
</Application>

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
namespace Foo.ClientServices.GUIDebugStepExe
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

View File

@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{4C81A790-31CA-4A71-99AD-339D3837A5C6}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Foo.ClientServices.GUIDebugStepExe</RootNamespace>
<AssemblyName>GUIDebugStepExe</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Target\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Target\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="GUIDebugStepTestForm.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="GUIDebugStepTestForm.xaml.cs">
<DependentUpon>GUIDebugStepTestForm.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ButtonWPForm\ButtonWPForm.csproj">
<Project>{E179DF39-539A-407F-94DE-C21F690E02C4}</Project>
<Name>ButtonWPForm</Name>
</ProjectReference>
<ProjectReference Include="..\GUIWPForms\GUIWPForms.csproj">
<Project>{A02E052C-3C52-43DB-BB30-A47446B8165F}</Project>
<Name>GUIWPForms</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,22 @@
<Window x:Class="Foo.ClientServices.GUIDebugStepExe.GUIDebugStepTestForm"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Loaded="wvGUIDebugStepTestForm_Loaded" Closed="wvGUIDebugStepTestForm_Closed"
Title="GUIDebugStepTestForm" Height="382" Width="223" Name="wvGUIDebugStepTestForm" WindowStartupLocation="CenterScreen" WindowStyle="SingleBorderWindow">
<Grid>
<Rectangle x:Name="recGradiant" Stroke="Black" RadiusY="7.5" RadiusX="7.5">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" Opacity="1.0">
<GradientStop Color="#FF000000" Offset="0.238"/>
<GradientStop Color="#FE333333" Offset="0.778"/>
<GradientStop Color="#FE202020" Offset="0.613"/>
<GradientStop Color="#FE333333" Offset="0.87"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Button Height="23" Margin="37,83,39,0" Name="btnLaunchArtifactWall" VerticalAlignment="Top" Click="btnLaunchArtifactWall_Click">ArtifactWall</Button>
<Button Margin="37,124,39,0" Name="btnWorkspaceSelector" Height="23" VerticalAlignment="Top" Click="btnWorkspaceSelector_Click">WorkspaceSelector</Button>
<Button Margin="37,165,39,0" Name="btnSettingsNMain" Height="23" VerticalAlignment="Top" Click="btnSettingsNMain_Click">MainNSettings</Button>
<Label Height="55" Margin="12,12,12,0" Name="lblGuiRemote" VerticalAlignment="Top" Foreground="White" FontSize="14" Focusable="True" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" BorderThickness="1" BorderBrush="White">GUIDebugStep Remote</Label>
<Button Margin="37,206,39,0" Name="btnButtonForm" Height="23" VerticalAlignment="Top" Click="btnButtonForm_Click">ButtonForm</Button>
</Grid>
</Window>

View File

@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
// Foo Namespaces
using Foo.ClientServices.ButtonWPForm;
using Foo.ClientServices.GUIWPForms;
namespace Foo.ClientServices.GUIDebugStepExe
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class GUIDebugStepTestForm : Window
{
// Private Members
GUIWPForms.GUIWPForms m_Gui = null;
ButtonWPForm.ButtonWPFormCCW m_ButtonForm = null;
public GUIDebugStepTestForm()
{
InitializeComponent();
}
private void btnLaunchArtifactWall_Click(object sender, RoutedEventArgs e)
{
m_Gui.LaunchArtifactWall(IntPtr.Zero);
}
private void btnWorkspaceSelector_Click(object sender, RoutedEventArgs e)
{
m_Gui.LaunchWorkspaceSelector(IntPtr.Zero);
}
private void btnSettingsNMain_Click(object sender, RoutedEventArgs e)
{
m_Gui.LaunchSettingsNAboutUs(IntPtr.Zero);
}
private void btnButtonForm_Click(object sender, RoutedEventArgs e)
{
}
private void wvGUIDebugStepTestForm_Loaded(object sender, RoutedEventArgs e)
{
// Instantiate the objects
m_Gui = new GUIWPForms.GUIWPForms();
//m_ButtonForm = new ButtonWPForm.ButtonWPFormCCW();
// instantiate any dependent threads, etc
m_Gui.Start();
//m_ButtonForm.Start();
}
private void wvGUIDebugStepTestForm_Closed(object sender, EventArgs e)
{
// close any dependent threads
m_Gui.Stop();
//m_ButtonForm.Stop();
// delete objects
m_Gui = null;
//m_ButtonForm = null;
}
}
}

View File

@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("GUIDebugStepExe")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GUIDebugStepExe")]
[assembly: AssemblyCopyright("Copyright © 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4200
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Foo.ClientServices.GUIDebugStepExe.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Foo.ClientServices.GUIDebugStepExe.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4200
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Foo.ClientServices.GUIDebugStepExe.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Reflection;
// Ooganizer Namespaces
using Foo.Platform;
using Foo.DataAccessLayer;
using Foo.DataAccessLayer.DataTypes;
namespace Foo.ClientServices.GUIWPForms
{
/// <summary>
/// This class is responsible for launch all secondary threads required for this application as
/// well as hold any variables that are needed by all classes
/// created.
/// </summary>
[ComVisible(false)]
internal class ComponentState
{
// Declare the Log4net Variable
private static log4net.ILog Log = Logger.GetLog4NetInterface(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// This class manages the state / main variables of the COM+ that maybe needed by multiple classes.
/// It is responsible for starting and stopping any secondary threads.
/// </summary>
static ComponentState()
{
// We must subscribe to assembly resolver
Log.Info(string.Format("{0}() - GUIWPForms ComponentState() called. Application is starting...", MethodBase.GetCurrentMethod().Name));
// Let's Preload the Database *Right here, right now* that should be good for all of us
Data.Artifacts.DoesArtifactExistInSystem(DataTypeHelpers.CreateLocationOnlyArtifact("C:\\Dummy.file"));
// Start GUI Dispatcher Thread
Log.Info(string.Format("{0}() - GUIWPForms ComponentState() called. Activating DispatcherThread", MethodBase.GetCurrentMethod().Name));
DispatcherThread.Run = true;
}
/// <summary>
/// Private Variables
/// </summary>
private static bool s_bApplicationIsRunning = false;
/// <summary>
/// Use this to enable/disable all threads and variables for
/// the component states
/// </summary>
public static bool ApplicationIsRunning
{
get { return s_bApplicationIsRunning; }
set
{
if (!value)
{
Log.Info(string.Format("{0}() - ComponentState() sApplicationRunning set to False", MethodBase.GetCurrentMethod().Name));
DispatcherThread.Run = false;
}
s_bApplicationIsRunning = value;
}
}
/// <summary>
/// Use this to access the GUIFormsMgr Object in order to
/// communicate to wpfForms (Setter should only be called by
/// DispatcherThread)
/// </summary>
public static GUIFormsMgr GUIFormsMgr
{
get { return DispatcherThread.s_GUIFormsMgr; }
}
}
}

View File

@@ -0,0 +1,131 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Threading;
using System.Reflection;
// Ooganizer Namespaces
using Foo.Platform;
using System.Windows.Threading;
namespace Foo.ClientServices.GUIWPForms
{
/// <summary>
/// This class is responsible for creation and deltion of ButtonFormMgr.cs on a
/// Dispatcher Thread. ~The Dispatcher is responsible for all the messages being passed
/// for the Form Objects, it must be running at all times and created before any forms get
/// created.
/// </summary>
[ComVisible(false)]
class DispatcherThread
{
// Member Variables
private static Thread s_DispatcherThread = null;
private static bool s_DispatcherThreadIsInitialized = false;
internal static GUIFormsMgr s_GUIFormsMgr = null;
// Declare the Log4net Variable
private static log4net.ILog Log = Logger.GetLog4NetInterface(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Constructor by default will launch the thread if needed
/// </summary>
static DispatcherThread()
{
Log.Info(string.Format("{0}() - DispatcherThread() called", MethodBase.GetCurrentMethod().Name));
StartDispatcherThreadIfNeeded();
}
/// <summary>
/// Use this property to set the Dispatcher to running / not running
/// </summary>
public static bool Run
{
get { return s_DispatcherThreadIsInitialized; }
set
{
if (!value)
TerminateDispatcherThreadIfNeeded();
s_DispatcherThreadIsInitialized = value;
}
}
/// <summary>
/// Message Loop Thread for wpfGUIForms
/// </summary>
private static void DispatcherThreadProc()
{
// Create ButtonFormMgr Object on this thread *Allow global access to the object*
Log.Info(string.Format("{0}() - About to new GUIFormsMgr via DispatcherThread", MethodBase.GetCurrentMethod().Name));
s_GUIFormsMgr = new GUIFormsMgr(Dispatcher.CurrentDispatcher);
Log.Info(string.Format("{0}() - GUIFormsMgr DispatcherThread is initialized s_DispatcherThreadIsInitialized is True", MethodBase.GetCurrentMethod().Name));
s_DispatcherThreadIsInitialized = true; // always set to true to allow caller to exit out
if (s_GUIFormsMgr != null)
{
Log.Info(string.Format("{0}() - GUIFormsMgr Launched via DispatcherThread", MethodBase.GetCurrentMethod().Name));
//Enter Dispatcher Message Loop
System.Windows.Threading.Dispatcher.Run();
}
else
{
Log.Error(string.Format("{0}() - GUIFormsMgr Launch Failed! Exiting Thread - Major Error must have occured", MethodBase.GetCurrentMethod().Name));
// exit thread - no need to stay here
}
}
/// <summary>
/// Use this function to start ThreadProc(above) if needed. COM+ can shutdown the thread anytime,
/// we need to make sure that the thread is alive BEFORE calling ButtonForms
/// </summary>
private static void StartDispatcherThreadIfNeeded()
{
if (s_DispatcherThread != null && s_DispatcherThread.IsAlive)
{
return;
}
else
{
s_DispatcherThreadIsInitialized = false;
// Start a new Thread so it can become the Message Loop
s_DispatcherThread = new Thread(new ThreadStart(DispatcherThread.DispatcherThreadProc));
// GUI components require the thread to be STA; otherwise throws an error
s_DispatcherThread.SetApartmentState(ApartmentState.STA);
Log.Info(string.Format("{0}() - Starting DispatcherThread...", MethodBase.GetCurrentMethod().Name));
s_DispatcherThread.Start();
Log.Info(string.Format("{0}() - DispatcherThread Started.", MethodBase.GetCurrentMethod().Name));
// Make sure the Application Object is running
// (COM will eventually just time out otherwise)
//while (!s_DispatcherThreadIsInitialized)
// System.Threading.Thread.Sleep(20); // Syncronous call
}
}
/// <summary>
/// Terminates all ButtonForm Objects and the Message Dispatcher Thread *do this only on shutdown*
/// </summary>
private static void TerminateDispatcherThreadIfNeeded()
{
if (s_DispatcherThreadIsInitialized)
{
// Delete s_GUIFormsMgr and all wpfForms from this thread
s_GUIFormsMgr.TerminateDISP();
s_GUIFormsMgr = null;
s_DispatcherThread.Abort();
s_DispatcherThreadIsInitialized = false;
Log.Info(string.Format("{0}() - GUIFormsMgr is DispatcherThread shutdown s_DispatcherThreadIsInitialized is False", MethodBase.GetCurrentMethod().Name));
}
}
}
}

View File

@@ -0,0 +1,381 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Drawing;
using System.Threading;
using System.Windows.Interop;
using System.EnterpriseServices;
using System.Windows;
using System.IO;
using System.Windows.Threading;
using System.Collections;
using System.Reflection;
using Foo.Platform;
using Foo.GUILib;
namespace Foo.ClientServices.GUIWPForms
{
internal enum WPForms
{
ArtifactWall,
WorkspaceSelector,
SettingsNAboutUs,
}
/// <summary>
/// Object Factory Creator for WPForms above
/// </summary>
internal class GUIWPFormsObjectFactory
{
/// <summary>
/// Object Form Factory for all our GUI Forms
/// </summary>
/// <param name="form">a WPF form object to create</param>
/// <param name="bPerformanceCache">true if to create a performanceCache window, should be false all other times</param>
/// <returns></returns>
public static Window CreateWPFormWindow(WPForms form, bool bPerformanceCache)
{
Window wpfForm = null;
switch (form)
{
case WPForms.ArtifactWall:
wpfForm = new ArtifactWall(bPerformanceCache);
break;
case WPForms.WorkspaceSelector:
wpfForm = new WorkspaceSelector(bPerformanceCache);
break;
case WPForms.SettingsNAboutUs:
wpfForm = new SettingsNAboutUs(bPerformanceCache);
break;
}
// Imp! - if this is being loaded for performance we must handle it
WPFHiddenWindow.ExecuteShowOnAHiddenWindow(wpfForm, bPerformanceCache);
return wpfForm;
}
}
/// <summary>
/// This class manages the creation/deletion and actions of (1 - n) ButtonForms
/// </summary>
[ComVisible(false)]
internal class GUIFormsMgr
{
private const int INITIAL_OBJECT_CAPACITY = 30;
private Hashtable m_ObjectList = null;
private Dispatcher m_Dispatcher = null;
// load one instance of all wpforms (hidden) cached always, as a performance cache
private Window[] m_wpfCachedForms = null;
private bool m_AreWpfFormsCached = false;
// Imp! - allows external caller to run any action on a Window
public delegate void _Action(Window wpfForm);
//custom private delegates
private delegate bool delegate_Create(WPForms wpfFormType);
private delegate bool delegate_Show(WPForms wpfFormType);
private delegate bool delegate_Delete(WPForms wpfFormType);
private delegate bool delegate_Action(WPForms wpfFormType, _Action action);
// Declare the Log4net Variable
private static log4net.ILog Log = Logger.GetLog4NetInterface(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// GUIFormsMgr - Responsible for managing the GUI Window Messaging Threads
/// </summary>
/// <param name="disp">Dispatcher Thread Context</param>
public GUIFormsMgr(Dispatcher disp)
{
m_ObjectList = new Hashtable();
m_Dispatcher = disp;
if (!m_AreWpfFormsCached)
BetterPerformance();
}
/// <summary>
/// Calls Create_WpfForm via Dispatcher if neccessary
/// </summary>
/// <param name="wpfFormType">Object type to create</param>
public bool Create_WpfFormDISP(WPForms wpfFormType)
{
if (m_Dispatcher.Thread == Thread.CurrentThread)
{
return Create_WpfForm(wpfFormType);
}
else
{
object[] parameters = new object[] { wpfFormType };
return (bool) m_Dispatcher.Invoke((delegate_Create)Create_WpfFormDISP, System.Windows.Threading.DispatcherPriority.Normal, parameters);
}
}
/// <summary>
/// Calls Show_WpfForm via Dispatcher if neccessary
/// </summary>
/// <param name="wpfFormType">Object type to create</param>
public bool Show_WpfFormDISP(WPForms wpfFormType)
{
if (m_Dispatcher.Thread == Thread.CurrentThread)
{
return Show_WpfForm(wpfFormType);
}
else
{
object[] parameters = new object[] { wpfFormType };
return (bool) m_Dispatcher.Invoke((delegate_Create)Show_WpfFormDISP, System.Windows.Threading.DispatcherPriority.Normal, parameters);
}
}
/// <summary>
/// Calls Delete_WpfForm via Dispatcher if neccessary
/// </summary>
/// <param name="wpfFormType">Object type to delete</param>
public bool Delete_WpfFormDISP(WPForms wpfFormType)
{
if (m_Dispatcher.Thread == Thread.CurrentThread)
{
return Delete_WpfForm(wpfFormType);
}
else
{
object[] parameters = new object[] { wpfFormType };
return (bool)m_Dispatcher.Invoke((delegate_Delete)Delete_WpfFormDISP, System.Windows.Threading.DispatcherPriority.Normal, parameters);
}
}
/// <summary>
/// Use this Dispatching Action Function to run any _Action on the WpfForm
/// </summary>
/// <param name="wpfFormType">Object type to run action on</param>
public bool RunAction_WpfFormDISP(WPForms wpfFormType, _Action action)
{
if (m_Dispatcher.Thread == Thread.CurrentThread)
{
return RunAction_WpfForm(wpfFormType, action);
}
else
{
object[] parameters = new object[] { wpfFormType, action };
return (bool) m_Dispatcher.Invoke((delegate_Action)RunAction_WpfFormDISP, System.Windows.Threading.DispatcherPriority.Normal, parameters);
}
}
/// <summary>
/// Calls Terminate via Dispatcher if neccessary
/// </summary>
public void TerminateDISP()
{
if (m_Dispatcher.Thread == Thread.CurrentThread)
{
Terminate();
}
else
{
m_Dispatcher.Invoke((Action)TerminateDISP, System.Windows.Threading.DispatcherPriority.Normal, null);
}
}
/// <summary>
/// Creates a new WpfForm object into the ObjectList
/// </summary>
/// <param name="wpfFormType">Object type to run action on</param>
private bool Create_WpfForm(WPForms wpfFormType)
{
try
{
if (!m_AreWpfFormsCached)
BetterPerformance();
// we only allow one object * so delete the previous one if exists *
if (m_ObjectList[wpfFormType] != null)
Delete_WpfForm(wpfFormType);
m_ObjectList[wpfFormType] = GUIWPFormsObjectFactory.CreateWPFormWindow(wpfFormType, false);
Window wpfForm = (Window) m_ObjectList[wpfFormType];
if (wpfForm == null)
{
Log.Error(string.Format("{0}() - Some Type of Error Occured. wpfForm is null", MethodBase.GetCurrentMethod().Name));
return false;
}
else
{
return true;
}
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - error thrown", MethodBase.GetCurrentMethod().Name), e);
}
return false;
}
/// <summary>
/// Show a WpfForm object in the ObjectList
/// </summary>
/// <param name="wpfFormType">Object type to run action on</param>
private bool Show_WpfForm(WPForms wpfFormType)
{
try
{
Window wpfForm = (Window)m_ObjectList[wpfFormType];
if (wpfForm == null)
{
Log.Error(string.Format("{0}() - Some Type of Error Occured. wpfForm is null", MethodBase.GetCurrentMethod().Name));
return false;
}
else
{
// We use the InteropHelper to see if this WPFForm has been created previously
WindowInteropHelper InteropHelper = new WindowInteropHelper(wpfForm);
if (InteropHelper.Handle == IntPtr.Zero)
{
wpfForm.Show();
return true;
}
}
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - error thrown", MethodBase.GetCurrentMethod().Name), e);
}
return false;
}
/// <summary>
/// Use this function to delete the WpfForm Object
/// </summary>
/// <param name="wpfFormType">Object type to run action on</param>
private bool Delete_WpfForm(WPForms wpfFormType)
{
try
{
if (m_ObjectList.ContainsKey(wpfFormType))
{
Window wpfForm = (Window)m_ObjectList[wpfFormType];
if (wpfForm != null)
{
m_ObjectList.Remove(wpfFormType);
wpfForm.Close();
return true;
}
}
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - error thrown", MethodBase.GetCurrentMethod().Name), e);
}
return false;
}
/// <summary>
/// Use this to run void() function actions on the specified wpfForm
/// </summary>
/// <param name="wpfFormType">Object type to run action on</param>
/// <param name="action">a pointer to a delegate (action function) to run</param>
private bool RunAction_WpfForm(WPForms wpfFormType, _Action action)
{
try
{
if (m_ObjectList.ContainsKey(wpfFormType))
{
Window wpfForm = (Window)m_ObjectList[wpfFormType];
if (wpfForm != null && action != null)
{
action(wpfForm);
return true;
}
}
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - error thrown", MethodBase.GetCurrentMethod().Name), e);
}
return false;
}
/// <summary>
/// Kills all ButtonForm Instances (STOPS ALL)
/// </summary>
private void Terminate()
{
try
{
foreach (object o in m_ObjectList)
{
if ((o != null) && (o is Window))
{
Window WpfForm = (Window)o;
WpfForm.Close();
}
}
m_ObjectList.Clear();
if (m_AreWpfFormsCached)
{
foreach (Window window in m_wpfCachedForms)
{
if (window != null)
window.Close();
}
// Caching is incomplete
m_AreWpfFormsCached = false;
}
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - error thrown", MethodBase.GetCurrentMethod().Name), e);
}
}
/// <summary>
/// In order to improve WPForm performance we have one set of forms
/// loaded at all times. (opacity set to 0).
/// ~it has no parent setting so it is just a form of the desktop
/// </summary>
private void BetterPerformance()
{
if (!m_AreWpfFormsCached && (m_wpfCachedForms == null))
{
try
{
lock (this)
{
int nForms = Enum.GetValues(typeof(WPForms)).Length;
if (nForms > 0)
{
// Allocate the cached forms array
m_wpfCachedForms = new Window[nForms];
// Iterate thru enums and create the corresponding objects in the Cache
for (int i = 0; i < nForms; ++i)
{
WPForms form = (WPForms)Enum.ToObject(typeof(WPForms), i);
m_wpfCachedForms[i] = GUIWPFormsObjectFactory.CreateWPFormWindow(form, true);
}
// Caching is complete
m_AreWpfFormsCached = true;
}
}
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - error thrown", MethodBase.GetCurrentMethod().Name), e);
}
}
}
}
}

View File

@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// Foo Namespaces
using Foo.DataAccessLayer;
using Foo.DataAccessLayer.DataTypes;
using System.Windows;
namespace Foo.ClientServices.GUIWPForms
{
/// <summary>
/// Used to save GUI State Information for all of GUIWPForms,
/// such as last selected SortOrder etc. ~very useful for having multiple forms
/// communicate with each other * C# Singleton #
/// </summary>
public static class GUIState
{
// WorkspaceSelector_StandardPage comboBox Workspace SortOrder
public static SortOrderForWorkspaces LastSelectedSotOrderWorkspaces { get; set; }
public static int LastSelectedSotOrderWorkspacesIndex { get; set; }
// WorkspaceSelector_StandardPage dataGrid Selected WorkspaceName
public static string LastSelectedWorkspaceName { get; set; }
// ArtifactWall
public static SortOrderForArtifacts LastSelectedSotOrderArtifacts { get; set; }
public static int LastSelectedSotOrderArtifactsIndex { get; set; }
// Keeping track of launched WPF GUI's
public static Window CurrentlyShowingWPFWindow { get; set; }
/// <summary>
/// Defaults
/// </summary>
static GUIState()
{
// Defaults for comboBox Workspace SortOrder
LastSelectedSotOrderWorkspaces = SortOrderForWorkspaces.Ascending;
LastSelectedSotOrderWorkspacesIndex = 0;
// Defaults for Selected WorkspaceName
LastSelectedWorkspaceName = String.Empty;
// Artifact Wall
LastSelectedSotOrderArtifacts = SortOrderForArtifacts.Ascending;
LastSelectedSotOrderArtifactsIndex = 0;
// Keeping track of launched WPF GUI's
CurrentlyShowingWPFWindow = null;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 943 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

View File

@@ -0,0 +1,20 @@
<Page x:Class="Foo.ClientServices.GUIWPForms.WorkspaceSelector_DeleteWorkspacePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WorkspaceSelector_DeleteWorkspacePage" Height="312" Width="250" Loaded="Page_Loaded">
<Grid>
<Rectangle x:Name="recGradiant" Stroke="Black" RadiusY="1" RadiusX="1" Grid.ColumnSpan="2">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" Opacity="1.0">
<GradientStop Color="#FF000000" Offset="0.238"/>
<GradientStop Color="#FE333333" Offset="0.778"/>
<GradientStop Color="#FE202020" Offset="0.613"/>
<GradientStop Color="#FE333333" Offset="0.87"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Button Height="23" Margin="32,0,0,51" Name="btnNo" VerticalAlignment="Bottom" IsCancel="True" HorizontalAlignment="Left" Width="75" Click="btnNo_Click">_No</Button>
<Button HorizontalAlignment="Right" Margin="0,0,26,52" Name="btnYes" Width="75" Height="22" IsDefault="True" VerticalAlignment="Bottom" Click="btnYes_Click">_Yes</Button>
<TextBlock Margin="32,38,26,91" Name="txtAreYouSure" Foreground="White" TextWrapping="Wrap" TextAlignment="Left" />
</Grid>
</Page>

View File

@@ -0,0 +1,158 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Foo.DataAccessLayer;
using Foo.DataAccessLayer.DataTypes;
using System.Windows.Threading;
namespace Foo.ClientServices.GUIWPForms
{
/// <summary>
/// Interaction logic for WorkspaceSelector_DeleteWorkspacePage.xaml
/// </summary>
public partial class WorkspaceSelector_DeleteWorkspacePage : Page
{
// passed to us by parent
private WorkspaceSelector m_WorkspaceSelectorObj = null;
private bool m_bPerformanceCache = false;
// private state variables
private string m_strWorkspaceName;
public WorkspaceSelector_DeleteWorkspacePage(bool bPerformanceCache)
{
m_strWorkspaceName = String.Empty;
m_bPerformanceCache = bPerformanceCache;
if (!m_bPerformanceCache)
{
}
InitializeComponent();
}
/// <summary>
/// Occurs when page gets loaded
/// </summary>
private void Page_Loaded(object sender, RoutedEventArgs e)
{
if (!m_bPerformanceCache)
{
// Make sure that the Selector Frame is big enough to hold this page
m_WorkspaceSelectorObj = (WorkspaceSelector)this.Tag;
// Make sure that we have a workspace Name to work with otherwise Navigate Back
if (String.IsNullOrEmpty(GUIState.LastSelectedWorkspaceName))
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
else
m_strWorkspaceName = GUIState.LastSelectedWorkspaceName;
// Set Height and Width
m_WorkspaceSelectorObj.Height = this.Height + m_WorkspaceSelectorObj.MarginTopBottom;
m_WorkspaceSelectorObj.Width = this.Width;
// Set the Warning Label for this Particular Workspace
ConstructAreYouSureMessage();
}
}
/// <summary>
/// Constructs a thorough Warning Message to be displayed to the user in the label
/// Iterates and warns the user of exactly the number of changes that will occur in the system
/// </summary>
private void ConstructAreYouSureMessage()
{
int nArtifactsCount = Data.Artifacts.GetArtifactLinkCountForWorkspace(m_strWorkspaceName);
int nUniqueArtifactsCount = Data.Artifacts.GetUniqureArtifactsCountForWorkspace(m_strWorkspaceName);
if (nArtifactsCount >= 0 && nUniqueArtifactsCount >= 0)
{
StringBuilder sr = new StringBuilder();
sr.Append(String.Format("Are you Sure you want to Delete Workspace '{0}'? \n\n", m_strWorkspaceName));
sr.Append(String.Format("This Workspace contains {0} Artifact Links ", (nArtifactsCount - nUniqueArtifactsCount)));
sr.Append(String.Format("and {0} Artifacts. ", nUniqueArtifactsCount));
sr.Append(String.Format("\n\n In Total: {0} Items will be deleted. There is no way to undo this operation.", nArtifactsCount));
txtAreYouSure.Text = sr.ToString();
}
else
{
// an error occured
Foo.Platform.ErrorReporting.UserError.Show("An Error Occurred", "Navigating you back to the WorkspaceSelector");
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
}
}
/// <summary>
/// Button Yes Event Handler - Go ahead and delete the workspace
/// </summary>
private void btnYes_Click(object sender, RoutedEventArgs e)
{
if (Data.Workspace.DeleteWorkspace(GUIState.LastSelectedWorkspaceName))
{
// Show Confirm Delete Message and Go Back
StringBuilder sr = new StringBuilder();
sr.Append(String.Format("The Workspace '{0}' was deleted successfully. \n\n", m_strWorkspaceName));
sr.Append("You will no longer be able to access this Workspace and any Artifacts that were exclusive to it.");
ShowMessageAndNavigateBack(sr.ToString());
// Set GUI State
GUIState.LastSelectedWorkspaceName = String.Empty;
}
else
{
// an error occured
Foo.Platform.ErrorReporting.UserError.Show("An Error Occurred", String.Format("An Error occured while deleting the Workspace {0}. Navigating you back to the WorkspaceSelector", m_strWorkspaceName));
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
}
}
/// <summary>
/// Shows the passed in message in the text box and then navigates back to the main page
/// </summary>
/// <param name="strMessage"></param>
private void ShowMessageAndNavigateBack(string strMessage)
{
// Hide the buttons
btnYes.Visibility = Visibility.Hidden;
btnNo.Visibility = Visibility.Hidden;
// Show Message
txtAreYouSure.Text = strMessage;
// Pause for 2 second and Navigate Back
DispatcherTimer dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1, 500);
dispatcherTimer.Start();
}
/// <summary>
/// Timer set specifically to allow the message to be seen for a little bit before navigating back
/// </summary>
void dispatcherTimer_Tick(object sender, EventArgs e)
{
DispatcherTimer dispatcherTimer = (DispatcherTimer) sender;
dispatcherTimer.Stop();
// Navigate Back
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
}
/// <summary>
/// Button No Event Handler - Go back to parent
/// </summary>
private void btnNo_Click(object sender, RoutedEventArgs e)
{
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
}
}
}

View File

@@ -0,0 +1,25 @@
<Page x:Class="Foo.ClientServices.GUIWPForms.WorkspaceSelector_NewWorkspacePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WorkspaceSelector_NewWorkspacePage" Height="312" Width="250" Loaded="Page_Loaded">
<Grid>
<Rectangle x:Name="recGradiant" Stroke="Black" RadiusY="1" RadiusX="1" Grid.ColumnSpan="2">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" Opacity="1.0">
<GradientStop Color="#FF000000" Offset="0.238"/>
<GradientStop Color="#FE333333" Offset="0.778"/>
<GradientStop Color="#FE202020" Offset="0.613"/>
<GradientStop Color="#FE333333" Offset="0.87"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Button IsCancel="True" Height="23" Margin="32,0,0,51" Name="btnNo" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="75" Click="btnNo_Click">_Cancel</Button>
<Button IsDefault="True" HorizontalAlignment="Right" Margin="0,0,26,52" Name="btnYes" Width="75" Height="22" VerticalAlignment="Bottom" Click="btnYes_Click">C_reate</Button>
<Label Margin="32,20,26,0" Name="lblCreateWorkspaceTitle" Foreground="White" VerticalContentAlignment="Top" Height="68" VerticalAlignment="Top" HorizontalContentAlignment="Center">
<TextBlock Margin="0,0,0,0" Name="txtCreateWorkspaceTitle" TextWrapping="Wrap" Text="" TextAlignment="Center" />
</Label>
<Label Height="31" Margin="37,86,26,0" Name="lblEnterNewName" VerticalAlignment="Top" Foreground="White" HorizontalContentAlignment="Center">Enter New Name:</Label>
<TextBox Margin="37,115,26,0" Name="txtNewName" Height="23" VerticalAlignment="Top" TextChanged="txtNewName_TextChanged" />
<Label Margin="38,136,26,148" Name="lblWarningMessage" HorizontalContentAlignment="Right" Foreground="OrangeRed" FontSize="11" FontStyle="Italic">Label</Label>
</Grid>
</Page>

View File

@@ -0,0 +1,201 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using System.Windows.Forms;
using System.Drawing;
namespace Foo.ClientServices.GUIWPForms
{
/// <summary>
/// Interaction logic for WorkspaceSelector_NewWorkspacePage.xaml
/// </summary>
public partial class WorkspaceSelector_NewWorkspacePage : Page
{
// passed to us by parent
private WorkspaceSelector m_WorkspaceSelectorObj = null;
private bool m_bPerformanceCache = false;
// private state variables
private bool m_bIsValidName;
public WorkspaceSelector_NewWorkspacePage(bool bPerformanceCache)
{
m_bPerformanceCache = bPerformanceCache;
if (!m_bPerformanceCache)
{
}
InitializeComponent();
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
if (!m_bPerformanceCache)
{
// Make sure that the Selector Frame is big enough to hold this page
m_WorkspaceSelectorObj = (WorkspaceSelector)this.Tag;
m_WorkspaceSelectorObj.Height = this.Height + m_WorkspaceSelectorObj.MarginTopBottom;
m_WorkspaceSelectorObj.Width = this.Width;
// Set the Warning Label for this Particular Workspace
ConstructAreYouSureMessage();
// Set intial Error Message
SetWarningMessage("Enter Characters");
m_bIsValidName = false;
// Set intial focus
txtNewName.Focus();
}
}
/// <summary>
/// Constructs a renaming Message to be displayed to the user
/// </summary>
private void ConstructAreYouSureMessage()
{
StringBuilder sr = new StringBuilder();
sr.Append("Create New Workspace \n");
txtCreateWorkspaceTitle.Text = sr.ToString();
}
/// <summary>
/// Sets the validator label to a warning message
/// </summary>
/// <param name="strMessage"></param>
private void SetWarningMessage(string strMessage)
{
lblWarningMessage.Foreground = new SolidColorBrush(Colors.OrangeRed);
lblWarningMessage.Content = strMessage;
}
/// <summary>
/// Sets the validator label to a success message
/// </summary>
/// <param name="strMessage"></param>
private void SetSuccessMessage(string strMessage)
{
lblWarningMessage.Foreground = new SolidColorBrush(Colors.RoyalBlue);
lblWarningMessage.Content = strMessage;
}
/// <summary>
/// Button Yes Event Handler - Go ahead and Create the new WorkspaceName
/// </summary>
private void btnYes_Click(object sender, RoutedEventArgs e)
{
if (m_bIsValidName)
{
if (!DataAccessLayer.Data.Workspace.InsertWorkspaceName(txtNewName.Text))
{
// an error occured
Foo.Platform.ErrorReporting.UserError.Show("An Error Occurred", "Creating the Workspace Failed! Navigating you back to the WorkspaceSelector");
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
}
else
{
// Set GUI State
GUIState.LastSelectedWorkspaceName = txtNewName.Text;
// Show Success Message
ShowMessageAndNavigateBack(String.Format("Workspace '{0}' has been successfully created", txtNewName.Text));
}
}
}
/// <summary>
/// Shows the passed in message in the text box and then navigates back to the main page
/// </summary>
/// <param name="strMessage"></param>
private void ShowMessageAndNavigateBack(string strMessage)
{
// Hide the buttons
btnYes.Visibility = Visibility.Hidden;
btnNo.Visibility = Visibility.Hidden;
// Hide the textbox and Labels
lblEnterNewName.Visibility = Visibility.Hidden;
txtNewName.Visibility = Visibility.Hidden;
lblWarningMessage.Visibility = Visibility.Hidden;
// Show Message
txtCreateWorkspaceTitle.Text = strMessage;
// Dynamically calculate the height of the textbox * No need to do this in this case *
// System.Drawing.Size sz = new System.Drawing.Size((int)this.Width, int.MaxValue);
// Font font = new Font(txtRenameWorkspaceTitle.FontFamily.ToString(), (float)txtRenameWorkspaceTitle.FontSize);
// sz = TextRenderer.MeasureText(txtRenameWorkspaceTitle.Text, font, sz, TextFormatFlags.WordBreak);
// Change Height as needed
// lblRenameWorkspaceTitle.Height = sz.Height;
// txtRenameWorkspaceTitle.Height = sz.Height;
// default to change height to Max available space
lblCreateWorkspaceTitle.Height = this.Height - m_WorkspaceSelectorObj.MarginTopBottom;
txtCreateWorkspaceTitle.Height = this.Height - m_WorkspaceSelectorObj.MarginTopBottom;
// Pause for 1.5 second and Navigate Back
DispatcherTimer dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1, 500);
dispatcherTimer.Start();
}
/// <summary>
/// Timer set specifically to allow the message to be seen for a little bit before navigating back
/// </summary>
void dispatcherTimer_Tick(object sender, EventArgs e)
{
DispatcherTimer dispatcherTimer = (DispatcherTimer)sender;
dispatcherTimer.Stop();
// Navigate Back
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
}
/// <summary>
/// Button No Event Handler - Go back to parent
/// </summary>
private void btnNo_Click(object sender, RoutedEventArgs e)
{
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
}
/// <summary>
/// Perform NewWorkspaceName TextBox Validation
/// </summary>
private void txtNewName_TextChanged(object sender, TextChangedEventArgs e)
{
System.Windows.Controls.TextBox textBox = (System.Windows.Controls.TextBox)sender;
if (String.IsNullOrEmpty(textBox.Text))
{
SetWarningMessage("Enter Characters");
m_bIsValidName = false;
}
else if (!DataAccessLayer.DataTypes.DataTypeValidation.IsValidWorkspaceName(textBox.Text))
{
SetWarningMessage("Invalid Workspace Name");
m_bIsValidName = false;
}
else if (DataAccessLayer.Data.Workspace.DoesWorkspaceNameExist(textBox.Text))
{
SetWarningMessage("Workspace Name Already Exists");
m_bIsValidName = false;
}
else
{
SetSuccessMessage("Valid Workspace Name");
m_bIsValidName = true;
}
}
}
}

View File

@@ -0,0 +1,25 @@
<Page x:Class="Foo.ClientServices.GUIWPForms.WorkspaceSelector_RenameWorkspacePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WorkspaceSelector_RenameWorkspacePage" Height="312" Width="250" Loaded="Page_Loaded">
<Grid>
<Rectangle x:Name="recGradiant" Stroke="Black" RadiusY="1" RadiusX="1" Grid.ColumnSpan="2">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" Opacity="1.0">
<GradientStop Color="#FF000000" Offset="0.238"/>
<GradientStop Color="#FE333333" Offset="0.778"/>
<GradientStop Color="#FE202020" Offset="0.613"/>
<GradientStop Color="#FE333333" Offset="0.87"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Button Height="23" Margin="32,0,0,51" Name="btnNo" VerticalAlignment="Bottom" IsCancel="True" HorizontalAlignment="Left" Width="75" Click="btnNo_Click">_Cancel</Button>
<Button HorizontalAlignment="Right" Margin="0,0,26,52" Name="btnYes" IsDefault="True" Width="75" Height="22" VerticalAlignment="Bottom" Click="btnYes_Click">_Rename</Button>
<Label Margin="32,20,26,0" Name="lblRenameWorkspaceTitle" Foreground="White" VerticalContentAlignment="Top" Height="68" VerticalAlignment="Top" HorizontalContentAlignment="Center">
<TextBlock Margin="0,0,0,0" Name="txtRenameWorkspaceTitle" TextWrapping="Wrap" Text="" TextAlignment="Center" />
</Label>
<Label Height="31" Margin="37,86,26,0" Name="lblEnterNewName" VerticalAlignment="Top" Foreground="White" HorizontalContentAlignment="Center">Enter New Name:</Label>
<TextBox Margin="37,115,26,0" Name="txtNewName" Height="23" VerticalAlignment="Top" TextChanged="txtNewName_TextChanged" />
<Label Margin="38,136,26,148" Name="lblWarningMessage" HorizontalContentAlignment="Right" Foreground="OrangeRed" FontSize="11" FontStyle="Italic">Label</Label>
</Grid>
</Page>

View File

@@ -0,0 +1,210 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using System.Windows.Forms;
using System.Drawing;
namespace Foo.ClientServices.GUIWPForms
{
/// <summary>
/// Interaction logic for WorkspaceSelector_RenameWorkspacePage.xaml
/// </summary>
public partial class WorkspaceSelector_RenameWorkspacePage : Page
{
// passed to us by parent
private WorkspaceSelector m_WorkspaceSelectorObj = null;
private bool m_bPerformanceCache = false;
// private state variables
private string m_strWorkspaceName;
private bool m_bIsValidName;
public WorkspaceSelector_RenameWorkspacePage(bool bPerformanceCache)
{
m_bPerformanceCache = bPerformanceCache;
if (!m_bPerformanceCache)
{
}
InitializeComponent();
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
if (!m_bPerformanceCache)
{
// Make sure that the Selector Frame is big enough to hold this page
m_WorkspaceSelectorObj = (WorkspaceSelector)this.Tag;
// Make sure that we have a workspace Name to work with otherwise Navigate Back
if (String.IsNullOrEmpty(GUIState.LastSelectedWorkspaceName))
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
else
m_strWorkspaceName = GUIState.LastSelectedWorkspaceName;
// Set Height and Width
m_WorkspaceSelectorObj.Height = this.Height + m_WorkspaceSelectorObj.MarginTopBottom;
m_WorkspaceSelectorObj.Width = this.Width;
// Set the Warning Label for this Particular Workspace
ConstructAreYouSureMessage();
// Set intial Error Message
SetWarningMessage("Enter Characters");
m_bIsValidName = false;
// Set intial focus
txtNewName.Focus();
}
}
/// <summary>
/// Constructs a renaming Message to be displayed to the user
/// </summary>
private void ConstructAreYouSureMessage()
{
StringBuilder sr = new StringBuilder();
sr.Append(String.Format("Rename Workspace '{0}'\n", m_strWorkspaceName));
txtRenameWorkspaceTitle.Text = sr.ToString();
}
/// <summary>
/// Sets the validator label to a warning message
/// </summary>
/// <param name="strMessage"></param>
private void SetWarningMessage(string strMessage)
{
lblWarningMessage.Foreground = new SolidColorBrush(Colors.OrangeRed);
lblWarningMessage.Content = strMessage;
}
/// <summary>
/// Sets the validator label to a success message
/// </summary>
/// <param name="strMessage"></param>
private void SetSuccessMessage(string strMessage)
{
lblWarningMessage.Foreground = new SolidColorBrush(Colors.RoyalBlue);
lblWarningMessage.Content = strMessage;
}
/// <summary>
/// Button Yes Event Handler - Go ahead and Rename the WorkspaceName
/// </summary>
private void btnYes_Click(object sender, RoutedEventArgs e)
{
if (m_bIsValidName)
{
if (!DataAccessLayer.Data.Workspace.RenameWorkspace(m_strWorkspaceName, txtNewName.Text))
{
// an error occured
Foo.Platform.ErrorReporting.UserError.Show("An Error Occurred", "Renaming the Workspace Failed! Navigating you back to the WorkspaceSelector");
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
}
else
{
// Set GUI State
GUIState.LastSelectedWorkspaceName = txtNewName.Text;
// Show Success Message
ShowMessageAndNavigateBack(String.Format("'{0}' has been successfully renamed to '{1}'", m_strWorkspaceName, txtNewName.Text));
}
}
}
/// <summary>
/// Shows the passed in message in the text box and then navigates back to the main page
/// </summary>
/// <param name="strMessage"></param>
private void ShowMessageAndNavigateBack(string strMessage)
{
// Hide the buttons
btnYes.Visibility = Visibility.Hidden;
btnNo.Visibility = Visibility.Hidden;
// Hide the textbox and Labels
lblEnterNewName.Visibility = Visibility.Hidden;
txtNewName.Visibility = Visibility.Hidden;
lblWarningMessage.Visibility = Visibility.Hidden;
// Show Message
txtRenameWorkspaceTitle.Text = strMessage;
// Dynamically calculate the height of the textbox * No need to do this in this case *
// System.Drawing.Size sz = new System.Drawing.Size((int)this.Width, int.MaxValue);
// Font font = new Font(txtRenameWorkspaceTitle.FontFamily.ToString(),(float) txtRenameWorkspaceTitle.FontSize);
// sz = TextRenderer.MeasureText(txtRenameWorkspaceTitle.Text, font, sz, TextFormatFlags.WordBreak);
// Change Height as needed
// lblRenameWorkspaceTitle.Height = sz.Height;
// txtRenameWorkspaceTitle.Height = sz.Height;
// default to change height to Max available space
lblRenameWorkspaceTitle.Height = this.Height - m_WorkspaceSelectorObj.MarginTopBottom;
txtRenameWorkspaceTitle.Height = this.Height - m_WorkspaceSelectorObj.MarginTopBottom;
// Pause for 1.5 second and Navigate Back
DispatcherTimer dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1, 500);
dispatcherTimer.Start();
}
/// <summary>
/// Timer set specifically to allow the message to be seen for a little bit before navigating back
/// </summary>
void dispatcherTimer_Tick(object sender, EventArgs e)
{
DispatcherTimer dispatcherTimer = (DispatcherTimer)sender;
dispatcherTimer.Stop();
// Navigate Back
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
}
/// <summary>
/// Button No Event Handler - Go back to parent
/// </summary>
private void btnNo_Click(object sender, RoutedEventArgs e)
{
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
}
/// <summary>
/// Perform NewWorkspaceName TextBox Validation
/// </summary>
private void txtNewName_TextChanged(object sender, TextChangedEventArgs e)
{
System.Windows.Controls.TextBox textBox = (System.Windows.Controls.TextBox)sender;
if (String.IsNullOrEmpty(textBox.Text))
{
SetWarningMessage("Enter Characters");
m_bIsValidName = false;
}
else if (!DataAccessLayer.DataTypes.DataTypeValidation.IsValidWorkspaceName(textBox.Text))
{
SetWarningMessage("Invalid Workspace Name");
m_bIsValidName = false;
}
else if (DataAccessLayer.Data.Workspace.DoesWorkspaceNameExist(textBox.Text))
{
SetWarningMessage("Workspace Name Already Exists");
m_bIsValidName = false;
}
else
{
SetSuccessMessage("Valid Workspace Name");
m_bIsValidName = true;
}
}
}
}

View File

@@ -0,0 +1,151 @@
<Page x:Class="Foo.ClientServices.GUIWPForms.WorkspaceSelector_StandardPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Custom="http://schemas.microsoft.com/wpf/2008/toolkit"
Title="WorkspaceSelector_StandardPage" Height="312" Loaded="Page_Loaded" Width="250" Foreground="Black">
<Page.Resources>
<Style x:Key="DataGridCellStyle" TargetType="{x:Type Custom:DataGridCell}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Custom:DataGridCell}">
<Border Background="Transparent"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="0"
SnapsToDevicePixels="True">
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- Custom Brushes -->
<LinearGradientBrush x:Key="RowBackgroundSelectedBrush" StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#4F8CC7" Offset="0" />
<GradientStop Color="#1C4B7C" Offset="0.7" />
<GradientStop Color="#042D5B" Offset="1" />
</LinearGradientBrush>
<SolidColorBrush x:Key="RowBackgroundAlternationIndex2Brush" Color="#44FF0000" />
<SolidColorBrush x:Key="RowBackgroundAlternationIndex3Brush" Color="#44CCCCCC" />
<Style x:Key="DataGridDemoRowStyle" TargetType="{x:Type Custom:DataGridRow}">
<Style.Triggers>
<Trigger Property="AlternationIndex" Value="2" >
<Setter Property="Background" Value="{StaticResource RowBackgroundAlternationIndex2Brush}" />
</Trigger>
<Trigger Property="AlternationIndex" Value="3">
<Setter Property="Background" Value="{StaticResource RowBackgroundAlternationIndex3Brush}" />
</Trigger>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Background" Value="{StaticResource RowBackgroundSelectedBrush}" />
</Trigger>
</Style.Triggers>
</Style>
</Page.Resources>
<Grid>
<Rectangle x:Name="recGradiant" Stroke="Black" RadiusY="1" RadiusX="1" Grid.ColumnSpan="2">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" Opacity="1.0">
<GradientStop Color="#FF000000" Offset="0.238"/>
<GradientStop Color="#FE333333" Offset="0.778"/>
<GradientStop Color="#FE202020" Offset="0.613"/>
<GradientStop Color="#FE333333" Offset="0.87"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<my:DataGrid ItemsSource="{Binding ElementName=This, Path=WorkspacesDT.DefaultView}"
AutoGenerateColumns="False" Margin="12,54,12,33" Name="dataGridWorkspaces"
HorizontalScrollBarVisibility="Disabled" HeadersVisibility="None"
VerticalScrollBarVisibility="Auto" TabIndex="1"
GridLinesVisibility="Horizontal"
CellStyle="{StaticResource DataGridCellStyle}"
RowStyle="{StaticResource DataGridDemoRowStyle}"
RowHeaderWidth="3" ColumnHeaderHeight="15"
SelectionMode="Single" SelectionUnit="FullRow"
CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False"
CanUserResizeColumns="False" CanUserResizeRows="False" CanUserSortColumns="False"
MouseRightButtonDown="dataGridWorkspaces_MouseRightButtonDown"
MouseDoubleClick="dataGridWorkspaces_MouseDoubleClick"
SelectedCellsChanged="dataGridWorkspaces_SelectedCellsChanged"
xmlns:my="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit" Background="White" BorderBrush="Transparent" BorderThickness="0" IsTabStop="False">
<my:DataGrid.Columns>
<!--<my:DataGridTextColumn Binding="{Binding WorkspaceName}" />-->
<my:DataGridTemplateColumn KeyboardNavigation.TabIndex="1" Header="WorkspaceName" Width="188" IsReadOnly="True">
<my:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextWrapping="NoWrap" Text="{Binding WorkspaceName}">
<TextBlock.ToolTip>
<TextBlock TextWrapping="Wrap" Width="188" Text="{Binding WorkspaceName}"/>
</TextBlock.ToolTip>
</TextBlock>
</DataTemplate>
</my:DataGridTemplateColumn.CellTemplate>
</my:DataGridTemplateColumn>
<my:DataGridTemplateColumn KeyboardNavigation.TabIndex="1" Header="Date" Width="20" IsReadOnly="True">
<my:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<!--<TextBlock Text="{Binding Date, StringFormat=d}" />-->
<!--<Button Visibility="{Binding ButtonIsVisible}" Background="Transparent" Height="16" Width="16" Margin="0,0,0,0" VerticalAlignment="Bottom" HorizontalAlignment="Left" Click="ButtonGrid_Click">
<Button.Content>-->
<!--<Image Source="PageImages/Launch.png"></Image>-->
<Image Source="{Binding ButtonResUri}" Height="16" Width="16">
<Image.ToolTip>
<TextBlock TextWrapping="Wrap" Width="100" Text="{Binding ButtonToolTipText}"/>
</Image.ToolTip>
</Image>
<!--<TextBlock Text="{Binding Word, StringFormat=d}" />-->
<!--</Button.Content>
</Button>-->
</DataTemplate>
</my:DataGridTemplateColumn.CellTemplate>
</my:DataGridTemplateColumn>
</my:DataGrid.Columns>
<!--<my:DataGrid.ContextMenu>
<ContextMenu >
<MenuItem x:Name="menuItemLaunch" Header="Launch">
<MenuItem.Icon>
<Image Source="Images/cut.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</my:DataGrid.ContextMenu>-->
</my:DataGrid>
<Label Height="28" Margin="16,-2,12,0" Name="lblCurrentWorkspace" VerticalAlignment="Top"
Foreground="White" HorizontalContentAlignment="Center">Workspaces</Label>
<ComboBox Height="23" Margin="33,23,32,0" Name="comboBoxSortBy" VerticalAlignment="Top" TabIndex="0" SelectionChanged="comboBoxSortBy_SelectionChanged" />
<Button Background="Transparent" BorderThickness="0" BorderBrush="Transparent" Height="24" Width="24" HorizontalAlignment="Left" Margin="12,0,0,5" Name="btnNew" VerticalAlignment="Bottom" Click="btnNew_Click" TabIndex="2">
<Button.Content>
<Image Source="PageImages/AddWorkspace.png"></Image>
</Button.Content>
<!--<Button.ToolTip>
<ToolTip>
<TextBlock TextWrapping="Wrap" Width="150">Doris Loves to play with her piano. Piano is alot of fun and she likes to play with it</TextBlock>
</ToolTip>
</Button.ToolTip>-->
</Button>
<Button Background="Transparent" BorderThickness="0" BorderBrush="Transparent" Height="24" Width="24" Margin="42,0,0,5" Name="btnEdit" VerticalAlignment="Bottom" HorizontalAlignment="Left" Click="btnEdit_Click" TabIndex="3">
<Button.Content>
<Image Source="PageImages/EditWorkspace.png"></Image>
</Button.Content>
</Button>
<Button Background="Transparent" BorderThickness="0" BorderBrush="Transparent" Height="24" Width="24" Margin="72,0,0,5" Name="btnDelete" VerticalAlignment="Bottom" HorizontalAlignment="Left" Click="btnDelete_Click" TabIndex="4">
<Button.Content>
<Image Source="PageImages/DeleteWorkspace.png"></Image>
</Button.Content>
</Button>
<Button Background="Transparent" BorderThickness="0" BorderBrush="Transparent" Height="24" Width="24" HorizontalAlignment="Right" Margin="0,0,12,5" Name="btnCloseAll" VerticalAlignment="Bottom" Click="btnCloseAll_Click" TabIndex="5">
<Button.Content>
<Image Source="PageImages/CloseAll.png"></Image>
</Button.Content>
</Button>
</Grid>
</Page>

View File

@@ -0,0 +1,418 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using Microsoft.Windows.Controls;
using System.Data;
using System.ComponentModel;
// Foo Namespace
using Foo.WorkspaceMgr;
using Foo.DataAccessLayer;
using Foo.DataAccessLayer.DataTypes;
using Foo.GUILib;
namespace Foo.ClientServices.GUIWPForms
{
/// <summary>
/// Interaction logic for WorkspaceSelector_StandardPage.xaml
/// </summary>
public partial class WorkspaceSelector_StandardPage : Page
{
// passed to us by parent
private WorkspaceSelector m_WorkspaceSelectorObj = null;
private bool m_bPerformanceCache = false;
// WorkspaceMgr - Imp
private WorkspaceMgr.WorkspaceMgr m_WorkspaceMgr = null;
// private DT holds all information needed for the DataGrid
public DataTable WorkspacesDT { get; private set; }
/// <summary>
/// Constructor
/// </summary>
/// <param name="bPerformanceCache"></param>
public WorkspaceSelector_StandardPage(bool bPerformanceCache)
{
// We preload & require the WorkspaceMgr in this class
m_WorkspaceMgr = new WorkspaceMgr.WorkspaceMgr();
// Preload Database call - to make sure it is fast when the user sees it
String[] workspaceNames = Data.Workspace.GetAllWorkspaceNames(SortOrderForWorkspaces.Ascending);
m_bPerformanceCache = bPerformanceCache;
if (!m_bPerformanceCache)
{
}
InitializeComponent();
}
/// <summary>
/// Called when we want to Update the DataGrid with new DataTable Items
/// ~Responsible for reloading the WorkspacesDT
/// </summary>
private void UpdateWorkspaceGridItems(SortOrderForWorkspaces sortOrder)
{
// First Step - Clear the Grid
WorkspacesDT.Rows.Clear();
// Second Step - Fill the Grid with the WorkspaceNames
String[] workspaceNames = Data.Workspace.GetAllWorkspaceNames(sortOrder);
int i = 0;
int selectedIndex = -1;
foreach (string workspaceName in workspaceNames)
{
var row = WorkspacesDT.NewRow();
WorkspacesDT.Rows.Add(row);
row["WorkspaceName"] = workspaceName;
row["ButtonResUri"] = "PageImages/Launch.png";//"PageImages/Launch.png";
row["ButtonToolTipText"] = "Launch This Workspace";
// Let's Determine which index is supposed to be selected
if (!String.IsNullOrEmpty(GUIState.LastSelectedWorkspaceName) &&
(workspaceName == GUIState.LastSelectedWorkspaceName))
selectedIndex = i;
i = i + 1; // incr.
}
// Third Step - Refresh The DataGrid
dataGridWorkspaces.ItemsSource = WorkspacesDT.DefaultView;
// Other ways to refresh * appears to not be needed here * could be useful later
//dataGridWorkspaces.ItemsSource = (WorkspacesDT as IListSource).GetList();
//dataGridWorkspaces.Items.Refresh();
// Fourth Step - Reset the ColumnWidth of the WorkspaceName if no Scrollbar is visible
if (workspaceNames.Length <= 13)
{
// scrollbar not visible
DataGridLength gridbuffer = new DataGridLength(188 + 18);
dataGridWorkspaces.Columns[0].Width = gridbuffer;
}
else
{
// scrollbar visible
DataGridLength gridbuffer = new DataGridLength(188);
dataGridWorkspaces.Columns[0].Width = gridbuffer;
}
// Fifth Step - Set the Selected Index of the DataGrid to the last set
// Workspace Or 0 if not found
if (selectedIndex >= 0)
dataGridWorkspaces.SelectedIndex = selectedIndex;
else
dataGridWorkspaces.SelectedIndex = 0;
}
#region Page Events
/// <summary>
/// Called when the Page is loaded
/// </summary>
private void Page_Loaded(object sender, RoutedEventArgs e)
{
if (!m_bPerformanceCache)
{
// Make sure that the Selector Frame is big enough to hold this page
m_WorkspaceSelectorObj = (WorkspaceSelector)this.Tag;
m_WorkspaceSelectorObj.Height = this.Height + m_WorkspaceSelectorObj.MarginTopBottom;
m_WorkspaceSelectorObj.Width = this.Width;
// InitializeWorkspaceDT
WorkspacesDT = new DataTable("WorkspaceData");
WorkspacesDT.Columns.Add(new DataColumn("WorkspaceName", typeof(string)));
WorkspacesDT.Columns.Add(new DataColumn("ButtonResUri", typeof(string)));
WorkspacesDT.Columns.Add(new DataColumn("ButtonToolTipText", typeof(string)));
// Set Workspaces Label
lblCurrentWorkspace.Content = "Workspaces";
// Load ComboBox Sort Orders
comboBoxSortBy.Items.Add(WPFHelper.CreateAComboBoxItem("Sort By Last Accessed", SortOrderForWorkspaces.LastAccessedDescending));
comboBoxSortBy.Items.Add(WPFHelper.CreateAComboBoxItem("Sort By Most Frequently Used", SortOrderForWorkspaces.MostFrequentlyAccessedDescending));
comboBoxSortBy.Items.Add(WPFHelper.CreateAComboBoxItem("Sort By Name", SortOrderForWorkspaces.Ascending));
// Load GUI State (or Default Index)
comboBoxSortBy.SelectedIndex = GUIState.LastSelectedSotOrderWorkspacesIndex;
// Assign ToolTips for the Buttons
btnNew.ToolTip = WPFHelper.CreateNewStringToolTip("New Workspace", 0, 120);
btnEdit.ToolTip = WPFHelper.CreateNewStringToolTip("Rename Workspace", 0, 120);
btnDelete.ToolTip = WPFHelper.CreateNewStringToolTip("Delete Workspace", 0, 120);
btnCloseAll.ToolTip = WPFHelper.CreateNewStringToolTip("Close All Workspaces", 0, 120);
}
}
#endregion
#region ComboBox Events
/// <summary>
/// Combo Box - SortBy - Selection Change Event * Deal with repopulating the Workspace Datagrid
/// </summary>
private void comboBoxSortBy_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ComboBox combobox = sender as ComboBox;
if (combobox != null)
{
ComboBoxItem item = (ComboBoxItem)combobox.SelectedItem;
string Content = item.Content.ToString();
SortOrderForWorkspaces sortOrder = (SortOrderForWorkspaces)item.Tag;
// Save the State Information * Last SortOrder and Last SortOrder Index *
GUIState.LastSelectedSotOrderWorkspaces = sortOrder;
GUIState.LastSelectedSotOrderWorkspacesIndex = combobox.SelectedIndex;
// Update The Grid
UpdateWorkspaceGridItems(sortOrder);
}
}
#endregion
#region DataGrid Events
/// <summary>
/// Upon double-click we should be launching the Workspace (unload any previously loaded ones)
/// </summary>
private void dataGridWorkspaces_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
string strWorkspaceName = dataGrid_GetSelectedWorkspaceIfThereIsOne();
if (!String.IsNullOrEmpty(strWorkspaceName))
{
}
}
/// <summary>
/// Selection changed - Keep track of last selected workspace in GUIState
/// </summary>
private void dataGridWorkspaces_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
{
string strWorkspaceName = dataGrid_GetSelectedWorkspaceIfThereIsOne();
if (!String.IsNullOrEmpty(strWorkspaceName))
GUIState.LastSelectedWorkspaceName = strWorkspaceName;
}
/// <summary>
/// Get Whatever Workspace the User currently has selected in the Grid
/// </summary>
/// <returns>Selected Workpsace Or Empty String if there is none</returns>
private string dataGrid_GetSelectedWorkspaceIfThereIsOne()
{
String strWorkspaceName = String.Empty;
// We only allow single selection
IList<DataGridCellInfo> cells = dataGridWorkspaces.SelectedCells;
if (cells.Count > 0)
{
DataGridCellInfo cell = cells[0];
DataRowView row = (DataRowView)cell.Item;
strWorkspaceName = row["WorkspaceName"].ToString();
}
return strWorkspaceName;
}
/// <summary>
/// Creates the DataGrid Context Menu according to the Selected Workspace State
/// </summary>
/// <returns>valid Context Menu or Null</returns>
private ContextMenu dataGrid_CreateDataGridContextMenu()
{
string strWorkspaceName = dataGrid_GetSelectedWorkspaceIfThereIsOne();
if (!String.IsNullOrEmpty(strWorkspaceName))
{
// We also want to load the state of the workspace here
ContextMenu menu = new ContextMenu();
menu.PlacementTarget = this;
// Load all the MenuItems
MenuItem m1 = new MenuItem();
m1.Header = "Launch";
m1.Click += new RoutedEventHandler(ContextMenu_Item_Click);
m1.FontWeight = FontWeights.Bold;
m1.Icon = WPFHelper.CreateWPFImageFromRelativeResourceUri("PageImages/Launch.png", 16, 16);
menu.Items.Add(m1);
MenuItem m2 = new MenuItem();
m2.Header = "Show";
m2.Click += new RoutedEventHandler(ContextMenu_Item_Click);
m2.Icon = WPFHelper.CreateWPFImageFromRelativeResourceUri("PageImages/Hide.png", 16, 16);
menu.Items.Add(m2);
MenuItem m3 = new MenuItem();
m3.Header = "Hide";
m3.Click += new RoutedEventHandler(ContextMenu_Item_Click);
m3.Icon = WPFHelper.CreateWPFImageFromRelativeResourceUri("PageImages/Hide.png", 16, 16);
menu.Items.Add(m3);
MenuItem m4 = new MenuItem();
m4.Header = "Close";
m4.Click += new RoutedEventHandler(ContextMenu_Item_Click);
m4.Icon = WPFHelper.CreateWPFImageFromRelativeResourceUri("PageImages/Close.png", 16, 16);
menu.Items.Add(m4);
// Load all the Events
menu.Closed += new RoutedEventHandler(ContextMenu_Closed);
menu.MouseLeave += new MouseEventHandler(ContextMenu_MouseLeave);
return menu;
}
return null;
}
/// <summary>
/// We need to manually implement the context menu upon right click and not use wpf,
/// because of the mouse leave event
/// </summary>
private void dataGridWorkspaces_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
ContextMenu menu = dataGrid_CreateDataGridContextMenu();
if (menu != null)
{
// Make sure that leave doesn't work
m_WorkspaceSelectorObj.DontCloseOnMouseLeave = true;
// Show the Context Menu
menu.IsOpen = true;
}
}
#endregion
#region ContextMenu Events
/// <summary>
/// Context Menu - Closed Event
/// </summary>
void ContextMenu_Closed(object sender, RoutedEventArgs e)
{
// Make sure that navigator leave works again
m_WorkspaceSelectorObj.DontCloseOnMouseLeave = false;
// Close the Navigation Form *if the mouse is NOT over it*
if (!WPFHelper.IsMouseCursorOverWPFormWindow(m_WorkspaceSelectorObj))
m_WorkspaceSelectorObj.Close();
}
/// <summary>
/// Context Menu - Mouse Leave Event
/// </summary>
void ContextMenu_MouseLeave(object sender, MouseEventArgs e)
{
// On Leave just close the Menu
ContextMenu menu = (ContextMenu)sender;
menu.IsOpen = false;
}
/// <summary>
/// Context Menu - Menu Item Clicked Event
/// </summary>
void ContextMenu_Item_Click(object sender, RoutedEventArgs e)
{
MenuItem m = (MenuItem)sender;
string strWorkspaceName = dataGrid_GetSelectedWorkspaceIfThereIsOne();
if (!String.IsNullOrEmpty(strWorkspaceName))
{
bool bSuccess = false;
switch (m.Header.ToString())
{
case "Launch":
{
bSuccess = m_WorkspaceMgr.LaunchWorkspace(strWorkspaceName);
}
break;
case "Show":
{
bSuccess = m_WorkspaceMgr.HideShowWorkspace(strWorkspaceName, true);
}
break;
case "Hide":
{
bSuccess = m_WorkspaceMgr.HideShowWorkspace(strWorkspaceName, false);
}
break;
case "Close":
{
bSuccess = m_WorkspaceMgr.CloseWorkspace(strWorkspaceName);
}
break;
}
}
}
#endregion
#region Button Click Events
/// <summary>
/// New Button - Event Handler
/// </summary>
private void btnNew_Click(object sender, RoutedEventArgs e)
{
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_NewWorkspacePage);
}
/// <summary>
/// Edit Button - Event Handler
/// </summary>
private void btnEdit_Click(object sender, RoutedEventArgs e)
{
string strWorkspaceName = dataGrid_GetSelectedWorkspaceIfThereIsOne();
if (!String.IsNullOrEmpty(strWorkspaceName))
{
GUIState.LastSelectedWorkspaceName = strWorkspaceName;
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_RenameWorkspacePage);
}
}
/// <summary>
/// Delete Button - Event Handler
/// </summary>
private void btnDelete_Click(object sender, RoutedEventArgs e)
{
string strWorkspaceName = dataGrid_GetSelectedWorkspaceIfThereIsOne();
if (!String.IsNullOrEmpty(strWorkspaceName))
{
GUIState.LastSelectedWorkspaceName = strWorkspaceName;
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_DeleteWorkspacePage);
}
}
/// <summary>
/// CloseAll Button - Event Handler
/// </summary>
private void btnCloseAll_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("Does Nothing");
}
/// <summary>
/// Button on the Grid is being clicked - Event Handler
/// </summary>
private void ButtonGrid_Click(object sender, RoutedEventArgs e)
{
string strWorkspaceName = dataGrid_GetSelectedWorkspaceIfThereIsOne();
if (String.IsNullOrEmpty(strWorkspaceName))
return;
}
#endregion
}
}

View File

@@ -0,0 +1,237 @@
// For GUIDebugStepExe Debugging Only - Uncomment this #define
#define GUIDEBUGSTEPEXE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Runtime.InteropServices;
using System.Windows.Interop;
using System.EnterpriseServices;
using System.Reflection;
using Foo.Platform;
using Foo.Platform.Win32;
using System.Windows;
namespace Foo.ClientServices.GUIWPForms
{
/// <summary>
/// GUIWPForms - Com Callable Wrapper Class exposed to ButtonHook.
/// This class is responsible for creating the ButtonWPForm (a form created in response to a ButtonHook W32 Click)
/// </summary>
[Guid("481C24F8-D619-460b-955A-22055571430C")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("Foo.ClientServices.GUIWPForms")]
[ComVisible(true)]
[ObjectPooling(Enabled = true, MinPoolSize = 1, MaxPoolSize = 2500, CreationTimeout = 5000)]
#if GUIDEBUGSTEPEXE
public class GUIWPForms : IGUIPWPForms
#else
public class GUIWPForms : ServicedComponent, IProcessInitializer, IGUIPWPForms
#endif
{
// Declare the Log4net Variable
private static log4net.ILog Log = Logger.GetLog4NetInterface(MethodBase.GetCurrentMethod().DeclaringType);
#region Construction / Destruction
public GUIWPForms() {}
~GUIWPForms() { }
#endregion
#if GUIDEBUGSTEPEXE
#region GuiDebugStepCustomStarterStopers
public void Start()
{
Log.Info(string.Format("{0}() - ComponentState Application Is being started", MethodBase.GetCurrentMethod().Name));
ComponentState.ApplicationIsRunning = true;
}
public void Stop()
{
Log.Info(string.Format("{0}() - ComponentState Application Is being stopped", MethodBase.GetCurrentMethod().Name));
ComponentState.ApplicationIsRunning = false;
}
#endregion
#else
#region IProcessInitializer Members
public void Startup(object punkProcessControl)
{
Log.Info(string.Format("{0}() - ComponentState Application Is being started", MethodBase.GetCurrentMethod().Name));
ComponentState.ApplicationIsRunning = true;
}
public void Shutdown()
{
Log.Info(string.Format("{0}() - ComponentState Application Is being stopped", MethodBase.GetCurrentMethod().Name));
ComponentState.ApplicationIsRunning = false;
}
#endregion
#endif
#region IGUIPWPForms Members
/// <summary>
/// Launches the ArtifactWall WPForm (if one already exists, relaunches)
/// </summary>
/// <param name="hDeskbandButtonWnd">handle to the Button on the Deskband (used for positioning)</param>
/// <returns>true if successful, false otherwise</returns>
public bool LaunchArtifactWall(IntPtr hDeskbandButtonWnd)
{
try
{
RECT rect;
bool bFillRect = false;
if (hDeskbandButtonWnd != IntPtr.Zero)
bFillRect = Win32Functions.GetWindowRect(hDeskbandButtonWnd, out rect);
// First Step - Create the WpfForm
ComponentState.GUIFormsMgr.Create_WpfFormDISP(WPForms.ArtifactWall);
// Second Step - If we have a Rect, set the location
if (bFillRect)
{
//GUIFormsMgr._Action action = new GUIFormsMgr._Action(delegate(Window wpfForm)
//{
// wpfForm.Height = nHeight;
// wpfForm.Width = nWidth;
//});
//ComponentState.GUIFormsMgr.RunAction_WpfFormDISP(WPForms.ArtifactWall, action);
}
// Third Step - Show the WpfForm
ComponentState.GUIFormsMgr.Show_WpfFormDISP(WPForms.ArtifactWall);
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - Error Occured", MethodBase.GetCurrentMethod().Name), e);
}
return true;
}
/// <summary>
/// Closes the ArtifactWall if exists
/// </summary>
/// <returns>true if closed, false if not existent</returns>
public bool CloseArtifactWall()
{
try
{
return ComponentState.GUIFormsMgr.Delete_WpfFormDISP(WPForms.ArtifactWall);
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - Error Occured", MethodBase.GetCurrentMethod().Name), e);
}
return false;
}
/// <summary>
/// Launches the WorkspaceSelector WPForm (if one already exists, relaunches)
/// </summary>
/// <param name="hDeskbandButtonWnd">handle to the Button on the Deskband (used for positioning)</param>
/// <returns>true if successful, false otherwise</returns>
public bool LaunchWorkspaceSelector(IntPtr hDeskbandButtonWnd)
{
try
{
RECT rect = new RECT();
rect.top = 0;
rect.left = 0;
bool bSuccess = false;
bool bFillRect = false;
if (hDeskbandButtonWnd != IntPtr.Zero)
bFillRect = Win32Functions.GetWindowRect(hDeskbandButtonWnd, out rect);
// First Step - Create the WpfForm
bSuccess = ComponentState.GUIFormsMgr.Create_WpfFormDISP(WPForms.WorkspaceSelector);
if (!bSuccess)
return false;
// Second Step - If we have a Rect, set the location of the Workspace Selector
if (bFillRect)
{
GUIFormsMgr._Action action = new GUIFormsMgr._Action(delegate(Window wpfForm)
{
wpfForm.Top = rect.top + rect.AsRectangle.Height + 2;
wpfForm.Left = rect.left - 200;
});
bSuccess = ComponentState.GUIFormsMgr.RunAction_WpfFormDISP(WPForms.WorkspaceSelector, action);
if (!bSuccess)
return false;
}
// Third Step - Show the WpfForm
bSuccess = ComponentState.GUIFormsMgr.Show_WpfFormDISP(WPForms.WorkspaceSelector);
if (!bSuccess)
return false;
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - Error Occured", MethodBase.GetCurrentMethod().Name), e);
return false;
}
return true;
}
/// <summary>
/// Closes the WorkspaceSelector if exists
/// </summary>
/// <param name="hDeskbandButtonWnd"></param>
/// <returns>true if closed, false if not existent</returns>
public bool CloseWorkspaceSelector()
{
try
{
return ComponentState.GUIFormsMgr.Delete_WpfFormDISP(WPForms.WorkspaceSelector);
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - Error Occured", MethodBase.GetCurrentMethod().Name), e);
}
return false;
}
/// <summary>
/// Launches the Settings and Abouts WPForm (if one already exists, relaunches)
/// </summary>
/// <param name="hDeskbandButtonWnd">handle to the Button on the Deskband (used for positioning)</param>
/// <returns>true if successful, false otherwise</returns>
public bool LaunchSettingsNAboutUs(IntPtr hDeskbandButtonWnd)
{
try
{
// First Step - Create the WpfForm
ComponentState.GUIFormsMgr.Create_WpfFormDISP(WPForms.SettingsNAboutUs);
// Second Step - Show the WpfForm
ComponentState.GUIFormsMgr.Show_WpfFormDISP(WPForms.SettingsNAboutUs);
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - Error Occured", MethodBase.GetCurrentMethod().Name), e);
}
return true;
}
/// <summary>
/// Closes the Settings And About us
/// </summary>
/// <returns>true if closed, false if not existent</returns>
public bool CloseSettingsNAboutUs()
{
try
{
return ComponentState.GUIFormsMgr.Delete_WpfFormDISP(WPForms.WorkspaceSelector);
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - Error Occured", MethodBase.GetCurrentMethod().Name), e);
}
return false;
}
#endregion
}
}

View File

@@ -0,0 +1,212 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{A02E052C-3C52-43DB-BB30-A47446B8165F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Foo.ClientServices.GUIWPForms</RootNamespace>
<AssemblyName>GUIWPForms</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<StartupObject>
</StartupObject>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>MyKeyFile.SNK</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Target\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Target\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Infragistics3.Wpf.v8.2, Version=8.2.20082.1002, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb, processorArchitecture=MSIL" />
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Components\log4net.dll</HintPath>
</Reference>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</ItemGroup>
<ItemGroup>
<Compile Include="ComponentState.cs" />
<Compile Include="DispatcherThread.cs" />
<Compile Include="GUIFormsMgr.cs" />
<Compile Include="GUIWPForms.cs" />
<Compile Include="GUIWPForms\ArtifactWall.xaml.cs">
<DependentUpon>ArtifactWall.xaml</DependentUpon>
</Compile>
<Compile Include="GUIWPForms\SettingsNAboutUs.xaml.cs">
<DependentUpon>SettingsNAboutUs.xaml</DependentUpon>
</Compile>
<Compile Include="GUIWPForms\WorkspaceSelector.xaml.cs">
<DependentUpon>WorkspaceSelector.xaml</DependentUpon>
</Compile>
<Compile Include="GUIState.cs" />
<Compile Include="GUIWPFPages\WorkspaceSelector_DeleteWorkspacePage.xaml.cs">
<DependentUpon>WorkspaceSelector_DeleteWorkspacePage.xaml</DependentUpon>
</Compile>
<Compile Include="GUIWPFPages\WorkspaceSelector_NewWorkspacePage.xaml.cs">
<DependentUpon>WorkspaceSelector_NewWorkspacePage.xaml</DependentUpon>
</Compile>
<Compile Include="GUIWPFPages\WorkspaceSelector_RenameWorkspacePage.xaml.cs">
<DependentUpon>WorkspaceSelector_RenameWorkspacePage.xaml</DependentUpon>
</Compile>
<Compile Include="GUIWPFPages\WorkspaceSelector_StandardPage.xaml.cs">
<DependentUpon>WorkspaceSelector_StandardPage.xaml</DependentUpon>
</Compile>
<Compile Include="IGUIWPForms.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\DataAccessLayer\DataAccessLayer.csproj">
<Project>{C7E4B4C1-64D4-45FF-AAFD-C4B9AE216618}</Project>
<Name>DataAccessLayer</Name>
</ProjectReference>
<ProjectReference Include="..\..\GUILib\GUILib.csproj">
<Project>{C1282050-455B-44F4-8520-1C005E38EFB2}</Project>
<Name>GUILib</Name>
</ProjectReference>
<ProjectReference Include="..\..\Platform\Platform.csproj">
<Project>{F6929AFC-BF61-43A0-BABD-F807B65FFFA1}</Project>
<Name>Platform</Name>
</ProjectReference>
<ProjectReference Include="..\..\WorkspaceMgr\WorkspaceMgr.csproj">
<Project>{09ED5DCC-9350-42E5-8E3A-4A3EA25BCD35}</Project>
<Name>WorkspaceMgr</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="MyKeyFile.SNK" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Page Include="GUIWPForms\ArtifactWall.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="GUIWPForms\SettingsNAboutUs.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="GUIWPForms\WorkspaceSelector.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="GUIWPFPages\WorkspaceSelector_DeleteWorkspacePage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="GUIWPFPages\WorkspaceSelector_NewWorkspacePage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="GUIWPFPages\WorkspaceSelector_RenameWorkspacePage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="GUIWPFPages\WorkspaceSelector_StandardPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\licenses.licx" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Resource Include="GUIWPFPages\PageImages\AddWorkspace.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="GUIWPFPages\PageImages\Close.png" />
<Resource Include="GUIWPFPages\PageImages\CloseAll.png" />
<Resource Include="GUIWPFPages\PageImages\DeleteWorkspace.png" />
<Resource Include="GUIWPFPages\PageImages\EditWorkspace.png" />
<Resource Include="GUIWPFPages\PageImages\Hide.png" />
<Resource Include="GUIWPFPages\PageImages\Launch.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="GUIWPFPages\PageImages\House.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PostBuildEvent>$(FrameworkDir)\regasm.exe "$(SolutionDir)target\$(ConfigurationName)\$(TargetFileName)" /unregister
$(FrameworkDir)\regasm.exe "$(SolutionDir)target\$(ConfigurationName)\$(TargetFileName)" /tlb:$(TargetName).tlb /codebase
REM $(FrameworkDir)\regsvcs.exe /reconfig "$(SolutionDir)target\$(ConfigurationName)\$(TargetFileName)" /appdir:"$(SolutionDir)target\$(ConfigurationName)"
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{A02E052C-3C52-43DB-BB30-A47446B8165F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Foo.ClientServices.GUIWPForms</RootNamespace>
<AssemblyName>GUIWPForms</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>MyKeyFile.SNK</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Infragistics3.Wpf.v8.2, Version=8.2.20082.1002, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb, processorArchitecture=MSIL" />
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Components\log4net.dll</HintPath>
</Reference>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ComponentState.cs" />
<Compile Include="DispatcherThread.cs" />
<Compile Include="GUIFormsMgr.cs" />
<Compile Include="GUIWPForms.cs" />
<Compile Include="GUIWPForms\ArtifactWall.xaml.cs">
<DependentUpon>ArtifactWall.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Platform\Platform.csproj">
<Project>{F6929AFC-BF61-43A0-BABD-F807B65FFFA1}</Project>
<Name>Platform</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="MyKeyFile.SNK" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Page Include="GUIWPForms\ArtifactWall.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PostBuildEvent>copy "$(TargetDir)$(TargetFileName)" "$(SolutionDir)target\$(ConfigurationName)" /Y
copy "$(TargetDir)$(TargetName).pdb" "$(SolutionDir)target\$(ConfigurationName)" /Y
$(FrameworkDir)\regasm.exe "$(SolutionDir)target\$(ConfigurationName)\$(TargetFileName)" /unregister
$(FrameworkDir)\regasm.exe "$(SolutionDir)target\$(ConfigurationName)\$(TargetFileName)" /tlb:$(TargetName).tlb /codebase
$(FrameworkDir)\regsvcs.exe /reconfig "$(SolutionDir)target\$(ConfigurationName)\$(TargetFileName)" /appdir:"$(SolutionDir)target\$(ConfigurationName)"
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,63 @@
<Window x:Class="Foo.ClientServices.GUIWPForms.ArtifactWall"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Loaded="Window_Loaded" Closing="Window_Closing"
Background="Black" WindowStyle="None" ShowInTaskbar="False"
Title="ArtifactWall" Height="569" Width="968" xmlns:igWindows="http://infragistics.com/Windows" Grid.IsSharedSizeScope="True">
<Window.Resources>
<DataTemplate x:Key="ArtifactWallTemplate">
<Border BorderBrush="{Binding BorderBrush}" BorderThickness="{Binding BorderThickness}">
<StackPanel Height="{Binding StackPanelHeight}" Width="{Binding StackPanelWidth}" Background="{Binding StackPanelBackground}">
<Image Source="{Binding ImagePath}" Height="{Binding ImageHeight}" Width="{Binding ImageWidth}" Stretch="Fill">
<Image.ToolTip>
<TextBlock TextWrapping="Wrap" Width="100" Text="{Binding Title}"/>
</Image.ToolTip>
</Image>
<TextBlock TextWrapping="Wrap" HorizontalAlignment="Center" Background="Black" Foreground="White" VerticalAlignment="Center" Width="{Binding StackPanelWidth}" Height="28" Text="{Binding Title}"/>
<TextBlock TextWrapping="Wrap" HorizontalAlignment="Center" Background="Black" Foreground="White" VerticalAlignment="Center" Width="{Binding StackPanelWidth}" Height="28" Text="{Binding LastLaunch}"/>
<TextBlock TextWrapping="Wrap" HorizontalAlignment="Center" Background="Black" Foreground="White" VerticalAlignment="Center" Width="{Binding StackPanelWidth}" Height="28" Text="{Binding FreqLaunch}"/>
<!--<Label Content="{Binding Title}" Background="Black" Foreground="White"/>-->
</StackPanel>
</Border>
</DataTemplate>
<!--<Image Source="{Binding ImagePath}" Height="840" Width="400">
</Image>-->
<!--<StackPanel>
<Image Source="{Binding ImagePath}" Height="640" Width="400">
<Image.ToolTip>
<TextBlock TextWrapping="Wrap" Width="100" Text="{Binding Title}"/>
</Image.ToolTip>
</Image>
<Label Content="{Binding Title}" Background="Black" Foreground="White"/>
<Label Content="{Binding Note}" Background="Black" Foreground="White"/>
</StackPanel>-->
<!--<ContentPresenter Content="{Binding XPath=Make}" />-->
<!--<ContentPresenter Content="{Binding XPath=Model}" />-->
</Window.Resources>
<Grid Name="grid1" ShowGridLines="False">
<Rectangle x:Name="recGradiant" Stroke="Black" RadiusY="1" RadiusX="1" Grid.ColumnSpan="2">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" Opacity="1.0">
<GradientStop Color="#FF000000" Offset="0.238"/>
<GradientStop Color="#FE333333" Offset="0.778"/>
<GradientStop Color="#FE202020" Offset="0.613"/>
<GradientStop Color="#FE333333" Offset="0.87"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<igWindows:XamCarouselListBox Name="xamCarouselPanel1" Margin="21,59,82,21" ItemsSource="{Binding ElementName=This, Path=ArtifactsDT.DefaultView}" ItemTemplate="{StaticResource ArtifactWallTemplate}" BorderBrush="Transparent" Focusable="False" FlowDirection="LeftToRight" IsHitTestVisible="True" IsTabStop="False">
</igWindows:XamCarouselListBox>
<Button Height="23" HorizontalAlignment="Right" Margin="0,12,5,0" Name="btnClose" VerticalAlignment="Top" Width="20" Click="btnClose_Click">X</Button>
<TextBox Height="23" HorizontalAlignment="Left" Margin="21,23,0,0" Name="txtSearch" VerticalAlignment="Top" Width="201" />
<Label Height="45" Margin="413,14,336,0" Name="lblTitle" VerticalAlignment="Top" Foreground="White" FontSize="24">Title</Label>
<ComboBox Height="23" HorizontalAlignment="Right" Margin="0,23,82,0" Name="comboBox1" VerticalAlignment="Top" Width="93" />
<Button Margin="0,167,15,0" Name="btnUp" Click="btnUp_Click" HorizontalAlignment="Right" Width="52" Height="58" VerticalAlignment="Top">Up</Button>
<Button Height="58" HorizontalAlignment="Right" Margin="0,0,15,171" Name="btnDown" VerticalAlignment="Bottom" Width="52" Click="btnDown_Click">Down</Button>
</Grid>
</Window>

View File

@@ -0,0 +1,269 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Interop;
using System.Windows.Threading;
using System.Threading;
using Foo.Platform;
using Foo.GUILib;
using Foo.DataAccessLayer;
using Foo.DataAccessLayer.DataTypes;
using System.Data;
namespace Foo.ClientServices.GUIWPForms
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class ArtifactWall : Window
{
private bool m_bPerformanceCache = false;
// Height and Width Settings
private int m_ItemHeight = 0;
private int m_ItemWidth = 0;
private int m_ImageHeight = 0;
private int m_ImageWidth = 0;
private int m_StackPanelHeight = 0;
private int m_StackPanelWidth = 0;
// Hard-coded Settings
private const int ITEM_BORDER_THICKNESS = 2;
private const int SELECTION_BORDER_SIZE_MARGIN = 10;
// private DT holds all information needed for the DataGrid
public DataTable ArtifactsDT { get; private set; }
//object CreateImage(string Path)
//{
// Image myImage1 = new Image();
// myImage1.Height = HEIGHT;
// myImage1.Width = WIDTH;
// BitmapImage myBitmapImage1 = new BitmapImage();
// myBitmapImage1.BeginInit();
// myBitmapImage1.UriSource = new Uri(Path);
// myBitmapImage1.DecodePixelHeight = HEIGHT;
// myBitmapImage1.DecodePixelWidth = WIDTH;
// myBitmapImage1.EndInit();
// myImage1.Source = myBitmapImage1;
// //myImage1.Margin = new Thickness(25);
// return myImage1;
//}
Path CreatePath()
{
LineGeometry myLineGeometry = new LineGeometry();
myLineGeometry.StartPoint = new Point(10, 50);
myLineGeometry.EndPoint = new Point(1600,50);
Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
myPath.Data = myLineGeometry;
return myPath;
}
void AddWorkspaceArtifacts(string workspaceName)
{
//using (OoganizerState oogyState = new OoganizerState())
//{
// oogyState.SetCurrentWorkspace(workspaceName);
// using (OoganizerAPIProxy proxy = oogyState.GetAPIProxy())
// {
// Workspace workspace = proxy.API.GetWorkspace(workspaceName);
// foreach (OoganizerDAL.Artifact artifact in workspace.Artifacts)
// {
// xamCarouselPanel1.ChildElements.Add(CreateImage(artifact.Snapshot_Path));
// }
// }
//}
}
private void CalculateHeightAndWidthSettings()
{
// Image Settings
m_ImageHeight = 627;
m_ImageWidth = 400;
// StackPanel Settings
const int STACK_PANEL_ITEMS_HEIGHT = 84; // add together the other StackPanel items
m_StackPanelHeight = m_ImageHeight + STACK_PANEL_ITEMS_HEIGHT;
m_StackPanelWidth = m_ImageWidth;
// Item settings
m_ItemHeight = m_StackPanelHeight + SELECTION_BORDER_SIZE_MARGIN;
m_ItemWidth = m_StackPanelWidth + SELECTION_BORDER_SIZE_MARGIN;
}
/// <summary>
///
///
/// </summary>
private void UpdateArtifactsWall(SortOrderForWorkspaces sortOrder)
{
// First Step - Clear the DT
ArtifactsDT.Rows.Clear();
// Second Step - Calculate Height/Width Settings
CalculateHeightAndWidthSettings();
// Third Step - Fill the DT with Artifact Information
ArtifactItem[] artifacts = Data.Artifacts.GetAllArtifactsInTheSystem(SortOrderForArtifacts.MostFrequentlyAccessedAscending);
foreach (ArtifactItem artifact in artifacts)
{
var row = ArtifactsDT.NewRow();
ArtifactsDT.Rows.Add(row);
// Border Settings
row["BorderBrush"] = "Aqua";
row["BorderThickness"] = ITEM_BORDER_THICKNESS;
// StackPanel Settings
row["StackPanelHeight"] = m_StackPanelHeight;
row["StackPanelWidth"] = m_StackPanelWidth;
row["StackPanelBackground"] = "Transparent";
// Image Settings
row["ImagePath"] = artifact.SnapshotFile;
row["ImageHeight"] = m_ImageHeight;
row["ImageWidth"] = m_ImageWidth;
// Artifact Information
if(artifact.IsFile)
row["Title"] = artifact.Name + " (" + artifact.FileName + ")";
else if(artifact.IsUrl)
row["Title"] = artifact.Name + " (" + artifact.Location + ")";
row["LastLaunch"] = "Last Accessed: " + artifact.LastAccessed.ToString();
row["FreqLaunch"] = "No. Times Accessed: " + artifact.AccessCounter.ToString();
row["Notes"] = artifact.Note;
}
// Third Step - Set xmlCarousel's Item Size
xamCarouselPanel1.ViewSettings.ItemSize = new Size(m_ItemWidth, m_ItemHeight);
// Fourth Step - Set the number of items * we could change this later*
xamCarouselPanel1.ViewSettings.ItemsPerPage = 3;
// Fifth Step - Refresh The xmlCarousel
xamCarouselPanel1.ItemsSource = ArtifactsDT.DefaultView;
}
public ArtifactWall(bool bPerformanceCache)
{
InitializeComponent();
// * For Performance Caching *
if (WPFHiddenWindow.HiddenWindowConstructor(this, bPerformanceCache))
{
m_bPerformanceCache = true;
}
else
{
// Set Window Position Here
WindowState = WindowState.Maximized;
WindowStartupLocation = WindowStartupLocation.CenterScreen;
xamCarouselPanel1.ViewSettings.ItemPath = CreatePath();
xamCarouselPanel1.ViewSettings.ItemHorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
xamCarouselPanel1.ViewSettings.ItemVerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
xamCarouselPanel1.ViewSettings.AutoScaleItemContentsToFit = true;
xamCarouselPanel1.Focus();
}
//WindowInteropHelper hInter = new WindowInteropHelper(this);
//int width = System.Windows.Forms.Screen.FromHandle(hInter.Handle).Bounds.Width;
//int height = System.Windows.Forms.Screen.FromHandle(hInter.Handle).Bounds.Height;
}
#region Page Events
private void Window_Loaded(object sender, RoutedEventArgs e)
{
// * For Performance Caching *
if (WPFHiddenWindow.HiddenWindowOnLoad(this, m_bPerformanceCache))
{
// Do anything you would like to load
}
else
{
// InitializeArtifactsDT
ArtifactsDT = new DataTable("ArtifactsData");
// Border Related Settings
ArtifactsDT.Columns.Add(new DataColumn("BorderBrush", typeof(string)));
ArtifactsDT.Columns.Add(new DataColumn("BorderThickness", typeof(string)));
// Image related Settings
ArtifactsDT.Columns.Add(new DataColumn("ImagePath", typeof(string)));
ArtifactsDT.Columns.Add(new DataColumn("ImageHeight", typeof(string)));
ArtifactsDT.Columns.Add(new DataColumn("ImageWidth", typeof(string)));
// StackPanel Settings
ArtifactsDT.Columns.Add(new DataColumn("StackPanelHeight", typeof(string)));
ArtifactsDT.Columns.Add(new DataColumn("StackPanelWidth", typeof(string)));
ArtifactsDT.Columns.Add(new DataColumn("StackPanelBackground", typeof(string)));
// Artifact Settings
ArtifactsDT.Columns.Add(new DataColumn("Title", typeof(string)));
ArtifactsDT.Columns.Add(new DataColumn("LastLaunch", typeof(string)));
ArtifactsDT.Columns.Add(new DataColumn("FreqLaunch", typeof(string)));
ArtifactsDT.Columns.Add(new DataColumn("Notes", typeof(string)));
//
UpdateArtifactsWall(SortOrderForWorkspaces.Ascending);
}
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
// * For Performance Caching *
if (WPFHiddenWindow.HiddenWindowClosing(this, m_bPerformanceCache))
{
// Do anything you would like to load
}
else
{
}
}
#endregion
# region Button Click Events
private void btnClose_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void btnUp_Click(object sender, RoutedEventArgs e)
{
}
private void btnDown_Click(object sender, RoutedEventArgs e)
{
}
#endregion
}
}

View File

@@ -0,0 +1,42 @@
<Window x:Class="Foo.ClientServices.GUIWPForms.SettingsNAboutUs"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Loaded="Window_Loaded" Closing="Window_Closing" Background="Transparent" AllowsTransparency="True"
Title="SettingsNAboutUs" Height="461" Width="697" WindowStyle="None">
<Grid>
<Rectangle x:Name="recGradiant" Stroke="Black" RadiusY="7.5" RadiusX="7.5">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" Opacity="1.0">
<GradientStop Color="#FF000000" Offset="0.238"/>
<GradientStop Color="#FE333333" Offset="0.778"/>
<GradientStop Color="#FE202020" Offset="0.613"/>
<GradientStop Color="#FE333333" Offset="0.87"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Button Height="18" HorizontalAlignment="Right" Margin="0,3,5,0" Name="btnClose" VerticalAlignment="Top" Width="17" Click="btnClose_Click" Foreground="White">X</Button>
<TabControl Margin="12,27,12,12" Name="tabControl1" Background="Transparent">
<TabItem Header="Settings" Name="tabSettings">
<Grid>
<GroupBox Header="Workspace Selector" Margin="6,6,335,167" Name="groupBoxWorkspaceSelector" Foreground="White" ForceCursor="False">
<Grid>
<CheckBox Height="37" Margin="6,15,6,0" Name="checkBox1" VerticalAlignment="Top" Foreground="White">
Auto-Hide Workspaces
</CheckBox>
<CheckBox Foreground="White" Margin="6,47,0,72" Name="checkBox2">Auto-Save Office Documents</CheckBox>
</Grid>
</GroupBox>
<GroupBox Header="Artifact Wall" Margin="348,6,6,167" Name="groupBoxArtifactWall" Foreground="White">
<Grid />
</GroupBox>
</Grid>
</TabItem>
<TabItem Header="Help" Name="tabHelp">
<Grid />
</TabItem>
<TabItem Header="About Us" Name="tabAboutUs">
<Grid />
</TabItem>
</TabControl>
</Grid>
</Window>

View File

@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Foo.GUILib;
using Foo.Platform.Satellite;
namespace Foo.ClientServices.GUIWPForms
{
/// <summary>
/// Interaction logic for SettingsNAboutUs.xaml
/// </summary>
public partial class SettingsNAboutUs : Window
{
private bool m_bPerformanceCache = false;
public SettingsNAboutUs(bool bPerformanceCache)
{
InitializeComponent();
// * For Performance Caching *
if (WPFHiddenWindow.HiddenWindowConstructor(this, bPerformanceCache))
{
m_bPerformanceCache = true;
}
else
{
// Set Window Position Here
WindowStartupLocation = WindowStartupLocation.CenterScreen;
}
}
#region Internationalization
private void LoadAllTexts_Internationalization()
{
// Load Tab Headers
tabSettings.Header = GUIResx.GetString("TAB_SETTINGSNABOUTUS_SETTINGS");
tabHelp.Header = GUIResx.GetString("TAB_SETTINGSNABOUTUS_HELP");
tabAboutUs.Header = GUIResx.GetString("TAB_SETTINGSNABOUTUS_ABOUTUS");
// Load Group Labels
groupBoxWorkspaceSelector.Header = GUIResx.GetString("GROUPBOX_SETTINGABOUTUS_WORKSPACESELECTOR");
groupBoxArtifactWall.Header = GUIResx.GetString("GROUPBOX_SETTINGABOUTUS_ARTIFACTWALL");
// Load Labels
}
#endregion
#region Window Events
private void Window_Loaded(object sender, RoutedEventArgs e)
{
// * For Performance Caching *
if (WPFHiddenWindow.HiddenWindowOnLoad(this, m_bPerformanceCache))
{
}
else
{
// Load Texts
LoadAllTexts_Internationalization();
}
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
// * For Performance Caching *
if (WPFHiddenWindow.HiddenWindowClosing(this, m_bPerformanceCache))
{
}
else
{
}
}
#endregion
private void btnClose_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

View File

@@ -0,0 +1,20 @@
<Window x:Class="Foo.ClientServices.GUIWPForms.WorkspaceSelector"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Closing="Window_Closing" MouseEnter="Window_MouseEnter"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Loaded="Window_Loaded" MouseLeave="Window_MouseLeave"
BorderBrush="AliceBlue" ShowInTaskbar="False" ResizeMode="NoResize" Topmost="True"
WindowStyle="None" AllowsTransparency="True" Background="Transparent"
Title="WorkspaceSelector" Height="322" Width="250" Opacity="1" VerticalContentAlignment="Stretch">
<Grid>
<Rectangle x:Name="recGradiant" Stroke="Black" RadiusY="7.5" RadiusX="7.5">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" Opacity="1.0">
<GradientStop Color="#FF000000" Offset="0.238"/>
<GradientStop Color="#FE333333" Offset="0.778"/>
<GradientStop Color="#FE202020" Offset="0.613"/>
<GradientStop Color="#FE333333" Offset="0.87"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Frame Name="frmWorkspaceSelector" Margin="0,6.003" NavigationUIVisibility="Hidden" VerticalContentAlignment="Top" />
</Grid>
</Window>

View File

@@ -0,0 +1,249 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Interop;
using System.Reflection;
using System.Windows.Threading;
using Foo.Platform;
using Foo.GUILib;
namespace Foo.ClientServices.GUIWPForms
{
public enum ChildPages
{
WorkspaceSelector_StandardPage,
WorkspaceSelector_NewWorkspacePage,
WorkspaceSelector_RenameWorkspacePage,
WorkspaceSelector_DeleteWorkspacePage,
}
/// <summary>
/// Interaction logic for WorkspaceSelector.xaml
/// </summary>
public partial class WorkspaceSelector : Window
{
private bool m_bPerformanceCache = false;
private Page[] m_ChildPages = null;
// Declare the Log4net Variable
private static log4net.ILog Log = Logger.GetLog4NetInterface(MethodBase.GetCurrentMethod().DeclaringType);
// Allow Childresn access to the Frame
public Frame WorkspaceSelectorFrm { get { return frmWorkspaceSelector; } }
// Allow Children to overwrite MouseLeave Close Behavior
public bool DontCloseOnMouseLeave { get; set; }
// Allow Children access to margin top/bottom
public int MarginTopBottom { get; set; }
// internal flags
private bool m_bMouseFirstTimeEnter = false;
private bool m_bMouseHasEnteredBack = false;
private bool m_bMouseLeaveTimerCreated = false;
/// <summary>
/// Child Page Creation Factory * should only be called internally *
/// </summary>
/// <param name="page">the page to instantiate</param>
/// <returns>a new page object or null</returns>
private Page CreateChildPage(ChildPages page)
{
Page pageObj = null;
switch (page)
{
case ChildPages.WorkspaceSelector_NewWorkspacePage:
pageObj = new WorkspaceSelector_NewWorkspacePage(m_bPerformanceCache);
break;
case ChildPages.WorkspaceSelector_RenameWorkspacePage:
pageObj = new WorkspaceSelector_RenameWorkspacePage(m_bPerformanceCache);
break;
case ChildPages.WorkspaceSelector_DeleteWorkspacePage:
pageObj = new WorkspaceSelector_DeleteWorkspacePage(m_bPerformanceCache);
break;
case ChildPages.WorkspaceSelector_StandardPage:
pageObj = new WorkspaceSelector_StandardPage(m_bPerformanceCache);
break;
}
return pageObj;
}
/// <summary>
/// Use this to actually navigate to a child page object on the WorkspaceSelector
/// </summary>
/// <param name="page">a page to navigate to</param>
public void NavigateToChildPage(ChildPages page)
{
try
{
Page pageObj = CreateChildPage(page);
if (pageObj != null)
{
pageObj.Tag = this; // pass out this object
if (!frmWorkspaceSelector.Navigate(pageObj))
Log.Info(string.Format("{0}() - WorkspaceSelector could not navigate to ChildPage {1}", MethodBase.GetCurrentMethod().Name, (int)page));
}
}
catch (Exception e)
{
Log.Error(string.Format("{0}() - Error Thrown", MethodBase.GetCurrentMethod().Name, e));
}
}
/// <summary>
/// WorkspaceSelector Constructor - set's default values for the object
/// Instantiates all child pages when in Performance Mode
/// </summary>
/// <param name="bPerformanceCache">true if this is a cached form for performance, false every other time</param>
public WorkspaceSelector(bool bPerformanceCache)
{
InitializeComponent();
// * For Performance Caching *
if (WPFHiddenWindow.HiddenWindowConstructor(this, bPerformanceCache))
{
m_bPerformanceCache = true;
// Performance Load the Child Pages as well
int n = Enum.GetValues(typeof(ChildPages)).Length;
m_ChildPages = new Page[n];
// Iterate thru enums and create the corresponding objects in the Cache
for (int i = 0; i < n; ++i)
{
ChildPages page = (ChildPages)Enum.ToObject(typeof(ChildPages), i);
m_ChildPages[i] = CreateChildPage(page);
}
}
// By default allow mouse leave to close the form
DontCloseOnMouseLeave = false;
// MarginTopBottom is the space up and below the frame 2 * 6 = 12 (but we want 2 pixels trimmed)
MarginTopBottom = 10;
}
#region Window Events
/// <summary>
/// Window Load Event - Hook into MessageHook if in performance mode,
/// otherwise load default child
/// </summary>
private void Window_Loaded(object sender, RoutedEventArgs e)
{
// * For Performance Caching *
if (WPFHiddenWindow.HiddenWindowOnLoad(this, m_bPerformanceCache))
{
// To Anything her you may want to do
}
else
{
// Navigate to the Default Page
NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
// Set the GUI State to this object
GUIState.CurrentlyShowingWPFWindow = this;
// Start the Load Mouse Enter Timer for 1.5 seconds
DispatcherTimer dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(dispatcherTimerOnLoadMouseEnter_Tick);
dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1, 500);
dispatcherTimer.Start();
}
}
/// <summary>
/// keep track of window closed
/// </summary>
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
// * For Performance Caching *
if (WPFHiddenWindow.HiddenWindowClosing(this, m_bPerformanceCache))
{
// To Anything her you may want to do
}
else
{
// Set the GUI State to this object
GUIState.CurrentlyShowingWPFWindow = null;
}
}
/// <summary>
/// Keep track of mouse enter
/// </summary>
private void Window_MouseEnter(object sender, MouseEventArgs e)
{
m_bMouseFirstTimeEnter = true;
m_bMouseHasEnteredBack = true;
}
/// <summary>
/// General Standard behavior - Close the form on Mouse Leave, except when
/// children overwrite this behavior via DontCloseOnMouseLeave
/// </summary>
private void Window_MouseLeave(object sender, MouseEventArgs e)
{
m_bMouseHasEnteredBack = false;
if (!m_bMouseLeaveTimerCreated)
{
// Start Mouse Leave Timer for 1.5 seconds
DispatcherTimer dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(dispatcherTimerMouseLeave_Tick);
dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1, 500);
dispatcherTimer.Start();
// Set flag
m_bMouseLeaveTimerCreated = true;
}
}
#endregion
/// <summary>
/// Run One Time - after Mouse Leaves. Closes Form if Mouse has not entered
/// </summary>
void dispatcherTimerMouseLeave_Tick(object sender, EventArgs e)
{
// Turn off the timer
DispatcherTimer dispatcherTimer = (DispatcherTimer)sender;
dispatcherTimer.Stop();
m_bMouseLeaveTimerCreated = false;
// Close this window, but only if the mouse has not entered back ||
// we are told not to do it
if (!m_bMouseHasEnteredBack && !DontCloseOnMouseLeave)
this.Close();
}
/// <summary>
/// Run One Time - Upon Load. Closes form if mouse has not entered
/// </summary>
void dispatcherTimerOnLoadMouseEnter_Tick(object sender, EventArgs e)
{
// We only want to run this timer Once * Always *
DispatcherTimer dispatcherTimer = (DispatcherTimer)sender;
dispatcherTimer.Stop();
// Close this window, but only if the mouse has not entered back
// Close this Form *always*
if (!m_bMouseFirstTimeEnter && !DontCloseOnMouseLeave)
this.Close();
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace Foo.ClientServices.GUIWPForms
{
/// <summary>
/// GUIPWPForms uses IGUIPWPForms Interface. It exposes functions to external
/// callers regarding the type of GUIWPForms we can launch.
/// ~Most functions require an hWnd which is the DeskbandButton to properly Position the form.
/// ~However if hWnd is Zero and we are in Debug we just center it. * For Debugging Purpose *
/// </summary>
[Guid("652DDE0A-D3FA-4525-8272-1616127819D2")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[ComVisible(true)]
public interface IGUIPWPForms
{
// ArtifactWall
bool LaunchArtifactWall(IntPtr hDeskbandButtonWnd);
bool CloseArtifactWall();
// WorkspaceSelector
bool LaunchWorkspaceSelector(IntPtr hDeskbandButtonWnd);
bool CloseWorkspaceSelector();
// Settings N' About Us Page
bool LaunchSettingsNAboutUs(IntPtr hDeskbandButtonWnd);
bool CloseSettingsNAboutUs();
}
}

Binary file not shown.

View File

@@ -0,0 +1,58 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
using System.EnterpriseServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("GUIWPForms")]
[assembly: AssemblyDescription("Performance Caching for GUIWPForms")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Ooganizer Corporation")]
[assembly: AssemblyProduct("GUIWPForms")]
[assembly: AssemblyCopyright("Copyright © Ooganizer Corporation 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(true)]
[assembly: ApplicationID("E6A84616-5ED1-4679-B26D-64F80A5E41CD")]
[assembly: ApplicationActivation(ActivationOption.Server)]
[assembly: ApplicationAccessControl(Value = false, Authentication = AuthenticationOption.None)]
[assembly: ApplicationName("Foo.ClientServices")]
[assembly: Description("Provides Data Access and Performance Caching for Ooganizer Components")]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4200
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Foo.ClientServices.GUIWPForms.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Foo.ClientServices.GUIWPForms.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4200
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Foo.ClientServices.GUIWPForms.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
</SettingsFile>

View File

@@ -0,0 +1 @@
Infragistics.Windows.Controls.XamCarouselListBox, Infragistics3.Wpf.v8.2, Version=8.2.20082.1002, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb

BIN
Components/log4net.dll Normal file

Binary file not shown.

298
DataAccessLayer/DB.cs Normal file
View File

@@ -0,0 +1,298 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Data.SqlServerCe;
using System.Text;
using System.IO;
using System.Resources;
using System.Reflection;
namespace Foo.DataAccessLayer
{
public class DB
{
/// <summary>
/// Private Properties
/// </summary>
private static string _dbPath = "C:\\_ROOT_\\TestANizer\\DataAccessLayer";
private static string _dbName = "OggyNize.sdf";
private static string _dbPassword = "1kso123!~~!@";
private static string _connString { get { return String.Format("Data Source={0}\\{1}; encryption mode=platform default; Password=\"{2}\"; Encrypt = TRUE;", Path.GetFullPath(_dbPath), _dbName, _dbPassword); } }
/// <summary>
/// Public Properties
/// </summary>
public static bool DoesDBExist { get { return (File.Exists(_dbPath + "\\" + _dbName)); } }
/// <summary>
/// Use this to create the Default Database
/// </summary>
public static void CreateDefaultDB()
{
CreateDB(_dbPath, _dbName, _dbPassword);
}
/// <summary>
/// Use this to delete the Default Database
/// </summary>
public static void DeleteDefaultDB()
{
if (!String.IsNullOrEmpty(_dbPath) &&
!String.IsNullOrEmpty(_dbName) &&
Directory.Exists(_dbPath) &&
File.Exists(_dbPath + "\\" + _dbName))
{
File.Delete(_dbPath + "\\" + _dbName);
}
}
/// <summary>
/// Use this function to create a New Database, if it doesn't already exist
/// </summary>
/// <param name="dbPath">Path to the Database</param>
/// <param name="dbName">Name of the Database</param>
/// <param name="dbPassword">Password to use on the Database</param>
internal static void CreateDB(string dbPath, string dbName, string dbPassword)
{
try
{
if (dbPath.Length > 3 && dbPath[dbPath.Length - 1] == '\\')
dbPath = dbPath.Remove(dbPath.Length - 1);
if (!String.IsNullOrEmpty(dbName) && !dbName.ToLower().Contains(".sdf"))
dbName = dbName + ".sdf";
if (!String.IsNullOrEmpty(dbPath) &&
!String.IsNullOrEmpty(dbName) &&
Directory.Exists(dbPath) &&
!File.Exists(dbPath + "\\" + dbName))
{
_dbPath = dbPath;
_dbName = dbName;
_dbPassword = dbPassword;
using (SqlCeEngine engine = new SqlCeEngine(_connString))
{
engine.CreateDatabase();
}
// This will now Construct all the necessary Tables
// we need ~very nice and automatic
CreateInitialDBTables();
}
}
catch (Exception) { /* ignore */ }
}
/// <summary>
/// Responsible for creating all the initial Tables for the database
/// </summary>
private static void CreateInitialDBTables()
{
foreach (string TableResourceName in ResourceHelper.GetTableResourceNames())
{
string strSQL = ResourceHelper.GetTextSqlFromResourceFile(TableResourceName);
string[] strCommands = strSQL.Split(';');
foreach (string strCommand in strCommands)
{
// Is there a Label
if (strCommand.Contains(':'))
{
string[] strLabelAndCommand = strCommand.Split(':');
string strLabel = strLabelAndCommand[0];
string strCommand2 = strLabelAndCommand[1];
// Save the Label in the Version Map
string strTableName = ResourceHelper.GetTableNameFromTableResourceName(TableResourceName);
ResourceHelper.s_VersioningTablesMap[strTableName] = strLabel;
// Run the Command
RunSQLCommandTextExecuteNonQuery(strCommand2.Trim());
}
else
{
RunSQLCommandTextExecuteNonQuery(strCommand.Trim());
}
}
}
// Now that all Tables are created, we can now save the VersionMap into the Database
dVersioningTables versionTable = new dVersioningTables();
foreach (string key in ResourceHelper.s_VersioningTablesMap.Keys)
versionTable.AddUpdateVersionInformationForSpecifiedTable(key, ResourceHelper.s_VersioningTablesMap[key]);
}
/// <summary>
/// Use this to Run SQL with the ExecuteNonQuery() Command Object
/// </summary>
/// <param name="SqlCommandText">SQL Text/Commands to execute</param>
/// <returns>the result of the ExecuteNonQuery() operation</returns>
internal static int RunSQLCommandTextExecuteNonQuery(string SqlCommandText)
{
int nResult = -1;
try
{
using (SqlCeConnection conn = new SqlCeConnection(_connString))
{
conn.Open();
using (SqlCeCommand cmd = conn.CreateCommand())
{
cmd.CommandText = SqlCommandText;
nResult = cmd.ExecuteNonQuery();
}
}
}
catch (Exception) { /* ignore */ }
return nResult;
}
/// <summary>
/// Use this to Run SQL with the ExecuteNonQuery() Command Object
/// </summary>
/// <param name="SqlCommandText">SQL Text/Commands to execute</param>
/// <param name="parameters">Allows the use of sql parameters</param>
/// <returns>the result of the ExecuteNonQuery() operation</returns>
internal static int RunSQLCommandTextExecuteNonQuery(string SqlCommandText, SqlCeParameter[] parameters)
{
int nResult = -1;
try
{
using (SqlCeConnection conn = new SqlCeConnection(_connString))
{
conn.Open();
using (SqlCeCommand cmd = conn.CreateCommand())
{
cmd.CommandText = SqlCommandText;
foreach (SqlCeParameter parameter in parameters)
cmd.Parameters.Add(parameter);
nResult = cmd.ExecuteNonQuery();
}
}
}
catch (Exception) { /* ignore */ }
return nResult;
}
/// <summary>
/// Use this to Run SQL with the ExecuteScalar() Command Object
/// </summary>
/// <param name="SqlCommandText">SQL Text/Commands to execute</param>
/// <returns>the result of the ExecuteScalar() operation</returns>
internal static object RunSQLCommandTextExecuteScalar(string SqlCommandText)
{
object oResult = null;
try
{
using (SqlCeConnection conn = new SqlCeConnection(_connString))
{
conn.Open();
using (SqlCeCommand cmd = conn.CreateCommand())
{
cmd.CommandText = SqlCommandText;
oResult = cmd.ExecuteScalar();
}
}
}
catch (Exception) { /* ignore */ }
// Try Parsing the oResult, if an error occurs return null
try
{
if (String.IsNullOrEmpty(oResult.ToString()))
oResult = null;
}
catch (Exception) { oResult = null; }
return oResult;
}
/// <summary>
/// Use this to Run SQL with the ExecuteScalar() Command Object
/// </summary>
/// <param name="SqlCommandText">SQL Text/Commands to execute</param>
/// <param name="parameters">Allows the use of sql parameters</param>
/// <returns>the result of the ExecuteScalar() operation</returns>
internal static object RunSQLCommandTextExecuteScalar(string SqlCommandText, SqlCeParameter[] parameters)
{
object oResult = null;
try
{
using (SqlCeConnection conn = new SqlCeConnection(_connString))
{
conn.Open();
using (SqlCeCommand cmd = conn.CreateCommand())
{
cmd.CommandText = SqlCommandText;
foreach (SqlCeParameter parameter in parameters)
cmd.Parameters.Add(parameter);
oResult = cmd.ExecuteScalar();
}
}
}
catch (Exception) { /* ignore */ }
// Try Parsing the oResult, if an error occurs return null
try
{
if (String.IsNullOrEmpty(oResult.ToString()))
oResult = null;
}
catch (Exception) { oResult = null; }
return oResult;
}
/// <summary>
/// Use this to Run SQL with the DataAdapter Fill()
/// </summary>
/// <param name="SqlText">SQL Text to execute</param>
/// <returns>the result of the DataAdapter Fill() operation</returns>
internal static DataSet RunSQLTextFillDataSet(string SqlText)
{
DataSet dataset = new DataSet();
try
{
using (SqlCeConnection conn = new SqlCeConnection(_connString))
{
conn.Open();
using (SqlCeDataAdapter dataAdapter = new SqlCeDataAdapter(SqlText, conn))
{
dataAdapter.Fill(dataset);
}
}
}
catch (Exception) { /* ignore */ }
return dataset;
}
/// <summary>
/// Use this to Run SQL with the DataAdapter Fill()
/// </summary>
/// <param name="SqlText">SQL Text to execute</param>
/// <param name="parameters">Allows the use of sql parameters</param>
/// <returns>the result of the DataAdapter Fill() operation</returns>
internal static DataSet RunSQLTextFillDataSet(string SqlText, SqlCeParameter[] parameters)
{
DataSet dataset = new DataSet();
try
{
using (SqlCeConnection conn = new SqlCeConnection(_connString))
{
conn.Open();
using (SqlCeCommand cmd = conn.CreateCommand())
{
cmd.CommandText = SqlText;
foreach (SqlCeParameter parameter in parameters)
cmd.Parameters.Add(parameter);
using (SqlCeDataAdapter dataAdapter = new SqlCeDataAdapter(cmd))
{
dataAdapter.Fill(dataset);
}
}
}
}
catch (Exception) { /* ignore */ }
return dataset;
}
}
}

48
DataAccessLayer/Data.cs Normal file
View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Foo.DataAccessLayer
{
public class Data
{
/// <summary>
/// Public Properties
/// </summary>
public static dArtifacts Artifacts { get { return _artifacts; } }
public static dWorkspace Workspace { get { return _workspace; } }
public static dState State { get { return _state; } }
public static dUserSettings UserSettings { get { return _UserSettings; } }
/// <summary>
/// Internal Properties
/// </summary>
internal static dVersioningTables VersioningTables { get { return _VersioningTables; } }
/// <summary>
/// Private Locations for above Properties
/// </summary>
private static dArtifacts _artifacts;
private static dWorkspace _workspace;
private static dState _state;
private static dVersioningTables _VersioningTables;
private static dUserSettings _UserSettings;
static Data()
{
// Upon First Instantiation of Data,
// ensure that the Default DB Exists
DB.CreateDefaultDB();
// Load All Public Data Types
_artifacts = new dArtifacts();
_workspace = new dWorkspace();
_state = new dState();
_UserSettings = new dUserSettings();
// Load All Internal Data Types
_VersioningTables = new dVersioningTables();
}
}
}

View File

@@ -0,0 +1,224 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C7E4B4C1-64D4-45FF-AAFD-C4B9AE216618}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Foo.DataAccessLayer</RootNamespace>
<AssemblyName>DataAccessLayer</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>MyKeyFile.SNK</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\Target\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\Target\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL" />
<Reference Include="System.Data.SqlXml" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="dUserSettings.cs" />
<Compile Include="dArtifacts.cs" />
<Compile Include="DataTypes.cs" />
<Compile Include="Data.cs" />
<Compile Include="DB.cs" />
<Compile Include="nUnitTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="ResourceHelper.cs" />
<Compile Include="dState.cs" />
<Compile Include="TestData\TestData.cs" />
<Compile Include="dVersioningTables.cs" />
<Compile Include="dWorkspace.cs" />
<Compile Include="Tests\StressTest.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Sql\Tables\Artifacts.sqlce" />
<EmbeddedResource Include="Sql\Tables\WorkspaceLinks.sqlce" />
<EmbeddedResource Include="Sql\Tables\State.sqlce" />
<EmbeddedResource Include="Sql\Tables\VersioningTables.sqlce" />
<EmbeddedResource Include="Sql\Tables\Workspaces.sqlce" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="MyKeyFile.SNK" />
<None Include="TestData\Files\DupFiles1\Albin likes apples.doc" />
<None Include="TestData\Files\DupFiles1\Book1.xls" />
<None Include="TestData\Files\DupFiles1\Book1.xlsx" />
<None Include="TestData\Files\DupFiles1\Book2.xls" />
<None Include="TestData\Files\DupFiles1\Book2.xlsx" />
<None Include="TestData\Files\DupFiles1\Book3.xls" />
<None Include="TestData\Files\DupFiles1\Book4.xls" />
<None Include="TestData\Files\DupFiles1\Doc1.rtf" />
<None Include="TestData\Files\DupFiles1\Doc2.rtf" />
<None Include="TestData\Files\DupFiles1\Document1.docx" />
<None Include="TestData\Files\DupFiles1\Document2.doc" />
<None Include="TestData\Files\DupFiles1\Document3.docx" />
<None Include="TestData\Files\DupFiles1\Document4.doc" />
<None Include="TestData\Files\DupFiles1\Document5.docx" />
<None Include="TestData\Files\DupFiles1\Document6.docx" />
<None Include="TestData\Files\DupFiles1\Document7.docx" />
<None Include="TestData\Files\DupFiles1\Doris likes apples.doc" />
<None Include="TestData\Files\DupFiles1\doris.docx" />
<None Include="TestData\Files\DupFiles1\Doris.xlsx" />
<None Include="TestData\Files\DupFiles1\doris2.docx" />
<None Include="TestData\Files\DupFiles1\Drawing1.vsd" />
<None Include="TestData\Files\DupFiles1\Drawing2.vsd" />
<None Include="TestData\Files\DupFiles1\Map1.mmap" />
<None Include="TestData\Files\DupFiles1\Map2.mmap" />
<None Include="TestData\Files\DupFiles1\New Mindmap1.mm" />
<None Include="TestData\Files\DupFiles1\New Mindmap2.mm" />
<None Include="TestData\Files\DupFiles1\Presentation1.ppt" />
<None Include="TestData\Files\DupFiles1\Presentation2.ppt" />
<None Include="TestData\Files\DupFiles1\Publication1.pub" />
<None Include="TestData\Files\DupFiles1\Publication2.pub" />
<EmbeddedResource Include="Sql\Tables\UserSettings.sqlce" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<None Include="TestData\Files\DupFiles1\DatabaseBills.accdb">
</None>
<None Include="TestData\Files\DupFiles1\DatabaseReceits.accdb">
</None>
<None Include="TestData\Files\DupFiles2\Albin likes apples.doc" />
<None Include="TestData\Files\DupFiles2\Book1.xls" />
<None Include="TestData\Files\DupFiles2\Book1.xlsx" />
<None Include="TestData\Files\DupFiles2\Book2.xls" />
<None Include="TestData\Files\DupFiles2\Book2.xlsx" />
<None Include="TestData\Files\DupFiles2\Book3.xls" />
<None Include="TestData\Files\DupFiles2\Book4.xls" />
<None Include="TestData\Files\DupFiles2\Doc1.rtf" />
<None Include="TestData\Files\DupFiles2\Doc2.rtf" />
<None Include="TestData\Files\DupFiles2\Document1.docx" />
<None Include="TestData\Files\DupFiles2\Document2.doc" />
<None Include="TestData\Files\DupFiles2\Document3.docx" />
<None Include="TestData\Files\DupFiles2\Document4.doc" />
<None Include="TestData\Files\DupFiles2\Document5.docx" />
<None Include="TestData\Files\DupFiles2\Document6.docx" />
<None Include="TestData\Files\DupFiles2\Document7.docx" />
<None Include="TestData\Files\DupFiles2\Doris likes apples.doc" />
<None Include="TestData\Files\DupFiles2\doris.docx" />
<None Include="TestData\Files\DupFiles2\Doris.xlsx" />
<None Include="TestData\Files\DupFiles2\doris2.docx" />
<None Include="TestData\Files\DupFiles2\Drawing1.vsd" />
<None Include="TestData\Files\DupFiles2\Drawing2.vsd" />
<None Include="TestData\Files\DupFiles2\Map1.mmap" />
<None Include="TestData\Files\DupFiles2\Map2.mmap" />
<None Include="TestData\Files\DupFiles2\New Mindmap1.mm" />
<None Include="TestData\Files\DupFiles2\New Mindmap2.mm" />
<None Include="TestData\Files\DupFiles2\Presentation1.ppt" />
<None Include="TestData\Files\DupFiles2\Presentation2.ppt" />
<None Include="TestData\Files\DupFiles2\Publication1.pub" />
<None Include="TestData\Files\DupFiles2\Publication2.pub" />
<Content Include="TestData\Files\DupFiles1\MoreDefects.TXT" />
<Content Include="TestData\Files\DupFiles1\OogyKeepInMind.txt" />
<Content Include="TestData\Files\DupFiles1\textfile1.txt" />
<None Include="TestData\Files\DupFiles2\DatabaseBills.accdb">
</None>
<None Include="TestData\Files\DupFiles2\DatabaseReceits.accdb">
</None>
<None Include="TestData\Files\DupFiles3\Albin likes apples.doc" />
<None Include="TestData\Files\DupFiles3\Book1.xls" />
<None Include="TestData\Files\DupFiles3\Book1.xlsx" />
<None Include="TestData\Files\DupFiles3\Book2.xls" />
<None Include="TestData\Files\DupFiles3\Book2.xlsx" />
<None Include="TestData\Files\DupFiles3\Book3.xls" />
<None Include="TestData\Files\DupFiles3\Book4.xls" />
<None Include="TestData\Files\DupFiles3\Doc1.rtf" />
<None Include="TestData\Files\DupFiles3\Doc2.rtf" />
<None Include="TestData\Files\DupFiles3\Document1.docx" />
<None Include="TestData\Files\DupFiles3\Document2.doc" />
<None Include="TestData\Files\DupFiles3\Document3.docx" />
<None Include="TestData\Files\DupFiles3\Document4.doc" />
<None Include="TestData\Files\DupFiles3\Document5.docx" />
<None Include="TestData\Files\DupFiles3\Document6.docx" />
<None Include="TestData\Files\DupFiles3\Document7.docx" />
<None Include="TestData\Files\DupFiles3\Doris likes apples.doc" />
<None Include="TestData\Files\DupFiles3\doris.docx" />
<None Include="TestData\Files\DupFiles3\Doris.xlsx" />
<None Include="TestData\Files\DupFiles3\doris2.docx" />
<None Include="TestData\Files\DupFiles3\Drawing1.vsd" />
<None Include="TestData\Files\DupFiles3\Drawing2.vsd" />
<None Include="TestData\Files\DupFiles3\Map1.mmap" />
<None Include="TestData\Files\DupFiles3\Map2.mmap" />
<None Include="TestData\Files\DupFiles3\New Mindmap1.mm" />
<None Include="TestData\Files\DupFiles3\New Mindmap2.mm" />
<None Include="TestData\Files\DupFiles3\Presentation1.ppt" />
<None Include="TestData\Files\DupFiles3\Presentation2.ppt" />
<None Include="TestData\Files\DupFiles3\Publication1.pub" />
<None Include="TestData\Files\DupFiles3\Publication2.pub" />
<Content Include="TestData\Files\DupFiles2\MoreDefects.TXT" />
<Content Include="TestData\Files\DupFiles2\OogyKeepInMind.txt" />
<Content Include="TestData\Files\DupFiles2\textfile1.txt" />
<None Include="TestData\Files\DupFiles3\DatabaseBills.accdb">
</None>
<None Include="TestData\Files\DupFiles3\DatabaseReceits.accdb">
</None>
<Content Include="TestData\Files\DupFiles3\MoreDefects.TXT" />
<Content Include="TestData\Files\DupFiles3\OogyKeepInMind.txt" />
<Content Include="TestData\Files\DupFiles3\textfile1.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,564 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Data.SqlTypes;
using System.Data;
namespace Foo.DataAccessLayer.DataTypes
{
// ArtifactTypes
public enum ArtifactTypes
{
File,
Url
}
// Artifacts
public enum SortOrderForArtifacts
{
None,
Ascending,
Descending,
LocationAscending,
LocationDescending,
LastAccessedAscending,
LastAccessedDescending,
MostFrequentlyAccessedAscending,
MostFrequentlyAccessedDescending
}
// Workspaces
public enum SortOrderForWorkspaces
{
None,
Ascending,
Descending,
LastAccessedAscending,
LastAccessedDescending,
MostFrequentlyAccessedAscending,
MostFrequentlyAccessedDescending
}
/// <summary>
/// This class holds the SortOrder Helper SQL functions for the SortOrder Enums listed above
/// </summary>
public class SortOrderSQLHelpers
{
/// <summary>
/// Use this to create the OrderBy Clause for the Workspace SortOrder Function
/// </summary>
/// <param name="sql">sql string to add sortOrder to</param>
/// <param name="sortOrder">the Workspace SortOrder Enum</param>
/// <returns>modified SQL String</returns>
public static string SortOrderForArtifactsHelper(string sql, SortOrderForArtifacts sortOrder)
{
switch (sortOrder)
{
case SortOrderForArtifacts.None:
break;
case SortOrderForArtifacts.Ascending:
sql = sql + " ORDER BY [Artifacts].[Name] ASC";
break;
case SortOrderForArtifacts.Descending:
sql = sql + " ORDER BY [Artifacts].[Name] DESC";
break;
case SortOrderForArtifacts.LastAccessedAscending:
sql = sql + " ORDER BY [Artifacts].[LastAccessed] ASC";
break;
case SortOrderForArtifacts.LastAccessedDescending:
sql = sql + " ORDER BY [Artifacts].[LastAccessed] DESC";
break;
case SortOrderForArtifacts.LocationAscending:
sql = sql + " ORDER BY [Artifacts].[Location] ASC";
break;
case SortOrderForArtifacts.LocationDescending:
sql = sql + " ORDER BY [Artifacts].[Location] DESC";
break;
case SortOrderForArtifacts.MostFrequentlyAccessedAscending:
sql = sql + " ORDER BY [Artifacts].[AccessCounter] ASC";
break;
case SortOrderForArtifacts.MostFrequentlyAccessedDescending:
sql = sql + " ORDER BY [Artifacts].[AccessCounter] DESC";
break;
}
return sql;
}
/// <summary>
/// Use this to create the OrderBy Clause for the Workspace SortOrder Function
/// </summary>
/// <param name="sql">sql string to add sortOrder to</param>
/// <param name="sortOrder">the Workspace SortOrder Enum</param>
/// <returns>modified SQL String</returns>
public static string SortOrderForWorkspacesHelper(string sql, SortOrderForWorkspaces sortOrder)
{
switch (sortOrder)
{
case SortOrderForWorkspaces.None:
break;
case SortOrderForWorkspaces.Ascending:
sql = sql + " ORDER BY [Workspaces].[Name] ASC";
break;
case SortOrderForWorkspaces.Descending:
sql = sql + " ORDER BY [Workspaces].[Name] DESC";
break;
case SortOrderForWorkspaces.LastAccessedAscending:
sql = sql + " ORDER BY [Workspaces].[LastAccessed] ASC";
break;
case SortOrderForWorkspaces.LastAccessedDescending:
sql = sql + " ORDER BY [Workspaces].[LastAccessed] DESC";
break;
case SortOrderForWorkspaces.MostFrequentlyAccessedAscending:
sql = sql + " ORDER BY [Workspaces].[AccessCounter] ASC";
break;
case SortOrderForWorkspaces.MostFrequentlyAccessedDescending:
sql = sql + " ORDER BY [Workspaces].[AccessCounter] DESC";
break;
}
return sql;
}
}
/// <summary>
/// Validation Classes
/// </summary>
public class DataTypeValidation
{
/// <summary>
/// Checks the logistics of the WorkspaceName (not the DB)
/// </summary>
/// <returns>true if valid logistically, false otherwise</returns>
public static bool IsValidWorkspaceName(string WorkspaceName)
{
if ((String.IsNullOrEmpty(WorkspaceName)) ||
(WorkspaceName.Length < 1) ||
(WorkspaceName.Length > 75))
return false;
else
return true;
}
/// <summary>
/// Use this to check the return of an ArtifactItemGroup
/// </summary>
/// <param name="artifactItems">ArtifactGroup</param>
/// <returns>true if ArtifactItemGroup is Empty, false otherwise</returns>
public static bool IsEmptyArtifactItemGroup(ArtifactItem[] artifactItems)
{
if ((artifactItems.Length == 1) && !artifactItems[0].IsLocationValid)
return true;
else
return false;
}
/// <summary>
/// Use this to check the return of an WorkspaceItemGroup
/// </summary>
/// <param name="artifactItems">WorkspaceItemGroup</param>
/// <returns>true if WorkspaceItemGroup is Empty, false otherwise</returns>
public static bool IsEmptyWorkspaceItemGroup(WorkspaceItem[] workspaceItems)
{
if ((workspaceItems.Length == 1) && !workspaceItems[0].IsValid)
return true;
else
return false;
}
/// <summary>
/// Uset this for quick and easy DataSet Validation
/// </summary>
/// <param name="dataset">a dataset object</param>
/// <returns>true if dataset is empty, false otherwise</returns>
public static bool IsEmptyDataSet(DataSet dataset)
{
if ((dataset == null) ||
(dataset.Tables.Count == 0) ||
((dataset.Tables.Count == 1) && (dataset.Tables[0].Rows.Count <= 0)))
{
return true;
}
return false;
}
/// <summary>
/// For internal use only - Check if the TableName entered is Valid
/// </summary>
/// <param name="TableName">a table name</param>
/// <returns>true if valid logistically, false otherwise</returns>
internal static bool IsValidTableName(string TableName)
{
if ((String.IsNullOrEmpty(TableName)) ||
(TableName.Length < 1) ||
(TableName.Length > 75))
return false;
else
return true;
}
/// <summary>
/// For internal use only - Check to see if Version information is valid
/// </summary>
/// <param name="VersionInformation">Version Information for a table</param>
/// <returns>true if valid logistically, false otherwise</returns>
internal static bool IsValidVersionInformation(string VersionInformation)
{
bool bIsValid = (!String.IsNullOrEmpty(VersionInformation) && (VersionInformation.Length == 8));
if (bIsValid)
{
string[] versionEntities = VersionInformation.Split('.');
bIsValid = (versionEntities.Length == 3);
}
return (bIsValid);
}
}
/// <summary>
/// Helper Classes
/// </summary>
public class DataTypeHelpers
{
/// <summary>
/// Many Artifact Checking Functions (Except for Insert/modify) Only need the location,
/// So if you have a location, use this function to create a quick Artifact to use in those
/// checking functions
/// </summary>
/// <param name="location"></param>
/// <returns></returns>
public static ArtifactItem CreateLocationOnlyArtifact(string location)
{
ArtifactItem artifactItem = new ArtifactItem()
{
Location = location
};
return artifactItem;
}
/// <summary>
/// Use this to create an empty ArtifactItemGroup (should only be used internally)
/// </summary>
/// <returns>An Empty ArtifactItemGroups</returns>
internal static ArtifactItem[] EmptyArtifactItemGroup()
{
ArtifactItem[] artifactItems = new ArtifactItem[] { new ArtifactItem() { Location = "" } };
return artifactItems;
}
/// <summary>
/// Use this to create an empty WorkspaceItemGroup (should only be used internally)
/// </summary>
/// <returns>An Empty WorkspaceItemGroups</returns>
internal static WorkspaceItem[] EmptyWorkspaceItemGroup()
{
WorkspaceItem[] workspaceItems = new WorkspaceItem[] { new WorkspaceItem() { Name = "" } };
return workspaceItems;
}
}
/// <summary>
/// Use this class for some of our Workspace Methods. Holds Workspace Information as well
/// as performs Validation.
/// </summary>
public class WorkspaceItem
{
public string Name { get; set; }
public DateTime LastAccessed { get; private set; }
public int AccessCounter { get; set; }
// Needed to make sure that dateTime is within limits of SQL,
// Otherwise SQL stmt may generate an error
public bool SetLastAccessed(DateTime dateTime)
{
if (dateTime >= SqlDateTime.MinValue.Value &&
dateTime <= SqlDateTime.MaxValue.Value)
{
LastAccessed = dateTime;
return true;
}
return false;
}
// *Custom Tag Property * To be used by Callers to tag the object
public string Tag { get; set; }
// default
public WorkspaceItem()
{
Name = "";
LastAccessed = SqlDateTime.MinValue.Value;
AccessCounter = 0;
// Tag
Tag = "";
}
/// <summary>
/// Performs basic Type Validity Tests
/// </summary>
public bool IsValid
{
get
{
if ((Name.Length > 1) &&
(Name.Length <= 75) &&
(AccessCounter >= 0) &&
(LastAccessed != SqlDateTime.MinValue.Value)
)
{
return true;
}
else
{
return false;
}
}
}
#region ICloneable Members
public object Clone()
{
return this.MemberwiseClone();
}
#endregion
}
/// <summary>
/// Use this Class for all our Artifact Methods. Holds Artifact Information as well
/// as performs Validation. Use IsValidFileIntegrity() for IO validation
/// </summary>
public class ArtifactItem : ICloneable
{
public String Name { get; set; }
public ArtifactTypes Type { get; set; }
public String Location { get; set; }
public String Note { get; set; }
public String SnapshotFile { get; set; }
public DateTime LastAccessed { get; private set; }
public int AccessCounter { get; set; }
// Needed to make sure that dateTime is within limits of SQL,
// Otherwise SQL stmt may generate an error
public bool SetLastAccessed(DateTime dateTime)
{
if (dateTime >= SqlDateTime.MinValue.Value &&
dateTime <= SqlDateTime.MaxValue.Value)
{
LastAccessed = dateTime;
return true;
}
return false;
}
// default
public ArtifactItem()
{
SetAsFileType();
Name = "";
Location = "";
Note = "";
SnapshotFile = "";
// LinkProperties
WindowTop = 0;
WindowLeft = 0;
WindowHeight = 0;
WindowWidth = 0;
// Access properties
LastAccessed = SqlDateTime.MinValue.Value;
AccessCounter = 0;
// Tag
Tag = "";
}
// Type Check
public bool IsUrl { get { return Type == ArtifactTypes.Url; } }
public bool IsFile { get { return Type == ArtifactTypes.File; } }
// Type Helpers
public string FileName
{
get
{
if (IsFile)
{
int nIndex = Location.LastIndexOf('\\');
if (nIndex > 0 && nIndex < Location.Length)
return Location.Substring((nIndex + 1));
}
return String.Empty;
}
}
public string FileLocation
{
get
{
if (IsFile)
{
int nIndex = Location.LastIndexOf('\\');
if (nIndex > 0 && nIndex < Location.Length)
return Location.Substring(0,nIndex);
}
return String.Empty;
}
}
// Type Setting
public void SetAsFileType() { Type = ArtifactTypes.File; }
public void SetAsUrlType() { Type = ArtifactTypes.Url; }
public bool SetType(string strType)
{
if (strType.ToUpper() == "FILE")
{
SetAsFileType();
return true;
}
else if (strType.ToUpper() == "URL")
{
SetAsUrlType();
return true;
}
else
{
return false;
}
}
// Setters
public bool SetFile(string fileNameAndLocation)
{
if ((fileNameAndLocation.Length > 1) && File.Exists(fileNameAndLocation))
{
SetAsFileType();
Location = fileNameAndLocation;
return true;
}
return false;
}
public bool SetUrl(string Url)
{
if ((Url.Length > 1)) // To Do - Better Url Checking
{
SetAsUrlType();
Location = Url;
return true;
}
return false;
}
// *Custom Tag Property * To be used by Callers to tag the object
public string Tag { get; set; }
/// <summary>
/// This Information is used by the link in the Workspace.
/// ~This information is only filed in the artifact when being retrieved
/// from a workspace which has link information
/// </summary>
public int WindowTop { get; set; }
public int WindowLeft { get; set; }
public int WindowHeight { get; set; }
public int WindowWidth { get; set; }
/// <summary>
/// Use this function to do proper validation of the Link Properties
/// </summary>
public bool AreWorkspaceLinkPropertiesValid
{
get
{
if ((WindowHeight > 0) &&
(WindowWidth > 0))
return true;
else
return false;
}
}
/// <summary>
/// Performs basic Type Validity Tests
/// </summary>
public bool IsValid
{
get
{
if((Name.Length > 1) &&
(Name.Length <= 150) &&
(Location.Length > 1) &&
(Location.Length <= 300) &&
(Note.Length <= 3000) &&
(SnapshotFile.Length > 1) &&
(SnapshotFile.Length <= 300) &&
(AccessCounter >= 0) //&&
//(LastAccessed != SqlDateTime.MinValue.Value)
)
{
return true;
}
else
{
return false;
}
}
}
/// <summary>
/// Since Artifact Location is our main source of determining
/// existence (this provides an easy check only for valid location)
/// </summary>
public bool IsLocationValid
{
get
{
if ((Location.Length > 1) &&
(Location.Length <= 300))
return true;
else
return false;
}
}
/// <summary>
/// Performs Advanced File Validity Tests
/// </summary>
public bool IsValidFileIntegrity
{
get
{
if (IsFile && !File.Exists(Location))
return false;
// To Do * Check if is Valid Url *
if (!File.Exists(SnapshotFile))
return false;
return true;
}
}
#region ICloneable Members
public object Clone()
{
return this.MemberwiseClone();
}
#endregion
}
}

Binary file not shown.

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("DataAccessLayer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DataAccessLayer")]
[assembly: AssemblyCopyright("Copyright © 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4eac069e-728a-48b2-989e-0be548d211ef")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4200
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Foo.DataAccessLayer.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Foo.DataAccessLayer.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,37 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4200
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Foo.DataAccessLayer.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)]
[global::System.Configuration.DefaultSettingValueAttribute("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\\TestData\\Files\\DupF" +
"iles2\\DatabaseBills.accdb;Persist Security Info=True")]
public string DatabaseBillsConnectionString {
get {
return ((string)(this["DatabaseBillsConnectionString"]));
}
}
}
}

View File

@@ -0,0 +1,14 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Foo.DataAccessLayer.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="DatabaseBillsConnectionString" Type="(Connection string)" Scope="Application">
<DesignTimeValue Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
&lt;ConnectionString&gt;Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\TestData\Files\DupFiles2\DatabaseBills.accdb;Persist Security Info=True&lt;/ConnectionString&gt;
&lt;ProviderName&gt;System.Data.OleDb&lt;/ProviderName&gt;
&lt;/SerializableConnectionString&gt;</DesignTimeValue>
<Value Profile="(Default)">Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\TestData\Files\DupFiles2\DatabaseBills.accdb;Persist Security Info=True</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.IO;
using System.Collections.Specialized;
namespace Foo.DataAccessLayer
{
class ResourceHelper
{
// Used by DB to keep track of labels and Versioning
public static StringDictionary s_VersioningTablesMap = new StringDictionary();
/// <summary>
/// Get All Sql Table Resource Names
/// </summary>
/// <returns></returns>
public static string[] GetTableResourceNames()
{
List<String> tableResources = new List<string>();
string[] resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
foreach (string ResourceName in resourceNames)
{
if(ResourceName.Contains("DataAccessLayer.Sql.Tables."))
tableResources.Add(ResourceName);
}
return tableResources.ToArray<String>();
}
/// <summary>
/// Gives you just the Table Name without the Resource string before and after
/// </summary>
/// <param name="TableResouceName">a table Resource name</param>
/// <returns>the table name</returns>
public static string GetTableNameFromTableResourceName(string TableResouceName)
{
// First trim the sqlce
TableResouceName = TableResouceName.Replace(".sqlce", "");
// Now find the last dot and trim from there
int index = TableResouceName.LastIndexOf('.');
return TableResouceName.Substring(index + 1);
}
/// <summary>
/// Get the Text/SQL String from a specified ResourceFileName
/// </summary>
/// <param name="resourceFileName">a specific ResourceFileName</param>
/// <returns></returns>
public static string GetTextSqlFromResourceFile(string resourceFileName)
{
StreamReader stream = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceFileName));
if (stream != null)
{
string strText = stream.ReadToEnd();
strText = strText.Replace('\r', ' ');
strText = strText.Replace('\n', ' ');
return strText;
}
else
return string.Empty;
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More