小编Roh*_*ats的帖子

火鸟的按位运算符

我们可以bitwise and在不使用UDF的情况下执行firebird程序吗?是否有一个内置函数或有一种方法可以使用标准内置命令获得相同的结果?

我也尝试了http://www.firebirdsql.org/refdocs/langrefupd21-intfunc-bin_and.html(BIN_AND)但我需要一些没有UDF的实现.

例如:(3 & 3) returns 3在SQL中但不在firebird中(firebird 2.1).

sql firebird firebird2.1

6
推荐指数
1
解决办法
1040
查看次数

在C#中保存打印屏幕

Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, 
                                    Screen.PrimaryScreen.Bounds.Height);
Graphics graphics = Graphics.FromImage(bitmap as Image);
graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);
bitmap.Save(@"C:\Temp\printscreen.jpg", ImageFormat.Jpeg);
Run Code Online (Sandbox Code Playgroud)

这是我的打印屏幕按钮代码.问题是我按下按钮几次,它只是写在旧图像文件(printscreen.jpg)上,它不会创建另一个新的图像文件,如printscreen1.jpg.

c#

6
推荐指数
2
解决办法
1万
查看次数

绑定到后面的代码中的relativesource

在我的UserControl中,我在XAML中有以下代码

<TextBlock Grid.Row="2" Text="{Binding Path=StartTime,
                               RelativeSource={RelativeSource Mode=FindAncestor,
                                AncestorLevel=1, AncestorType=Window}}" />
Run Code Online (Sandbox Code Playgroud)

这只是从父窗口获取属性的值,它工作得很好.

我怎么能在后面的代码中执行此操作?

Binding b = new Binding();
b.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor,
                                      typeof(Window), 1);
b.Path = "StartTime";

myProperty = b.value;// obviously there is no b.value but this
                     // is what I'm trying to achieve.

//BindingOperations.SetBinding(StartTime, StartTimeProperty, b);
//This does not work sadly, it can't convert string to DependancyObject
Run Code Online (Sandbox Code Playgroud)

c# wpf binding

6
推荐指数
2
解决办法
1万
查看次数

上标不会进入wpf richtext框

我在wpf mvvm应用程序中实现了一个自定义的富文本框,并且可以选择格式化输入的文本,如下所示:

<Button Style="{StaticResource formatTextStyle}"
        Command="EditingCommands.ToggleBold" ToolTip="Bold">
   <TextBlock FontWeight="Bold">B</TextBlock>
</Button>
Run Code Online (Sandbox Code Playgroud)

我正在使用EditingCommands.ToggleBold使文本变为粗体.以同样的方式,我给出了ToggleSuperscript的选项

<Button Style="{StaticResource formatImageStyle}" 
        Command="EditingCommands.ToggleSuperscript" ToolTip="Superscript">
   <TextBlock FontStyle="Italic" FontWeight="Bold">SubScript</TextBlock>
</Button>
Run Code Online (Sandbox Code Playgroud)

但它不起作用......

这里是StaticResource

<Style TargetType="{x:Type Button}" x:Key="formatTextStyle">
   <Setter Property="FontFamily" Value="Palatino Linotype"></Setter>
   <Setter Property="Width" Value="30"></Setter>
   <Setter Property="FontSize" Value ="14"></Setter>
   <Setter Property="CommandTarget" Value="{Binding ElementName=mainRTB}"/>
</Style>
Run Code Online (Sandbox Code Playgroud)

和mainRTB是我的RichTextBox名称.

<RichTextBox Name="mainRTB" AcceptsTab="True" Height="160"
             asis:RichTextboxAssistant.BoundDocument="{Binding Path=Text, 
                                             ElementName=uxRichTextEditor}"
             VerticalScrollBarVisibility="Visible" />
Run Code Online (Sandbox Code Playgroud)

我对此毫无头绪.任何机构都可以建议如何启用ToggleSuperscript和ToggleSubscript.

c# wpf richtextbox mvvm

6
推荐指数
1
解决办法
714
查看次数

WPF DataGrid过滤 - 刷新CollectionViewSource刷新

我想知道如何在单击按钮时刷新CollectionViewSource?

到目前为止我有

<Window.Resources>
    <CollectionViewSource x:Key="cvsCustomers"
                          Source="{Binding CustomerCollection}" 
                          Filter="CollectionViewSource_Filter" >
    </CollectionViewSource>
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)

这创建了CollectionViewSource ......

<DataGrid HorizontalAlignment="Left" 
              Height="210" 
              Margin="47,153,0,0"
              VerticalAlignment="Top" Width="410"
              ItemsSource="{Binding Source={StaticResource cvsCustomers}}"
              CanUserAddRows="False"
Run Code Online (Sandbox Code Playgroud)

这将源绑定到我的Datagrid

    private void CollectionViewSource_Filter(object sender, FilterEventArgs e)
    {
        Customer t = e.Item as Customer;
        if (t != null)
        // If filter is turned on, filter completed items.
        {
            if (t.Name.Contains(txtSearch.Text))
            {
                e.Accepted = true;
            }
            else
            {
                e.Accepted = false;
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

在我的视图中有一个过滤器,

一切似乎都在工作(项目正在被绑定到网格)但是如何刷新视图或网格以便我可以再次激活上面的函数以便网格被过滤?(真的按一下按钮)

谢谢

c# wpf xaml datagrid collectionviewsource

6
推荐指数
1
解决办法
9946
查看次数

使用Reflection在同一程序集的不同版本中使用类对象

我需要加载不同版本的程序集(我的应用程序中已经有相同名称的程序集).

我能够加载程序集并加载我需要使用反射调用的方法但是当我通过传递我的类对象作为参数来调用方法时,我得到了类对象无法转换为参数类型参数的异常.

示例代码 -

Assembly myAssembly = Assembly.LoadFrom("Assembly Path for assembly with different version");
object classObject = myAssembly.CreateInstance("ClassName");
Type classType = myAssembly.GetType("ClassName");
MethodInfo myMethod = classType.GetMethod("MyMethod", BindingFlags.Instance);

// Creating an object of class in the latest assembly and need to pass this
// to method in assembly with different version.
ClassInBothVesions parameter = new ClassInBothVesions();

myMethod.Invoke(classObject, new object[] { parameter });
Run Code Online (Sandbox Code Playgroud)

这里的参数是我在汇编中具有的类的对象,但是因为参数类是在当前版本的程序集中创建的.当我尝试将它传递给前一个程序集的方法时,我得到一个例外,它无法转换.

我怎样才能实现这一目标?如果我需要在这里提供更多信息,请告诉我.提前致谢.

c# reflection reflection.emit c#-3.0

5
推荐指数
1
解决办法
898
查看次数

打开文件夹问题

我想打开刚刚保存文件的文件夹并选择文件,因为我使用这个小代码:

 var psi = new ProcessStartInfo("Explorer.exe", "/select," + dlg.FileName);
                Process.Start(psi);
Run Code Online (Sandbox Code Playgroud)

它完美地运作.

我需要将此代码放在几个地方,所以我决定创建一个方法,这个方法中还有一个条件:

 private static void OpenFolderAndSelectMyFile(string fileName)
 {
     if (MySettings.Default.openFolder == true)
     {
         var psi = new ProcessStartInfo("Explorer.exe", "/select," + fileName);
         psi.WindowStyle = ProcessWindowStyle.Maximized;
         Process.Start(psi);
     }    
 }
Run Code Online (Sandbox Code Playgroud)

这不能按预期工作:这将打开父文件夹(包含我的文件的文件夹).它还选择文件夹.

为什么这种行为差异以及如何解决呢?

c# directory

5
推荐指数
1
解决办法
175
查看次数

WPF:以编程方式提升SelectionChangedEvent

在WPF中,我想以编程方式在组合框中引发SelectionChanged事件.我尝试了以下代码,但它不起作用:

 myComboBox.RaiseEvent(new RoutedEventArgs(ComboBox.SelectionChangedEvent,
                                            myComboBox));
Run Code Online (Sandbox Code Playgroud)

我怎么能举起这个活动?

谢谢

c# wpf combobox visual-studio-2010

5
推荐指数
2
解决办法
5444
查看次数

使用isql对firebird数据库运行多个插入查询

我有要求inserting enormous data in table of firebird database around 40K entries.我准备好了我的脚本,但是在使用flameRobin执行它时,UI一下子插入如此庞大的数据就永远挂起了.

我知道如果我在255个查询块中执行插入查询会很好,但我想知道bulk insert tool available for Firebird在从scripts.sql文件读取时是否有任何这样的条目.

经过一些谷歌搜索后,我遇到了isql工具,但无法对其执行脚本.有人可以指导我使用任何其他工具或正确的文档一次性输入如此庞大的数据吗?

我已经firebird version 2.5在我的系统上安装了.

firebird isql firebird2.5

4
推荐指数
2
解决办法
1万
查看次数

与私有CLR属性相比,与私有依赖属性绑定的工作方式不同

我有一个窗口,DataContext设置为自己这个简单的XAML布局 -

<StackPanel>
   <TextBlock Text="{Binding NameCLR}"/>
   <TextBlock Text="{Binding NameDP}"/>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)

在代码后面我有两个属性NameCLR - CLR propertyNameDP - Dependency Property.

    private string NameCLR
    {
        get { return "CLRProperty"; }
    }

    private string NameDP
    {
        get { return (string)GetValue(NameDPProperty); }
        set { SetValue(NameDPProperty, value); }
    }

    private static readonly DependencyProperty NameDPProperty =
        DependencyProperty.Register("NameDP", typeof(string), typeof(MainWindow),
                                        new UIPropertyMetadata("DPProperty"));
Run Code Online (Sandbox Code Playgroud)

由于代码隐藏是部分类定义,而部分是XAML.所以,我假设私有财产应该对XAML可见.但令我惊讶的是,CLR和DP表现不同.

私有依赖属性是可访问的,但私有CLR属性不可访问.

我把输出作为 -

DPProperty
Run Code Online (Sandbox Code Playgroud)

代替

CLRProperty
DPProperty
Run Code Online (Sandbox Code Playgroud)

有人能让我知道DP和CLR属性中的这种不同行为吗?

c# wpf xaml dependency-properties properties

4
推荐指数
1
解决办法
1501
查看次数