Esempio n. 1
0
        ScLayer CreateItemControlFieldTest3(ScMgr scmgr, ColumnSetting columnSetting)
        {
            listView             = new ScListView(scmgr);
            listView.Name        = "ListView";
            listView.IsUseShadow = false;
            listView.ShadowRange = 4;
            listView.Margin      = new Margin(10, 10, 10, 10);

            listView.DisplayItemValue += DisplayItem;
            listView.CreateDefaultContentInfoSeting();
            listView.Dock = ScDockStyle.Fill;

            ScLayer listViewPack;

            if (listView.IsUseShadow)
            {
                listViewPack      = new ScLayer();
                listViewPack.Name = "ListViewPack";
                listViewPack.Dock = ScDockStyle.Fill;
                listViewPack.Add(listView);
                return(listViewPack);
            }
            else
            {
                return(listView);
            }
        }
Esempio n. 2
0
        private void LoadWindowSettings()
        {
            MyViewModel = DataContext as MainViewModel;
            MyViewModel.SetStatus("Starting up");

            // Setup events
            StateChanged += Window_StateChanged;
            SizeChanged  += Window_SizeChanged;
            Closed       += Window_Closed;

            MyViewModel.CurrentView = ViewType.DataGrid;

            Width  = AppGlobal.Settings.Windows["Main"].Width;
            Height = AppGlobal.Settings.Windows["Main"].Height;
            Left   = (SystemParameters.PrimaryScreenWidth - Width) / 2;
            Top    = (SystemParameters.PrimaryScreenHeight - Height) / 2;

            // Column settings
            var columns = view_DataGridView.Columns.ToList();

            ColumnHeadings = columns.Select(x => x.Header.ToString()).ToList();

            if (!ColumnHeadings.Contains(AppGlobal.Settings.DefaultSortColumn))
            {
                AppGlobal.Settings.DefaultSortColumn = "Name";
            }

            if (AppGlobal.Settings.ColumnSettings.Count == 0 || AppGlobal.Settings.ColumnSettings.Count != columns.Count)
            {
                AppGlobal.Settings.SaveColumnSetting(columns, true);
            }
            else
            {
                bool tampered = false;
                foreach (DataGridColumn column in columns)
                {
                    ColumnSetting setting = AppGlobal.Settings.ColumnSettings.SingleOrDefault(x => x.Name == column.Header.ToString());

                    if (setting == null)
                    {
                        tampered = true;
                        break;
                    }
                }

                if (!tampered)
                {
                    columns.ForEach(column =>
                    {
                        ColumnSetting setting = AppGlobal.Settings.ColumnSettings.SingleOrDefault(s => s.Name == column.Header.ToString());
                        column.Width          = setting.Width;
                        column.Visibility     = setting.Visible ? Visibility.Visible : Visibility.Collapsed;
                    });
                }
                else
                {
                    AppGlobal.Settings.SaveColumnSetting(columns, true);
                }
            }
        }
        public void GetHashCodeTest()
        {
            var co1 = new ColumnSetting("proName", true, 10, 10, 100);
            var co2 = new ColumnSetting("proName2", true, 10, 10, 100);

            Assert.AreNotEqual(co1.GetHashCode(), co2.GetHashCode());
        }
        public void ShouldSerializeValueTextTest()
        {
            var co1 = new ColumnSetting("proName", true, 0, 10, 100);

            Assert.AreEqual(false, co1.ShouldSerializeValueText());
            co1.ValueText = "hello";
            Assert.AreEqual(true, co1.ShouldSerializeValueText());
        }
        public void ShouldSerializeValueDateTest()
        {
            var co1 = new ColumnSetting("proName", true, 0, 10, 100);

            Assert.AreEqual(false, co1.ShouldSerializeValueDate());
            co1.ValueDate = DateTime.Now;
            Assert.AreEqual(true, co1.ShouldSerializeValueDate());
        }
        public void ShouldSerializeValueFiltersTest()
        {
            var co1 = new ColumnSetting("proName", true, 0, 10, 100);

            Assert.AreEqual(false, co1.ShouldSerializeValueFilters());
            co1.ValueFilters.Add(new ColumnSetting.ValueFilter("Cond", "display"));
            Assert.AreEqual(true, co1.ShouldSerializeValueFilters());
        }
        public void ShouldSerializeSortTest()
        {
            var co1 = new ColumnSetting("proName", true, 0, 10, 100);

            Assert.AreEqual(false, co1.ShouldSerializeSort());
            var co2 = new ColumnSetting("proName", true, 1, 10, 100);

            Assert.AreEqual(true, co2.ShouldSerializeSort());
        }
Esempio n. 8
0
        ScLayer CreateItemControlFieldTest(ScMgr scmgr, ColumnSetting columnSetting)
        {
            ScLabel label = new ScLabel(scmgr);

            label.Dock      = ScDockStyle.Fill;
            label.ForeFont  = new D2DFont("微软雅黑", 17, SharpDX.DirectWrite.FontWeight.Bold);
            label.ForeColor = Color.FromArgb(255, 58, 166, 254);
            return(label);
        }
Esempio n. 9
0
        public static int GetPixel(ColumnSetting columnSetting)
        {
            if (!string.IsNullOrWhiteSpace(columnSetting.DataType))
            {
                if (!Enum.IsDefined(typeof(SQLDataTypes), columnSetting.DataType))
                {
                    switch (columnSetting.DataType)
                    {
                    case "decimal":
                        return(columnSetting.MaxLength * 5);

                    case "int":
                        return(80);

                    case "name":
                        return(columnSetting.MaxLength * 30 > 119 ? 220 : 120);

                    case "char":
                        return(columnSetting.MaxLength < 11 ? 100 : columnSetting.MaxLength < 26 ? 170 : columnSetting.MaxLength < 51 ? 220 : 270);
                    }
                }
                else
                {
                    if (Enum.IsDefined(typeof(SQLDataTypes), columnSetting.DataType))
                    {
                        var sqlDataType = (SQLDataTypes)Enum.Parse(typeof(SQLDataTypes), columnSetting.DataType, true);
                        switch (sqlDataType)
                        {
                        case SQLDataTypes.bigint:
                            return(160);

                        case SQLDataTypes.dropdown:
                            return(columnSetting.MaxLength * 30 > 119 ? 120 : 100);

                        case SQLDataTypes.image:
                            return(columnSetting.MaxLength * 30);

                        case SQLDataTypes.bit:
                            return(80);

                        case SQLDataTypes.Name:
                            return(columnSetting.MaxLength * 30 > 119 ? 220 : 120);

                        case SQLDataTypes.ntext:
                            return(150);

                        case SQLDataTypes.nvarchar:
                        case SQLDataTypes.varchar:
                            return(columnSetting.MaxLength < 11 ? 100 : columnSetting.MaxLength < 26 ? 170 : columnSetting.MaxLength < 51 ? 220 : 270);
                        }
                    }
                }
            }
            return(80);
        }
Esempio n. 10
0
        public void SaveTest()
        {
            // Window情報
            var w = new Window();

            w.Name   = "FMainWindow";
            w.Left   = 100;
            w.Top    = 110;
            w.Width  = 320;
            w.Height = 240;

            var r = Setting.MainWindowBounds;

            Assert.IsTrue(w.Left == r.Left);
            Assert.IsTrue(w.Top == r.Top);
            Assert.IsTrue(w.Width == r.Width);
            Assert.IsTrue(w.Height == r.Height);

            // DataGridColumns情報
            var c1 = new ColumnSetting()
            {
                DisplayIndex = 0, Width = -2
            };
            var c2 = new ColumnSetting()
            {
                DisplayIndex = 1, Width = 100
            };
            var c3 = new ColumnSetting()
            {
                DisplayIndex = 2, Width = 200
            };
            var c4 = new ColumnSetting()
            {
                DisplayIndex = 3, Width = -1
            };
            var c5 = new ColumnSetting()
            {
                DisplayIndex = 4, Width = 0
            };

            var cols = Setting.DataGridColumns;
            var c    = cols[0];

            Assert.IsTrue(c1.Equals(c));
            c = cols[1];
            Assert.IsTrue(c2.Equals(c));
            c = cols[2];
            Assert.IsTrue(c3.Equals(c));
            c = cols[3];
            Assert.IsTrue(c4.Equals(c));
            c = cols[4];
            Assert.IsTrue(c5.Equals(c));
        }
Esempio n. 11
0
        public async Task DeleteColumn(ColumnSetting column)
        {
            var columnModel = _columns.First(x => x.Action == column.Action && x.Name == column.Name &&
                                             x.Parameter == column.Parameter &&
                                             x.ColumnSetting.Identifier == column.Identifier);

            columnModel.Dispose();
            _columns.Remove(columnModel);

            AccountSetting.Column.Remove(column);

            await AdvancedSettingService.AdvancedSetting.SaveToAppSettings();
        }
Esempio n. 12
0
        ScLayer CreateHeaderControlFieldTest(ScMgr scmgr, ColumnSetting columnSetting)
        {
            ScLabel label = new ScLabel(scmgr);

            label.Dock     = ScDockStyle.Fill;
            label.ForeFont = new D2DFont("微软雅黑", 17, SharpDX.DirectWrite.FontWeight.Bold);

            if (!columnSetting.columnBaseInfo.isHideName)
            {
                label.Text = columnSetting.columnBaseInfo.displayName;
            }

            return(label);
        }
Esempio n. 13
0
        public async Task AddColumn(ColumnSetting column)
        {
            if (column.Index == -1)
            {
                column.Index = _columns.Count;
            }

            column.Identifier = DateTime.Now.Ticks;

            AccountSetting.Column.Add(column);
            await AdvancedSettingService.AdvancedSetting.SaveToAppSettings();

            var columnModel = new ColumnModel(column, AccountSetting, this);

            _columns.Add(columnModel);

            await columnModel.Initialize();
        }
Esempio n. 14
0
        ScLayer CreateItemControlFieldTest1(ScMgr scmgr, ColumnSetting columnSetting)
        {
            ScLayer layer = new ScLayer(scmgr);

            layer.Dock = ScDockStyle.Fill;

            ScCheckBox checkBox = new ScCheckBox(scmgr);

            checkBox.CheckType    = 0;
            checkBox.boxSideWidth = 1;
            checkBox.FillMargin   = new Margin(2, 2, 3, 3);
            checkBox.CheckColor   = Color.DarkRed;
            checkBox.Dock         = ScDockStyle.Center;
            checkBox.Size         = new SizeF(15, 15);

            checkBox.SetDrawCheckDirectParentLayer(layer);
            layer.Add(checkBox);
            return(layer);
        }
Esempio n. 15
0
        public static List <ColumnSetting> GetColumnSetting(Type valuetype, ObjectStoreParameters parameters)
        {
            List <ColumnSetting> columnList = new List <ColumnSetting>();

            int relativePosition = 0;

            if (parameters.ColumnList.Count > 0)
            {
                foreach (var item in parameters.ColumnList)
                {
                    ColumnSetting column = new ColumnSetting();
                    column.FieldName = item.Key;

                    FieldInfo fieldinfo = valuetype.GetField(item.Key);

                    if (fieldinfo != null)
                    {
                        column.KeyType = fieldinfo.FieldType;
                        column.isField = true;
                    }
                    else
                    {
                        //try get property.
                        PropertyInfo propertyinfo = valuetype.GetProperty(item.Key);
                        if (propertyinfo != null)
                        {
                            column.KeyType    = propertyinfo.PropertyType;
                            column.isProperty = true;
                        }
                        else
                        {
                            throw new Exception("field or property does not exists " + item);
                        }
                    }

                    column.length           = Helper.KeyHelper.GetKeyLen(column.KeyType, item.Value);
                    column.relativePosition = relativePosition;
                    relativePosition       += column.length;
                    columnList.Add(column);
                }
            }
            return(columnList);
        }
Esempio n. 16
0
        public void DataGridColumnsTest()
        {
            var dg = new DataGrid();
            dg.Name = "FDataGrid";
            var c1 = new ColumnSetting() { DisplayIndex = 0, Width = -1 };
            var c2 = new ColumnSetting() { DisplayIndex = 1, Width = 100 };
            var c3 = new ColumnSetting() { DisplayIndex = 2, Width = 200 };
            dg.Columns.Add(new DataGridTemplateColumn() { DisplayIndex = c1.DisplayIndex, Width = c1.Width });
            dg.Columns.Add(new DataGridTemplateColumn() { DisplayIndex = c2.DisplayIndex, Width = c2.Width });
            dg.Columns.Add(new DataGridTemplateColumn() { DisplayIndex = c3.DisplayIndex, Width = c3.Width });

            Setting.SetDataGridColumns(dg);
            var cols = Setting.DataGridColumns;
            var c = cols[0];
            Assert.IsTrue(c1.Equals(c));
            c = cols[1];
            Assert.IsTrue(c2.Equals(c));
            c = cols[2];
            Assert.IsTrue(c3.Equals(c));
        }
Esempio n. 17
0
        public void DataGridColumnsTest()
        {
            var dg = new DataGrid();

            dg.Name = "FDataGrid";
            var c1 = new ColumnSetting()
            {
                DisplayIndex = 0, Width = -1
            };
            var c2 = new ColumnSetting()
            {
                DisplayIndex = 1, Width = 100
            };
            var c3 = new ColumnSetting()
            {
                DisplayIndex = 2, Width = 200
            };

            dg.Columns.Add(new DataGridTemplateColumn()
            {
                DisplayIndex = c1.DisplayIndex, Width = c1.Width
            });
            dg.Columns.Add(new DataGridTemplateColumn()
            {
                DisplayIndex = c2.DisplayIndex, Width = c2.Width
            });
            dg.Columns.Add(new DataGridTemplateColumn()
            {
                DisplayIndex = c3.DisplayIndex, Width = c3.Width
            });

            Setting.SetDataGridColumns(dg);
            var cols = Setting.DataGridColumns;
            var c    = cols[0];

            Assert.IsTrue(c1.Equals(c));
            c = cols[1];
            Assert.IsTrue(c2.Equals(c));
            c = cols[2];
            Assert.IsTrue(c3.Equals(c));
        }
Esempio n. 18
0
 public IEnumerable <string> GetQuickSearchColumnTitleList()
 {
     return(ColumnSetting.JsonToDictionaryList().Where(a => !string.IsNullOrEmpty(a.GetValue("quickSearch")) && a.GetValue("quickSearch").ToLower() == "true")
            .Select(a => a.GetValue("title")));
 }
 private bool ShouldSkipColumnDueToEffortTracking(ColumnSetting column)
 {
     return(column.EffortTracking && !dataLayer.EffortTracking.TrackEffort);
 }
Esempio n. 20
0
 /// <summary>
 /// Add a property-column mapping
 /// </summary>
 /// <param name="propertyName"></param>
 /// <param name="columnName"></param>
 /// <remarks>
 /// The sequence of adding will be the sequence of the column. 
 /// If the columnName is null or string.Empty, the property won't be included in the report unless you set it as a deep copy
 /// </remarks>
 /// <param name="formatString"></param>
 /// <param name="deepCopy"></param>
 private void AddMapping(string propertyName, string columnName, string formatString, bool deepCopy)
 {
     if (PropertyColumnMappings.ContainsKey(propertyName)) {
         PropertyColumnMappings[propertyName].ColumnName = columnName;
         if (string.IsNullOrEmpty(columnName))
             throw new Exception("the property " + propertyName +
                                 " is already adedd, you can't remove it afterwards");
         return;
     }
     int index = -1;
     if (!string.IsNullOrEmpty(columnName)) {
         index = numOfValidMappings;
         numOfValidMappings ++;
     }
     PropertyColumnMappings[propertyName] = new ColumnSetting(columnName, index, formatString, deepCopy);
 }
Esempio n. 21
0
        public void SaveTest()
        {
            // Window情報
            var w = new Window();
            w.Name = "FMainWindow";
            w.Left = 100;
            w.Top = 110;
            w.Width = 320;
            w.Height = 240;

            var r = Setting.MainWindowBounds;
            Assert.IsTrue(w.Left == r.Left);
            Assert.IsTrue(w.Top == r.Top);
            Assert.IsTrue(w.Width == r.Width);
            Assert.IsTrue(w.Height == r.Height);

            // DataGridColumns情報
            var c1 = new ColumnSetting() { DisplayIndex = 0, Width = -2 };
            var c2 = new ColumnSetting() { DisplayIndex = 1, Width = 100 };
            var c3 = new ColumnSetting() { DisplayIndex = 2, Width = 200 };
            var c4 = new ColumnSetting() { DisplayIndex = 3, Width = -1 };
            var c5 = new ColumnSetting() { DisplayIndex = 4, Width = 0 };

            var cols = Setting.DataGridColumns;
            var c = cols[0];
            Assert.IsTrue(c1.Equals(c));
            c = cols[1];
            Assert.IsTrue(c2.Equals(c));
            c = cols[2];
            Assert.IsTrue(c3.Equals(c));
            c = cols[3];
            Assert.IsTrue(c4.Equals(c));
            c = cols[4];
            Assert.IsTrue(c5.Equals(c));
        }
Esempio n. 22
0
        public void SavingDataGridStateActionTest()
        {
            var trigger = new System.Windows.Interactivity.EventTrigger("Closed");
            var trg = new SavingDataGridStateAction();
            trigger.Actions.Add(trg);

            var w = new Window();
            Interaction.GetTriggers(w).Add(trigger);

            var dg = new DataGrid();
            dg.Name = "FDataGrid";
            var c1 = new ColumnSetting() { DisplayIndex = 0, Width = -2 };
            var c2 = new ColumnSetting() { DisplayIndex = 1, Width = 100 };
            var c3 = new ColumnSetting() { DisplayIndex = 2, Width = 200 };
            var c4 = new ColumnSetting() { DisplayIndex = 3, Width = -1 };
            var c5 = new ColumnSetting() { DisplayIndex = 4, Width = 0 };
            dg.Columns.Add(new DataGridTemplateColumn() { DisplayIndex = c1.DisplayIndex, Width = c1.Width });
            dg.Columns.Add(new DataGridTemplateColumn() { DisplayIndex = c2.DisplayIndex, Width = c2.Width });
            dg.Columns.Add(new DataGridTemplateColumn() { DisplayIndex = c3.DisplayIndex, Width = c3.Width });
            dg.Columns.Add(new DataGridTemplateColumn() { DisplayIndex = c4.DisplayIndex, Width = c4.Width });
            dg.Columns.Add(new DataGridTemplateColumn() { DisplayIndex = c5.DisplayIndex, Width = c5.Width });
            trg.Parameter = dg;

            w.ShowDialog();

            var cols = Setting.DataGridColumns;
            var c = cols[0];
            Assert.IsTrue(c1.Equals(c));
            c = cols[1];
            Assert.IsTrue(c2.Equals(c));
            c = cols[2];
            Assert.IsTrue(c3.Equals(c));
            c = cols[3];
            Assert.IsTrue(c4.Equals(c));
            c = cols[4];
            Assert.IsTrue(c5.Equals(c));

            Setting.Save();
        }
 public WorkitemPropertyDescriptor(Entity entity, string name, ColumnSetting settings, Attribute[] attrs, PropertyUpdateSource updateSource)
     : this(entity, name, settings.Attribute, attrs, updateSource)
 {
     readOnly |= settings.ReadOnly;
 }
Esempio n. 24
0
        public void SavingDataGridStateActionTest()
        {
            var trigger = new System.Windows.Interactivity.EventTrigger("Closed");
            var trg     = new SavingDataGridStateAction();

            trigger.Actions.Add(trg);

            var w = new Window();

            Interaction.GetTriggers(w).Add(trigger);

            var dg = new DataGrid();

            dg.Name = "FDataGrid";
            var c1 = new ColumnSetting()
            {
                DisplayIndex = 0, Width = -2
            };
            var c2 = new ColumnSetting()
            {
                DisplayIndex = 1, Width = 100
            };
            var c3 = new ColumnSetting()
            {
                DisplayIndex = 2, Width = 200
            };
            var c4 = new ColumnSetting()
            {
                DisplayIndex = 3, Width = -1
            };
            var c5 = new ColumnSetting()
            {
                DisplayIndex = 4, Width = 0
            };

            dg.Columns.Add(new DataGridTemplateColumn()
            {
                DisplayIndex = c1.DisplayIndex, Width = c1.Width
            });
            dg.Columns.Add(new DataGridTemplateColumn()
            {
                DisplayIndex = c2.DisplayIndex, Width = c2.Width
            });
            dg.Columns.Add(new DataGridTemplateColumn()
            {
                DisplayIndex = c3.DisplayIndex, Width = c3.Width
            });
            dg.Columns.Add(new DataGridTemplateColumn()
            {
                DisplayIndex = c4.DisplayIndex, Width = c4.Width
            });
            dg.Columns.Add(new DataGridTemplateColumn()
            {
                DisplayIndex = c5.DisplayIndex, Width = c5.Width
            });
            trg.Parameter = dg;

            w.ShowDialog();

            var cols = Setting.DataGridColumns;
            var c    = cols[0];

            Assert.IsTrue(c1.Equals(c));
            c = cols[1];
            Assert.IsTrue(c2.Equals(c));
            c = cols[2];
            Assert.IsTrue(c3.Equals(c));
            c = cols[3];
            Assert.IsTrue(c4.Equals(c));
            c = cols[4];
            Assert.IsTrue(c5.Equals(c));

            Setting.Save();
        }
Esempio n. 25
0
        /// <summary>
        /// 生成列
        /// </summary>
        void CreateColumnSetting()
        {
            ColumnSetting columnSetting = new ColumnSetting("Test", "测试列1", true, false, 200);

            columnSetting.CreateHeaderControl += CreateHeaderControlFieldTest;
            columnSetting.CreateItemControl   += CreateItemControlFieldTest;
            columnSetting.DisplayItemValue    += DisplayItem;
            gridView.AppendColumnSetting(columnSetting);


            columnSetting = new ColumnSetting("Test2", "测试列2", false, false, 100);
            columnSetting.CreateHeaderControl += CreateHeaderControlFieldTest;
            columnSetting.CreateItemControl   += CreateItemControlFieldTest1;
            columnSetting.DisplayItemValue    += DisplayItem1;
            gridView.AppendColumnSetting(columnSetting);

            columnSetting = new ColumnSetting("Test3", "测试列3", false, false, 100);
            columnSetting.CreateHeaderControl += CreateHeaderControlFieldTest;
            columnSetting.CreateItemControl   += CreateItemControlFieldTest3;
            columnSetting.DisplayItemValue    += DisplayItem3;
            gridView.AppendColumnSetting(columnSetting);


            columnSetting = new ColumnSetting("Test4", "测试列4", false, false, 100);
            columnSetting.CreateHeaderControl += CreateHeaderControlFieldTest;
            columnSetting.CreateItemControl   += CreateItemControlFieldTest;
            columnSetting.DisplayItemValue    += DisplayItem;
            gridView.AppendColumnSetting(columnSetting);


            columnSetting = new ColumnSetting("Test5", "测试列5", false, false, 100);
            columnSetting.CreateHeaderControl += CreateHeaderControlFieldTest;
            columnSetting.CreateItemControl   += CreateItemControlFieldTest;
            columnSetting.DisplayItemValue    += DisplayItem;
            gridView.AppendColumnSetting(columnSetting);


            columnSetting = new ColumnSetting("Test6", "测试列6", false, false, 100);
            columnSetting.CreateHeaderControl += CreateHeaderControlFieldTest;
            columnSetting.CreateItemControl   += CreateItemControlFieldTest;
            columnSetting.DisplayItemValue    += DisplayItem;
            gridView.AppendColumnSetting(columnSetting);


            columnSetting = new ColumnSetting("Test7", "测试列7", false, false, 100);
            columnSetting.CreateHeaderControl += CreateHeaderControlFieldTest;
            columnSetting.CreateItemControl   += CreateItemControlFieldTest;
            columnSetting.DisplayItemValue    += DisplayItem;
            gridView.AppendColumnSetting(columnSetting);


            columnSetting = new ColumnSetting("Test8", "测试列8", false, false, 100);
            columnSetting.CreateHeaderControl += CreateHeaderControlFieldTest;
            columnSetting.CreateItemControl   += CreateItemControlFieldTest;
            columnSetting.DisplayItemValue    += DisplayItem;
            gridView.AppendColumnSetting(columnSetting);


            columnSetting = new ColumnSetting("Test9", "测试列9", false, false, 100);
            columnSetting.CreateHeaderControl += CreateHeaderControlFieldTest;
            columnSetting.CreateItemControl   += CreateItemControlFieldTest;
            columnSetting.DisplayItemValue    += DisplayItem;
            gridView.AppendColumnSetting(columnSetting);


            columnSetting = new ColumnSetting("Test10", "测试列10", false, false, 100);
            columnSetting.CreateHeaderControl += CreateHeaderControlFieldTest;
            columnSetting.CreateItemControl   += CreateItemControlFieldTest;
            columnSetting.DisplayItemValue    += DisplayItem;
            gridView.AppendColumnSetting(columnSetting);

            gridView.AppendColumnSettingEnd();
        }
Esempio n. 26
0
        /// <summary>
        /// Get the column Name by the property Name, and ensure that the column exists.
        /// </summary>
        /// <param name="propertyName"></param>
        /// <param name="dt"></param>
        /// <returns>the mapped column name if the property is not ignored according to the mapping, otherwise string.empty</returns>
        private ColumnSetting MapTableColumn(string propertyName, DataTable dt)
        {
            ColumnSetting retVal = new ColumnSetting(propertyName,
                                                     Math.Max(dt.Columns.Count, numOfValidMappings),
                                                     DefaultFormatString,
                                                     false);
            if (PropertyColumnMappings.ContainsKey(propertyName))
                retVal = PropertyColumnMappings[propertyName];

            if (retVal.IsShowing && dt.Columns.IndexOf(retVal.ColumnName) < 0) {
                for (int i = dt.Columns.Count; i <= retVal.ColumnIndex; i++)
                    dt.Columns.Add(EMPTY_COLUMN_NAME + i);
                dt.Columns[retVal.ColumnIndex].ColumnName = retVal.ColumnName;
            }

            return retVal;
        }
Esempio n. 27
0
 public IEnumerable <Dictionary <string, object> > GetColumnList()
 {
     return(ColumnSetting.JsonToDictionaryList().OrderBy(a => Convert.ToInt32(
                                                             string.IsNullOrEmpty(a.GetValue("OrderIndex")) ? 0 : Convert.ToInt32(a.GetValue("OrderIndex")))
                                                         ));
 }
Esempio n. 28
0
        public UserProfileSettingsFlyoutViewModel()
        {
            Model = new UserProfileSettingsFlyoutModel();

            Tokens     = Model.ToReactivePropertyAsSynchronized(x => x.Tokens);
            IconSource = new ReactiveProperty <string>("http://localhost/");
            UserId     = Model.ToReactivePropertyAsSynchronized(x => x.UserId);
            ScreenName = Model.ToReactivePropertyAsSynchronized(x => x.ScreenName);

            PivotSelectedIndex = new ReactiveProperty <int>(0);
            PivotSelectedIndex.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x =>
            {
                switch (x)
                {
                case 1:
                    if (!Model.OpenFollowing)
                    {
                        await Model.UpdateFollowing();
                        Model.OpenFollowing = true;
                    }
                    break;

                case 2:
                    if (!Model.OpenFollowers)
                    {
                        await Model.UpdateFollowers();
                        Model.OpenFollowers = true;
                    }
                    break;

                case 3:
                    if (!Model.OpenFavorite)
                    {
                        await Model.UpdateFavorites();
                        Model.OpenFavorite = true;
                    }
                    break;
                }
            });

            UrlEntities            = Model.ObserveProperty(x => x.UrlEntities).ToReactiveProperty();
            DescriptionEntities    = Model.ObserveProperty(x => x.DescriptionEntities).ToReactiveProperty();
            Description            = Model.ObserveProperty(x => x.Description).ToReactiveProperty();
            FavouritesCount        = Model.ObserveProperty(x => x.FavouritesCount).ToReactiveProperty();
            FollowersCount         = Model.ObserveProperty(x => x.FollowersCount).ToReactiveProperty();
            FriendsCount           = Model.ObserveProperty(x => x.FriendsCount).ToReactiveProperty();
            ListedCount            = Model.ObserveProperty(x => x.ListedCount).ToReactiveProperty();
            IsMuting               = Model.ObserveProperty(x => x.IsMuting).Select(x => x ? "" : "").ToReactiveProperty();
            IsProtected            = Model.ObserveProperty(x => x.IsProtected).Select(x => x ? "🔒" : "").ToReactiveProperty();
            IsVerified             = Model.ObserveProperty(x => x.IsVerified).Select(x => x ? "" : "").ToReactiveProperty();
            Location               = Model.ObserveProperty(x => x.Location).ToReactiveProperty();
            ProfileBackgroundColor = Model.ObserveProperty(x => x.ProfileBackgroundColor)
                                     .Select(x => string.IsNullOrWhiteSpace(x) ? "#C0DEED" : "#" + x)
                                     .ToReactiveProperty();
            ProfileBannerUrl = Model.ObserveProperty(x => x.ProfileBannerUrl)
                               .Select(x => string.IsNullOrWhiteSpace(x) ? "http://localhost/" : x + "/1500x500")
                               .ToReactiveProperty();
            ProfileImageUrl = Model.ObserveProperty(x => x.ProfileImageUrl)
                              .Select(x => string.IsNullOrWhiteSpace(x) ? "http://localhost/" : x.Replace("_normal", ""))
                              .ToReactiveProperty();
            StatusesCount = Model.ObserveProperty(x => x.StatusesCount).ToReactiveProperty();
            Url           = Model.ObserveProperty(x => x.Url).ToReactiveProperty();
            Name          = Model.ObserveProperty(x => x.Name).ToReactiveProperty();

            UpdatingStatuses  = Model.ObserveProperty(x => x.UpdatingStatuses).ToReactiveProperty();
            UpdatingFavorites = Model.ObserveProperty(x => x.UpdatingFavorites).ToReactiveProperty();
            UpdatingFollowers = Model.ObserveProperty(x => x.UpdatingFollowers).ToReactiveProperty();
            UpdationFollowing = Model.ObserveProperty(x => x.UpdatingFollowing).ToReactiveProperty();

            IsMyUserProfile = Model.ObserveProperty(x => x.ScreenName)
                              .CombineLatest(Tokens,
                                             (screenName, tokens) =>
            {
                if (tokens == null)
                {
                    return(false);
                }

                return(screenName == tokens.ScreenName);
            })
                              .ToReactiveProperty();

            MuteMenuEnabled = IsMyUserProfile.CombineLatest(Model.ObserveProperty(x => x.IsMuting),
                                                            (isMyProfile, isMuting) => !isMyProfile && !isMuting)
                              .ToReactiveProperty();
            UnmuteMenuEnabled = IsMyUserProfile.CombineLatest(Model.ObserveProperty(x => x.IsMuting),
                                                              (isMyProfile, isMuting) => !isMyProfile && isMuting)
                                .ToReactiveProperty();
            BlockMenuEnabled = IsMyUserProfile.CombineLatest(Model.ObserveProperty(x => x.IsBlocking),
                                                             (isMyProfile, isBlocking) => !isMyProfile && !isBlocking)
                               .ToReactiveProperty();
            UnblockMenuEnabled = IsMyUserProfile.CombineLatest(Model.ObserveProperty(x => x.IsBlocking),
                                                               (isMyProfile, isBlocking) => !isMyProfile && isBlocking)
                                 .ToReactiveProperty();

            OpenUserListEnabled = Tokens
                                  .Select(x => x?.Platform == Models.Twitter.Wrapper.Tokens.PlatformEnum.Twitter)
                                  .ToReactiveProperty();
            OpenUserCollectionEnabled = Tokens
                                        .Select(x => x?.Platform == Models.Twitter.Wrapper.Tokens.PlatformEnum.Twitter)
                                        .ToReactiveProperty();

            FollowButtonText = Model.ObserveProperty(x => x.IsBlocking)
                               .CombineLatest(Model.ObserveProperty(x => x.IsFollowing),
                                              Model.ObserveProperty(x => x.IsFollowRequestSent),
                                              (isBlocking, isFollowing, isFollowRequestSent) =>
            {
                if (isBlocking)
                {
                    return("Blocking");
                }
                if (isFollowing)
                {
                    return("Following");
                }
                if (isFollowRequestSent)
                {
                    return("Reqest Sent");
                }
                return("Follow");
            })
                               .ToReactiveProperty();
            FollowButtonPointerOverText = Model.ObserveProperty(x => x.IsBlocking)
                                          .CombineLatest(Model.ObserveProperty(x => x.IsFollowing),
                                                         Model.ObserveProperty(x => x.IsFollowRequestSent),
                                                         (isBlocking, isFollowing, isFollowRequestSent) =>
            {
                if (isBlocking)
                {
                    return("Unblock");
                }
                if (isFollowing)
                {
                    return("Unfollow");
                }
                if (isFollowRequestSent)
                {
                    return("Cancel Request");
                }
                return("Follow");
            })
                                          .ToReactiveProperty();

            FollowedByText = Model.ObserveProperty(x => x.IsFollowedBy)
                             .CombineLatest(IsMyUserProfile,
                                            (isFollowedBy, isMyUserProfile) =>
            {
                if (isFollowedBy)
                {
                    return(_resourceLoader.GetString("SettingsFlyout_UserProfile_FollowBacked"));
                }
                if (isMyUserProfile)
                {
                    return(_resourceLoader.GetString("SettingsFlyout_UserProfile_ThatsYou"));
                }
                return("");
            })
                             .ToReactiveProperty();

            ClearCommand = new ReactiveCommand();
            ClearCommand.Subscribe(x =>
            {
                PivotSelectedIndex.Value = 0;

                Model.UserId     = 0;
                Model.ScreenName = "";

                Model.OpenFavorite  = false;
                Model.OpenFollowers = false;
                Model.OpenFollowing = false;

                Model.Statuses.Clear();
                Model.Favorites.Clear();
                Model.Following.Clear();
                Model.Followers.Clear();

                Model.UrlEntities            = null;
                Model.DescriptionEntities    = null;
                Model.Description            = "";
                Model.FavouritesCount        = 0;
                Model.FollowersCount         = 0;
                Model.FriendsCount           = 0;
                Model.ListedCount            = 0;
                Model.IsMuting               = false;
                Model.IsProtected            = false;
                Model.IsVerified             = false;
                Model.Location               = "";
                Model.ProfileBackgroundColor = "";
                Model.ProfileBannerUrl       = "";
                Model.ProfileImageUrl        = "";
                Model.StatusesCount          = 0;
                Model.Url  = "";
                Model.Name = "";
                Model.IsFollowRequestSent = false;
                Model.IsFollowing         = false;
                Model.IsFollowedBy        = false;
                Model.IsBlocking          = false;
            });

            UpdateCommand = new ReactiveCommand();
            UpdateCommand.Subscribe(async x =>
            {
                await Model.UpdateUserInfomation();
                await Model.UpdateRelationShip();
                await Model.UpdateStatuses();
            });

            FollowCommand = new ReactiveCommand();
            FollowCommand.SubscribeOn(ThreadPoolScheduler.Default).Subscribe(async x => { await Model.Follow(); });

            BlockUserCommand = new ReactiveCommand();
            BlockUserCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x =>
            {
                var msgNotification = new ConfirmMessageDialogNotification
                {
                    Message = _resourceLoader.GetString("ConfirmDialog_Block"),
                    Title   = "Confirmation"
                };
                await Notice.ShowComfirmMessageDialogMessenger.Raise(msgNotification);

                if (!msgNotification.Result)
                {
                    return;
                }

                await Model.CreateBlock();
            });

            UnblockUserCommand = new ReactiveCommand();
            UnblockUserCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x => { await Model.DestroyBlock(); });

            MuteUserCommand = new ReactiveCommand();
            MuteUserCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x =>
            {
                var msgNotification = new ConfirmMessageDialogNotification
                {
                    Message = _resourceLoader.GetString("ConfirmDialog_Mute"),
                    Title   = "Confirmation"
                };
                await Notice.ShowComfirmMessageDialogMessenger.Raise(msgNotification);

                if (msgNotification.Result)
                {
                    await Model.CreateMute();
                }

                msgNotification = new ConfirmMessageDialogNotification
                {
                    Message = _resourceLoader.GetString("ConfirmDialog_MuteInFlantter"),
                    Title   = "Confirmation"
                };
                await Notice.ShowComfirmMessageDialogMessenger.Raise(msgNotification);

                if (!msgNotification.Result)
                {
                    return;
                }

                if (!AdvancedSettingService.AdvancedSetting.MuteUsers.Contains(Model.ScreenName))
                {
                    AdvancedSettingService.AdvancedSetting.MuteUsers.Add(Model.ScreenName);
                    await AdvancedSettingService.AdvancedSetting.SaveToAppSettings();
                }
            });

            UnmuteUserCommand = new ReactiveCommand();
            UnmuteUserCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x => { await Model.DestroyMute(); });

            StatusesIncrementalLoadCommand = new ReactiveCommand();
            StatusesIncrementalLoadCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x =>
            {
                if (Model.Statuses.Count <= 0)
                {
                    return;
                }

                var id     = Model.Statuses.Last().Id;
                var status = Model.Statuses.Last();
                if (status.HasRetweetInformation)
                {
                    id = status.RetweetInformation.Id;
                }

                await Model.UpdateStatuses(id);
            });

            FavoritesIncrementalLoadCommand = new ReactiveCommand();
            FavoritesIncrementalLoadCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x =>
            {
                if (Model.Favorites.Count <= 0)
                {
                    return;
                }

                var id     = Model.Favorites.Last().Id;
                var status = Model.Favorites.Last();
                if (status.HasRetweetInformation)
                {
                    id = status.RetweetInformation.Id;
                }

                await Model.UpdateFavorites(id);
            });

            FollowersIncrementalLoadCommand = new ReactiveCommand();
            FollowersIncrementalLoadCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x => await Model.UpdateFollowers(true));

            FollowingIncrementalLoadCommand = new ReactiveCommand();
            FollowingIncrementalLoadCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x => await Model.UpdateFollowing(true));

            OpenUserProfileInWebCommand = new ReactiveCommand();
            OpenUserProfileInWebCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x =>
            {
                if (Model.Tokens.Platform == Models.Twitter.Wrapper.Tokens.PlatformEnum.Twitter)
                {
                    await Launcher.LaunchUriAsync(new Uri("https://twitter.com/" + Model.ScreenName));
                }
                else
                {
                    await Launcher.LaunchUriAsync(new Uri("https://" + Model.Tokens.Instance + "/@" + Model.ScreenName));
                }
            });

            AddColumnCommand = new ReactiveCommand();
            AddColumnCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(x =>
            {
                if (string.IsNullOrWhiteSpace(Model.ScreenName))
                {
                    return;
                }

                var columnSetting = new ColumnSetting
                {
                    Action      = SettingSupport.ColumnTypeEnum.UserTimeline,
                    AutoRefresh = false,
                    AutoRefreshTimerInterval = 180.0,
                    Filter                = "()",
                    Name                  = "User : " + Model.ScreenName,
                    Parameter             = Model.UserId.ToString(),
                    Streaming             = false,
                    Index                 = -1,
                    DisableStartupRefresh = false,
                    FetchingNumberOfTweet = 40
                };
                Notice.Instance.AddColumnCommand.Execute(columnSetting);
            });

            Statuses  = Model.Statuses.ToReadOnlyReactiveCollection(x => new StatusViewModel(x, Tokens.Value.UserId));
            Favorites = Model.Favorites.ToReadOnlyReactiveCollection(x => new StatusViewModel(x, Tokens.Value.UserId));
            Followers = Model.Followers.ToReadOnlyReactiveCollection(x => new UserViewModel(x));
            Following = Model.Following.ToReadOnlyReactiveCollection(x => new UserViewModel(x));

            Notice = Notice.Instance;
        }
        public PublicTimelineSettingsFlyoutViewModel()
        {
            Model = new PublicTimelineSettingsFlyoutModel();

            Tokens     = Model.ToReactivePropertyAsSynchronized(x => x.Tokens);
            Type       = Model.ToReactivePropertyAsSynchronized(x => x.Type);
            IconSource = new ReactiveProperty <string>("http://localhost/");

            ClearCommand = new ReactiveCommand();
            ClearCommand.SubscribeOn(ThreadPoolScheduler.Default).Subscribe(x => { Model.PublicTimelineStatuses.Clear(); });

            UpdateCommand = new ReactiveCommand();
            UpdateCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x => { await Model.UpdatePublicTimeline(); });

            RefreshCommand = new ReactiveCommand();
            RefreshCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x => { await Model.UpdatePublicTimeline(clear: false); });

            PublicTimelineIncrementalLoadCommand = new ReactiveCommand();
            PublicTimelineIncrementalLoadCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x =>
            {
                if (Model.PublicTimelineStatuses.Count <= 0)
                {
                    return;
                }

                var id     = Model.PublicTimelineStatuses.Last().Id;
                var status = Model.PublicTimelineStatuses.Last();
                if (status.HasRetweetInformation)
                {
                    id = status.RetweetInformation.Id;
                }

                await Model.UpdatePublicTimeline(id);
            });

            PublicTimelineStatuses =
                Model.PublicTimelineStatuses.ToReadOnlyReactiveCollection(x => new StatusViewModel(x, Tokens.Value.UserId));

            AddColumnCommand = new ReactiveCommand();
            AddColumnCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(x =>
            {
                var columnSetting = new ColumnSetting
                {
                    Action      = Model.Type == "Local" ? SettingSupport.ColumnTypeEnum.Local : SettingSupport.ColumnTypeEnum.Federated,
                    AutoRefresh = false,
                    AutoRefreshTimerInterval = 180.0,
                    Filter                = "()",
                    Name                  = Model.Type,
                    Parameter             = null,
                    Streaming             = true,
                    Index                 = -1,
                    DisableStartupRefresh = false,
                    FetchingNumberOfTweet = 40
                };
                Notice.Instance.AddColumnCommand.Execute(columnSetting);
            });

            Updating = Model.ObserveProperty(x => x.Updating).ToReactiveProperty();

            Notice = Notice.Instance;
        }
Esempio n. 30
0
 private void AddProperty(ColumnSetting column, string prefix)
 {
     dataLayer.AddProperty(column.Attribute, prefix, column.Type == "List" || column.Type == "Multi");
 }
        public SearchSettingsFlyoutViewModel()
        {
            Model = new SearchSettingsFlyoutModel();

            Tokens     = Model.ToReactivePropertyAsSynchronized(x => x.Tokens);
            IconSource = new ReactiveProperty <string>("http://localhost/");

            StatusSearchWords = new ReactiveProperty <string>();
            UserSearchWords   = new ReactiveProperty <string>();

            PivotSelectedIndex = new ReactiveProperty <int>(0);
            PivotSelectedIndex.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x =>
            {
                if (x == 2)
                {
                    await Model.UpdateSavedSearches();
                    await Model.UpdateTrends();
                }
            });

            SavedSearchesScreenName = Model.ObserveProperty(x => x.SavedSearchesScreenName).ToReactiveProperty();
            TrendPlace = Model.ObserveProperty(x => x.TrendsPlace).ToReactiveProperty();

            AdvancedSearchOpen           = new ReactiveProperty <bool>();
            AdvancedSearchContentOpen    = new ReactiveProperty <bool>();
            AdvancedSearchEngagementOpen = new ReactiveProperty <bool>();

            AdvancedSearchContentRetweetsOption    = new ReactiveProperty <int>(0);
            AdvancedSearchContentShowingOption     = new ReactiveProperty <int>(0);
            AdvancedSearchContentWrittenInOption   = new ReactiveProperty <int>(0);
            AdvancedSearchEngagementFavoritesCount = new ReactiveProperty <int>(0);
            AdvancedSearchEngagementRetweetsCount  = new ReactiveProperty <int>(0);

            UpdatingStatusSearch = Model.ObserveProperty(x => x.UpdatingStatusSearch).ToReactiveProperty();
            UpdatingUserSearch   = Model.ObserveProperty(x => x.UpdatingUserSearch).ToReactiveProperty();

            StatusSuggestion = new ReactiveCollection <string>();
            UserSuggestion   = new ReactiveCollection <string>();

            ClearCommand = new ReactiveCommand();
            ClearCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(x =>
            {
                if (AdvancedSearchOpen.Value)
                {
                    AdvancedSearchContentOpen.Value    = false;
                    AdvancedSearchEngagementOpen.Value = false;
                    AdvancedSearchOpen.Value           = false;
                }

                StatusSearchWords.Value = "";
                UserSearchWords.Value   = "";

                PivotSelectedIndex.Value = 0;
                Model.Statuses.Clear();
                Model.Users.Clear();
            });

            UpdateStatusSearchCommand = new ReactiveCommand();
            UpdateStatusSearchCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x =>
            {
                var e = x as AutoSuggestBoxQuerySubmittedEventArgs;
                if (!string.IsNullOrWhiteSpace(e?.QueryText))
                {
                    StatusSearchWords.Value = e.QueryText;
                }

                if (string.IsNullOrWhiteSpace(StatusSearchWords.Value))
                {
                    Model.Statuses.Clear();
                    Model.StatusSearchWords = "";
                    return;
                }

                var searchWords = StatusSearchWords.Value;

                switch (AdvancedSearchContentShowingOption.Value)
                {
                case 1:
                    searchWords += " filter:images";
                    break;

                case 2:
                    searchWords += " filter:videos";
                    break;

                case 3:
                    searchWords += " filter:vine";
                    break;

                case 4:
                    searchWords += " filter:media";
                    break;

                case 5:
                    searchWords += " filter:links";
                    break;
                }

                switch (AdvancedSearchContentWrittenInOption.Value)
                {
                case 1:
                    searchWords += " lang:en";
                    break;

                case 2:
                    searchWords += " lang:ja";
                    break;
                }

                switch (AdvancedSearchContentRetweetsOption.Value)
                {
                case 1:
                    searchWords += " exclude:retweets";
                    break;
                }

                if (AdvancedSearchEngagementRetweetsCount.Value != 0)
                {
                    searchWords += " min_retweets:" + AdvancedSearchEngagementRetweetsCount.Value.ToString();
                }

                if (AdvancedSearchEngagementFavoritesCount.Value != 0)
                {
                    searchWords += " min_faves:" + AdvancedSearchEngagementFavoritesCount.Value.ToString();
                }

                if (Model.StatusSearchWords == searchWords)
                {
                    await Model.UpdateStatuses(clear: false);
                }
                else
                {
                    Model.StatusSearchWords = searchWords;
                    await Model.UpdateStatuses();
                }
            });

            UpdateUserSearchCommand = new ReactiveCommand();
            UpdateUserSearchCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x =>
            {
                var e = x as AutoSuggestBoxQuerySubmittedEventArgs;
                if (!string.IsNullOrWhiteSpace(e?.QueryText))
                {
                    UserSearchWords.Value = e.QueryText;
                }

                if (string.IsNullOrWhiteSpace(UserSearchWords.Value))
                {
                    Model.Users.Clear();
                    Model.UserSearchWords = "";
                    return;
                }

                Model.UserSearchWords = UserSearchWords.Value;

                await Model.UpdateUsers();
            });

            TextChangedStatusSearchCommand = new ReactiveCommand();
            TextChangedStatusSearchCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(y =>
            {
                var e = y as AutoSuggestBoxTextChangedEventArgs;
                if (e == null || string.IsNullOrWhiteSpace(StatusSearchWords.Value))
                {
                    StatusSuggestion.ClearOnScheduler();
                    return;
                }

                IEnumerable <string> suggestHashtags;
                lock (Connecter.Instance.TweetCollecter[Tokens.Value.UserId].EntitiesObjectsLock)
                {
                    suggestHashtags = Connecter.Instance.TweetCollecter[Tokens.Value.UserId]
                                      .HashTagObjects.Where(x => x.StartsWith(StatusSearchWords.Value.TrimStart('#')))
                                      .OrderBy(x => x).Select(x => "#" + x);
                }
                if (suggestHashtags.Any())
                {
                    StatusSuggestion.ClearOnScheduler();
                    StatusSuggestion.AddRangeOnScheduler(suggestHashtags);
                }
                else
                {
                    StatusSuggestion.ClearOnScheduler();
                }
            });

            TextChangedUserSearchCommand = new ReactiveCommand();
            TextChangedUserSearchCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(y =>
            {
                var e = y as AutoSuggestBoxTextChangedEventArgs;
                if (e == null || string.IsNullOrWhiteSpace(UserSearchWords.Value) &&
                    UserSearchWords.Value.Length <= 1)
                {
                    UserSuggestion.ClearOnScheduler();
                    return;
                }

                IEnumerable <string> suggestUsers;
                lock (Connecter.Instance.TweetCollecter[Tokens.Value.UserId].EntitiesObjectsLock)
                {
                    suggestUsers = Connecter.Instance.TweetCollecter[Tokens.Value.UserId]
                                   .ScreenNameObjects.Where(x => x.StartsWith(UserSearchWords.Value.TrimStart('@')))
                                   .OrderBy(x => x);
                }
                if (suggestUsers.Any())
                {
                    UserSuggestion.ClearOnScheduler();
                    UserSuggestion.AddRangeOnScheduler(suggestUsers);
                }
                else
                {
                    UserSuggestion.ClearOnScheduler();
                }
            });

            SaveSearchCommand = new ReactiveCommand();
            SaveSearchCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x =>
            {
                if (string.IsNullOrWhiteSpace(Model.StatusSearchWords))
                {
                    return;
                }

                await Model.CreateSavedSearches(Model.StatusSearchWords);
            });

            DeleteHistoryCommand = new ReactiveCommand();
            DeleteHistoryCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(x =>
            {
                var manager = new SearchSuggestionManager();
                manager.ClearHistory();
            });

            StatusesIncrementalLoadCommand = new ReactiveCommand();
            StatusesIncrementalLoadCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x =>
            {
                if (Model.Statuses.Count <= 0)
                {
                    return;
                }

                var id     = Model.Statuses.Last().Id;
                var status = Model.Statuses.Last();
                if (status.HasRetweetInformation)
                {
                    id = status.RetweetInformation.Id;
                }

                await Model.UpdateStatuses(id);
            });

            UsersIncrementalLoadCommand = new ReactiveCommand();
            UsersIncrementalLoadCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x => { await Model.UpdateUsers(true); });

            SavedSearchesSelectCommand = new ReactiveCommand();
            SavedSearchesSelectCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(x =>
            {
                var e = x as ItemClickEventArgs;
                if (e == null)
                {
                    return;
                }

                var searchQuery         = e.ClickedItem as SearchQueryViewModel;
                StatusSearchWords.Value = searchQuery.Model.Name;

                UpdateStatusSearchCommand.Execute();

                PivotSelectedIndex.Value = 0;
            });

            TrendsSelectCommand = new ReactiveCommand();
            TrendsSelectCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(x =>
            {
                var e = x as ItemClickEventArgs;
                if (e == null)
                {
                    return;
                }

                var trend = e.ClickedItem as TrendViewModel;
                StatusSearchWords.Value = trend.Model.Name;

                UpdateStatusSearchCommand.Execute();

                PivotSelectedIndex.Value = 0;
            });

            Notice.Instance.SearchSettingsFlyoutDeleteSearchQueryCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(async x =>
            {
                var searchQuery = x as SearchQueryViewModel;
                if (searchQuery == null || searchQuery.Model.Id == 0)
                {
                    return;
                }

                await Model.DestroySavedSearches(searchQuery.Model.Id);
            });

            AdvancedSearchCommand = new ReactiveCommand();
            AdvancedSearchCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(_ =>
            {
                if (AdvancedSearchOpen.Value)
                {
                    AdvancedSearchContentOpen.Value    = false;
                    AdvancedSearchEngagementOpen.Value = false;
                }
                AdvancedSearchOpen.Value = !AdvancedSearchOpen.Value;
            });
            AdvancedSearchContentCommand = new ReactiveCommand();
            AdvancedSearchContentCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(_ => AdvancedSearchContentOpen.Value = !AdvancedSearchContentOpen.Value);
            AdvancedSearchEngagementCommand = new ReactiveCommand();
            AdvancedSearchEngagementCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(_ => AdvancedSearchEngagementOpen.Value = !AdvancedSearchEngagementOpen.Value);

            AddColumnCommand = new ReactiveCommand();
            AddColumnCommand.SubscribeOn(ThreadPoolScheduler.Default)
            .Subscribe(x =>
            {
                if (string.IsNullOrWhiteSpace(Model.StatusSearchWords))
                {
                    return;
                }

                var columnSetting = new ColumnSetting
                {
                    Action      = SettingSupport.ColumnTypeEnum.Search,
                    AutoRefresh = false,
                    AutoRefreshTimerInterval = 180.0,
                    Filter                = "()",
                    Name                  = "Search : " + Model.StatusSearchWords,
                    Parameter             = Model.StatusSearchWords,
                    Streaming             = false,
                    Index                 = -1,
                    DisableStartupRefresh = false,
                    FetchingNumberOfTweet = 40
                };
                Notice.Instance.AddColumnCommand.Execute(columnSetting);
            });

            Statuses      = Model.Statuses.ToReadOnlyReactiveCollection(x => new StatusViewModel(x, Tokens.Value.UserId));
            Users         = Model.Users.ToReadOnlyReactiveCollection(x => new UserViewModel(x));
            Trends        = Model.Trends.ToReadOnlyReactiveCollection(x => new TrendViewModel(x));
            SavedSearches = Model.SavedSearches.ToReadOnlyReactiveCollection(x => new SearchQueryViewModel(x));

            Notice = Notice.Instance;
        }