首页 \ 问答 \ 用鼠标旋转文本框(Rotate textbox with mouse)

用鼠标旋转文本框(Rotate textbox with mouse)

我在wpf用户控件中有一个文本框,当我点击屏幕时会在弹出窗口中显示。 我试图让它成为用户可以抓住文本框或usercontrol的角落并用鼠标旋转它。

控件的要点是我已经为地图组件添加了一些绘图工具,这样用户就可以向地图添加文本了。 我希望如果在弹出文本框时输入文本,他们也可以用鼠标旋转文本框。

<Popup Grid.Row="1"   
           Name="_drawText"
           DataContext="{Binding Path=MapControlViewModel}"
           IsOpen="{Binding IsTextDrawingSelected, Mode=OneWay}"
           PopupAnimation="None"  
           AllowsTransparency="True"                    
           Placement="Mouse">
            <map:TextBoxDrawingControl DataContext="{Binding TextBoxDrawingControlViewModel}"/>
    </Popup>

有任何想法吗? 我在绘图工具中看到过这样的东西,你可以选择一个项目并旋转它。


I have a textbox in a wpf user control that shows in a popup when I click the screen. I am trying to make it so the user can grab the corner of the textbox or usercontrol and rotate it with the mouse.

The point of the control is I have added some drawing tools to a map component and this is so the user can add text to the map. I would like it if while entering the text when the textbox pops up they could also rotate the textbox with the mouse.

<Popup Grid.Row="1"   
           Name="_drawText"
           DataContext="{Binding Path=MapControlViewModel}"
           IsOpen="{Binding IsTextDrawingSelected, Mode=OneWay}"
           PopupAnimation="None"  
           AllowsTransparency="True"                    
           Placement="Mouse">
            <map:TextBoxDrawingControl DataContext="{Binding TextBoxDrawingControlViewModel}"/>
    </Popup>

Any ideas? I have seen stuff like this in drawing tools where you can select an item and rotate it.


原文:https://stackoverflow.com/questions/21123466
更新时间:2024-05-25 15:05

最满意答案

如果您正在使用名称空间,则可以模拟fgets()。

namespace My\Namespace;

class SomeClass
{
    public static function getPassword($prompt = '')
    {
        echo $prompt;
        \system('stty -echo');

        // Notice how the global function "fgets()" is called without the leading backslash 
        // (relative instead of absolute call in a namespaced environment). 
        // This will let us later mock the call
        $pass = fgets(STDIN);

        \system('stty echo');
        return $pass;
    }
}

测试文件:

namespace My\Namespace {
    // And this here, does the trick: it will override the fgets()
    // function in your code *just for the namespace* where you are defining it.
    function fgets($Handle) {
        return 'Pa$$Word';      // Password Text for testing
    }

include_once './SomeClass.php';

class Test_SomeClass extends \PHPUnit_Framework_TestCase
{
    /**
     * This will test the success case.
     * @test
     */
    public function testPass()
    {
        $dummy = new \My\Namespace\SomeClass;
        $this->assertEqual('Pa$$Word', $dummy->getPassword());
    }
}

本文讨论了一个处理异常的套接字示例。


You can mock the fgets() if you have namespaces in use.

namespace My\Namespace;

class SomeClass
{
    public static function getPassword($prompt = '')
    {
        echo $prompt;
        \system('stty -echo');

        // Notice how the global function "fgets()" is called without the leading backslash 
        // (relative instead of absolute call in a namespaced environment). 
        // This will let us later mock the call
        $pass = fgets(STDIN);

        \system('stty echo');
        return $pass;
    }
}

The Test file:

namespace My\Namespace {
    // And this here, does the trick: it will override the fgets()
    // function in your code *just for the namespace* where you are defining it.
    function fgets($Handle) {
        return 'Pa$$Word';      // Password Text for testing
    }

include_once './SomeClass.php';

class Test_SomeClass extends \PHPUnit_Framework_TestCase
{
    /**
     * This will test the success case.
     * @test
     */
    public function testPass()
    {
        $dummy = new \My\Namespace\SomeClass;
        $this->assertEqual('Pa$$Word', $dummy->getPassword());
    }
}

This Post discusses a socket example as well that handles exceptions.

相关问答

更多
  • 在你的php.ini文件中找到以下行:short_open_tag =关 并将其更改为:short_open_tag =开 Find following line in your php.ini file: short_open_tag = Off And change it to: short_open_tag = On
  • 使用双引号" 。 echo "next line\n"; 另外您可以使用系统依赖的常量PHP_EOL echo "this is my text" . PHP_EOL; Use double quotes ". echo "next line\n"; Additional you can use the system-dependent constant PHP_EOL echo "this is my text" . PHP_EOL;
  • 找到了! php需要'php-posix'包来输出centos中的颜色。 这是通过这个软件包安装的: php-process-7.0.12-2.el7.remi.x86_64 Found it! 'php-posix' package was needed for php to output colors in centos. This was installed via this package: php-process-7.0.12-2.el7.remi.x86_64
  • 您可以将测试结果保存为工件并下载,因为已知网址类似于http://jenkins.yourcompany.com/job/yourjob/buildId/artifact/testResults.xml You can just save the results of your test as artifact, and download it, as the url is known to be something like http://jenkins.yourcompany.com/job/yourj ...
  • 你应该有一个文件php.exe,这是CLI版本。 所以你可以做 php.exe -f phpfile.php 使用命令行运行文件。 You should have a file php.exe, which is the CLI version. So you can do php.exe -f phpfile.php to run a file using the command line.
  • 摘要将其与自己的方法进行比较。 在测试中模拟该方法以控制它是否进入该块。 if ($this->_isCli()) { header('HTTP/1.1 '.$statusCode); } protected function _isCli() { return PHP_SAPI!='cli'; } Abstract that comparison into its own method. Mock that method in your test to control whether or ...
  • 如果你正在做 php a2addvhost.php example.com 你还在Unix。 因此a2addvhost.php文件必须位于当前目录中才能工作。 If you're doing php a2addvhost.php example.com You're still in Unix. So the a2addvhost.php file must be in the current directory for it to work.
  • dirname(__FILE__) __DIR__ dirname(__FILE__) (或新版本中的__DIR__ )应该足够了。 您可以在Magic Constants章节中找到进一步的参考。 dirname(__FILE__) (or __DIR__ in newer versions) should be enough. You can find further reference at the Magic Constants chapter.
  • 如果您正在使用名称空间,则可以模拟fgets()。 namespace My\Namespace; class SomeClass { public static function getPassword($prompt = '') { echo $prompt; \system('stty -echo'); // Notice how the global function "fgets()" is called without the ...
  • 此问题已修复。 CURL完美地运行了Vendors API集成,但没有按预期运行。 它要求一个JSON选项变量,但没有记录的是ORDER很重要,如果你请求一个JSON,这是完全不可接受的。 供应商被通知并将修补此问题,因为在进行详细调查时发现解析JSON的方式会产生一些安全后果。 This issue is fixed. The CURL works perfectly it was the Vendors API integration which was not acting as expected. ...

相关文章

更多

最新问答

更多
  • 谁有JAVA的视频教程啊 最好从基础开始到精通 打包好的
  • 仅根据表格的一列删除重复的值(Remove duplicate values based on only one column of the table)
  • 从数据库值填充数组的最有效方法?(Most efficient way to populate array from database values?)
  • 我在data属性中有一个变量,并从prop传递相同的变量。(I have one variable in data attribute, and pass the same variable from prop. why the {{}} template display the value from prop rather than data)
  • Reg Ex Django Url Conf(Reg Ex Django Url Conf)
  • 本地化不适用于主要活动(Localization does not work on main activity)
  • 我有一个同学让我去福州科闽计算机学校学习室内设计,这个学校好吗?
  • 变量的模板参数中的Decltype(Decltype in template parameter of variable)
  • 代码签名错误与Xcode 4.2(Code Sign error with Xcode 4.2)
  • 在保留表达式生命周期的同时强制执行参数评估顺序(Enforce parameter evaluation order while retaining lifetime of of expressions)
  • 查询以获取早于开始日期的日期行(不是简单的WHERE)(Query to get date rows older than a start date (not a simple WHERE))
  • 武清哪家会计培训机构通过率高?
  • Java正则表达式逻辑OR(Java regex logical OR)
  • 使用for循环创建异步Vue组件(Use for loop to create async Vue component)
  • 从magento数据库获取客户名称和电子邮件(Get customer names and emails from magento database)
  • 运行Ruby冒泡排序(Running Through a Ruby Bubble Sort)
  • 减去返回多于1行的两个SQL子查询的结果(Subtracting the results of the two SQL subqueries that returns more than 1 row)
  • 对于Ruby http请求,响应“呃?”是间歇性的(The response “er ?” is getting intermittently for Ruby http request)
  • 请问嘉定区有没有培训上海市电脑中级的,有的话在哪里?
  • 根据日期范围查询最小分区键(聚类键)(Query min partition key based on date range (clustering key))
  • int listinsert(sqlist * & L)中的&是什么意思
  • 原始套接字的会话管理(Session Management on Raw Socket)
  • 将Type用作“属性”是不好的做法?(Is it bad practise to use Type as a 'Property'?)
  • 电脑等级证书二级和三级有什么区别啊 !!我们学校有二级和三级培训到底该选着那个呢????????
  • linux 安装新硬盘如何设置权限
  • 无法从RecyclerView的onBindViewHolder更改根视图的大小或位置(Cannot change root view's size or position from RecyclerView's onBindViewHolder)
  • spin.js没出现在我的网站上?(spin.js is not showing up on my site?)
  • Gulp + Bootstrap字体(Gulp + Bootstrap Fonts)
  • 如何使用短信Alfresco.util.PopupManager.displayPrompt显示图标(How to show icon with text message Alfresco.util.PopupManager.displayPrompt)
  • Skype.getAllChats()未检测到基于云的群组聊天(Skype.getAllChats() not detecting cloud-based group chats)