Example #1
0
        private static IEnumerable <T> GetAllExclusions <T>(this IExclusive <T> me, List <T> progress)
        {
            var res = progress;

            if (me.Exclusions == null)
            {
                return(res);
            }
            var fs = me.Exclusions.Except(res).ToList();

            res.AddRange(fs);
            foreach (var f in fs)
            {
                GetAllExclusions((IExclusive <T>)f, res);
            }
            return(res);
        }
Example #2
0
 public static IEnumerable <T> GetAllExclusions <T>(this IExclusive <T> me) => GetAllExclusions(me, new List <T>(new T[] { }));
Example #3
0
        private void BarItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                if (e.Item.Tag == null)
                {
                    return;
                }

                if (!m_DictCommands.ContainsKey(e.Item.Tag as string))
                {
                    return;
                }

                ICommand cmdCurrent = m_DictCommands[e.Item.Tag as string] as ICommand;
                if (cmdCurrent == null)
                {
                    return;
                }

                // 判断独占
                if (m_ExclusiveCommand != null)
                {
                    // 必须独占的是同一对象
                    if (cmdCurrent != m_ExclusiveCommand && cmdCurrent is IExclusive && (cmdCurrent as IExclusive).Resource == m_ExclusiveCommand.Resource)
                    {
                        if (!m_ExclusiveCommand.Release())
                        {
                            SendMessage("当前命令与正在进行的操作冲突,操作中止。");
                            return;
                        }
                        //if (m_ExclusiveCommand.IsExclusiving)
                        //{
                        //    if (XtraMessageBox.Show(string.Format("当前正在进行{0}操作,您确定要中断此操作吗", (m_ExclusiveCommand as ICommand).Caption), "系统提示", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
                        //    {
                        //        m_ExclusiveCommand.Release();
                        //    }
                        //    else
                        //    {
                        //        SendMessage("操作冲突,用户取消");
                        //        return;
                        //    }
                        //}

                        m_ExclusiveCommand = (cmdCurrent as IExclusive);
                    }
                }
                SendMessage(string.Format("当前操作:{0}", cmdCurrent.Message));
                // 调用Command
                cmdCurrent.OnClick();

                if (cmdCurrent is ITool)
                {
                    ITool toolCurrent = cmdCurrent as ITool;
                    //// 制裁当前Tool
                    //if (m_ExclusiveCommand != null)
                    //    m_ExclusiveCommand.Release();

                    m_ExclusiveCommand = toolCurrent;


                    ////更新状态
                    ////foreach (BarItem barItem in m_BarItems)
                    ////{
                    ////    if (barItem is BarCheckItem && barItem != e.Item)
                    ////        (barItem as BarCheckItem).Checked = false;
                    ////}
                    //if (e.Item is BarCheckItem)
                    //{
                    //    (e.Item as BarCheckItem).Checked = true;
                    //}
                }
            }
            catch (Exception exp)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("抱歉,操作出现了意外错误,详情请查看日志!");
                Environment.LogWriter.AppendMessage(enumLogType.Error, exp.ToString());
            }
        }
Example #4
0
        private void BarItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                if (e.Item.Tag == null)
                    return;

                if (!m_DictCommands.ContainsKey(e.Item.Tag as string))
                    return;

                ICommand cmdCurrent = m_DictCommands[e.Item.Tag as string] as ICommand;
                if (cmdCurrent == null)
                    return;

                // 判断独占
                if (m_ExclusiveCommand != null)
                {
                    // 必须独占的是同一对象
                    if (cmdCurrent!=m_ExclusiveCommand && cmdCurrent is IExclusive && (cmdCurrent as IExclusive).Resource == m_ExclusiveCommand.Resource)
                    {
                        if (!m_ExclusiveCommand.Release())
                        {
                            SendMessage("当前命令与正在进行的操作冲突,操作中止。");
                            return;
                        }
                        //if (m_ExclusiveCommand.IsExclusiving)
                        //{
                        //    if (XtraMessageBox.Show(string.Format("当前正在进行{0}操作,您确定要中断此操作吗", (m_ExclusiveCommand as ICommand).Caption), "系统提示", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
                        //    {
                        //        m_ExclusiveCommand.Release();
                        //    }
                        //    else
                        //    {
                        //        SendMessage("操作冲突,用户取消");
                        //        return;
                        //    }
                        //}

                        m_ExclusiveCommand = (cmdCurrent as IExclusive);
                    }
                }
                SendMessage(string.Format("当前操作:{0}" , cmdCurrent.Message));
                // 调用Command
                cmdCurrent.OnClick();

                if (cmdCurrent is ITool)
                {
                    ITool toolCurrent = cmdCurrent as ITool;
                    //// 制裁当前Tool
                    //if (m_ExclusiveCommand != null)
                    //    m_ExclusiveCommand.Release();

                    m_ExclusiveCommand = toolCurrent;

                    ////更新状态
                    ////foreach (BarItem barItem in m_BarItems)
                    ////{
                    ////    if (barItem is BarCheckItem && barItem != e.Item)
                    ////        (barItem as BarCheckItem).Checked = false;
                    ////}
                    //if (e.Item is BarCheckItem)
                    //{
                    //    (e.Item as BarCheckItem).Checked = true;
                    //}

                }
            }
            catch(Exception exp)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("抱歉,操作出现了意外错误,详情请查看日志!");
                Environment.LogWriter.AppendMessage(enumLogType.Error, exp.ToString());
            }
        }
Example #5
0
 public static IEnumerable <T> GetAllExclusions <T>(this IExclusive <T> me)
 {
     //return GetAllExclusions(me, new List<T>(new[] { (T)me }));
     return(GetAllExclusions(me, new List <T>(new T[] { })));
 }