public override Func <TValue, string, bool> ToPredicate <TKey, TValue>(GTabSettings <TKey, TValue> settings) { if (Value.StartsWith("[") && Value.EndsWith("]")) { string se = Value.Substring(1, Value.Length - 2); var att = settings.AttributeList.Find(se); if (att >= 0) { return(new Func <TValue, string, bool>((t, s) => { string val = t.GetValue <string>(att); bool ival2; Boolean.TryParse(val, out ival2); return ival2; })); } return(new Func <TValue, string, bool>((t, s) => false)); } bool b; Boolean.TryParse(Value, out b); return(new Func <TValue, string, bool>((t, s) => b)); }
private void _setSettings(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { List <DbAttribute> attributes; if (gdb.LayoutSearch != null) { attributes = gdb.LayoutSearch.ToList(); } else { attributes = new DbAttribute[] { settings.AttId, settings.AttDisplay }.Concat(gdb.AttributeList.Attributes.Skip(1).Where(p => p.IsSearchable != null && p != settings.AttId && p != settings.AttDisplay)).ToList(); } if (attributes.Count % 2 != 0) { attributes.Add(null); } settings.SearchEngine.SetAttributes(attributes); settings.SearchEngine.SetSettings(settings.AttId, true); settings.SearchEngine.SetSettings(settings.AttDisplay, true); foreach (DbAttribute attribute in attributes) { if (attribute != null && attribute.IsSearchable == true) { settings.SearchEngine.SetSettings(attribute, true); } } }
public void InitAttributes(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { settings.AttributeList = gdb.AttributeList; settings.AttId = gdb.AttributeList.PrimaryAttribute; settings.AttDisplay = gdb.AttributeList.Attributes.FirstOrDefault(p => p.IsDisplayAttribute) ?? gdb.AttributeList.Attributes[1]; if (typeof(TKey) == typeof(string)) { settings.AttIdWidth = 120; } }
public override Func <TValue, string, double> ToInt <TKey, TValue>(GTabSettings <TKey, TValue> settings, out bool isInt) { isInt = false; if (_comparison >= RelationalComparison.BinaryAnd) { isInt = true; bool int2; var predicateLeft = _leftCondition.ToInt(settings, out int2); var predicateRight = _rightCondition.ToInt(settings, out int2); switch (_comparison) { case RelationalComparison.BinaryAnd: return(new Func <TValue, string, double>((t, s) => (int)predicateLeft(t, s) & (int)predicateRight(t, s))); case RelationalComparison.BinaryOr: return(new Func <TValue, string, double>((t, s) => (int)predicateLeft(t, s) | (int)predicateRight(t, s))); case RelationalComparison.BinaryRightShift: return(new Func <TValue, string, double>((t, s) => (int)predicateLeft(t, s) >> (int)predicateRight(t, s))); case RelationalComparison.BinaryLeftShift: return(new Func <TValue, string, double>((t, s) => (int)predicateLeft(t, s) << (int)predicateRight(t, s))); case RelationalComparison.Add: return(new Func <TValue, string, double>((t, s) => predicateLeft(t, s) + predicateRight(t, s))); case RelationalComparison.Minus: return(new Func <TValue, string, double>((t, s) => predicateLeft(t, s) - predicateRight(t, s))); case RelationalComparison.Mult: return(new Func <TValue, string, double>((t, s) => predicateLeft(t, s) * predicateRight(t, s))); case RelationalComparison.Div: return(new Func <TValue, string, double>((t, s) => predicateLeft(t, s) / predicateRight(t, s))); case RelationalComparison.Mod: return(new Func <TValue, string, double>((t, s) => predicateLeft(t, s) % (int)predicateRight(t, s))); case RelationalComparison.Pow: return(new Func <TValue, string, double>((t, s) => Math.Pow(predicateLeft(t, s), predicateRight(t, s)))); } } return(new Func <TValue, string, double>((t, s) => 0)); }
public static bool IsTabEnabled(GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { if (DbPathLocator.DetectPath(settings.DbData) == null) { return(false); } if (!gdb.IsEnabled) { return(false); } if (!Boolean.Parse(ProjectConfiguration.ConfigAsker["[Server database editor - Enabled state - " + settings.DbData.DisplayName + "]", true.ToString()])) { return(false); } return(true); }
public override Func <TValue, string, string> ToValue <TKey, TValue>(GTabSettings <TKey, TValue> settings) { if (Value.StartsWith("[") && Value.EndsWith("]")) { string se = Value.Substring(1, Value.Length - 2); var att = settings.AttributeList.Find(se); if (att >= 0) { return(new Func <TValue, string, string>((t, s) => t.GetValue <string>(att))); } } if (Value.StartsWith("\"") && Value.EndsWith("\"")) { Value = Value.Substring(1, Value.Length - 2); } return(new Func <TValue, string, string>((t, s) => Value)); }
private void _onSetCustomCommands(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { int max = MaxElementsToCopyInCustomMethods < 0 ? settings.AttributeList.Attributes.Count - StartIndexInCustomMethods : MaxElementsToCopyInCustomMethods; settings.AddedCommands.Add(new GItemCommand <TKey, ReadableTuple <TKey> > { AllowMultipleSelection = true, DisplayName = "Copy entries to clipboard", ImagePath = "export.png", InsertIndex = 3, AddToCommandsStack = false, Shortcut = ApplicationShortcut.Copy, GenericCommand = delegate(List <ReadableTuple <TKey> > items) { StringBuilder builder = new StringBuilder(); List <int> toRemove = (from attribute in gdb.AttributeList.Attributes.OrderByDescending(p => p.Index) where attribute.IsSkippable && !_isAttributeEnabled(attribute, gdb) select attribute.Index).ToList(); for (int i = 0; i < items.Count; i++) { ReadableTuple <TKey> item = items[i]; List <string> objs = item.GetRawElements().Skip(StartIndexInCustomMethods).Take(max).Select(p => (p ?? "").ToString()).ToList(); foreach (var index in toRemove) { objs.RemoveAt(index); } builder.AppendLine(string.Join(",", objs.ToArray())); } Clipboard.SetDataObject(builder.ToString()); } }); }
private GDbTab _gDbTabMaker(SdeDatabase database, TabControl control, BaseDb gdb) { GTabSettings <TKey, ReadableTuple <TKey> > settings = new GTabSettings <TKey, ReadableTuple <TKey> >(gdb); GDbTabWrapper <TKey, ReadableTuple <TKey> > tab = new GDbTabWrapper <TKey, ReadableTuple <TKey> >(); Table <TKey, ReadableTuple <TKey> > table = gdb.To <TKey>().Table; settings.Table = table; settings.Control = control; Settings.Control = control; Settings.Gdb = gdb; Settings.Tab = tab; Settings.Table = table; Settings.Database = database; InitStyle(tab, settings, gdb); InitAttributes(tab, settings, gdb); if (OnInitSettings != null) { OnInitSettings(tab, settings, gdb); } DisplayableProperty <TKey, ReadableTuple <TKey> > generalProperties = new DisplayableProperty <TKey, ReadableTuple <TKey> >(); generalProperties.Spacing = DefaultSpacing; Settings.GeneralProperties = generalProperties; SdeEditor.Instance.SelectionChanged += new SdeEditor.SdeSelectionChangedEventHandler((sender, oldTab, newTab) => { try { TabItem item = newTab; if (gdb.DbSource.AlternativeName != null) { if (WpfUtilities.IsTab(item, gdb.DbSource.Filename) || WpfUtilities.IsTab(item, gdb.DbSource.AlternativeName)) { if (generalProperties.OnTabVisible != null) { generalProperties.OnTabVisible(this); } if (OnPreviewTabVisualUpdate != null) { OnPreviewTabVisualUpdate(tab, settings, gdb); } if (OnTabVisualUpdate != null) { OnTabVisualUpdate(tab, settings, gdb); } if (OnTabRefreshed != null) { OnTabRefreshed(Settings); } } } else { if (WpfUtilities.IsTab(item, gdb.DbSource)) { if (generalProperties.OnTabVisible != null) { generalProperties.OnTabVisible(this); } if (OnPreviewTabVisualUpdate != null) { OnPreviewTabVisualUpdate(tab, settings, gdb); } if (OnTabVisualUpdate != null) { OnTabVisualUpdate(tab, settings, gdb); } if (OnTabRefreshed != null) { OnTabRefreshed(Settings); } } } } catch (Exception err) { ErrorHandler.HandleException(err); } }); database.PreviewReloaded += delegate { if (OnPreviewDatabaseReloaded != null) { OnPreviewDatabaseReloaded(tab, settings, gdb); } }; database.Reloaded += delegate { //if (OnPreviewTabVisualUpdate != null) OnPreviewTabVisualUpdate(tab, settings, gdb); //if (OnTabVisualUpdate != null) OnTabVisualUpdate(tab, settings, gdb); DisplayablePropertyHelper.CheckAttributeRestrictions(tab, settings, gdb); if (OnDatabaseReloaded != null) { OnDatabaseReloaded(tab, settings, gdb); } if (OnTabRefreshed != null) { OnTabRefreshed(Settings); } }; int line = 0; if (OnPreviewGenerateGrid != null) { OnPreviewGenerateGrid(ref line, Settings); } if (GenerateGrid != null) { GenerateGrid(ref line, Settings); } if (OnGenerateGrid != null) { OnGenerateGrid(ref line, Settings); } settings.DisplayablePropertyMaker = generalProperties; settings.ClientDatabase = database; if (SetSettings != null) { SetSettings(tab, settings, gdb); } if (OnSetCustomCommands != null) { OnSetCustomCommands(tab, settings, gdb); } if (OnPreviewTabInitialize != null) { OnPreviewTabInitialize(tab, settings, gdb); } tab.Initialize(settings); if (OnAfterTabInitialize != null) { OnAfterTabInitialize(tab, settings, gdb); } return(tab); }
private void _onPreviewTabInitialize(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { }
public void Deploy(GDbTabWrapper <TKey, TValue> tab, GTabSettings <TKey, TValue> settings, bool noUpdate = false) { foreach (Tuple <FrameworkElement, FrameworkElement> element in _deployControls) { Grid grid = element.Item2 as Grid; FrameworkElement fElement = element.Item1; if (grid == null) { grid = tab.PropertiesGrid; } if (fElement is TextBox || fElement is TextEditor) { RemoveUndoAndRedoEvents(fElement, tab); } int gridRow = (int)fElement.GetValue(Grid.RowProperty); while (grid.RowDefinitions.Count <= gridRow) { grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(-1, GridUnitType.Auto) }); } if (fElement.Parent == null) { grid.Children.Add(fElement); } } foreach (Action <Grid> command in _deployCommands) { command(tab.PropertiesGrid); } if (noUpdate) { return; } foreach (Tuple <DbAttribute, FrameworkElement> v in _update) { Tuple <DbAttribute, FrameworkElement> x = v; if (x.Item1.DataType == typeof(int)) { TextBox element = (TextBox)x.Item2; _updateActions.Add(new Action <TValue>(item => element.Dispatch( delegate { Debug.Ignore(() => element.Text = item.GetValue <int>(x.Item1).ToString(CultureInfo.InvariantCulture)); element.UndoLimit = 0; element.UndoLimit = int.MaxValue; }))); element.TextChanged += delegate { ApplyCommand(tab, x.Item1, element.Text); }; } else if (x.Item1.DataType == typeof(bool)) { CheckBox element = (CheckBox)x.Item2; _updateActions.Add(new Action <TValue>(item => element.Dispatch(p => Debug.Ignore(() => p.IsChecked = item.GetValue <bool>(x.Item1))))); element.Checked += (sender, args) => ApplyCommand(tab, x.Item1, true, false); element.Unchecked += (sender, args) => ApplyCommand(tab, x.Item1, false, false); } else if (x.Item1.DataType == typeof(string)) { TextBox element = (TextBox)x.Item2; _updateActions.Add(new Action <TValue>(item => element.Dispatch( delegate { try { string val = item.GetValue <string>(x.Item1); if (val == element.Text) { return; } element.Text = item.GetValue <string>(x.Item1); element.UndoLimit = 0; element.UndoLimit = int.MaxValue; } catch { } }))); element.TextChanged += delegate { ApplyCommand(tab, x.Item1, element.Text); }; } else if (x.Item1.DataType.BaseType == typeof(Enum)) { ComboBox element = (ComboBox)x.Item2; List <int> values = Enum.GetValues(x.Item1.DataType).Cast <int>().ToList(); _updateActions.Add(new Action <TValue>(item => element.Dispatch(delegate { try { element.SelectedIndex = values.IndexOf(item.GetValue <int>(x.Item1)); } catch { element.SelectedIndex = -1; } }))); element.SelectionChanged += delegate { if (tab.ItemsEventsDisabled) { return; } try { ApplyCommand(tab, x.Item1, values[element.SelectedIndex], false); } catch (Exception err) { ErrorHandler.HandleException(err); } }; } } foreach (ICustomControl <TKey, TValue> property in _customProperties) { property.Init(tab, this); } foreach (FormatConverter <TKey, TValue> property in _formattedProperties) { property.Init(tab, this); } _orderTabs(tab); OnDeployed(); }
public static void TgOnTabVisualUpdate(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { Exception exception = null; bool success = tab.Dispatch(delegate { try { UIElement content = (UIElement)tab.Content; // (UIElement)(tab.Content ?? ((Window)tab.AttachedProperty["AttachedWindow"]).Content); if (gdb.To <TKey>().TabGenerator == null || gdb.To <TKey>().TabGenerator.IsTabEnabledMethod == null) { content.IsEnabled = IsTabEnabled(settings, gdb); } else { content.IsEnabled = gdb.To <TKey>().TabGenerator.IsTabEnabledMethod(settings, gdb); } return(true); } catch (Exception err) { exception = err; return(false); } }); if (!success) { throw exception; } List <DbAttribute> attributes = settings.AttributeList.Attributes; if (gdb.LayoutIndexes != null) { foreach (var attribute in attributes) { if (attribute.IsSkippable) { bool isSet = _isAttributeEnabled(attribute, gdb); tab.Dispatch(delegate { var elements = DisplayablePropertyHelper.GetAll(tab.PropertiesGrid, attribute.DisplayName); foreach (var element in elements) { element.Visibility = isSet ? Visibility.Visible : Visibility.Collapsed; element.IsEnabled = isSet; } }); } } } }
public virtual Func <TValue, string, double> ToInt <TKey, TValue>(GTabSettings <TKey, TValue> settings, out bool isInt) where TValue : Tuple { isInt = false; return(new Func <TValue, string, double>((t, s) => 0)); }
public static void CheckAttributeRestrictions <TKey>(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { foreach (var attributeS in settings.AttributeList.Attributes) { DbAttribute attribute = attributeS; if (attribute.Requirements.Renewal == RenewalType.Both && attribute.Requirements.Server == ServerType.Both) { continue; } tab.PropertiesGrid.Dispatch(delegate { var gridAttributes = GetAll(tab.PropertiesGrid, attribute); RenewalType rType = DbPathLocator.GetIsRenewal() ? RenewalType.Renewal : RenewalType.PreRenewal; ServerType sType = DbPathLocator.GetServerType(); gridAttributes.ForEach(p => p.IsEnabled = false); if ((attribute.Requirements.Renewal & rType) == rType && (attribute.Requirements.Server & sType) == sType) { gridAttributes.ForEach(p => p.IsEnabled = true); } else { gridAttributes.ForEach(p => p.IsEnabled = false); } }); } }
public void Initialize(GTabSettings <TKey, TValue> settings) { Settings = settings; ProjectDatabase = settings.ClientDatabase; DbComponent = ProjectDatabase.GetDb <TKey>(settings.DbData); Table = Settings.Table; Header = Settings.TabName; Style = TryFindResource(settings.Style) as Style ?? Style; SearchEngine = settings.SearchEngine; SearchEngine.Init(_dbSearchPanel, this); Table.TableUpdated += new Table <TKey, TValue> .UpdateTableEventHandler(_table_TableUpdated); if (Settings.SearchEngine.SetupImageDataGetter != null) { Extensions.GenerateListViewTemplate(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.GeneralColumnInfo { Header = Settings.AttId.DisplayName, DisplayExpression = "[" + Settings.AttId.Index + "]", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = Settings.AttIdWidth, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + Settings.AttId.Index + "]" }, new ListViewDataTemplateHelper.ImageColumnInfo { Header = "", DisplayExpression = "DataImage", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = 26, MaxHeight = 24 }, new ListViewDataTemplateHelper.RangeColumnInfo { Header = Settings.AttDisplay.DisplayName, DisplayExpression = "[" + Settings.AttDisplay.Index + "]", SearchGetAccessor = Settings.AttDisplay.AttributeName, IsFill = true, ToolTipBinding = "[" + Settings.AttDisplay.Index + "]", MinWidth = 100, TextWrapping = TextWrapping.Wrap } }, new DatabaseItemSorter(Settings.AttributeList), new string[] { "Deleted", "Red", "Modified", "Green", "Added", "Blue", "Normal", "Black" }, "generateStyle", "false"); } else { Extensions.GenerateListViewTemplate(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.GeneralColumnInfo { Header = Settings.AttId.DisplayName, DisplayExpression = "[" + Settings.AttId.Index + "]", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = Settings.AttIdWidth, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + Settings.AttId.Index + "]" }, new ListViewDataTemplateHelper.RangeColumnInfo { Header = Settings.AttDisplay.DisplayName, DisplayExpression = "[" + Settings.AttDisplay.Index + "]", SearchGetAccessor = Settings.AttDisplay.AttributeName, IsFill = true, ToolTipBinding = "[" + Settings.AttDisplay.Index + "]", MinWidth = 100, TextWrapping = TextWrapping.Wrap } }, new DatabaseItemSorter(Settings.AttributeList), new string[] { "Deleted", "Red", "Modified", "Green", "Added", "Blue", "Normal", "Black" }, "generateStyle", "false"); } if (!Settings.CanBeDelayed || Settings.AttributeList.Attributes.Any(p => p.IsSkippable)) { _deployTabControls(); } _initTableEvents(); if (Settings.ContextMenu != null) { if (Header is Control) { ((Control)Header).ContextMenu = Settings.ContextMenu; } } if (Settings.Loaded != null) { Settings.Loaded((GDbTabWrapper <TKey, ReadableTuple <TKey> >)(object) this, (GTabSettings <TKey, ReadableTuple <TKey> >)(object) Settings, ProjectDatabase.GetDb <TKey>(Settings.DbData)); } if (Settings.DisplayablePropertyMaker.OnTabVisible != null) { Settings.DisplayablePropertyMaker.OnTabVisible(this); } Loaded += delegate { TabControl parent = WpfUtilities.FindParentControl <TabControl>(this); if (parent != null) { parent.SelectionChanged += new SelectionChangedEventHandler(_parent_SelectionChanged); } }; _listView.PreviewMouseDown += delegate { _listView.Focus(); }; _listView.Loaded += delegate { try { if (IsVisible) { Keyboard.Focus(_listView); } } catch { } }; ApplicationShortcut.Link(ApplicationShortcut.Paste, () => ImportFromFile("clipboard"), _listView); ApplicationShortcut.Link(ApplicationShortcut.AdvancedPaste, () => ImportFromFile("clipboard", true), this); ApplicationShortcut.Link(ApplicationShortcut.AdvancedPaste2, () => ImportFromFile("clipboard", true), this); ApplicationShortcut.Link(ApplicationShortcut.Cut, () => _miCut_Click(null, null), _listView); }
public override Func <TValue, string, string> ToValue <TKey, TValue>(GTabSettings <TKey, TValue> settings) { var predicate = ToPredicate(settings); return((t, s) => predicate(t, s).ToString()); }
public override Func <TValue, string, double> ToInt <TKey, TValue>(GTabSettings <TKey, TValue> settings, out bool isInt) { isInt = false; if (Value.StartsWith("[") && Value.EndsWith("]")) { string se = Value.Substring(1, Value.Length - 2); var att = settings.AttributeList.Find(se); bool?canDirect = null; if (att >= 0) { return(new Func <TValue, string, double>((t, s) => { int ival2; if (canDirect == true) { try { ival2 = t.GetValue <int>(att); return ival2; } catch { canDirect = false; } } string val = t.GetValue <string>(att); if (canDirect == null) { try { ival2 = t.GetValue <int>(att); return ival2; } catch { canDirect = false; } } if (!Int32.TryParse(val, out ival2)) { if (val.StartsWith("0x", StringComparison.OrdinalIgnoreCase)) { ival2 = FormatConverters.IntOrHexConverter(val); } } return ival2; })); } return(new Func <TValue, string, double>((t, s) => 0)); } double ival; if (double.TryParse(Value.Replace(".", ","), out ival)) { isInt = true; } else if (double.TryParse(Value.Replace(",", "."), out ival)) { isInt = true; } else { if (Value.StartsWith("0x", StringComparison.OrdinalIgnoreCase)) { ival = FormatConverters.IntOrHexConverter(Value); isInt = true; } } return(new Func <TValue, string, double>((t, s) => ival)); }
public void InitStyle(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { GTabsMaker.SInit(tab, settings, gdb); }
public abstract Func <TValue, string, bool> ToPredicate <TKey, TValue>(GTabSettings <TKey, TValue> settings) where TValue : Tuple;
public override Func <TValue, string, bool> ToPredicate <TKey, TValue>(GTabSettings <TKey, TValue> settings) { return(new Func <TValue, string, bool>((t, s) => Value)); }
public override Func <TValue, string, bool> ToPredicate <TKey, TValue>(GTabSettings <TKey, TValue> settings) { Func <TValue, string, bool> leftCondition = (t, s) => false; Func <TValue, string, bool> rightCondition = (t, s) => false; Func <TValue, string, double> left = (t, s) => 0; Func <TValue, string, double> right = (t, s) => 0; Func <TValue, string, string> valueLeft = (t, s) => ""; Func <TValue, string, string> valueRight = (t, s) => ""; bool isLeftInt = false; bool isRightInt = false; if (_leftCondition != null) { leftCondition = _leftCondition.ToPredicate(settings); left = _leftCondition.ToInt(settings, out isLeftInt); valueLeft = _leftCondition.ToValue(settings); } if (_rightCondition != null) { rightCondition = _rightCondition.ToPredicate(settings); right = _rightCondition.ToInt(settings, out isRightInt); valueRight = _rightCondition.ToValue(settings); } switch (_comparison) { case RelationalComparison.And: return((t, s) => leftCondition(t, s) && rightCondition(t, s)); case RelationalComparison.Or: return((t, s) => leftCondition(t, s) || rightCondition(t, s)); case RelationalComparison.Eq: if (isLeftInt || isRightInt) { return((t, s) => left(t, s) == right(t, s)); } return((t, s) => String.Compare(valueLeft(t, s), valueRight(t, s), StringComparison.OrdinalIgnoreCase) == 0); case RelationalComparison.NotEq: if (isLeftInt || isRightInt) { return((t, s) => left(t, s) != right(t, s)); } return((t, s) => String.Compare(valueLeft(t, s), valueRight(t, s), StringComparison.OrdinalIgnoreCase) != 0); case RelationalComparison.Ge: return((t, s) => left(t, s) >= right(t, s)); case RelationalComparison.Le: return((t, s) => left(t, s) <= right(t, s)); case RelationalComparison.Gt: return((t, s) => left(t, s) > right(t, s)); case RelationalComparison.Lt: return((t, s) => left(t, s) < right(t, s)); } return((t, s) => false); }
public GSearchEngine(string tabName, GTabSettings <TKey, TValue> settings) { _settings = settings; _itemsSearchSettings = new GSearchSettings(ProjectConfiguration.ConfigAsker, tabName); }
public override Func <TValue, string, double> ToInt <TKey, TValue>(GTabSettings <TKey, TValue> settings, out bool isInt) { var predicate = Condition.ToInt(settings, out isInt); return(predicate); }
public override Func <TValue, string, bool> ToPredicate <TKey, TValue>(GTabSettings <TKey, TValue> settings) { var predicate = Condition.ToPredicate(settings); return(new Func <TValue, string, bool>((t, s) => IsReversed ? predicate(t, s) : !predicate(t, s))); }
public abstract Func <TValue, string, string> ToValue <TKey, TValue>(GTabSettings <TKey, TValue> settings) where TValue : Tuple;
public void Initialize(GTabSettings <TKey, TValue> settings) { Settings = settings; _displayGrid = new Grid(); _displayGrid.SetValue(Grid.ColumnProperty, 2); _displayGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }); _displayGrid.ColumnDefinitions.Add(new ColumnDefinition()); _displayGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(10) }); _displayGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }); _displayGrid.ColumnDefinitions.Add(new ColumnDefinition()); if (Settings.DbData == ServerDbs.ClientItems || Settings.DbData == ServerDbs.Pet || Settings.DbData == ServerDbs.Pet2 || Settings.DbData == ServerDbs.Mobs || Settings.DbData == ServerDbs.Mobs2 || Settings.DbData == ServerDbs.MobGroups || Settings.DbData == ServerDbs.Items || Settings.DbData == ServerDbs.Items2) { _viewGrid.Children.Add(_displayGrid); } else { ScrollViewer sv = new ScrollViewer(); sv.SetValue(Grid.ColumnProperty, 2); sv.SetValue(ScrollViewer.VerticalScrollBarVisibilityProperty, ScrollBarVisibility.Auto); sv.Focusable = false; sv.Content = _displayGrid; _viewGrid.Children.Add(sv); } ProjectDatabase = settings.ClientDatabase; DbComponent = ProjectDatabase.GetDb <TKey>(settings.DbData); Table = Settings.Table; Header = Settings.TabName; Style = TryFindResource(settings.Style) as Style ?? Style; SearchEngine = settings.SearchEngine; SearchEngine.Init(_dbSearchPanel, this); Table.TableUpdated += new Table <TKey, TValue> .UpdateTableEventHandler(_table_TableUpdated); if (Settings.SearchEngine.SetupImageDataGetter != null) { ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.GeneralColumnInfo { Header = Settings.AttId.DisplayName, DisplayExpression = "[" + Settings.AttId.Index + "]", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = Settings.AttIdWidth, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + Settings.AttId.Index + "]" }, new ListViewDataTemplateHelper.ImageColumnInfo { Header = "", DisplayExpression = "DataImage", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = 26, MaxHeight = 24 }, new ListViewDataTemplateHelper.RangeColumnInfo { Header = Settings.AttDisplay.DisplayName, DisplayExpression = "[" + Settings.AttDisplay.Index + "]", SearchGetAccessor = Settings.AttDisplay.AttributeName, IsFill = true, ToolTipBinding = "[" + Settings.AttDisplay.Index + "]", MinWidth = 100, TextWrapping = TextWrapping.Wrap } }, new DatabaseItemSorter(Settings.AttributeList), new string[] { "Deleted", "{DynamicResource CellBrushRemoved}", "Modified", "{DynamicResource CellBrushModified}", "Added", "{DynamicResource CellBrushAdded}", "Normal", "{DynamicResource TextForeground}" }); } else { ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.GeneralColumnInfo { Header = Settings.AttId.DisplayName, DisplayExpression = "[" + Settings.AttId.Index + "]", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = Settings.AttIdWidth, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + Settings.AttId.Index + "]" }, new ListViewDataTemplateHelper.RangeColumnInfo { Header = Settings.AttDisplay.DisplayName, DisplayExpression = "[" + Settings.AttDisplay.Index + "]", SearchGetAccessor = Settings.AttDisplay.AttributeName, IsFill = true, ToolTipBinding = "[" + Settings.AttDisplay.Index + "]", MinWidth = 100, TextWrapping = TextWrapping.Wrap } }, new DatabaseItemSorter(Settings.AttributeList), new string[] { "Deleted", "{DynamicResource CellBrushRemoved}", "Modified", "{DynamicResource CellBrushModified}", "Added", "{DynamicResource CellBrushAdded}", "Normal", "{DynamicResource TextForeground}" }); } if (!Settings.CanBeDelayed || Settings.AttributeList.Attributes.Any(p => p.IsSkippable)) { _deployTabControls(); } _initTableEvents(); if (Settings.ContextMenu != null) { if (Header is Control) { ((Control)Header).ContextMenu = Settings.ContextMenu; } } if (Settings.Loaded != null) { Settings.Loaded((GDbTabWrapper <TKey, ReadableTuple <TKey> >)(object) this, (GTabSettings <TKey, ReadableTuple <TKey> >)(object) Settings, ProjectDatabase.GetDb <TKey>(Settings.DbData)); } if (Settings.DisplayablePropertyMaker.OnTabVisible != null) { Settings.DisplayablePropertyMaker.OnTabVisible(this); } Loaded += delegate { TabControl parent = WpfUtilities.FindParentControl <TabControl>(this); if (parent != null) { parent.SelectionChanged += new SelectionChangedEventHandler(_parent_SelectionChanged); } }; _listView.PreviewMouseDown += delegate { _listView.Focus(); }; _listView.Loaded += delegate { try { if (IsVisible) { Keyboard.Focus(_listView); } } catch { } }; ApplicationShortcut.Link(ApplicationShortcut.Paste, () => ImportFromFile("clipboard"), _listView); ApplicationShortcut.Link(ApplicationShortcut.AdvancedPaste, () => ImportFromFile("clipboard", true), this); ApplicationShortcut.Link(ApplicationShortcut.AdvancedPaste2, () => ImportFromFile("clipboard", true), this); ApplicationShortcut.Link(ApplicationShortcut.Cut, () => _miCut_Click(null, null), _listView); ApplicationShortcut.Link(ApplicationShortcut.FromString("F3", "Search next empty ID"), () => { if (_listView.SelectedItems.Count > 0) { ReadableTuple <int> item = (_listView.SelectedItems[_listView.SelectedItems.Count - 1]) as ReadableTuple <int>; var original = item; if (item != null) { int id = item.Key; while (true) { id++; var idGeneric = (TKey)(object)id; var tuple = (ReadableTuple <int>)(object) Table.TryGetTuple(idGeneric); if (tuple == null && item != original && item != null) { TabNavigation.SelectList(DbComponent.DbSource, new TKey[] { item.GetKey <TKey>() }); break; } item = tuple; } } } }, _listView); }
public override Func <TValue, string, double> ToInt <TKey, TValue>(GTabSettings <TKey, TValue> settings, out bool isInt) { var predicate = Condition.ToInt(settings, out isInt); return(new Func <TValue, string, double>((t, s) => IsReversed ? predicate(t, s) : ~(int)predicate(t, s))); }