本文整理汇总了C#中System.Windows.Application类的典型用法代码示例。如果您正苦于以下问题:C# Application类的具体用法?C# Application怎么用?C# Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Application类属于System.Windows命名空间,在下文中一共展示了Application类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlatformWpf
public PlatformWpf()
: base(null, true)
{
var app = new Application ();
var slCanvas = new Canvas ();
var win = new Window
{
Title = Title,
Width = Width,
Height = Height,
Content = slCanvas
};
var cirrusCanvas = new CirrusCanvas(slCanvas, Width, Height);
MainCanvas = cirrusCanvas;
win.Show ();
EntryPoint.Invoke (null, null);
var timer = new DispatcherTimer ();
timer.Tick += runDelegate;
timer.Interval = TimeSpan.FromMilliseconds (1);
timer.Start ();
app.Run ();
}
示例2: Main
public static void Main()
{
// original (doesn't work with snoop, well, can't find a window to own the snoop ui)
Window window = new Window();
window.Title = "Say Hello";
window.Show();
Application application = new Application();
application.Run();
// setting the MainWindow directly (works with snoop)
// Window window = new Window();
// window.Title = "Say Hello";
// window.Show();
//
// Application application = new Application();
// application.MainWindow = window;
// application.Run();
// creating the application first, then the window (works with snoop)
// Application application = new Application();
// Window window = new Window();
// window.Title = "Say Hello";
// window.Show();
// application.Run();
// creating the application first, then the window (works with snoop)
// Application application = new Application();
// Window window = new Window();
// window.Title = "Say Hello";
// application.Run(window);
} }
示例3: Main
public static void Main()
{
Application app = new Application();
Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
app.Startup += new StartupEventHandler(app_Startup);
app.Run();
}
示例4: UserAccountControlService
/// <summary>
/// Create a new instance of the <see cref="UserAccountControlService"/>.
/// </summary>
/// <param name="application">
/// An instance of the current <see cref="Application"/> object.
/// The service will use this to perform shutdown and re-launch operations.
/// </param>
public UserAccountControlService(Application application)
{
if (application == null)
throw new ArgumentNullException("application");
Application = application;
}
示例5: ConvertToBitmapSource
public ConvertToBitmapSource()
{
BitmapSource bs = null;
// OpenCVによる画像処理 (Threshold)
using (IplImage src = new IplImage(Const.ImageLenna, LoadMode.GrayScale))
using (IplImage dst = new IplImage(src.Size, BitDepth.U8, 1))
{
src.Smooth(src, SmoothType.Gaussian, 5);
src.Threshold(dst, 0, 255, ThresholdType.Otsu);
// IplImage -> BitmapSource
bs = dst.ToBitmapSource();
//bs = BitmapSourceConverter.ToBitmapSource(dst);
}
// WPFのWindowに表示してみる
Image image = new Image { Source = bs };
Window window = new Window
{
Title = "from IplImage to BitmapSource",
Width = bs.PixelWidth,
Height = bs.PixelHeight,
Content = image
};
Application app = new Application();
app.Run(window);
}
示例6: UiThread
public static void UiThread(object arg)
{
var app = new Application();
var window = new MainWindow();
window.onClosed += window_onClosed;
app.Run(window);
}
示例7: Main
static void Main(string[] args)
{
Standard s1 = new Standard("ГОСТ Р 21.1101-2009");
Standard s2 = new Standard("ГОСТ", "2.101");
HashSet<Standard> sl1 = new HashSet<Standard>();
HashSet<Standard> sl2 = new HashSet<Standard>();
sl1.Add(s1);
sl1.Add(s2);
string[] test = { "tesT", "best", "rest" };
IEnumerable<string> tt = test.Take(test.Length - 1).ToList();
ConfigManager.ConfigManager cm = ConfigManager.ConfigManager.Instance;
HashSet<Document> s1d = s1.Check();
Console.WriteLine(s1d.First());
string str = "333-ГОСТ--444";
Console.WriteLine(str.cleanAllWithWhiteList());
NormaCS ncs = new NormaCS(sl1);
ncs.checkStandards();
ReportWindow.Main mn = new ReportWindow.Main(ncs.Documents);
Application app = new Application();
app.Run(mn);
}
示例8: Main
public static void Main() {
var boardUi = new BoardUI();
var interactors = new Interactors();
var sync = new Synchronizer<IEnumerable<Task>>();
// Start
var columns_and_tasks = interactors.Start();
boardUi.Setup_Board(columns_and_tasks);
// Refresh
sync.Result += tasks => boardUi.Set_Tasks(tasks);
interactors.Refresh(tasks => sync.Process(tasks));
// Create Task
boardUi.Create_Task += text => {
var task = interactors.Create_Task(text);
boardUi.Add_Task(task);
};
// Show Task
boardUi.Show_Task += (column, position) => {
var text = interactors.Show_Task(column, position);
boardUi.Display_Text(text);
};
// Move Task
boardUi.Move_Task += (column, position, direction) => {
var tasks_and_selectedTask = interactors.Move_Task(column, position, direction);
boardUi.Set_Tasks(tasks_and_selectedTask.Item1, tasks_and_selectedTask.Item2);
};
var app = new Application { MainWindow = boardUi };
app.Run(boardUi);
}
示例9: ConvertToWriteableBitmap
public ConvertToWriteableBitmap()
{
WriteableBitmap wb = null;
// OpenCVによる画像処理 (Threshold)
using (IplImage src = new IplImage(Const.ImageLenna, LoadMode.GrayScale))
using (IplImage dst = new IplImage(src.Size, BitDepth.U8, 1))
{
src.Smooth(src, SmoothType.Gaussian, 5);
src.Threshold(dst, 0, 255, ThresholdType.Otsu);
// IplImage -> WriteableBitmap
wb = dst.ToWriteableBitmap(PixelFormats.BlackWhite);
//wb = WriteableBitmapConverter.ToWriteableBitmap(dst, PixelFormats.BlackWhite);
}
// WPFのWindowに表示してみる
Image image = new Image { Source = wb };
Window window = new Window
{
Title = "from IplImage to WriteableBitmap",
Width = wb.PixelWidth,
Height = wb.PixelHeight,
Content = image
};
Application app = new Application();
app.Run(window);
}
示例10: EnsureApplicationResources
static void EnsureApplicationResources()
{
if (!UriParser.IsKnownScheme("pack"))
{
UriParser.Register(new GenericUriParser(GenericUriParserOptions.GenericAuthority), "pack", -1);
}
var appResourcesUri = new Uri("pack://application:,,,/GitHub.Authentication;component/AppResources.xaml", UriKind.RelativeOrAbsolute);
// If we launch two dialogs in the same process (Credential followed by 2fa), calling new App()
// throws an exception stating the Application class can't be created twice. Creating an App
// instance happens to set Application.Current to that instance (it's weird). However, if you
// don't set the ShutdownMode to OnExplicitShutdown, the second time you launch a dialog,
// Application.Current is null even in the same process.
if (Application.Current == null)
{
var app = new Application();
Debug.Assert(Application.Current == app, "Current application not set");
app.ShutdownMode = ShutdownMode.OnExplicitShutdown;
app.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = appResourcesUri });
}
else
{
// Application.Current exists, but what if in the future, some other code created
// the singleton. Let's make sure our resources are still loaded.
var resourcesExist = Application.Current.Resources.MergedDictionaries.Any(r => r.Source == appResourcesUri);
if (!resourcesExist)
{
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = appResourcesUri });
}
}
}
示例11: Main
static void Main(string[] args)
{
Application app = new Application();
MainWindow win = new MainWindow();
//TestWnd win = new TestWnd();
app.Run(win);
}
示例12: RemoteControlHandler
/// <summary>
/// Initializes a new instance of the <see cref="RemoteControlHandler"/> class.
/// </summary>
/// <param name="app">The app.</param>
public RemoteControlHandler(Application app)
{
app.MainWindow.KeyDown += this.Window_KeyDown;
app.MainWindow.CommandBindings.Add(new CommandBinding(MediaCommands.Play, this.MediaCommands_Play));
app.MainWindow.CommandBindings.Add(new CommandBinding(MediaCommands.Stop, this.MediaCommands_Stop));
app.MainWindow.CommandBindings.Add(new CommandBinding(MediaCommands.Record, this.MediaCommands_Record));
}
示例13: Convert
public void Convert(string projectfile, string outputpath)
{
var app = new Application();
var project = ProjectSettings.Load(projectfile);
var jsf = Path.Combine(outputpath, "converter.settings.js");
project.Save(jsf);
var model = new ConverterModel();
model.PageTitle = project.PageTitle;
model.IsOptimized = false;
model.InlineAllScript = true;
model.OutputDirectory = outputpath;
// model.IncludeResources = new string[] { "base.css", "application.css", "*.png", "octicons.*" };
model.TraceOutputFile = "converter.output.html";
// trace flags
if (null != Flags)
{
Log.ShowVerbose = Flags.Verbose;
Log.ShowConverterModel = Flags.ShowFiles;
Log.ShowResources = Flags.ShowResources;
if (Flags.ShowClasses)
{
Log.ShowClassDependencies = Flags.ShowClasses;
}
}
// setting the project property triggers the conversion process
model.Project = project;
WarningCount = model.Converter.WarningCount;
ErrorCount = model.Converter.ErrorCount;
}
示例14: Run
protected override void Run()
{
RxApp.LoggerFactory = _ => new FileLogger("Squirrel") { Level = ReactiveUIMicro.LogLevel.Info };
ReactiveUIMicro.RxApp.ConfigureFileLogging(); // HACK: we can do better than this later
theApp = new Application();
// NB: These are mirrored instead of just exposing Command because
// Command is impossible to mock, since there is no way to set any
// of its properties
DisplayMode = Command.Display;
Action = Command.Action;
this.Log().Info("WiX events: DisplayMode: {0}, Action: {1}", Command.Display, Command.Action);
setupWiXEventHooks();
var bootstrapper = new WixUiBootstrapper(this);
theApp.MainWindow = new RootWindow
{
viewHost = { Router = bootstrapper.Router }
};
MainWindowHwnd = IntPtr.Zero;
if (Command.Display == Display.Full)
{
MainWindowHwnd = new WindowInteropHelper(theApp.MainWindow).Handle;
uiDispatcher = theApp.MainWindow.Dispatcher;
theApp.Run(theApp.MainWindow);
}
Engine.Quit(0);
}
示例15: StartRuntime
/// <summary>
/// Called by the bootstrapper's constructor at runtime to start the framework.
/// </summary>
protected virtual void StartRuntime() {
Execute.InitializeWithDispatcher();
EventAggregator.DefaultPublicationThreadMarshaller = Execute.OnUIThread;
EventAggregator.HandlerResultProcessing = (target, result) => {
var coroutine = result as IEnumerable<IResult>;
if (coroutine != null) {
var viewAware = target as IViewAware;
var view = viewAware != null ? viewAware.GetView() : null;
var context = new ActionExecutionContext { Target = target, View = (DependencyObject)view };
Coroutine.BeginExecute(coroutine.GetEnumerator(), context);
}
};
AssemblySource.Instance.AddRange(SelectAssemblies());
if (useApplication) {
Application = Application.Current;
PrepareApplication();
}
Configure();
IoC.GetInstance = GetInstance;
IoC.GetAllInstances = GetAllInstances;
IoC.BuildUp = BuildUp;
}