コード例 #1
0
        public static void ReloadSystemConfig()
        {
            bool wasRunning = Execution.IsOpen;

            Execution.CloseExecution();

            // purge all existing elements, nodes, and controllers (to try and clean up a bit).
            // might not actually matter, since we're going to make new Managers for them all
            // in a tick, but better safe than sorry.
            foreach (ElementNode cn in Nodes.ToArray())
            {
                Nodes.RemoveNode(cn, null, true);
            }
            foreach (OutputController oc in OutputControllers.ToArray())
            {
                OutputControllers.Remove(oc);
            }
            foreach (SmartOutputController smartOutputController in SmartOutputControllers.ToArray())
            {
                SmartOutputControllers.Remove(smartOutputController);
            }
            foreach (OutputPreview outputPreview in Previews.ToArray())
            {
                Previews.Remove(outputPreview);
            }

            LoadSystemConfig();

            if (wasRunning)
            {
                Execution.OpenExecution();
            }
        }
コード例 #2
0
        internal override IEnumerator LoadPreview(string path)
        {
            if (!File.Exists(path))
            {
                yield break;
            }

            byte[] textureByte = File.ReadAllBytes(path);
            yield return(textureByte);

            if (null == textureByte)
            {
                _assetsToLoad--;
                yield break;
            }
            Texture2D texture = KKAPI.Utilities.TextureUtils.LoadTexture(textureByte);

            yield return(texture);

            Texture2D preview = new Texture2D(texture.width, texture.height, texture.format, false);

            Graphics.CopyTexture(texture, preview);
            Util.ResizeTexture(preview, 64, 64);
            Previews.Add(preview);
            TexturePaths.Add(path);
            texture = null;
            _assetsToLoad--;
        }
コード例 #3
0
 public bool DeepEquals(ContentTypeDescription?other)
 {
     return(other is not null &&
            CType == other.CType &&
            Name == other.Name &&
            ContentDescription == other.ContentDescription &&
            PreviewImage == other.PreviewImage &&
            Priority == other.Priority &&
            Reminder == other.Reminder &&
            Properties.DeepEqualsList(other.Properties) &&
            TagMetadata.DeepEqualsList(other.TagMetadata) &&
            TagMetadataItems.DeepEqualsDictionary(other.TagMetadataItems) &&
            UsageExamples.DeepEqualsListNaive(other.UsageExamples) &&
            ShowInContentEditor == other.ShowInContentEditor &&
            TypeOf == other.TypeOf &&
            BindIdentifierToProperty == other.BindIdentifierToProperty &&
            BoundRegex == other.BoundRegex &&
            ForceIdentifierBinding == other.ForceIdentifierBinding &&
            AllowComments == other.AllowComments &&
            AutoEnglishPropertyFallback == other.AutoEnglishPropertyFallback &&
            BulkUploadable == other.BulkUploadable &&
            Previews.DeepEqualsList(other.Previews) &&
            SuppressCmsPath == other.SuppressCmsPath &&
            PropertySections.DeepEqualsList(other.PropertySections));
 }
コード例 #4
0
 private void Loaded(IList <RecipeDescriptionDto> rec)
 {
     foreach (var descriptionDto in rec)
     {
         Previews.Add(new PreviewViewModel(descriptionDto.Id, descriptionDto.Title, descriptionDto.PreviewUrl));
     }
 }
コード例 #5
0
        private void UpdatePreviews()
        {
            if (AlphaPreviews == null || NonAlphaPreviews == null)
            {
                return;
            }

            Previews.Clear();
            Previews.AddRange(ShowAlphaPreviews ? AlphaPreviews : NonAlphaPreviews);
            OnPropertyChanged(nameof(Preview));
        }
コード例 #6
0
        void Nodes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                foreach (var item in e.NewItems)
                {
                    if (item != null && item is NodeModel)
                    {
                        var node = item as NodeModel;

                        var nodeViewModel = new NodeViewModel(node);
                        _nodes.Add(nodeViewModel);
                        Errors.Add(nodeViewModel.ErrorBubble);
                        Previews.Add(nodeViewModel.PreviewBubble);
                    }
                }
                break;

            case NotifyCollectionChangedAction.Reset:
                _nodes.Clear();
                Errors.Clear();
                Previews.Clear();
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (var item in e.OldItems)
                {
                    var           node          = item as NodeModel;
                    NodeViewModel nodeViewModel = _nodes.First(x => x.NodeLogic == item);
                    Previews.Remove(nodeViewModel.PreviewBubble);
                    Errors.Remove(nodeViewModel.ErrorBubble);
                    _nodes.Remove(nodeViewModel);
                }
                break;
            }
        }
コード例 #7
0
 public static string GetMaxPhotoUrl(this Previews previews)
 {
     if (previews.Photo400 != null)
     {
         return(previews.Photo400.AbsoluteUri);
     }
     if (previews.Photo200 != null)
     {
         return(previews.Photo200.AbsoluteUri);
     }
     if (previews.Photo130 != null)
     {
         return(previews.Photo130.AbsoluteUri);
     }
     if (previews.Photo100 != null)
     {
         return(previews.Photo100.AbsoluteUri);
     }
     if (previews.Photo50 != null)
     {
         return(previews.Photo50.AbsoluteUri);
     }
     return(previews.PhotoMax.AbsoluteUri);
 }
コード例 #8
0
        public bool Equals(ContentTypeDescription input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     CType == input.CType ||
                     (CType != null && CType.Equals(input.CType))
                     ) &&
                 (
                     Name == input.Name ||
                     (Name != null && Name.Equals(input.Name))
                 ) &&
                 (
                     ContentDescription == input.ContentDescription ||
                     (ContentDescription != null && ContentDescription.Equals(input.ContentDescription))
                 ) &&
                 (
                     PreviewImage == input.PreviewImage ||
                     (PreviewImage != null && PreviewImage.Equals(input.PreviewImage))
                 ) &&
                 (
                     Priority == input.Priority ||
                     (Priority.Equals(input.Priority))
                 ) &&
                 (
                     Reminder == input.Reminder ||
                     (Reminder != null && Reminder.Equals(input.Reminder))
                 ) &&
                 (
                     Properties == input.Properties ||
                     (Properties != null && Properties.SequenceEqual(input.Properties))
                 ) &&
                 (
                     TagMetadata == input.TagMetadata ||
                     (TagMetadata != null && TagMetadata.SequenceEqual(input.TagMetadata))
                 ) &&
                 (
                     TagMetadataItems == input.TagMetadataItems ||
                     (TagMetadataItems != null && TagMetadataItems.SequenceEqual(input.TagMetadataItems))
                 ) &&
                 (
                     UsageExamples == input.UsageExamples ||
                     (UsageExamples != null && UsageExamples.SequenceEqual(input.UsageExamples))
                 ) &&
                 (
                     ShowInContentEditor == input.ShowInContentEditor ||
                     (ShowInContentEditor != null && ShowInContentEditor.Equals(input.ShowInContentEditor))
                 ) &&
                 (
                     TypeOf == input.TypeOf ||
                     (TypeOf != null && TypeOf.Equals(input.TypeOf))
                 ) &&
                 (
                     BindIdentifierToProperty == input.BindIdentifierToProperty ||
                     (BindIdentifierToProperty != null && BindIdentifierToProperty.Equals(input.BindIdentifierToProperty))
                 ) &&
                 (
                     BoundRegex == input.BoundRegex ||
                     (BoundRegex != null && BoundRegex.Equals(input.BoundRegex))
                 ) &&
                 (
                     ForceIdentifierBinding == input.ForceIdentifierBinding ||
                     (ForceIdentifierBinding != null && ForceIdentifierBinding.Equals(input.ForceIdentifierBinding))
                 ) &&
                 (
                     AllowComments == input.AllowComments ||
                     (AllowComments != null && AllowComments.Equals(input.AllowComments))
                 ) &&
                 (
                     AutoEnglishPropertyFallback == input.AutoEnglishPropertyFallback ||
                     (AutoEnglishPropertyFallback != null && AutoEnglishPropertyFallback.Equals(input.AutoEnglishPropertyFallback))
                 ) &&
                 (
                     BulkUploadable == input.BulkUploadable ||
                     (BulkUploadable != null && BulkUploadable.Equals(input.BulkUploadable))
                 ) &&
                 (
                     Previews == input.Previews ||
                     (Previews != null && Previews.SequenceEqual(input.Previews))
                 ) &&
                 (
                     SuppressCmsPath == input.SuppressCmsPath ||
                     (SuppressCmsPath != null && SuppressCmsPath.Equals(input.SuppressCmsPath))
                 ) &&
                 (
                     PropertySections == input.PropertySections ||
                     (PropertySections != null && PropertySections.SequenceEqual(input.PropertySections))
                 ));
        }
コード例 #9
0
 public void Update(ContentTypeDescription?other)
 {
     if (other is null)
     {
         return;
     }
     if (CType != other.CType)
     {
         CType = other.CType;
         OnPropertyChanged(nameof(CType));
     }
     if (Name != other.Name)
     {
         Name = other.Name;
         OnPropertyChanged(nameof(Name));
     }
     if (ContentDescription != other.ContentDescription)
     {
         ContentDescription = other.ContentDescription;
         OnPropertyChanged(nameof(ContentDescription));
     }
     if (PreviewImage != other.PreviewImage)
     {
         PreviewImage = other.PreviewImage;
         OnPropertyChanged(nameof(PreviewImage));
     }
     if (Priority != other.Priority)
     {
         Priority = other.Priority;
         OnPropertyChanged(nameof(Priority));
     }
     if (Reminder != other.Reminder)
     {
         Reminder = other.Reminder;
         OnPropertyChanged(nameof(Reminder));
     }
     if (!Properties.DeepEqualsList(other.Properties))
     {
         Properties = other.Properties;
         OnPropertyChanged(nameof(Properties));
     }
     if (!TagMetadata.DeepEqualsList(other.TagMetadata))
     {
         TagMetadata = other.TagMetadata;
         OnPropertyChanged(nameof(TagMetadata));
     }
     if (!TagMetadataItems.DeepEqualsDictionary(other.TagMetadataItems))
     {
         TagMetadataItems = other.TagMetadataItems;
         OnPropertyChanged(nameof(TagMetadataItems));
     }
     if (!UsageExamples.DeepEqualsListNaive(other.UsageExamples))
     {
         UsageExamples = other.UsageExamples;
         OnPropertyChanged(nameof(UsageExamples));
     }
     if (ShowInContentEditor != other.ShowInContentEditor)
     {
         ShowInContentEditor = other.ShowInContentEditor;
         OnPropertyChanged(nameof(ShowInContentEditor));
     }
     if (TypeOf != other.TypeOf)
     {
         TypeOf = other.TypeOf;
         OnPropertyChanged(nameof(TypeOf));
     }
     if (BindIdentifierToProperty != other.BindIdentifierToProperty)
     {
         BindIdentifierToProperty = other.BindIdentifierToProperty;
         OnPropertyChanged(nameof(BindIdentifierToProperty));
     }
     if (BoundRegex != other.BoundRegex)
     {
         BoundRegex = other.BoundRegex;
         OnPropertyChanged(nameof(BoundRegex));
     }
     if (ForceIdentifierBinding != other.ForceIdentifierBinding)
     {
         ForceIdentifierBinding = other.ForceIdentifierBinding;
         OnPropertyChanged(nameof(ForceIdentifierBinding));
     }
     if (AllowComments != other.AllowComments)
     {
         AllowComments = other.AllowComments;
         OnPropertyChanged(nameof(AllowComments));
     }
     if (AutoEnglishPropertyFallback != other.AutoEnglishPropertyFallback)
     {
         AutoEnglishPropertyFallback = other.AutoEnglishPropertyFallback;
         OnPropertyChanged(nameof(AutoEnglishPropertyFallback));
     }
     if (BulkUploadable != other.BulkUploadable)
     {
         BulkUploadable = other.BulkUploadable;
         OnPropertyChanged(nameof(BulkUploadable));
     }
     if (!Previews.DeepEqualsList(other.Previews))
     {
         Previews = other.Previews;
         OnPropertyChanged(nameof(Previews));
     }
     if (SuppressCmsPath != other.SuppressCmsPath)
     {
         SuppressCmsPath = other.SuppressCmsPath;
         OnPropertyChanged(nameof(SuppressCmsPath));
     }
     if (!PropertySections.DeepEqualsList(other.PropertySections))
     {
         PropertySections = other.PropertySections;
         OnPropertyChanged(nameof(PropertySections));
     }
 }
コード例 #10
0
        public async Task LoadImage(string path)
        {
            bool testing = false;  // Set to true to load mips single threaded and only the full image instead of a smaller one first.

            Task <List <object> > fullLoadingTask = null;

            if (!testing)
            {
                // Load full size image
                ////////////////////////////////////////////////////////////////////////////////////////
                fullLoadingTask = Task.Run(() =>
                {
                    ImageEngineImage fullimage = new ImageEngineImage(path);

                    List <BitmapSource> alphas    = new List <BitmapSource>();
                    List <BitmapSource> nonalphas = new List <BitmapSource>();

                    for (int i = 0; i < fullimage.NumMipMaps; i++)
                    {
                        alphas.Add(fullimage.GeneratePreview(i, true));
                        nonalphas.Add(fullimage.GeneratePreview(i, false));
                    }

                    List <object> bits = new List <object>();
                    bits.Add(fullimage);
                    bits.Add(alphas);
                    bits.Add(nonalphas);
                    return(bits);
                });
                ////////////////////////////////////////////////////////////////////////////////////////
            }



            SaveSuccess = null;
            Previews.Clear();
            savePreviews = new BitmapSource[2];
            SavePath     = null;
            SaveFormat   = ImageEngineFormat.Unknown;

            stopwatch.Start();



            ////////////////////////////////////////////////////////////////////////////////////////
            if (testing)
            {
                img = await Task.Run(() => new ImageEngineImage(path));
            }
            else
            {
                img = await Task.Run(() => new ImageEngineImage(path, 256, false));
            }
            ////////////////////////////////////////////////////////////////////////////////////////



            Console.WriteLine("");
            Console.WriteLine($"Format: {img.Format}");
            stopwatch.Stop();
            Console.WriteLine($"Image Loading: {stopwatch.ElapsedMilliseconds}");
            stopwatch.Restart();

            Previews.Add(img.GeneratePreview(0, ShowAlphaPreviews));
            MipIndex = 1;  // 1 based

            stopwatch.Stop();
            Debug.WriteLine($"Image Preview: {stopwatch.ElapsedMilliseconds}");
            stopwatch.Reset();

            OnPropertyChanged(nameof(ImagePath));
            OnPropertyChanged(nameof(Format));
            OnPropertyChanged(nameof(NumMipMaps));
            OnPropertyChanged(nameof(Preview));
            OnPropertyChanged(nameof(MipWidth));
            OnPropertyChanged(nameof(MipHeight));

            // KFreon: Get full image details
            ////////////////////////////////////////////////////////////////////////////////////////
            if (!testing)
            {
                List <object> FullImageObjects = await fullLoadingTask;
                double?       oldMipWidth      = MipWidth;
                img = (ImageEngineImage)FullImageObjects[0];

                AlphaPreviews    = (List <BitmapSource>)FullImageObjects[1];
                NonAlphaPreviews = (List <BitmapSource>)FullImageObjects[2];

                UpdatePreviews();

                // KFreon: Set selected mip index

                /*for (int i = 0; i < Previews.Count; i++)
                 * {
                 *  if (Previews[i].Width == oldMipWidth)
                 *  {
                 *      MipIndex = i + 1;  // 1 based
                 *      break;
                 *  }
                 * }*/
                MipIndex = 1;
            }

            ////////////////////////////////////////////////////////////////////////////////////////


            OnPropertyChanged(nameof(NumMipMaps));
            OnPropertyChanged(nameof(Preview));
            OnPropertyChanged(nameof(MipIndex));
            OnPropertyChanged(nameof(MipWidth));
            OnPropertyChanged(nameof(MipHeight));
            OnPropertyChanged(nameof(img));
        }
コード例 #11
0
ファイル: NewCasePage.xaml.cs プロジェクト: despinosa/Narf-
 private void _next_Click(object sender, RoutedEventArgs e)
 {
     PreviewIndex           = Modulo(PreviewIndex + 1, Previews.Count());
     _currentPreview.Source = Previews.ElementAt(PreviewIndex);
 }