Пример #1
0
        private async void RecoverValues(string entry)
        {
            foreach (WorkModel.WorkEntry e in NewBook.Entries)
            {
                if (entry == e.Name)
                {
                    NewEntry = e;
                    break;
                }
            }

            if (NewEntry.ImageChanged)
            {
                ImageSource = (StreamImageSource)Xamarin.Forms.ImageSource.FromStream(() => new MemoryStream(NewEntry.NewImageData));
            }
            else
            {
                NewEntry.OldImagePath = NewEntry.ImagePath;
                ImageSource           = await FileManager.GetImage(NewEntry.ImagePath);
            }

            NewName     = NewEntry.Name;
            Description = NewEntry.Description;
            foreach (WorkTag t in NewEntry.Tags)
            {
                CurrentTags.Add(t);
            }
        }
Пример #2
0
 private void OnRemoveLastTag()
 {
     if (CurrentTags.Count > 0)
     {
         CurrentTags.RemoveAt(CurrentTags.Count - 1);
     }
 }
Пример #3
0
 private void closeAllTagsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     currentTagsComboBox.Items.Clear();
     tagEditorPanel.Controls.Clear();
     CurrentTags.Clear();
     CurrentTag = null;
 }
Пример #4
0
        private void OnAddTag()
        {
            Tag tag = new Tag(NewTag, NewValue);

            CurrentTags.Add(tag);
            NewTag   = "";
            NewValue = "";
        }
Пример #5
0
        /// <summary>
        /// Removes the tag from its image.  The tag will still remain in the main collection of tags.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void Tag_RemoveRequested(object sender, EventArgs eventArgs)
        {
            var tag = (Tag)sender;

            CurrentTags.Remove(tag);

            RegisterTagEvents(tag, false);
        }
Пример #6
0
        private void OnAddTag()
        {
            WorkTag tag = new WorkTag(NewTag, NewValue);

            NewEntry.Tags.Add(tag);
            CurrentTags.Add(tag);
            NewTag   = "";
            NewValue = "";
        }
        /// <summary>
        /// Adds the given tag to the list of selected tags, if it is not already added.
        /// </summary>
        /// <param name="parameter">The tag to add, as a string.</param>
        public void AddTag(object parameter)
        {
            string tag = parameter as string;

            if (!CurrentTags.Contains(tag))
            {
                CurrentTags.Add(tag);
            }
        }
Пример #8
0
 private void OnRemoveLastTag()
 {
     if (NewEntry.Tags.Count > 0)
     {
         WorkTag temp = NewEntry.Tags[NewEntry.Tags.Count - 1];
         NewBook.EntryTags.Remove(temp.Name);
         NewEntry.Tags.RemoveAt(NewEntry.Tags.Count - 1);
         CurrentTags.RemoveAt(CurrentTags.Count - 1);
     }
 }
Пример #9
0
        private void saveCurrentTagToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CurrentTag == null || !CurrentTags.ContainsKey(CurrentTag.Index))
            {
                return;
            }

            var tagName = SaveTagChanges(CurrentTag, CurrentTags[CurrentTag.Index]);

            MessageBox.Show($"Saved changes to {tagName} successfully.", "Save Tag Changes", MessageBoxButtons.OK);
        }
        private void DisplayTagTree(ImageTag tag, int level)
        {
            // TODO: Can likely be optimised
            if (tag.Type != ImageTagTypes.Root && CurrentTags.Contains(tag))
            {
                DisplayTag(tag, level);
            }

            foreach (ImageTag child in tag.Children)
            {
                DisplayTagTree(child, level + 1);
            }
        }
Пример #11
0
        /// <summary>
        /// Adds a tag to the current image.
        /// </summary>
        /// <param name="tag"></param>
        void AddTagToImage(Tag tag)
        {
            if (CurrentTags.Contains(tag))
            {
                return;
            }

            CurrentTags.Add(tag);
            foreach (var image in _selectedItems)
            {
                if (image == SelectedImage)
                {
                    continue;
                }

                _imageTags[image.FilePath].Add(tag);
            }

            RegisterTagEvents(tag, true);
        }
Пример #12
0
        private void closeCurrentTagToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CurrentTag == null)
            {
                return;
            }

            tagEditorPanel.Controls.Clear();

            if (currentTagsComboBox.Items.Count > 0)
            {
                currentTagsComboBox.Items.RemoveAt(currentTagsComboBox.SelectedIndex);
            }

            if (!CurrentTags.ContainsKey(CurrentTag.Index))
            {
                return;
            }

            CurrentTags.Remove(CurrentTag.Index);
        }
 private void Create()
 {
     CurrentTags.Clear();
     tagDictionary.Clear();
     foreach (var device in myDevices.Values)
     {
         foreach (var tag in device.Collection.GetAllTags())
         {
             if (tagDictionary.ContainsKey(tag.Name))
             {
                 continue;
             }
             TagResult aTag = new TagResult(tag);
             tagDictionary.Add(tag.Name, aTag);
             tag.TagStatusChanged += Tag_TagStatusChanged;
             CurrentTags.Add(aTag);
         }
     }
     DeviceCount = myDevices.Count;
     Status      = LiveDataViewModelStatuses.Ready;
 }
Пример #14
0
 private void Create()
 {
     CurrentTags.Clear();
     tagDictionary.Clear();
     foreach (var device in myDevices.Values)
     {
         var readTags = from item in device.Collection.GetAllTags() where item.TagDirection == Kr.Communication.SmartModbusMaster.TagManagement.Types.Direction.Read select item;
         foreach (var tag in device.Collection.GetAllTags())
         {
             if (tagDictionary.ContainsKey(tag.Name))
             {
                 continue;
             }
             TagResult aTag = new TagResult(tag);
             tagDictionary.Add(tag.Name, aTag);
             tag.TagStatusChanged += Tag_TagStatusChanged;
             CurrentTags.Add(aTag);
         }
     }
     DeviceCount = myDevices.Count;
     Status      = LiveDataViewModelStatuses.Ready;
 }
Пример #15
0
 private void OnNewSearch(object obj)
 {
     CurrentTags.Clear();
 }
Пример #16
0
        public void LoadTagEditor(CachedTag tag)
        {
            if (tag == null || (CurrentTag != null && CurrentTag.Index == tag.Index))
            {
                return;
            }

            LoadingTag = true;

            object definition = null;

            if (CurrentTags.ContainsKey(tag.Index))
            {
                definition = CurrentTags[tag.Index];
            }

            tagTreeView.Enabled = false;

            tagEditorPanel.Controls.Clear();

            var tagName = tag.Name ?? $"0x{tag.Index:X4}";

            var groupName = Cache.StringTable.GetString(tag.Group.Name);

            statusLabel.Text = $"Loading {tagName}.{ groupName}...";

            progressBar.Style = ProgressBarStyle.Marquee;
            progressBar.MarqueeAnimationSpeed = 30;

            if (definition == null)
            {
                using (var stream = Cache.OpenCacheRead())
                    definition = Cache.Deserialize(stream, tag);
            }

            if (tagName.Contains("\\"))
            {
                var index = tagName.LastIndexOf('\\') + 1;
                tagName = tagName.Substring(index, tagName.Length - index);
            }

            statusLabel.Text = $"Generating {groupName} interface...";
            Application.DoEvents();

            var point = new Point();

            if (tag.IsInGroup("matg") || tag.IsInGroup("mulg") || tag.IsInGroup("scnr") || tag.IsInGroup("sbsp"))
            {
                var control = new StructMultiControl(this, Cache, tag, definition)
                {
                    Dock = DockStyle.Fill
                };

                control.GetFieldValue(null, definition, definition);

                tagEditorPanel.Controls.Add(control);
            }
            // todo: fixup/clean model rendering code
            // todo: finish bitm editing (save/import dds, add size scaling to image)
            else if (tag.IsInGroup("bitm") || tag.IsInGroup("obje"))
            {
                var splitContainer = new SplitContainer
                {
                    Dock        = DockStyle.Fill,
                    Orientation = Orientation.Horizontal
                };

                splitContainer.FixedPanel = FixedPanel.Panel1;

                tagEditorPanel.Controls.Add(splitContainer);
                splitContainer.BringToFront();

                /*if (tag.IsInGroup("bitm"))
                 *  splitContainer.SplitterDistance = 384;//Math.Min((short)512, Math.Max((short)16, ((TagTool.Tags.Definitions.Bitmap)definition).Images[0].Height));
                 * else if (tag.IsInGroup("obje"))
                 *  splitContainer.SplitterDistance = 384;*/

                if (tag.IsInGroup("bitm"))
                {
                    var bitmDefinition = (TagTool.Tags.Definitions.Bitmap)definition;

                    if (Cache.ResourceCache.GetBitmapTextureInteropResource(bitmDefinition.Resources[0]) != null)
                    {
                        splitContainer.SplitterDistance = 384;

                        var bitmapControl = new BitmapControl(Cache, bitmDefinition)
                        {
                            Dock = DockStyle.Fill
                        };

                        splitContainer.Panel1.Controls.Add(bitmapControl);
                        bitmapControl.BringToFront();
                    }
                }

                /*else if (tag.IsInGroup("obje"))
                 * {
                 *  var modelControl = new ObjectControl(Cache, (GameObject)definition)
                 *  {
                 *      Dock = DockStyle.Fill
                 *  };
                 *
                 *  splitContainer.Panel1.Controls.Add(modelControl);
                 *  modelControl.BringToFront();
                 * }*/

                var control = tag.IsInGroup("obje") ?
                              (Control) new StructMultiControl(this, Cache, tag, definition)
                {
                    Dock = DockStyle.Fill
                } :
                new StructControl(this, Cache, definition.GetType(), null);

                ((IFieldControl)control).GetFieldValue(null, definition, definition);
                control.Location = point;

                splitContainer.Panel2.Controls.Add(control);
                splitContainer.Panel2.AutoScroll = true;
            }
            else
            {
                if (tag.IsInGroup("snd!"))
                {
                    var soundControl = new SoundControl(Cache, tag, (Sound)definition)
                    {
                        Dock = DockStyle.Top
                    };

                    tagEditorPanel.Controls.Add(soundControl);
                    soundControl.BringToFront();

                    point.Y = soundControl.Bottom;
                }

                var control = new StructControl(this, Cache, definition.GetType(), null);
                control.GetFieldValue(null, definition, definition);

                control.Location = point;

                tagEditorPanel.Controls.Add(control);
            }

            statusLabel.Text = "";

            progressBar.Style = ProgressBarStyle.Continuous;
            progressBar.MarqueeAnimationSpeed = 0;

            tagTreeView.Enabled = true;
            CurrentTag          = tag;

            if (!CurrentTags.ContainsKey(tag.Index))
            {
                CurrentTags[tag.Index] = definition;

                var item = new TagInstanceItem {
                    Cache = Cache, Tag = tag
                };
                currentTagsComboBox.Items.Add(item);

                currentTagsComboBox.SelectedItem = item;
            }
            else
            {
                for (var i = 0; i < currentTagsComboBox.Items.Count; i++)
                {
                    var item = (TagInstanceItem)currentTagsComboBox.Items[i];

                    if (item.Tag.Index == tag.Index)
                    {
                        currentTagsComboBox.SelectedIndex = i;
                        break;
                    }
                }
            }

            LoadingTag = false;
        }
 /// <summary>
 /// Removes the given tag from the list of selected tags.
 /// </summary>
 /// <param name="parameter">The tag to remove, as a string.</param>
 public void RemoveTag(object parameter)
 {
     CurrentTags.Remove(parameter as string);
 }