Пример #1
0
        void DisplayCombBox()
        {
            var dict = JsonConverter.JsonDeserialize <Dictionary <string, string> >(TagLabel.Substring(5));

            xCombBox.ItemsSource   = dict;
            xCombBox.SelectedValue = Convert.ToString(mValue);
            xCombBox.GotFocus     += new RoutedEventHandler((sender, e) => {
                (sender as ComboBox).IsDropDownOpen = true;
            });
            xCombBox.KeyDown += new KeyEventHandler((sender, e) => {
                if (e.Key == Key.Enter)
                {
                    KeyValuePair <string, string> obj = dict.FirstOrDefault(kv => kv.Value.StartsWith(xCombBox.Text));
                    if (obj.Key != null)
                    {
                        xCombBox.SelectedValue = obj.Key;
                        xCombBox.Text          = obj.Value;
                    }
                    Commons.Keyboard.Press(Key.Tab);
                }
            });
            xCombBox.LostFocus += new RoutedEventHandler((sender, e) =>
            {
                mValue = xCombBox.SelectedValue;
                Console.WriteLine(string.Format("DisplayCombBox: {0}", mValue == null ? "null" : mValue.ToString()));
            });
            xString.Visibility = Visibility.Hidden;
        }
Пример #2
0
        public static bool IsCorrectNumber(int _index, string _number, Grid _grid)
        {
            grid       = _grid;
            number     = _number;
            index      = _index;
            label      = (TagLabel)grid.Children[index];
            labelText  = label.Text;
            labelIndex = grid.Children.IndexOf(label);

            return(IsCorrectRow() && IsCorrectColumn() && IsCorrectSquare(index, number, grid));
        }
Пример #3
0
        private void Highlightning(TagLabel tagLabel, bool isCorrectNumber)
        {
            var index = playGround.Children.IndexOf(tagLabel);

            foreach (var i in lastCells)
            {
                playGround.Children[i.Key].BackgroundColor = i.Value;
            }

            if (lastIndex >= 0)
            {
                playGround.Children[lastIndex].BackgroundColor = lastColor;
            }

            lastIndex = playGround.Children.IndexOf(tagLabel);
            lastColor = tagLabel.BackgroundColor;
            if (tagLabel.Text == "")
            {
                tagLabel.BackgroundColor = Color.LightBlue;
            }
            else
            {
                foreach (TagLabel label in playGround.Children)
                {
                    if (label.Text == tagLabel.Text)
                    {
                        var indexForeachLabel = playGround.Children.IndexOf(label);

                        if (lastCells.ContainsKey(indexForeachLabel))
                        {
                            lastCells.Remove(indexForeachLabel);
                        }

                        lastCells.Add(indexForeachLabel, label.BackgroundColor);

                        if (isCorrectNumber)
                        {
                            label.BackgroundColor = Color.LightBlue;
                        }
                        else
                        {
                            label.BackgroundColor = Color.Red;
                        }
                    }
                }
            }
        }
Пример #4
0
        private void RefreshData()
        {
            panelContainer.SuspendLayout();
            panelContainer.Controls.Clear();

            if (_contactViewModel != null)
            {
                foreach (var tag in _contactViewModel.Tags)
                {
                    var tagLabel = new TagLabel(this, tag);

                    panelContainer.Controls.Add(tagLabel);
                }
            }

            panelContainer.ResumeLayout(true);
        }
Пример #5
0
 public static TagLabel onfocus(this TagLabel tag, string value)
 {
     tag.OnFocus = value; return(tag);
 }
Пример #6
0
 public static TagLabel accesskey(this TagLabel tag, char value)
 {
     tag.AccessKey = value; return(tag);
 }
Пример #7
0
 public static TagLabel @for(this TagLabel tag, string value)
 {
     tag.For = value; return(tag);
 }
Пример #8
0
 public static TagLabel onkeyup(this TagLabel tag, string value)
 {
     tag.OnKeyUp = value; return(tag);
 }
Пример #9
0
        void ReleaseDesignerOutlets()
        {
            if (AddObservationView != null)
            {
                AddObservationView.Dispose();
                AddObservationView = null;
            }

            if (AttachmentContentView != null)
            {
                AttachmentContentView.Dispose();
                AttachmentContentView = null;
            }

            if (CheckButton != null)
            {
                CheckButton.Dispose();
                CheckButton = null;
            }

            if (ConfidentialConteinerView != null)
            {
                ConfidentialConteinerView.Dispose();
                ConfidentialConteinerView = null;
            }

            if (ConstraintHeightObservationContentView != null)
            {
                ConstraintHeightObservationContentView.Dispose();
                ConstraintHeightObservationContentView = null;
            }

            if (CreateObservationButton != null)
            {
                CreateObservationButton.Dispose();
                CreateObservationButton = null;
            }

            if (DateLabel != null)
            {
                DateLabel.Dispose();
                DateLabel = null;
            }

            if (DetailLabel != null)
            {
                DetailLabel.Dispose();
                DetailLabel = null;
            }

            if (EditButton != null)
            {
                EditButton.Dispose();
                EditButton = null;
            }

            if (HeightAddObservationConstraint != null)
            {
                HeightAddObservationConstraint.Dispose();
                HeightAddObservationConstraint = null;
            }

            if (HeightAttachmentConstraint != null)
            {
                HeightAttachmentConstraint.Dispose();
                HeightAttachmentConstraint = null;
            }

            if (HeightConfidentialConteinerConstraint != null)
            {
                HeightConfidentialConteinerConstraint.Dispose();
                HeightConfidentialConteinerConstraint = null;
            }

            if (HeightSectionConteinerViewConstraint != null)
            {
                HeightSectionConteinerViewConstraint.Dispose();
                HeightSectionConteinerViewConstraint = null;
            }

            if (ObservationContentView != null)
            {
                ObservationContentView.Dispose();
                ObservationContentView = null;
            }

            if (ObservationTextView != null)
            {
                ObservationTextView.Dispose();
                ObservationTextView = null;
            }

            if (PlaceLabel != null)
            {
                PlaceLabel.Dispose();
                PlaceLabel = null;
            }

            if (SectionConteinerView != null)
            {
                SectionConteinerView.Dispose();
                SectionConteinerView = null;
            }

            if (SectionTextField != null)
            {
                SectionTextField.Dispose();
                SectionTextField = null;
            }

            if (StatusLabel != null)
            {
                StatusLabel.Dispose();
                StatusLabel = null;
            }

            if (TagLabel != null)
            {
                TagLabel.Dispose();
                TagLabel = null;
            }

            if (TitleEventLabel != null)
            {
                TitleEventLabel.Dispose();
                TitleEventLabel = null;
            }

            if (TopAttachmentContentConstraint != null)
            {
                TopAttachmentContentConstraint.Dispose();
                TopAttachmentContentConstraint = null;
            }

            if (TopConfidentialContainerConstraint != null)
            {
                TopConfidentialContainerConstraint.Dispose();
                TopConfidentialContainerConstraint = null;
            }

            if (TopSectionConteinerViewConstraint != null)
            {
                TopSectionConteinerViewConstraint.Dispose();
                TopSectionConteinerViewConstraint = null;
            }

            if (TypeLabel != null)
            {
                TypeLabel.Dispose();
                TypeLabel = null;
            }

            if (ViewTagConteiner != null)
            {
                ViewTagConteiner.Dispose();
                ViewTagConteiner = null;
            }
        }
Пример #10
0
 public static TagLabel lang(this TagLabel tag, LangCode value)
 {
     tag.Lang = value; return(tag);
 }
Пример #11
0
 public static TagLabel @class(this TagLabel tag, string value)
 {
     tag.Class = value; return(tag);
 }
Пример #12
0
 public static TagLabel onmousemove(this TagLabel tag, string value)
 {
     tag.OnMouseMove = value; return(tag);
 }
Пример #13
0
 public static TagLabel onmouseup(this TagLabel tag, string value)
 {
     tag.OnMouseUp = value; return(tag);
 }
Пример #14
0
        /// <summary>
        /// 显示
        /// </summary>
        void Display()
        {
            if (IsEnabled && TagLabel.StartsWith("comb|"))
            {
                DisplayCombBox();
                return;
            }
            xCombBox.Visibility = Visibility.Hidden;
            if (mValue == null)
            {
                xString.Text = "";
            }
            else
            {
                xString.Text = Convert.ToString(mValue);
            }

            if (!IsEnabled)
            {
                xString.BorderThickness = new Thickness(0, 0, 0, 1);
                return;
            }

            if (DataType == typeof(long) || DataType == typeof(decimal) || DataType == typeof(byte) ||
                DataType == typeof(sbyte) || DataType == typeof(short) || DataType == typeof(int) ||
                DataType == typeof(ushort) || DataType == typeof(uint) || DataType == typeof(ulong) ||
                DataType == typeof(float) || DataType == typeof(double))
            {
                xString.HorizontalContentAlignment = HorizontalAlignment.Right;
            }
            xString.PreviewMouseDown += XString_PreviewMouseDown;
            xString.GotFocus         += new RoutedEventHandler((sender, e) =>
            {
                xString.SelectAll();
                xString.PreviewMouseDown -= XString_PreviewMouseDown;
                e.Handled = true;
            });
            xString.KeyDown += new KeyEventHandler((sender, e) => {
                if (e.Key == Key.Enter)
                {
                    Commons.Keyboard.Press(Key.Tab);
                }
            });
            xString.LostFocus += new RoutedEventHandler((sender, e) => {
                xString.PreviewMouseDown += XString_PreviewMouseDown;
                object defaultValue       = DataType.IsValueType ? Activator.CreateInstance(DataType) : null;
                bool err = false;
                try
                {
                    object oldValue = mValue;
                    mValue          = Convert.ChangeType(xString.Text, DataType);
                    if (mValue == defaultValue)
                    {
                        throw new Exception();
                    }
                    if (oldValue == mValue)
                    {
                        return;
                    }
                    DataChangedArgs args = new DataChangedArgs
                    {
                        Name     = this.Name,
                        OldValue = oldValue,
                        NewValue = mValue,
                        Cancel   = false,
                        DataType = DataType
                    };
                    DataChangedEvent?.Invoke(this, args);
                    if (args.Cancel)
                    {
                        Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background,
                                               new Action(() =>
                        {
                            if (oldValue == null)
                            {
                                xString.Text = "";
                            }
                            else
                            {
                                xString.Text = Convert.ToString(oldValue);
                            }
                            if (err)
                            {
                                xString.SelectAll();
                            }
                        }));
                        e.Handled = true;
                    }
                }
                catch
                {
                    mValue    = defaultValue;
                    e.Handled = true;
                    err       = true;
                }
                finally
                {
                    Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background,
                                           new Action(() =>
                    {
                        if (mValue == null)
                        {
                            xString.Text = "";
                        }
                        else
                        {
                            xString.Text = Convert.ToString(mValue);
                        }
                        if (err)
                        {
                            xString.SelectAll();
                        }
                    }));
                }
            });
        }
Пример #15
0
 public static TagLabel onblur(this TagLabel tag, string value)
 {
     tag.OnBlur = value; return(tag);
 }
Пример #16
0
 public static TagLabel id(this TagLabel tag, string value)
 {
     tag.Id = value; return(tag);
 }
Пример #17
0
 public static TagLabel onmouseout(this TagLabel tag, string value)
 {
     tag.OnMouseOut = value; return(tag);
 }
Пример #18
0
 public static TagLabel title(this TagLabel tag, string value)
 {
     tag.Title = value; return(tag);
 }
Пример #19
0
 public static TagLabel onkeypress(this TagLabel tag, string value)
 {
     tag.OnKeyPress = value; return(tag);
 }
Пример #20
0
 public static TagLabel xmllang(this TagLabel tag, string value)
 {
     tag.XmlLang = value; return(tag);
 }
Пример #21
0
 public static TagLabel onkeydown(this TagLabel tag, string value)
 {
     tag.OnKeyDown = value; return(tag);
 }