示例#1
0
 /// <summary>
 /// Adds the fork to the list of group-by forks
 /// </summary>
 /// <param name="forkName">Name of the fork.</param>
 public void AddGroupByFork(string forkName)
 {
     if (!GroupByForks.Contains(forkName))
     {
         GroupByForks.Add(forkName);
     }
     GroupsEnabled = true;
 }
示例#2
0
 public void SelecteClasses(IList <ClassificationSearchResultContractV2> objects)
 {
     foreach (var item in objects)
     {
         if (!_selectedClasses.Contains(item))
         {
             _selectedClasses.Add(item);
         }
     }
     UpdateSelecedClassesNotice();
 }
示例#3
0
        public SettingViewModel()
        {
            Languages    = new BindableCollection <string>();
            _langCodeDic = new Dictionary <string, string>();
            _langDic     = new Dictionary <string, string>();

            string        langfolder = Environment.CurrentDirectory + "\\Strings";
            DirectoryInfo dir        = new DirectoryInfo(langfolder);

            FileInfo[] files = dir.GetFiles("*.xml");  // 获取语言资源文件夹下的所有xml

            for (int i = 0; i < files.Length; i++)
            {
                string   path = files[i].FullName;
                XElement lang = XElement.Load(path);
                if (!lang.Name.LocalName.Equals("language"))
                {
                    continue;
                }
                XAttribute name = lang.Attribute(XName.Get("name"));
                XAttribute tag  = lang.Attribute(XName.Get("tag"));
                if (name == null || tag == null)
                {
                    continue;
                }

                // 加入语言列表
                Languages.Add(name.Value);
                _langCodeDic.Add(tag.Value, name.Value);
                _langDic.Add(name.Value, path);
            }

            // 程序内嵌入简体中文和英文
            // 如果语言资源文件夹下有相应资源
            // 就使用文件夹下资源而不是程序内的
            string zh = "简体中文";
            string en = "English";

            if (!Languages.Contains(zh))
            {
                Languages.Add(zh);
                _langCodeDic.Add("zh-CN", zh);
                _langDic.Add(zh, "pack://application:,,,/Resources/Strings/zh-CN.xml");
            }
            if (!Languages.Contains(en))
            {
                Languages.Add(en);
                _langCodeDic.Add("en-US", en);
                _langDic.Add(en, "pack://application:,,,/Resources/Strings/en-US.xml");
            }
        }
        public void RegisterTask(IRunningAction action)
        {
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            if (!runningActions.Contains(action))
            {
                runningActions.Insert(0, action);
                OnRunningActionRegistered(action);
                NotifyOfPropertyChange("HasRunningActions");
            }
        }
        /// <summary>
        /// Adds in order to a list of strings if input string is not on the list, assuming all strings
        /// are formatted using version numbers or ip addresses (xxx.xxx.xxx.xxx)
        /// </summary>
        /// <param name="stringList">in-out string list</param>
        /// <param name="newString">new string to be added</param>
        void AddInOrder(BindableCollection <string> stringList, string newString)
        {
            if (stringList.Contains(newString))
            {
                return;
            }

            Version newStringVersion = new Version(newString);

            int i = 0;

            while (i < stringList.Count - 1 && new Version(stringList[i]).CompareTo(newStringVersion) >= 0)
            {
                i++;
            }

            if (i <= stringList.Count - 1)
            {
                stringList.Insert(i, newString);
            }
            else
            {
                stringList.Add(newString);
            }
        }
示例#6
0
        public bool CheckAnswers()
        {
            BindableCollection <AnswerModel> selectedAnswers = new BindableCollection <AnswerModel>();
            BindableCollection <AnswerModel> correctAnswers  = this.CorrectAnswers();

            foreach (AnswerModel answer in this.Answers)
            {
                if (answer.IsSelected)
                {
                    selectedAnswers.Add(answer);
                }
            }
            foreach (AnswerModel answer in selectedAnswers)
            {
                if (correctAnswers.Contains(answer))
                {
                    correctAnswers.Remove(answer);
                }
                else
                {
                    return(false);
                }
            }
            if (correctAnswers.Any())
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        private void BindParameterValuesForPort(string portName)
        {
            var port = serialPortDefinitions.First(x => x.PortName == portName);

            BaudRates        = new BindableCollection <int>(port.SupportedBaudRates);
            SelectedBaudRate = BaudRates.Contains(9600) ? 9600 : BaudRates.First();

            DataBits         = new BindableCollection <int>(port.SupportedDataBits);
            SelectedDataBits = DataBits.Contains(8) ? 8 : DataBits.First();

            Parities       = new BindableCollection <Parity>(port.SupportedParityTypes);
            SelectedParity = Parities.Contains(Parity.None) ? Parity.None : Parities.First();

            StopBits         = new BindableCollection <StopBits>(port.SupportedStopBits);
            SelectedStopBits = StopBits.Contains(System.IO.Ports.StopBits.One) ? System.IO.Ports.StopBits.One : StopBits.First();
        }
        //Utility methods
        /// <summary>
        /// Adds in order to a list of ints if input int is not on the list
        /// </summary>
        /// <param name="intList">in-out list where the new integer is added</param>
        /// <param name="newInt">new integer to be added to the list</param>
        void AddInOrder(BindableCollection <int> intList, int newInt)
        {
            if (intList.Contains(newInt))
            {
                return;
            }

            int i = 0;

            while (i < intList.Count - 1 && intList[i] >= newInt)
            {
                i++;
            }

            if (i <= intList.Count - 1)
            {
                intList.Insert(i, newInt);
            }
            else
            {
                intList.Add(newInt);
            }
        }
示例#9
0
        public void Drop(IDropInfo dropInfo)
        {
            if (dropInfo.TargetItem == dropInfo.Data)
            {
                return;
            }

            ModuleOrderModuleViewModel viewModel = (ModuleOrderModuleViewModel)dropInfo.Data;
            BindableCollection <ModuleOrderModuleViewModel> targetCollection = (BindableCollection <ModuleOrderModuleViewModel>)dropInfo.TargetCollection;
            int insertIndex = dropInfo.InsertIndex;

            ModulePriorityCategory category;

            if (targetCollection == NormalModules)
            {
                category = ModulePriorityCategory.Normal;
            }
            else if (targetCollection == ApplicationModules)
            {
                category = ModulePriorityCategory.Application;
            }
            else
            {
                category = ModulePriorityCategory.Overlay;
            }

            // If moving down, take the removal of ourselves into consideration with the insert index
            if (targetCollection.Contains(viewModel) && targetCollection.IndexOf(viewModel) < insertIndex)
            {
                insertIndex--;
            }

            _moduleService.UpdateModulePriority(viewModel.Module, category, insertIndex);

            Update();
        }
示例#10
0
        private void SetupControls()
        {
            var dataModelProps = _layerEditorViewModel.DataModelProps;

            Name = _property + ":";

            // Populate target combobox
            Targets = new BindableCollection <GeneralHelpers.PropertyCollection>
            {
                new GeneralHelpers.PropertyCollection {
                    Display = "None"
                }
            };
            Targets.AddRange(dataModelProps.Where(p => (p.Type == "Int32") || (p.Type == "Single")));

            // Populate sources combobox
            Sources = new BindableCollection <GeneralHelpers.PropertyCollection>();
            Sources.AddRange(dataModelProps.Where(p => (p.Type == "Int32") || (p.Type == "Single")));

            // Preselect according to the model
            SelectedTarget    = dataModelProps.FirstOrDefault(p => p.Path == Proposed.GameProperty);
            SelectedSource    = dataModelProps.FirstOrDefault(p => p.Path == Proposed.PercentageProperty);
            LayerPropertyType = Proposed.LayerPropertyType;

            // Populate the extra options combobox
            switch (_property)
            {
            case "Width":
                LayerPropertyOptions = new BindableCollection <LayerPropertyOptions>
                {
                    Artemis.Profiles.Layers.Models.LayerPropertyOptions.LeftToRight,
                    Artemis.Profiles.Layers.Models.LayerPropertyOptions.RightToLeft
                };
                break;

            case "Height":
                LayerPropertyOptions = new BindableCollection <LayerPropertyOptions>
                {
                    Artemis.Profiles.Layers.Models.LayerPropertyOptions.Downwards,
                    Artemis.Profiles.Layers.Models.LayerPropertyOptions.Upwards
                };
                break;

            case "Opacity":
                LayerPropertyOptions = new BindableCollection <LayerPropertyOptions>
                {
                    Artemis.Profiles.Layers.Models.LayerPropertyOptions.Increase,
                    Artemis.Profiles.Layers.Models.LayerPropertyOptions.Decrease
                };
                break;
            }

            UserSourceIsVisible = LayerPropertyType == LayerPropertyType.PercentageOf;
            SourcesIsVisible    = LayerPropertyType == LayerPropertyType.PercentageOfProperty;

            // Set up a default for SelectedTarget if it was null
            if (SelectedTarget.Display == null)
            {
                SelectedTarget = Targets.FirstOrDefault();
            }
            // Set up a default for the extra option if it fell outside the range
            if (!LayerPropertyOptions.Contains(Proposed.LayerPropertyOptions))
            {
                Proposed.LayerPropertyOptions = LayerPropertyOptions.FirstOrDefault();
            }
        }
示例#11
0
		private void AfterUpdate(NameAndCount[] collectionDocumentsCount)
		{
            // update documents count

		    var nameToCount = collectionDocumentsCount.OrderByDescending(count => count.Count).ToDictionary(i => i.Name, i => i.Count);
		    var collections = Collections.OrderByDescending(model => model.Count).ToList();
            Collections = new BindableCollection<CollectionModel>(model => model.Name);
		    foreach (var collectionModel in collections)
		    {
		        Collections.Add(collectionModel);
		    }
		    
		    foreach (var collectionModel in Collections)
		    {
		        collectionModel.Count = nameToCount[collectionModel.Name];
		    }

			if (initialSelectedDatabaseName != null &&
				(SelectedCollection.Value == null || SelectedCollection.Value.Name != initialSelectedDatabaseName || Collections.Contains(SelectedCollection.Value) == false))
			{
				SelectedCollection.Value = Collections.FirstOrDefault(x => x.Name == initialSelectedDatabaseName);
			}

			if (SelectedCollection.Value == null)
				SelectedCollection.Value = Collections.FirstOrDefault();

            OnPropertyChanged(() => Collections);
		}
        private void SetupControls()
        {
            var dataModelProps = _layerEditorViewModel.DataModelProps;
            Name = _property + ":";

            // Populate target combobox
            Targets = new BindableCollection<GeneralHelpers.PropertyCollection>
            {
                new GeneralHelpers.PropertyCollection {Display = "None"}
            };
            Targets.AddRange(dataModelProps.Where(p => (p.Type == "Int32") || (p.Type == "Single")));

            // Populate sources combobox
            Sources = new BindableCollection<GeneralHelpers.PropertyCollection>();
            Sources.AddRange(dataModelProps.Where(p => (p.Type == "Int32") || (p.Type == "Single")));

            // Preselect according to the model
            SelectedTarget = dataModelProps.FirstOrDefault(p => p.Path == Proposed.GameProperty);
            SelectedSource = dataModelProps.FirstOrDefault(p => p.Path == Proposed.PercentageProperty);
            LayerPropertyType = Proposed.LayerPropertyType;

            // Populate the extra options combobox
            switch (_property)
            {
                case "Width":
                    LayerPropertyOptions = new BindableCollection<LayerPropertyOptions>
                    {
                        Artemis.Profiles.Layers.Models.LayerPropertyOptions.LeftToRight,
                        Artemis.Profiles.Layers.Models.LayerPropertyOptions.RightToLeft
                    };
                    break;
                case "Height":
                    LayerPropertyOptions = new BindableCollection<LayerPropertyOptions>
                    {
                        Artemis.Profiles.Layers.Models.LayerPropertyOptions.Downwards,
                        Artemis.Profiles.Layers.Models.LayerPropertyOptions.Upwards
                    };
                    break;
                case "Opacity":
                    LayerPropertyOptions = new BindableCollection<LayerPropertyOptions>
                    {
                        Artemis.Profiles.Layers.Models.LayerPropertyOptions.Increase,
                        Artemis.Profiles.Layers.Models.LayerPropertyOptions.Decrease
                    };
                    break;
            }

            UserSourceIsVisible = LayerPropertyType == LayerPropertyType.PercentageOf;
            SourcesIsVisible = LayerPropertyType == LayerPropertyType.PercentageOfProperty;

            // Set up a default for SelectedTarget if it was null
            if (SelectedTarget.Display == null)
                SelectedTarget = Targets.FirstOrDefault();
            // Set up a default for the extra option if it fell outside the range
            if (!LayerPropertyOptions.Contains(Proposed.LayerPropertyOptions))
                Proposed.LayerPropertyOptions = LayerPropertyOptions.FirstOrDefault();
        }
示例#13
0
        private void AfterUpdate(NameAndCount[] collectionDocumentsCount)
        {
            // update documents count

            var nameToCount = collectionDocumentsCount.OrderByDescending(count => count.Count).ToDictionary(i => i.Name, i => i.Count);
            var collections = Collections.OrderByDescending(model => model.Count).ToList();

            Collections = new BindableCollection <CollectionModel>(model => model.Name);
            foreach (var collectionModel in collections)
            {
                Collections.Add(collectionModel);
            }

            foreach (var collectionModel in Collections)
            {
                collectionModel.Count = nameToCount[collectionModel.Name];
            }

            if (initialSelectedDatabaseName != null &&
                (SelectedCollection.Value == null || SelectedCollection.Value.Name != initialSelectedDatabaseName || Collections.Contains(SelectedCollection.Value) == false))
            {
                SelectedCollection.Value = Collections.FirstOrDefault(x => x.Name == initialSelectedDatabaseName);
            }

            if (SelectedCollection.Value == null)
            {
                SelectedCollection.Value = Collections.FirstOrDefault();
            }

            OnPropertyChanged(() => Collections);
        }
示例#14
0
        public void LoadLayout(XmlReader xmlReader)
        {
            if (shellView != null && shellView.DockingManager != null)
            {
                Execute.OnUIThreadEx(() =>
                {
                    var layoutSerializer = new XmlLayoutSerializer(shellView.DockingManager);
                    //Here I've implemented the LayoutSerializationCallback just to show
                    // a way to feed layout desarialization with content loaded at runtime
                    //Actually I could in this case let AvalonDock to attach the contents
                    //from current layout using the content ids
                    //LayoutSerializationCallback should anyway be handled to attach contents
                    //not currently loaded
                    layoutSerializer.LayoutSerializationCallback += (s, e) =>
                    {
                        var contentId = e.Model.ContentId;
                        //if no content id is available or the content has already been found we dont bother loading it
                        if (string.IsNullOrEmpty(contentId) || e.Content != null)
                        {
                            return;
                        }

                        //restore the documents and sinks
                        var uri = new Uri(contentId);
                        if (uri.Scheme == "file")
                        {
                            e.Content = CShell.Shell.GetDocument(uri, true);
                        }
                        if (uri.Scheme == "sink")
                        {
                            e.Content = CShell.Shell.GetSink(uri, true);  //do not open sink
                        }
                        //make sure that the document is part of the shells items
                        var doc = e.Content as IDocument;
                        if (doc != null)
                        {
                            EnsureItem(doc);
                        }

                        //restore the tools
                        if (uri.Scheme == "tool")
                        {
                            e.Content = CShell.Shell.GetTool(uri, true);
                        }
                        var tool = e.Content as ITool;
                        if (tool != null && !_tools.Contains(tool))
                        {
                            _tools.Add(tool);
                        }
                    };
                    try
                    {
                        layoutSerializer.Deserialize(xmlReader);
                    }
                    catch (Exception ex)
                    {
                        //no big deal if the layout cannot be restored, there can be a few reasons, we just log the error and move on
                        // one reason is if there is no layout element in the xml
                        log.Error(ex);
                    }
                });
            }
        }//end method