示例#1
0
        protected internal virtual string GetText(OperationSymbol operation, OperationSettings os)
        {
            if (os != null && os.Text != null)
            {
                return(os.Text);
            }

            return(operation.NiceToString());
        }
示例#2
0
        protected internal virtual ImageSource GetImage(OperationSymbol operation, OperationSettings os)
        {
            if (os != null && os.Icon != null)
            {
                return(os.Icon);
            }

            if (IsSave(operation))
            {
                return(ImageLoader.GetImageSortName("save.png"));
            }

            return(null);
        }
示例#3
0
        protected internal virtual Brush GetBackground(OperationInfo oi, OperationSettings os)
        {
            if (os != null && os.Color != null)
            {
                return(new SolidColorBrush(os.Color.Value));
            }

            var bc = BackgroundColors.LastOrDefault(a => a.IsApplicable(oi));

            if (bc != null)
            {
                return(new SolidColorBrush(bc.Color));
            }

            return(null);
        }
示例#4
0
        public OS GetSettings <OS>(Type type, OperationSymbol operation)
            where OS : OperationSettings
        {
            OperationSettings settings = Settings.TryGetValue(type)?.TryGetC(operation);

            if (settings != null)
            {
                var result = settings as OS;

                if (result == null)
                {
                    throw new InvalidOperationException("{0}({1}) should be a {2}".FormatWith(settings.GetType().TypeName(), operation.Key, typeof(OS).TypeName()));
                }

                return(result);
            }

            return(null);
        }
示例#5
0
 public static void AddSetting(OperationSettings setting)
 {
     Manager.Settings.GetOrAddDefinition(setting.OverridenType).AddOrThrow(setting.OperationSymbol, setting, "{0} repeated");
     Manager.Settings.ClearCache();
 }
示例#6
0
 public static void ReplaceSetting(OperationSettings setting)
 {
     Manager.Settings.GetOrAddDefinition(setting.OverridenType)[setting.OperationSymbol] = setting;
     Manager.Settings.ClearCache();
 }
示例#7
0
        public bool ConfirmMessage()
        {
            string message = OperationSettings != null && OperationSettings.ConfirmMessage != null?OperationSettings.ConfirmMessage(this) :
                                 OperationInfo.OperationType == OperationType.Delete && Entities.Count > 1 ? OperationMessage.PleaseConfirmYouDLikeToDeleteTheSelectedEntitiesFromTheSystem.NiceToString() :
                                 OperationInfo.OperationType == OperationType.Delete && Entities.Count == 1 ? OperationMessage.PleaseConfirmYouDLikeToDeleteTheEntityFromTheSystem.NiceToString() : null;

            if (message == null)
            {
                return(true);
            }

            return(MessageBox.Show(Window.GetWindow(SearchControl), message, OperationInfo.OperationSymbol.NiceToString(), MessageBoxButton.OKCancel) == MessageBoxResult.OK);
        }