private void ExtrasViewLoaded(object sender, RoutedEventArgs e)
 {
     var vm = (ExtrasViewModel) DataContext;
     var cvsAvailable = Resources["cvsAvailableExtras"] as CollectionViewSource;
     var c = new CompositeCollection();
     c.Add(new CollectionContainer {Collection = vm.StatusHandlers});
     c.Add(new CollectionContainer {Collection = vm.UrlShorteners});
     cvsAvailable.Source = c;
 }
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        // create the new CompositeCollectionView for a CompositeCollection
        internal CompositeCollectionView(CompositeCollection collection)
            : base(collection, -1 /* don't move to first */)    // base.ctor also subscribes to CollectionChanged event of CompositeCollection
        {
            _collection = collection;
            _collection.ContainedCollectionChanged += new NotifyCollectionChangedEventHandler(OnContainedCollectionChanged);

            // Do the equivalent of MoveCurrentToFirst(), without calling virtuals
            int currentPosition = PrivateIsEmpty ? -1 : 0;
            int count = PrivateIsEmpty ? 0 : 1;
            SetCurrent(GetItem(currentPosition, out _currentPositionX, out _currentPositionY), currentPosition, count);
        }
        public ParameterViewModel()
        {
            coll = new CompositeCollection();
            settings = DataContainer.NeuralNetwork.Settings;
            PropertyInfo[] props = settings.GetType().GetProperties();
            foreach(PropertyInfo prop in props)
            {
                ObservableCollection<dynamic> tempcoll = new ObservableCollection<dynamic>();
                tempcoll.Add(prop.GetValue(settings));
                coll.Add(new CollectionContainer() { Collection = tempcoll });

            }
        }
        private void AccountsView_Loaded(object sender, RoutedEventArgs e)
        {
            var vm = (AccountsViewModel) DataContext;
            var cvsAvailable = Resources["cvsAvailableAccounts"] as CollectionViewSource;
            var c = new CompositeCollection();
            c.Add(new CollectionContainer {Collection = vm.NewMicroblogs});
            cvsAvailable.Source = c;

            var cvsCurrent = Resources["cvsCurrentAccounts"] as CollectionViewSource;
            c = new CompositeCollection();
            c.Add(new CollectionContainer {Collection = vm.PluginRepository.Microblogs});
            cvsCurrent.Source = c;
        }
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            var compositeCollection = new CompositeCollection();
            foreach (var value in values)
            {
                var enumerable = value as IEnumerable;
                if (enumerable != null)
                {
                    compositeCollection.Add(new CollectionContainer { Collection = enumerable });
                }
                else
                {
                    compositeCollection.Add(value);
                }
            }

            return compositeCollection;
        }
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            var res = new CompositeCollection();

            foreach (var item in values)
            {
                if (item is IEnumerable)
                {
                    res.Add(new CollectionContainer()
                    {
                        Collection = item as IEnumerable
                    });
                }
                else
                {
                    res.Add(item);
                }
            }

            return res;
        }
        private void DefineCellsPane_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (this.DataContext == null || !(this.DataContext is WorkbookModel)) return;

            var myWorkbookModel = this.DataContext as WorkbookModel;
            var defineCellsCollection = new CompositeCollection();

            #region collection containers
            var inputCellsCContoiner = new CollectionContainer()
            {
                Collection = myWorkbookModel.InputCells
            };
            defineCellsCollection.Add(inputCellsCContoiner);

            var intermediateCellsCContainer = new CollectionContainer()
            {
                Collection = myWorkbookModel.IntermediateCells
            };
            defineCellsCollection.Add(intermediateCellsCContainer);

            var outputCellsCContainer = new CollectionContainer()
            {
                Collection = myWorkbookModel.OutputCells
            };
            defineCellsCollection.Add(outputCellsCContainer);

            #endregion

            var defineCellsBinding = new Binding()
            {
                Source = defineCellsCollection,
                Mode = BindingMode.OneWay
            };

            this.CellDefinitionsList.SetBinding(ListBox.ItemsSourceProperty, defineCellsBinding);
        }
        /// <summary>
        /// Updates the Selector control's <see cref="ItemsControl.ItemsSource"/> to include the
        /// <see cref="NullItem"/> along with the objects in <see cref="ItemsSource"/>.
        /// </summary>
        protected void Adapt()
        {
            if (CollectionView != null)
            {
                CollectionView.CurrentChanged -= CollectionView_CurrentChanged;
                CollectionView = null;
            }
            if (Selector != null && ItemsSource != null)
            {
                CompositeCollection comp = new CompositeCollection();
                comp.Add(NullItem);
                comp.Add(new CollectionContainer { Collection = ItemsSource });

                CollectionView = CollectionViewSource.GetDefaultView(comp);
                if (CollectionView != null) CollectionView.CurrentChanged += CollectionView_CurrentChanged;

                Selector.ItemsSource = comp;
            }
        }
        public SurfaceWindow1ViewModel()
        {
            _allObjectsCollection = new CompositeCollection();

            _chromosomeBarViewModel = new ChromosomeBarViewModel(_genBankProvider, this);
            _chromosomeBarViewModel.NewGeneSelected += new GeneSelectedHandler((gene) => OnPropertyChanged("SelectedGene"));

            _testSVIViewModel = new TestSVIViewModel();
            _extendedDesktopViewModel = new ExtendedDesktopViewModel(this);
            _primerDesignerViewModel = new PrimerDesignerViewModel(this);

            _allObjectsCollection.Add(_chromosomeBarViewModel);
            //_allObjectsCollection.Add(_testSVIViewModel);
            _allObjectsCollection.Add(_extendedDesktopViewModel);
            _allObjectsCollection.Add(PersistentSearchMenu);
        }
        public NetworkDrawingViewModel()
        {
            rendercoll = new CompositeCollection();
            tracklines = new ObservableCollection<Track>();
            OCPcollection = new ObservableCollection<OCP>();
            switchcollection = new ObservableCollection<Switch>();
            penscale = 1;
            for(int i = 0; i < DataContainer.model.infrastructure.tracks.Count; i++)
            {
                Track temptrack = new Track();
                eTrack track = DataContainer.model.infrastructure.tracks[i];
                if (track.trackTopology.trackEnd.geoCoord.coord.Count != 0 && track.trackTopology.trackBegin.geoCoord.coord.Count != 0)
                {

                    temptrack.track = track;
                    temptrack.index = i;
                    temptrack.X1 = track.trackTopology.trackBegin.geoCoord.coord[0];
                    temptrack.X2 = track.trackTopology.trackEnd.geoCoord.coord[0];
                    temptrack.Y1 = track.trackTopology.trackBegin.geoCoord.coord[1];
                    temptrack.Y2 = track.trackTopology.trackEnd.geoCoord.coord[1];

                    temptrack.points.Add(new Point(track.trackTopology.trackBegin.geoCoord.coord[0],track.trackTopology.trackBegin.geoCoord.coord[1]));

                    foreach(tPlacedElement point in track.trackElements.geoMappings)
                    {
                        temptrack.points.Add(new Point(point.geoCoord.coord[0], point.geoCoord.coord[1]));
                    }
                    temptrack.points.Add(new Point(track.trackTopology.trackEnd.geoCoord.coord[0], track.trackTopology.trackEnd.geoCoord.coord[1]));

                    tracklines.Add(temptrack);

                    foreach(tCommonSwitchAndCrossingData connection in track.trackTopology.connections)
                    {
                        if (connection.geoCoord.coord.Count == 2)
                        {
                            Switch sw = new Switch();
                            sw.element = connection;
                            sw.X = connection.geoCoord.coord[0];
                            sw.Y = connection.geoCoord.coord[1];
                            switchcollection.Add(sw);
                        }
                    }

                }

            }

            foreach(eOcp ocp in DataContainer.model.infrastructure.operationControlPoints)
            {
                OCP tempocp = new OCP();
                tempocp.ocp = ocp;
                if (ocp.geoCoord.coord.Count == 2)
                {
                    tempocp.X = ocp.geoCoord.coord[0] - tempocp.diameter / 2;
                    tempocp.Y = ocp.geoCoord.coord[1] - tempocp.diameter / 2;
                    OCPcollection.Add(tempocp);
                }
            }
            rendercoll.Add(new CollectionContainer(){Collection = tracklines});
            rendercoll.Add(new CollectionContainer() { Collection = OCPcollection });
            rendercoll.Add(new CollectionContainer() {Collection = switchcollection});
        }
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            //var collection = NodeNetwork.Instance.FirstCollection;

            //if (collection == NodeNetwork.CollectionType.Cells)
            //{
            //    var res = new CompositeCollection
            //    {
            //        new CollectionContainer
            //        {
            //            Collection = values[3] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[2] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[1] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[0] as IEnumerable
            //        }
            //    };

            //    return res;
            //}

            //if (collection == NodeNetwork.CollectionType.Sink)
            //{
            //    var res = new CompositeCollection
            //    {
            //        new CollectionContainer
            //        {
            //            Collection = values[0] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[3] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[2] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[1] as IEnumerable
            //        }
            //    };

            //    return res;
            //}

            //if (collection == NodeNetwork.CollectionType.Nodes)
            //{
            //    var res = new CompositeCollection
            //    {
            //        new CollectionContainer
            //        {
            //            Collection = values[0] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[3] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[1] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[2] as IEnumerable
            //        }
            //    };

            //    return res;
            //}

            //if (collection == NodeNetwork.CollectionType.NodeLinks)
            //{
            //    var res = new CompositeCollection
            //    {
            //        new CollectionContainer
            //        {
            //            Collection = values[0] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[1] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[2] as IEnumerable
            //        },
            //        new CollectionContainer
            //        {
            //            Collection = values[3] as IEnumerable
            //        }
            //    };

            //    return res;
            //}

            var res = new CompositeCollection();

            foreach (var item in values)
            {
                if (item is IEnumerable)
                {
                    res.Add(new CollectionContainer
                    {
                        Collection = item as IEnumerable
                    });
                }
                else
                {
                    if (item is SinkViewModel)
                        res.Add(item);
                }
            }

            return res;
        }
        private void ScenarioDetailPane_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (this.DataContext == null || !(this.DataContext is Scenario)) return;

            var myScenario = this.DataContext as Scenario;

            //update bindings
            #region binding definitions
            var titleBinding = new Binding()
            {
                Source = myScenario,
                Path = new PropertyPath("Title"),
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };

            var authorBinding = new Binding()
            {
                Source = myScenario,
                Path = new PropertyPath("Author"),
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };

            var creationDateBinding = new Binding()
            {
                Source = myScenario,
                Path = new PropertyPath("CrationDate"),
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };

            var ratingBinding = new Binding()
            {
                Source = myScenario,
                Path = new PropertyPath("Rating"),
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };

            var descriptionBinding = new Binding()
            {
                Source = myScenario,
                Path = new PropertyPath("Description"),
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };

            #endregion

            #region set bindings
            //task pane title
            this.PaneTitle.SetBinding(TextBlock.TextProperty, titleBinding);

            //general
            #region general
            //title
            this.TitleTextBox.SetBinding(TextBox.TextProperty, titleBinding);

            //author
            this.AuthorTextbox.SetBinding(TextBox.TextProperty, authorBinding);

            //creation date
            this.CreateDatePicker.SetBinding(DatePicker.SelectedDateProperty, creationDateBinding);

            //rating
            this.RatingTextBox.SetBinding(TextBox.TextProperty, ratingBinding);

            #endregion

            //description
            this.DescriptionTextBox.SetBinding(TextBox.TextProperty, descriptionBinding);
            
            // input, intermediate and result cells data
            ScenarioDataCollection = new CompositeCollection();

            #region collection container
            var inputDataCContainer = new CollectionContainer()
            {
                Collection = (this.DataContext as Scenario).Inputs
            };
            ScenarioDataCollection.Add(inputDataCContainer);

            var intermediateCContainer = new CollectionContainer()
            {
                Collection = (this.DataContext as Scenario).Intermediates
            };
            ScenarioDataCollection.Add(intermediateCContainer);

            var resultDataCContainer = new CollectionContainer()
            {
                Collection = (this.DataContext as Scenario).Results
            };
            ScenarioDataCollection.Add(resultDataCContainer);
            #endregion

            /*this.ScenarioDataView = new ListCollectionView(scenarioDataCollection);
            this.ScenarioDataView.SortDescriptions.Add(new SortDescription("Location", ListSortDirection.Ascending));*/
            this.ScenarioDataListBox.ItemsSource = ScenarioDataCollection;

            #endregion
        }
Exemple #13
0
        internal virtual void ShowContextMenu(Card card)
        {
            if (Player.LocalPlayer.Spectator)
                return;
            // Modify selection
            if (card == null || !card.Selected) Selection.Clear();

            var menuItems = new CompositeCollection();            
            ContextGroup = group;
            ContextMenu = new ContextMenu {ItemsSource = menuItems, Tag = card};
            // card has to captured somehow, otherwise it may be overwritten before released in the OnClosed handler, e.g. when rightclicking on a card, then directly right-clicking on another card.
            ContextMenu.Opened += (sender, args) =>
                                      {
                                          ContextGroup.KeepControl();
                                          var c = ((ContextMenu) sender).Tag as Card;
                                          if (c != null) c.KeepControl();
                                      };
            ContextMenu.Closed += (sender, args) =>
                                      {
                                          ContextGroup.ReleaseControl();
                                          var c = ((ContextMenu) sender).Tag as Card;
                                          if (c != null) c.ReleaseControl();
                                      };

            ContextCard = card;
            menuItems.Clear();

            if (card != null)
            {
                //var cardMenuItems = await CreateCardMenuItems(card, group.Definition);
                var cardMenuItems = CreateCardMenuItems(card, group.Definition);
                var container = new CollectionContainer { Collection = cardMenuItems };
                menuItems.Add(container);
            }

            if (ShouldShowGroupActions(card))
            {
              var container = new CollectionContainer { Collection = CreateGroupMenuItems(group.Definition) };
              menuItems.Add(container);
            }
            //else // Group is being shuffled
            //    return;

            ContextMenu.IsOpen = false;
            // Required to trigger the ReleaseControl calls if the ContextMenu was already open
            ContextMenu.UpdateLayout(); // Required if the ContextMenu was already open
            ContextMenu.IsOpen = true;
            ContextMenu.FontFamily = groupFont;
            ContextMenu.FontSize = fontsize;
        }
        /// <summary>
        /// Updates the Selector control's <see cref="ItemsControl.ItemsSource"/> to include the
        /// <see cref="NullItem"/> along with the objects in <see cref="ItemsSource"/>.
        /// </summary>
        protected void Adapt()
        {
            //if (CollectionView != null)
            //{
            //    CollectionView.CurrentChanged -= CollectionView_CurrentChanged;
            //    CollectionView = null;
            //}

            if (Selector != null)
            {
                //if (ItemsSource is System.Collections.Specialized.INotifyCollectionChanged)
                //{
                //    var col = ItemsSource as System.Collections.Specialized.INotifyCollectionChanged;
                //    col.CollectionChanged -= ItemsSource_CollectionChanged;
                //    col.CollectionChanged += ItemsSource_CollectionChanged;
                //}

                CompositeCollection comp = new CompositeCollection();
                if (ItemsSource != null)
                {
                    comp.Add(new CollectionContainer { Collection = ItemsSource });
                }

                //comp.Add(new CollectionContainer { Collection = new string[] { "(None)" } });
                if (NullItems != null)
                {
                    foreach (var item in NullItems)
                    {
                        if (IsAddingNullItemsFirst)
                            comp.Insert(0, item);
                        else
                            comp.Add(item);
                    }
                }

                //CollectionView = CollectionViewSource.GetDefaultView(comp);
                //if (CollectionView != null) CollectionView.CurrentChanged += CollectionView_CurrentChanged;

                Selector.ItemsSource = comp;
            }
        }
        private void GetPath(Path obj)
        {
            Connects = new ObservableCollection<Connector>();

            Points = new ObservableCollection<Point>(
                obj.Points.Select(x => new Point()
                    {
                        X = ((x.From.X < 0) ? Math.Abs(Math.Abs(x.From.X) - 4096) : Math.Abs(x.From.X) + 4096),
                        Y = ((x.From.Z > 0) ? Math.Abs(Math.Abs(x.From.Z) - 5632) : Math.Abs(x.From.Z) + 5632)
                    })
            );

            for(int i = 0; i < Points.Count - 1; i++)
                Connects.Add(new Connector()
                {
                    StartPoint = Points[i],
                    EndPoint = Points[i+1]
                });

            Connects.Add(new Connector()
            {
                StartPoint = Points[Points.Count - 1],
                EndPoint = Points[0]
            });

            Collection = new CompositeCollection()
            {
                new CollectionContainer() { Collection = Points },
                new CollectionContainer() { Collection = Connects }
            };
        }
Exemple #16
0
        internal virtual void ShowContextMenu(Card card, bool showGroupActions = true)
        {
            // Modify selection
            if (card == null || !card.Selected) Selection.Clear();

            var menuItems = new CompositeCollection();            
            ContextGroup = group;
            ContextMenu = new ContextMenu {ItemsSource = menuItems, Tag = card};
            // card has to captured somehow, otherwise it may be overwritten before released in the OnClosed handler, e.g. when rightclicking on a card, then directly right-clicking on another card.
            ContextMenu.Opened += (sender, args) =>
                                      {
                                          ContextGroup.KeepControl();
                                          var c = ((ContextMenu) sender).Tag as Card;
                                          if (c != null) c.KeepControl();
                                      };
            ContextMenu.Closed += (sender, args) =>
                                      {
                                          ContextGroup.ReleaseControl();
                                          var c = ((ContextMenu) sender).Tag as Card;
                                          if (c != null) c.ReleaseControl();
                                      };

            ContextCard = card;
            menuItems.Clear();

            if (group.CanManipulate())
            {
                if (card != null)
                {
                    if (card.CanManipulate())
                    {
                        if (_cardHeader != null)
                        {
                            _cardHeader.Header = card.Name;
                            _cardHeader.Background = card.Controller.TransparentBrush;
                            menuItems.Add(_cardMenu);
                        }
                    }
                    else
                    {
                        var item = new MenuItem {Header = card.Name, Background = card.Controller.TransparentBrush};
                        item.SetResourceReference(StyleProperty, "MenuHeader");
                        menuItems.Add(item);

                        item = new MenuItem {Header = "Take control"};
                        item.Click += delegate { card.TakeControl(); };
                        menuItems.Add(item);
                    }

                    if (!card.FaceUp)
                    {
                        var peekItem = new MenuItem {Header = "Peek", InputGestureText = "Ctrl+P"};
                        peekItem.Click += delegate { ContextCard.Peek(); };
                        if (menuItems.Count == 0)
                        {
                            var item = new MenuItem {Header = card.Name, Background = card.Owner.TransparentBrush};
                            item.SetResourceReference(StyleProperty, "MenuHeader");
                            menuItems.Add(item);
                        }
                        menuItems.Add(peekItem);
                    }
                }

                if (showGroupActions)
                    menuItems.Add(_groupMenu);
            }
            else// if (!group.WantToShuffle)
            {
                menuItems.Add(CreateGroupHeader());

                var item = new MenuItem {Header = "Take control"};
                item.Click += delegate { group.TakeControl(); };
                menuItems.Add(item);

                menuItems.Add(new Separator());
                item = CreateLookAtCardsMenuItem();
                if (item != null) menuItems.Add(item);
            }
            //else // Group is being shuffled
            //    return;

            ContextMenu.IsOpen = false;
            // Required to trigger the ReleaseControl calls if the ContextMenu was already open
            ContextMenu.UpdateLayout(); // Required if the ContextMenu was already open
            ContextMenu.IsOpen = true;
            ContextMenu.FontFamily = groupFont;
            ContextMenu.FontSize = fontsize;
        }
Exemple #17
0
 private void OnPluginTabSelected()
 {
     var plugins = new CompositeCollection
     {
         new CollectionContainer
         {
             Collection = PluginManager.AllPlugins
         }
     };
     lbPlugins.ItemsSource = plugins;
     lbPlugins.SelectedIndex = 0;
 }
        public RoutineBuilder(Routine routine)
        {
            //View initialization
            InitializeComponent();
            LivePreview = false;
            //Initialize Routine
            _routine = routine;
            _routine.RoutineBuilder = this;
            tbxRoutineName.Text = _routine.Name;
            this.Title = _routine.Name;
            //Build Canvas toolbar - drawing shapes icons
            toolbarButtons = new List<ToggleButton>();
            toolbarButtons.Add(btnToolbarMove);
            toolbarButtons.Add(btnToolbarArc);
            toolbarButtons.Add(btnToolbarCircle);
            toolbarButtons.Add(btnToolbarDot);
            toolbarButtons.Add(btnToolbarLine);
            toolbarButtons.Add(btnToolbarPolyline);
            toolbarButtons.Add(btnToolbarRectangle);
            toolbarButtons.Add(btnToolbarReferencePoint);
            toolbarButtons.Add(btnToolbarAttrPoint);
            _activeTool = null;
            _drawing = false;
            _movingShape = false;
            _movingReferencePoint = false;
            _movingAttributePoint = false;
            _makingPath = false;
            _makingPathStep2 = false;
            attributePointPopup = new AttributePointPopup();
            //Build "Add Fixture" popup
            addFixturePop = new AddFixturePopup();
            addFixturePop.AddSelectedClick += new RoutedEventHandler(SubroutineBuilder_AddSelectedClick);

            //Initialize Timeline
            CollectionContainer items = new CollectionContainer();
            items.Collection = _routine.RoutineFixtures;
            CollectionContainer newFixtureLineCollection = new CollectionContainer();
            BindingList<string> newFixtureLine = new BindingList<string>();
            newFixtureLine.Add("Click here to add a fixture...");
            newFixtureLineCollection.Collection = newFixtureLine;

            CompositeCollection cmpc = new CompositeCollection();
            cmpc.Add(items);
            cmpc.Add(newFixtureLineCollection);

            lbxTimeline.ItemsSource = cmpc;
            //lbxTimeline.ItemsSource = _routine.RoutineFixtures;
            _lastSelectedFixture = null;

            //Step items list. necessary?
            lbxSteps.ItemsSource = null;

            //Reference Point list.
            lbxReferencePoints.ItemsSource = null;
        }
        private void Setting_Loaded(object sender, RoutedEventArgs ev)
        {
            ctlHotkey.OnHotkeyChanged += ctlHotkey_OnHotkeyChanged;
            ctlHotkey.SetHotkey(UserSettingStorage.Instance.Hotkey, false);

            cbHideWhenDeactive.Checked += (o, e) =>
            {
                UserSettingStorage.Instance.HideWhenDeactive = true;
                UserSettingStorage.Instance.Save();
            };

            cbHideWhenDeactive.Unchecked += (o, e) =>
            {
                UserSettingStorage.Instance.HideWhenDeactive = false;
                UserSettingStorage.Instance.Save();
            };

            lvCustomHotkey.ItemsSource = UserSettingStorage.Instance.CustomPluginHotkeys;
            cbStartWithWindows.IsChecked = File.Exists(woxLinkPath);
            cbHideWhenDeactive.IsChecked = UserSettingStorage.Instance.HideWhenDeactive;

            #region Load Theme

            if (!string.IsNullOrEmpty(UserSettingStorage.Instance.QueryBoxFont) &&
                Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(UserSettingStorage.Instance.QueryBoxFont)) > 0)
            {
                cbQueryBoxFont.Text = UserSettingStorage.Instance.QueryBoxFont;

                cbQueryBoxFontFaces.SelectedItem = SyntaxSugars.CallOrRescueDefault(() => ((FontFamily)cbQueryBoxFont.SelectedItem).ConvertFromInvariantStringsOrNormal(
                    UserSettingStorage.Instance.QueryBoxFontStyle,
                    UserSettingStorage.Instance.QueryBoxFontWeight,
                    UserSettingStorage.Instance.QueryBoxFontStretch
                    ));
            }
            if (!string.IsNullOrEmpty(UserSettingStorage.Instance.ResultItemFont) &&
                Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(UserSettingStorage.Instance.ResultItemFont)) > 0)
            {
                cbResultItemFont.Text = UserSettingStorage.Instance.ResultItemFont;

                cbResultItemFontFaces.SelectedItem = SyntaxSugars.CallOrRescueDefault(() => ((FontFamily)cbResultItemFont.SelectedItem).ConvertFromInvariantStringsOrNormal(
                    UserSettingStorage.Instance.ResultItemFontStyle,
                    UserSettingStorage.Instance.ResultItemFontWeight,
                    UserSettingStorage.Instance.ResultItemFontStretch
                    ));
            }
            resultPanelPreview.AddResults(new List<Result>()
            {
                new Result()
                {
                    Title = "Wox is an effective launcher for windows",
                    SubTitle = "Wox provide bundles of features let you access infomations quickly.",
                    IcoPath = "Images/work.png",
                    PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath)
                },
                new Result()
                {
                    Title = "Search applications",
                    SubTitle = "Search applications, files (via everything plugin) and browser bookmarks",
                    IcoPath = "Images/work.png",
                    PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath)
                },
                new Result()
                {
                    Title = "Search web contents with shortcuts",
                    SubTitle = "e.g. search google with g keyword or youtube keyword)",
                    IcoPath = "Images/work.png",
                    PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
                },
                new Result()
                {
                    Title = "clipboard history ",
                    IcoPath = "Images/work.png",
                    PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
                },
                new Result()
                {
                    Title = "Themes support",
                    SubTitle = "get more themes from http://www.getwox.com/theme",
                    IcoPath = "Images/work.png",
                    PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
                },
                new Result()
                {
                    Title = "Plugins support",
                    SubTitle = "get more plugins from http://www.getwox.com/plugin",
                    IcoPath = "Images/work.png",
                    PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
                },
                new Result()
                {
                    Title = "Wox is an open-source software",
                    SubTitle = "Wox benefits from the open-source community a lot",
                    IcoPath = "Images/work.png",
                    PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
                }
            });

            foreach (string theme in LoadAvailableThemes())
            {
                string themeName = System.IO.Path.GetFileNameWithoutExtension(theme);
                themeComboBox.Items.Add(themeName);
            }

            themeComboBox.SelectedItem = UserSettingStorage.Instance.Theme;
            slOpacity.Value = UserSettingStorage.Instance.Opacity;
            CbOpacityMode.SelectedItem = UserSettingStorage.Instance.OpacityMode;

            var wallpaper = WallpaperPathRetrieval.GetWallpaperPath();
            if (wallpaper != null && File.Exists(wallpaper))
            {
                var brush = new ImageBrush(new BitmapImage(new Uri(wallpaper)));
                brush.Stretch = Stretch.UniformToFill;
                PreviewPanel.Background = brush;
            }
            else
            {
                var wallpaperColor = WallpaperPathRetrieval.GetWallpaperColor();
                PreviewPanel.Background = new SolidColorBrush(wallpaperColor);
            }
            #endregion

            #region Load Plugin

            var plugins = new CompositeCollection
            {
                new CollectionContainer
                {
                    Collection =
                        PluginLoader.Plugins.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.System)
                            .Select(o => o.Plugin)
                            .Cast<ISystemPlugin>()
                },
                FindResource("FeatureBoxSeperator"),
                new CollectionContainer
                {
                    Collection =
                        PluginLoader.Plugins.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.ThirdParty)
                }
            };
            lbPlugins.ItemsSource = plugins;
            lbPlugins.SelectedIndex = 0;

            #endregion

            #region Proxy

            cbEnableProxy.Checked += (o, e) => EnableProxy();
            cbEnableProxy.Unchecked += (o, e) => DisableProxy();
            cbEnableProxy.IsChecked = UserSettingStorage.Instance.ProxyEnabled;
            tbProxyServer.Text = UserSettingStorage.Instance.ProxyServer;
            tbProxyPort.Text = UserSettingStorage.Instance.ProxyPort.ToString();
            tbProxyUserName.Text = UserSettingStorage.Instance.ProxyUserName;
            tbProxyPassword.Password = UserSettingStorage.Instance.ProxyPassword;
            if (UserSettingStorage.Instance.ProxyEnabled)
            {
                EnableProxy();
            }
            else
            {
                DisableProxy();
            }

            #endregion

            //PreviewPanel
            settingsLoaded = true;
            App.Window.SetTheme(UserSettingStorage.Instance.Theme);
        }
Exemple #20
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var sourceClass = value as TagClass;
            if (sourceClass == null)
                return null;

            //hax 2 tha max
            var nullTag = new TagEntry(null, null, "(null)");

            var tagList = new CompositeCollection();
            tagList.Add(nullTag);

            var mainTagListContainer = new CollectionContainer();
            mainTagListContainer.Collection = sourceClass.Children;

            tagList.Add(mainTagListContainer);

            return tagList;
        }
 internal FlatteningEnumerator(CompositeCollection collection, CompositeCollectionView view)
 {
     Invariant.Assert(collection != null && view != null);
     _collection = collection;
     _view = view;
     _version = view._version;
     Reset();
 }
Exemple #22
0
 private void InitProject()
 {
     ModulesView = new CompositeCollection {
         App.Project,
         new CollectionContainer { Collection = App.Project.Modules }
     };
     OnPropertyChanged("ModulesView");
     HasPacker = App.Project.Packer != null;
 }