本文整理汇总了C#中System.Windows.Forms.Timer.SetApartmentState方法的典型用法代码示例。如果您正苦于以下问题:C# System.Windows.Forms.Timer.SetApartmentState方法的具体用法?C# System.Windows.Forms.Timer.SetApartmentState怎么用?C# System.Windows.Forms.Timer.SetApartmentState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Timer
的用法示例。
在下文中一共展示了System.Windows.Forms.Timer.SetApartmentState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: newt_Drop
void newt_Drop(object sender, DragEventArgs e)
{
e.Handled = true;
var tabItemTarget = e.Source as CloseableTabItem;
var tabItemSource = e.Data.GetData(typeof(CloseableTabItem)) as CloseableTabItem;
if (tabItemSource != null)
{
if (!tabItemTarget.Equals(tabItemSource))
{
var tabControl = tabItemTarget.Parent as TabControl;
int tabState = -1;
int sourceIndex = tabControl.Items.IndexOf(tabItemSource);
int targetIndex = tabControl.Items.IndexOf(tabItemTarget);
if (!tabItemSource.IsSelected && tabItemTarget.IsSelected)
tabState = 1;
else if (!tabItemSource.IsSelected && !tabItemTarget.IsSelected)
tabState = 2;
else
tabState = 0;
tabControl.Items.Remove(tabItemSource);
tabControl.Items.Insert(targetIndex, tabItemSource);
tabControl.Items.Remove(tabItemTarget);
tabControl.Items.Insert(sourceIndex, tabItemTarget);
if (tabState == 1)
tabControl.SelectedIndex = sourceIndex;
else if (tabState == 0)
tabControl.SelectedIndex = targetIndex;
}
}
else
{
System.Windows.Point pt = e.GetPosition(sender as IInputElement);
//if (e.Data.GetDataPresent(DataFormats.FileDrop))
//{
if ((sender as CloseableTabItem).Path.IsFileSystemObject)
{
if ((e.KeyStates & DragDropKeyStates.ControlKey) == DragDropKeyStates.ControlKey)
{
e.Effects = DragDropEffects.Copy;
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
DropData PasteData = new DropData();
String[] collection = (String[])e.Data.GetData(DataFormats.FileDrop);
StringCollection scol = new StringCollection();
scol.AddRange(collection);
PasteData.DropList = scol;
PasteData.PathForDrop = (sender as CloseableTabItem).Path.ParsingName;
Thread t = null;
t = new Thread(new ParameterizedThreadStart(Explorer.DoCopy));
t.SetApartmentState(ApartmentState.STA);
t.Start(PasteData);
}
}
else
{
//if (Path.GetPathRoot((sender as CloseableTabItem).Path.ParsingName) ==
// Path.GetPathRoot(Explorer.NavigationLog.CurrentLocation.ParsingName))
//{
e.Effects = DragDropEffects.Move;
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
DropData PasteData = new DropData();
String[] collection = (String[])e.Data.GetData(DataFormats.FileDrop);
StringCollection scol = new StringCollection();
scol.AddRange(collection);
PasteData.DropList = scol;
PasteData.PathForDrop = (sender as CloseableTabItem).Path.ParsingName;
Thread t = null;
t = new Thread(new ParameterizedThreadStart(Explorer.DoMove));
t.SetApartmentState(ApartmentState.STA);
t.Start(PasteData);
}
//}
//else
//{
// e.Effects = DragDropEffects.Copy;
// if (e.Data.GetDataPresent(DataFormats.FileDrop))
// {
// DropData PasteData = new DropData();
// String[] collection = (String[])e.Data.GetData(DataFormats.FileDrop);
// StringCollection scol = new StringCollection();
// scol.AddRange(collection);
// PasteData.DropList = scol;
// PasteData.PathForDrop = (sender as CloseableTabItem).Path.ParsingName;
// Thread t = null;
// t = new Thread(new ParameterizedThreadStart(Explorer.DoCopy));
// t.SetApartmentState(ApartmentState.STA);
// t.Start(PasteData);
// }
//.........这里部分代码省略.........
示例2: bbi_Drop
void bbi_Drop(object sender, DragEventArgs e)
{
System.Windows.Point pt = e.GetPosition(sender as IInputElement);
if ((sender as BreadcrumbBarItem).ShellObject.IsFileSystemObject)
{
if ((e.KeyStates & DragDropKeyStates.ControlKey) == DragDropKeyStates.ControlKey)
{
e.Effects = DragDropEffects.Copy;
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
DropData PasteData = new DropData();
String[] collection = (String[])e.Data.GetData(DataFormats.FileDrop);
StringCollection scol = new StringCollection();
scol.AddRange(collection);
PasteData.DropList = scol;
PasteData.PathForDrop = (sender as BreadcrumbBarItem).ShellObject.ParsingName;
AddToLog("Copied Files to " + PasteData.PathForDrop + " Files copied: " + scol.ToString());
Thread t = null;
t = new Thread(new ParameterizedThreadStart(Explorer.DoCopy));
t.SetApartmentState(ApartmentState.STA);
t.Start(PasteData);
}
}
else
{
//if (Path.GetPathRoot((sender as CloseableTabItem).Path.ParsingName) ==
// Path.GetPathRoot(Explorer.NavigationLog.CurrentLocation.ParsingName))
//{
e.Effects = DragDropEffects.Move;
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
DropData PasteData = new DropData();
String[] collection = (String[])e.Data.GetData(DataFormats.FileDrop);
StringCollection scol = new StringCollection();
scol.AddRange(collection);
PasteData.DropList = scol;
PasteData.PathForDrop = (sender as BreadcrumbBarItem).ShellObject.ParsingName;
AddToLog("Moved Files to " + PasteData.PathForDrop + " Files moved: " + scol.ToString());
Thread t = null;
t = new Thread(new ParameterizedThreadStart(Explorer.DoMove));
t.SetApartmentState(ApartmentState.STA);
t.Start(PasteData);
}
//}
//else
//{
// e.Effects = DragDropEffects.Copy;
// if (e.Data.GetDataPresent(DataFormats.FileDrop))
// {
// DropData PasteData = new DropData();
// String[] collection = (String[])e.Data.GetData(DataFormats.FileDrop);
// StringCollection scol = new StringCollection();
// scol.AddRange(collection);
// PasteData.DropList = scol;
// PasteData.PathForDrop = (sender as CloseableTabItem).Path.ParsingName;
// Thread t = null;
// t = new Thread(new ParameterizedThreadStart(Explorer.DoCopy));
// t.SetApartmentState(ApartmentState.STA);
// t.Start(PasteData);
// }
//}
}
}
else
{
e.Effects = DragDropEffects.None;
}
DropTargetHelper.Drop(e.Data, pt, e.Effects);
}