解决Lock之后 unlock 不了的问题

摘要:
解决锁定后无法解锁的问题1.DesignPanel cs protectedvoidDesignPanelPreviewMouseLeftButtonDown(objectsender,MouseButton EventArgse)#regionNoKey if(!_selectedElementDict.ContainsKey(currentElement))

解决Lock之后 unlock 不了的问题

 

1.DesignPanel.cs

 

protectedvoidDesignPanelPreviewMouseLeftButtonDown(objectsender, MouseButtonEventArgse)

 

#region No Key

 

if (!_selectedElementDict.ContainsKey(currentElement))

                    {

                        foreach (FrameworkElementelementin_selectedElementDict.Keys)

                        {

                            if (elementisCommonElement) { ((CommonElement)element).ShowBorder=false; }

                        }

 

                        _selectedElementDict.Clear();

                        //if (currentElement != null && GetAllowDesign(currentElement))

                        if (currentElement!=null)

                        {

                            _selectedElementDict.Add(currentElement, newRect());

                            if (currentElementisCommonElement) ((CommonElement)currentElement).ShowBorder=true;

 

                            FocusedElement=currentElement;

                        }

 

                        OnSelectionChanged(newEventArgs());

                    }

 

2.DesignPanel.cs

protectedvoidDesignPanelPreviewMouseMove(objectsender, MouseEventArgse)

if (_direction==Direction.None)

                {

                    foreach (FrameworkElementelementin_selectedElementDict.Keys)

                    {

                        //Rect rect = _selectedElementDict[element];

                        //double left = rect.X;

                        //double top = rect.Y;

                        //element.Margin = new Thickness(left + position.X - _position.X,

                        //    top + position.Y - _position.Y, element.Margin.Right, element.Margin.Bottom);

 

                        if (GetAllowDesign(element))

                        {

                            Rectrect=_selectedElementDict[element];

                            doubleleft=rect.X;

                            doubletop=rect.Y;

                            element.Margin=newThickness(left+position.X-_position.X,

                                top+position.Y-_position.Y, element.Margin.Right, element.Margin.Bottom);

                        }

                    }

 

                    if (_selectedElementDict.Count>0)

                    {

                        OnElementPositionChanged(newEventArgs());

                    }

                }

3. CommonElement.cs

publicvirtualvoidSelected(SCTemplateViewview)

        {

           

            view.cbTextDecorations.SelectedIndex=-1;

            view.cbTextDecorations.IsEnabled=false;

            view.cbxFontColor.SelectedIndex=-1;

            view.cbxFontColor.IsEnabled=false;

            view.cbxColor.SelectedIndex=-1;

            view.cbxColor.IsEnabled=false;

            view.cbFontSize.SelectedIndex=-1;

            view.cbFontSize.IsEnabled=false;

            view.cbFontStyle.SelectedIndex=-1;

            view.cbFontStyle.IsEnabled=false;

            view.cbFontWeight.SelectedIndex=-1;

            view.cbFontWeight.IsEnabled=false;

 

 

            view.txtName.IsReadOnly=!this.CanDesign;

            view.cbVisible.IsEnabled=!this.CanDesign;

            view.txtLeft.IsReadOnly=!this.CanDesign;

            view.txtTop.IsReadOnly=!this.CanDesign;

            view.txtWidth.IsReadOnly=!this.CanDesign;

            view.txtHeight.IsReadOnly=!this.CanDesign;

            view.txtZIndex.IsReadOnly=!this.CanDesign;

            view.cbxColor.IsReadOnly=!this.CanDesign;

            view.cbFontSize.IsReadOnly=!this.CanDesign;

            view.cbxFontColor.IsReadOnly=!this.CanDesign;

            view.cbFontWeight.IsReadOnly=!this.CanDesign;

            view.cbFontStyle.IsReadOnly=!this.CanDesign;

            view.cbTextDecorations.IsReadOnly=!this.CanDesign;

            //view.cbIsLocked.IsEnabled = this.CanDesign;

        }

4. TextBlockElement.cs

  publicoverridevoidSelected(SCTemplateViewview)

        {

           // base.Selected(view);

           

            view.txtName.Text=Text==null?"" : Text;

            view.txtLeft.Text=Margin.Left+"";

            view.txtTop.Text=Margin.Top+"";

            view.txtWidth.Text=Width+"";

            view.txtHeight.Text=Height+"";

 

 

            view.cbTextDecorations.IsEnabled=true;

            view.cbFontWeight.IsEnabled=true;

            view.cbFontSize.IsEnabled=true;

            view.cbFontStyle.IsEnabled=true;

            view.cbxColor.IsEnabled=true;

            view.cbxFontColor.IsEnabled=true;

 

        

            ElementDecorations.init();

 

            #region background

           

            if (Background!=null)

            {

                for (inti=0; i<ElementDecorations.lsBackGround.Count; i++)

                {

                    if (Background+""==ElementDecorations.lsBackGround[i].ToString())

                    {

                        view.cbxColor.SelectedIndex=i;

                        break;

                    }

                }

            }

            else

            {

                view.cbxColor.SelectedIndex=0;

            }

 

            #endregion

 

            #region Foreground

            if (Foreground+""=="#FF000000")

            {

                view.cbxFontColor.SelectedIndex=0;

             

            }

            else

            {

 

                for (intj=0; j<ElementDecorations.lsFontColor.Count; j++)

                {

                    if (Foreground+""==ElementDecorations.lsFontColor[j].ToString())

                    {

                        view.cbxFontColor.SelectedIndex=j;

                        break;

                    }

                }

            }

            #endregion

 

            #region FontSize

            if ((FontSize+"").Length>0)

            {

                view.cbFontSize.Text=FontSize.ToString();

            }

 

            for (inti=0; i<ElementDecorations.lsFontWeight.Count; i++)

            {

                if (FontWeight+""==ElementDecorations.lsFontWeight[i].ToString())

                {

                    view.cbFontWeight.SelectedIndex=i;

                    break;

                }

            }

 

            #endregion

 

            #region FontStyle

 

            for (inti=0; i<ElementDecorations.lsFontStyle.Count; i++)

            {

                if (FontStyle.ToString() ==ElementDecorations.lsFontStyle[i].ToString())

                {

                    view.cbFontStyle.SelectedIndex=i;

                    break;

                }

            }

 

            #endregion

 

            #region TextDecorations  Added by xlding, 2012-03-29

            if (this.textBlock.TextDecorations.Count<=0)

            {

                view.cbTextDecorations.SelectedIndex=-1;

            }

            else

            {

                for (inti=0; i<ElementDecorations.lsTextDecoration.Count; i++)

                {

                    TextBlocktBlock=this.textBlock;

                    if (tBlock!=null)

                    {

                        intnum=tBlock.TextDecorations.Count;

                        TextDecorationtDecoration=tBlock.TextDecorations[0];

                        stringstrD=tBlock.TextDecorations[0].Location.ToString();

 

                        if (tBlock.TextDecorations==

                            ElementDecorations.ConvertTextDecrationStringToTextDecorations(ElementDecorations.lsTextDecoration[i].ToString()))

                        {

 

                            view.cbTextDecorations.SelectedIndex=i;

 

                            break;

                        }

                    }

                }

            }

            #endregion

 

 

 

            view.txtName.IsReadOnly=!this.CanDesign;

            view.cbVisible.IsEnabled=!this.CanDesign;

            view.txtLeft.IsReadOnly=!this.CanDesign;

            view.txtTop.IsReadOnly=!this.CanDesign;

            view.txtWidth.IsReadOnly=!this.CanDesign;

            view.txtHeight.IsReadOnly=!this.CanDesign;

            view.txtZIndex.IsReadOnly=!this.CanDesign;

            view.cbxColor.IsReadOnly=!this.CanDesign;

            view.cbFontSize.IsReadOnly=!this.CanDesign;

            view.cbxFontColor.IsReadOnly=!this.CanDesign;

            view.cbFontWeight.IsReadOnly=!this.CanDesign;

            view.cbFontStyle.IsReadOnly=!this.CanDesign;

            view.cbTextDecorations.IsReadOnly=!this.CanDesign;

 

        }

5. SCTemplateView.cs

<CheckBox Name="cbIsLocked" Margin="2,2,0,0" Grid.Row="13" Grid.Column="1" Grid.ColumnSpan="2"

                                                  VerticalContentAlignment="Top" HorizontalContentAlignment="Left"

                                                  IsChecked="{Binding Path=CanDesign, UpdateSourceTrigger=PropertyChanged}"

                                                   Click="cbIsLocked_Click" ></CheckBox>

 

  privatevoidcbIsLocked_Click(objectsender, RoutedEventArgse)

        {

            CheckBoxcbox=senderasCheckBox;

            if (cbox!=null)

            {

                boolbCanDesign= (bool)cbox.IsChecked;

                this.txtName.IsReadOnly=!bCanDesign;

                this.cbVisible.IsEnabled=!bCanDesign;

                this.txtLeft.IsReadOnly=!bCanDesign;

                this.txtTop.IsReadOnly=!bCanDesign;

                this.txtWidth.IsReadOnly=!bCanDesign;

                this.txtHeight.IsReadOnly=!bCanDesign;

                this.txtZIndex.IsReadOnly=!bCanDesign;

                this.cbxColor.IsReadOnly=!bCanDesign;

                this.cbFontSize.IsReadOnly=!bCanDesign;

                this.cbxFontColor.IsReadOnly=!bCanDesign;

                this.cbFontWeight.IsReadOnly=!bCanDesign;

                this.cbFontStyle.IsReadOnly=!bCanDesign;

                this.cbTextDecorations.IsReadOnly=!bCanDesign;

            }

        }

 

 

免责声明:文章转载自《解决Lock之后 unlock 不了的问题》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇mybatis源码分析(5)-----拦截器的实现原理(动态代理+责任链)JqueryEasyUI 解决IE下datagrid无法刷新的问题下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

随便看看

redis make报错

所以添加参数:makeMALLOC=libc第二种类型:makeCFLAGS=“-march=x86-64”在README中有此段。...

db2数据导出导入del与ixf格式

ixf格式保存的是结构和数据,是一个二进制文件,ixf文件不可视。...

安装qmake与环境变量解析

如果你已经有了qmake,可以跳过这里,请看10分钟学会使用qmake。手动安装qmake在手工连编Qt之前,下面这些环境变量必须被设置:QMAKESPEC这个必须设置为你所使用的系统的平台和编译器的组合。当编译完成时,qmake已经可以使用了。这里对添加环境变量时,是在path里头添加,还是new一个变量有点疑惑。而如果是new的话,当我们在为程序添加路径...

利用油猴插件实现全网VIP视频免费看

利用油猴插件实现全网VIP视频免费看第一步:首先打开谷歌应用商店搜索tampermonkey安装这个插件第二步:在百度搜索框搜索油猴可以看到以下页面,点击进入。下载谷歌上网助手解压后,将后缀为crx的文件拖入即可。之后注册一个谷歌上网助手账后登录即可进入谷歌应用商店油猴插件...

Sublime Text 格式化JSON-pretty json

输入prettyjson回车,稍等片刻即可完成安装。...