Windows 8 Metro风格项目(InkStroke.Add错误)

时间:2012-07-03 13:36:13

标签: c# microsoft-metro

Windows 8 Metro风格项目。

删除一些笔划后,我尝试使用InkManager.AddStroke()方法添加删除的笔划,以提供撤消和重做功能。

抛出异常

  

错误HRESULT E_FAIL已从调用COM组件返回。“

1 个答案:

答案 0 :(得分:0)

    public void OnDrawUndo(object sender, RoutedEventArgs e)
    {
        try
        {
            BackupInkStrokeCollection.Push(CurrentInkStrokeCollection.Pop());
            renderer.Clear();
            renderer.AddInk(CurrentInkStrokeCollection);

            //inkManager.GetStrokes()[inkManager.GetStrokes().Count - 1].Selected = true;

            InkStroke SelectedStroke = inkManager.GetStrokes()[inkManager.GetStrokes().Count - 1];
            SelectedStroke.Selected = true;
            var MyInkManager = new InkManager();
            MyInkManager.AddStroke(SelectedStroke.Clone());
            MyInkManagers.Add(MyInkManager);
            inkManager.DeleteSelected();
        }
        catch (Exception ee)
        {
            if (ee.Message == "Stack empty.")
                return;
            else
                new Windows.UI.Popups.MessageDialog(ee.ToString()).ShowAsync();
        }
    }