Esempio n. 1
0
        //TagPickerTagCollection tagPickerTags;
      
        public TagPickerView()
        {

            InitializeComponent();

            addTagAutoCompleteBox.CustomFindMatchesFunction = new UserControls.AutoCompleteBox.AutoCompleteBoxView.CustomFindMatchesDelegate((text) =>
            {
                List<Tag> results = new List<Tag>();

                using (TagDbCommands tc = new TagDbCommands())
                {
                    results = tc.getTagAutocompleteMatches(text, 50, IsStartsWithAutoCompleteMode);
                }

                return (results.Cast<Object>().ToList());
            });

            DependencyPropertyDescriptor.FromProperty(AutoCompleteBoxView.TextProperty, typeof(AutoCompleteBoxView)).AddValueChanged(addTagAutoCompleteBox, addTagAutoCompleteBox_TextChanged);
            DependencyPropertyDescriptor.FromProperty(AutoCompleteBoxView.SelectedItemProperty, typeof(AutoCompleteBoxView)).AddValueChanged(addTagAutoCompleteBox, addTagAutoCompleteBox_SelectedItemChanged);

            addButton.IsEnabled = false;
            clearButton.IsEnabled = false;
            selectedTags = new List<ToggleButton>();
        }
Esempio n. 2
0
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values.Any(obj => obj == DependencyProperty.UnsetValue))
                return DependencyProperty.UnsetValue;

            if ((string)parameter == "ganttLine")
            {
                var length = ((DateTime)values[0] - (DateTime)values[1]).TotalMinutes / 30;
                var interval = (double)values[2];
                return length * interval;
            }
            else
            {
                var vals = new List<double>();
                foreach (object val in values)
                    //box化されたintがdoubleへ直接キャストできないのでいったんunbox化した後にdoubleにする
                    vals.Add(val is int ? (double)(int)val : (double)val);
                switch ((string)parameter)
                {
                    case "sum":
                        return vals.Cast<double>().Sum();
                    case "product":
                        return vals.Aggregate((val, tmp) => val * tmp);
                    default:
                        throw new NotImplementedException();
                }
            }
        }