internal static HighlightRitchTextBox GetVerseAsTextBox(int bibleId, BibleVerseModel verse, int column) { HighlightRitchTextBox result = new HighlightRitchTextBox { Text = verse.VerseText, Tag = verse, BorderBrush = Brushes.Transparent, IsReadOnly = true, Margin = new Thickness(2, 0, 0, 15) }; List <HighlightVerseModel> verseColours = BiblesData.Database.GetVerseColours(verse.BibleVerseKey); foreach (HighlightVerseModel colour in verseColours) { string[] itemSplit = colour.BibleVerseKeyId.Split(BibleLoader.veseSplitValues); result.HighlightText(itemSplit[1].ToInt32(), itemSplit[2].ToInt32(), ColourConverters.GetBrushfromHex(colour.HexColour)); } Grid.SetRow(result, (Formatters.GetVerseFromKey(verse.BibleVerseKey) - 1)); Grid.SetColumn(result, column); return(result); }
public void SetModel() { //myBlueprintModel = new BlueprintModel(); #region setColour switch (this["colour"]) { case "hsv": { MyBlueprintModel.BlockColour = new SeHSV(float.Parse(this["h"]), float.Parse(this["s"]), float.Parse(this["v"])); break; } case "rgb": { ColourConverters.ConvertRgbToHsv(int.Parse(this["r"]), int.Parse(this["g"]), int.Parse(this["b"])); break; } } #endregion #region setArmour MyBlueprintModel.BlockArmour = CapitaliseFirstLetter(this["armour"]); #endregion #region BlockSize MyBlueprintModel.BlockSize = CapitaliseFirstLetter(this["size"]); #endregion #region HollowObject MyBlueprintModel.Solid = bool.Parse(this["solid"]); #endregion #region BlueprintName MyBlueprintModel.BlueprintName = this["bpname"]; #endregion #region BlueprintFilePath MyBlueprintModel.BlueprintFilePath = this["path"]; #endregion #region Shape MyBlueprintModel.Shape = this["shape"].ToLower(); #endregion #region Shape_fraction MyBlueprintModel.ShapeFraction = this["fraction"].ToLower(); #endregion #region SteamId MyBlueprintModel.SteamId = this["id"]; #endregion #region SteamName MyBlueprintModel.SteamName = this["owner"]; #endregion #region setX MyBlueprintModel.XAxis = int.Parse(this["x"]); #endregion #region setY MyBlueprintModel.YAxis = int.Parse(this["y"]); #endregion #region setZ MyBlueprintModel.ZAxis = int.Parse(this["z"]); #endregion // System.Diagnostics.Trace.WriteLine( myBlueprintModel.HasUsableData.ToString()); // MyBlueprintModel=myBlueprintModel; }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { try { string color = System.Convert.ToString(values[0]); return(ColourConverters.GetBrushfromHex(color)); } catch { return(System.Windows.DependencyProperty.UnsetValue); } }
private void BrowseButton_Clicked(object sender, RoutedEventArgs e) { if (this.ModelViewItemBrowse != null) { this.ModelViewItemBrowse(sender, ((ActionButton)sender).Tag.ToString()); } if (this.ObjectType == ModelItemTypeEnum.ColorBox) { Brush brush = this.parent.GetPropertyValue(this.PropertyName) as Brush; this.contentObject.SetPropertyValue("Background", brush); this.contentObject.SetPropertyValue("Foreground", ColourConverters.InvertFromHex(ColourConverters.GetHexFromBrush(brush))); } }
public void SetValue(object value) { switch (this.ObjectType) { case ModelItemTypeEnum.CheckBox: ((CheckBoxItem)this.contentObject).IsChecked = value.TryToBool(); break; case ModelItemTypeEnum.ComboBox: case ModelItemTypeEnum.EnumBox: ((ComboBoxTool)this.contentObject).SelectedValue = value; break; case ModelItemTypeEnum.DatePicker: ((DatePicker)this.contentObject).SelectedDate = value.TryToDate(); break; case ModelItemTypeEnum.SecureString: ((PasswordBoxBindable)this.contentObject).Password = value.ParseToString(); break; case ModelItemTypeEnum.ColorBox: TextBoxItem color = (TextBoxItem)this.contentObject; color.Background = ColourConverters.GetBrushfromHex(value.ParseToString()); color.Foreground = ColourConverters.InvertFromHex(value.ParseToString()); goto default; case ModelItemTypeEnum.TextBox: default: ((TextBoxItem)this.contentObject).Text = value.ParseToString(); break; } }
private void BackColour_Clicked(object sender, RoutedEventArgs e) { if (this.selectedKey.IsNullEmptyOrWhiteSpace() || Formatters.GetVerseFromKey(this.selectedKey) <= 0) { MessageDisplay.Show("Please select a Verse"); return; } try { ColourPicker picker = new ColourPicker(); if (picker.ShowDialog().IsFalse()) { return; } int verseNumber = Formatters.GetVerseFromKey(this.selectedKey); HighlightRitchTextBox textBox = this.loadedTextBoxDictionary[verseNumber]; int start = textBox.GetSelectionStartIndex(); int length = textBox.GetSelectedTextLength(); textBox.HighlightText(start, length, picker.SelectedColour); string bibleVerseKey = Formatters.IsBiblesKey(this.selectedKey) ? this.selectedKey : $"{this.Bible.BibleId}||{this.selectedKey}"; BiblesData.Database.InsertVerseColour(bibleVerseKey, start, length, ColourConverters.GetHexFromBrush(picker.SelectedColour)); } catch (Exception err) { ErrorLog.ShowError(err); } }
private void Item_Focuesd(object sender, RoutedEventArgs e) { try { if (this.ModelViewItemGotFocus != null) { this.ModelViewItemGotFocus(this, this.contentObject); } if (this.ObjectType == ModelItemTypeEnum.ColorBox) { TextBoxItem text = (TextBoxItem)sender; text.Background = ColourConverters.GetBrushfromHex(text.Text); text.Foreground = ColourConverters.InvertFromHex(text.Text); } } catch { // DO NOTHING } }
private void CreateContent(object parentObject, FieldInformationAttribute fieldValues) { BindingMode bindingMode = this.PropertyInfo.CanRead && this.PropertyInfo.CanWrite ? BindingMode.TwoWay : this.PropertyInfo.CanWrite ? BindingMode.OneWayToSource : BindingMode.OneWay; Binding binding = new Binding(this.PropertyInfo.Name) { Path = new PropertyPath(this.PropertyInfo.Name), Source = parentObject, Mode = bindingMode, BindsDirectlyToSource = true, }; binding.ValidationRules.Add(new IsRequiredValidationRule { IsRequired = fieldValues.IsRequired, ObjectType = this.ObjectType }); this.IsTabStop = !fieldValues.IsReadOnly; switch (this.ObjectType) { case ModelItemTypeEnum.CheckBox: #region CHECK BOX CheckBoxItem check = new CheckBoxItem { IsEnabled = !fieldValues.IsReadOnly }; check.GotFocus += this.Item_Focuesd; this.DependencyProperty = CheckBoxItem.IsCheckedProperty; check.SetBinding(CheckBoxItem.IsCheckedProperty, binding); this.BindingExpression = check.GetBindingExpression(CheckBoxItem.IsCheckedProperty); this.contentObject = check; break; #endregion case ModelItemTypeEnum.ComboBox: case ModelItemTypeEnum.EnumBox: #region COMBO BOX ComboBoxTool comboBox = new ComboBoxTool { IsEnabled = !fieldValues.IsReadOnly, IsEditable = this.isComboBoxEdit }; comboBox.HorizontalAlignment = HorizontalAlignment.Stretch; comboBox.GotFocus += this.Item_Focuesd; this.LoadContentValues(parentObject, comboBox); this.DependencyProperty = this.isComboBoxEdit ? ComboBoxTool.TextProperty : ComboBoxTool.ItemKeyProperty; comboBox.SetBinding(this.isComboBoxEdit ? ComboBoxTool.TextProperty : ComboBoxTool.ItemKeyProperty, binding); this.BindingExpression = comboBox.GetBindingExpression(this.isComboBoxEdit ? ComboBoxTool.TextProperty : ComboBoxTool.ItemKeyProperty); this.contentObject = comboBox; break; #endregion case ModelItemTypeEnum.DatePicker: #region DATE PICKER DatePicker date = new DatePicker { IsEnabled = !fieldValues.IsReadOnly }; //binding.ValidationRules.Clear(); date.HorizontalAlignment = HorizontalAlignment.Stretch; date.GotFocus += this.Item_Focuesd; this.DependencyProperty = DatePicker.SelectedDateProperty; date.SetBinding(DatePicker.SelectedDateProperty, binding); this.BindingExpression = date.GetBindingExpression(DatePicker.SelectedDateProperty); this.contentObject = date; break; #endregion case ModelItemTypeEnum.SecureString: #region SECURE STRING PasswordBoxBindable pass = new PasswordBoxBindable(parentObject) { IsEnabled = !fieldValues.IsReadOnly }; pass.HorizontalAlignment = HorizontalAlignment.Stretch; pass.HorizontalContentAlignment = HorizontalAlignment.Stretch; pass.LostFocus += this.Item_Focuesd; this.DependencyProperty = PasswordBoxBindable.PasswordTextProperty; pass.SetBinding(PasswordBoxBindable.PasswordTextProperty, binding); this.BindingExpression = pass.GetBindingExpression(PasswordBoxBindable.PasswordTextProperty); this.contentObject = pass; break; #endregion case ModelItemTypeEnum.ColorBox: case ModelItemTypeEnum.TextBox: default: #region TEXT BOX (DEFAULT) TextBoxItem text = new TextBoxItem { IsReadOnly = fieldValues.IsReadOnly, TextWrapping = TextWrapping.WrapWithOverflow }; text.MaxHeight = 250; text.MaxLength = fieldValues.MaxTextLength; text.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; text.HorizontalAlignment = HorizontalAlignment.Stretch; text.HorizontalContentAlignment = HorizontalAlignment.Stretch; text.SpellCheck.IsEnabled = this.isSpellCheck; text.LostFocus += this.Item_Focuesd; this.DependencyProperty = TextBoxItem.TextProperty; text.SetBinding(TextBoxItem.TextProperty, binding); this.BindingExpression = text.GetBindingExpression(TextBoxItem.TextProperty); this.contentObject = text; if (this.ObjectType == ModelItemTypeEnum.ColorBox && !text.Text.IsNullEmptyOrWhiteSpace()) { text.Background = ColourConverters.GetBrushfromHex(text.Text); text.Foreground = ColourConverters.InvertFromHex(text.Text); } break; #endregion } this.uxContent.Content = this.contentObject; }
private void ConvertModelColoursForThis() { compressedValues = ColourConverters.ConvertSEFormatHSVtoBluePrintFormat(basicData.BlockColour.H, basicData.BlockColour.S, basicData.BlockColour.V); }