Beispiel #1
0
 public void SerializeBindings(HeliosBindingCollection bindings, XmlWriter xmlWriter)
 {
     foreach (HeliosBinding binding in bindings)
     {
         SerializeBinding(binding, xmlWriter);
     }
 }
Beispiel #2
0
        public bool SaveProfile(HeliosProfile profile)
        {
            try
            {
                string tempPath   = Path.ChangeExtension(profile.Path, "tmp");
                string backupPath = Path.ChangeExtension(profile.Path, "bak");

                // Delete tmp file if exists
                if (File.Exists(tempPath))
                {
                    File.Delete(tempPath);
                }

                TextWriter    writer        = new StreamWriter(tempPath, false);
                TypeConverter boolConverter = TypeDescriptor.GetConverter(typeof(bool));

                XmlWriterSettings settings = new XmlWriterSettings();
                settings.Indent = true;

                XmlWriter xmlWriter = XmlWriter.Create(writer, settings);
                HeliosBindingCollection bindings = new HeliosBindingCollection();

                HeliosSerializer serializer = new HeliosSerializer(null);
                serializer.SerializeProfile(profile, xmlWriter);

                profile.IsDirty = false;
                xmlWriter.Close();
                writer.Close();

                // Delete existing backup
                if (File.Exists(backupPath))
                {
                    File.Delete(backupPath);
                }

                // backup existing file
                if (File.Exists(profile.Path))
                {
                    File.Move(profile.Path, backupPath);
                }

                // Rename .tmp to actual
                File.Move(tempPath, profile.Path);

                profile.LoadTime = Directory.GetLastWriteTime(profile.Path);

                return(true);
            }
            catch (Exception e)
            {
                Logger.Error(e, "Error saving profile");
                return(false);
            }
        }
Beispiel #3
0
 public void SerializeBindings(HeliosBindingCollection bindings, XmlWriter xmlWriter, HeliosBindingCollection skipBindings)
 {
     foreach (HeliosBinding binding in bindings)
     {
         if (!skipBindings.Contains(binding))
         {
             SerializeBinding(binding, xmlWriter);
             skipBindings.Add(binding);
         }
     }
 }
Beispiel #4
0
 public IEnumerable <StatusReportItem> ReportBindings(HeliosBindingCollection bindings)
 {
     foreach (HeliosBinding binding in bindings)
     {
         yield return(new StatusReportItem
         {
             Status = $"callback bound in the profile is not found in the key file '{binding.Value}'",
             Recommendation = $"Add missing callbacks to your key file.",
             Severity = StatusReportItem.SeverityCode.Error,
             Flags = StatusReportItem.StatusFlags.DoNotDisturb | StatusReportItem.StatusFlags.Verbose
         });
     }
 }
Beispiel #5
0
        public HeliosBindingCollection CheckBindings(HeliosBindingCollection heliosBindings)
        {
            HeliosBindingCollection missingCallbackBindings = new HeliosBindingCollection();

            foreach (HeliosBinding binding in heliosBindings)
            {
                if (binding.Value != "" && !_callbacks.HasCallback(binding.Value) && binding.ValueSource.ToString().Equals("StaticValue"))
                {
                    missingCallbackBindings.Add(binding);
                }
            }
            return(missingCallbackBindings);
        }
Beispiel #6
0
 public void SerializeBindings(HeliosBindingCollection bindings, XmlWriter xmlWriter)
 {
     foreach (HeliosBinding binding in bindings)
     {
         //SerializeBinding(binding, xmlWriter);
         //_skipbindings.Add(binding);
         if (!_skipbindings.Contains(binding))
         {
             SerializeBinding(binding, xmlWriter);
             _skipbindings.Add(binding);
         }
     }
 }
Beispiel #7
0
        private HeliosBindingCollection DeserializeBindings(HeliosProfile profile, HeliosVisual root, string copyRoot, List <HeliosVisual> localObjects, XmlReader xmlReader)
        {
            HeliosBindingCollection bindings = new HeliosBindingCollection();

            if (!xmlReader.IsEmptyElement)
            {
                xmlReader.ReadStartElement("Bindings");
                while (xmlReader.NodeType != XmlNodeType.EndElement)
                {
                    HeliosBinding binding = DeserializeBinding(profile, root, copyRoot, localObjects, xmlReader);
                    if (binding != null && binding.Action != null && binding.Trigger != null)
                    {
                        bindings.Add(binding);
                    }
                }
                xmlReader.ReadEndElement();
            }
            else
            {
                xmlReader.Read();
            }

            return(bindings);
        }
 private static void SerializeBindings(HeliosSerializer serializer, HeliosVisual control, XmlWriter xmlWriter, HeliosBindingCollection serializedBindings)
 {
     serializer.SerializeBindings(control.InputBindings, xmlWriter, serializedBindings);
     serializer.SerializeBindings(control.OutputBindings, xmlWriter, serializedBindings);
     foreach (HeliosVisual child in control.Children)
     {
         SerializeBindings(serializer, child, xmlWriter, serializedBindings);
     }
 }
        private static void CopySelection(HeliosVisualContainer root, HeliosVisualCollection controls)
        {
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;

            // Loop through controls and add them in the proper visual order for serialization to the copy buffer.
            HeliosVisualCollection copiedControls = new HeliosVisualCollection();
            foreach (HeliosVisual visual in root.Children)
            {
                if (controls.Contains(visual))
                {
                    copiedControls.Add(visual);
                }
            }

            StringBuilder sb = new StringBuilder();
            XmlWriter xmlWriter = XmlWriter.Create(sb, settings);
            xmlWriter.WriteStartElement("HeliosCopyBuffer");

            xmlWriter.WriteElementString("CopyRoot", HeliosSerializer.GetVisualPath(root));

            HeliosSerializer serializer = new HeliosSerializer(null);
            serializer.SerializeControls(copiedControls, xmlWriter);
            HeliosBindingCollection serializedBindings = new HeliosBindingCollection();

            xmlWriter.WriteStartElement("Bindings");
            foreach (HeliosVisual control in copiedControls)
            {
                SerializeBindings(serializer, control, xmlWriter, serializedBindings);
            }
            xmlWriter.WriteEndElement();

            xmlWriter.WriteEndElement();
            xmlWriter.Close();

            SetClipboard("Helios.Visuals", sb.ToString());
        }
Beispiel #10
0
        private HeliosBindingCollection DeserializeBindings(HeliosProfile profile, HeliosVisual root, string copyRoot, List<HeliosVisual> localObjects, XmlReader xmlReader)
        {
            HeliosBindingCollection bindings = new HeliosBindingCollection();

            if (!xmlReader.IsEmptyElement)
            {
                xmlReader.ReadStartElement("Bindings");
                while (xmlReader.NodeType != XmlNodeType.EndElement)
                {
                    HeliosBinding binding = DeserializeBinding(profile, root, copyRoot, localObjects, xmlReader);
                    if (binding != null && binding.Action != null && binding.Trigger != null)
                    {
                        bindings.Add(binding);
                    }
                }
                xmlReader.ReadEndElement();
            }
            else
            {
                xmlReader.Read();
            }

            return bindings;
        }
Beispiel #11
0
 public void SerializeBindings(HeliosBindingCollection bindings, XmlWriter xmlWriter, HeliosBindingCollection skipBindings)
 {
     foreach (HeliosBinding binding in bindings)
     {
         if (!skipBindings.Contains(binding))
         {
             SerializeBinding(binding, xmlWriter);
             skipBindings.Add(binding);
         }
     }
 }
Beispiel #12
0
 public void SerializeBindings(HeliosBindingCollection bindings, XmlWriter xmlWriter)
 {
     foreach (HeliosBinding binding in bindings)
     {
         SerializeBinding(binding, xmlWriter);
     }
 }