Ejemplo n.º 1
0
        /// <summary>
        /// Creates instance of module from HTML node
        /// </summary>
        /// <param name="node">Module HTML node</param>
        /// <returns>Instance of AModule with UserSetup</returns>
        public AModule GetModuleFromNode(HtmlNode node)
        {
            if (node.Attributes["name"] == null)
            {
                return(null);
            }

            AModule module = CModuleReader.Instance.GetModuleInstanceFromName(node.Attributes["name"].Value);

            // Set attributes
            foreach (HtmlAttribute attribute in node.Attributes)
            {
                try
                {
                    Object[] args = new Object[] { attribute.Value };
                    module.setup.GetType().InvokeMember(attribute.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty, null, module.setup, args);
                }
                catch (Exception)
                {
                    // Attribute not found, ignoring
                }
            }
            // And location
            RectangleConverter converter = new RectangleConverter();

            module.setup.location = (Rectangle)converter.ConvertFromString(node.Attributes["location"].Value);

            return(module);
        }
Ejemplo n.º 2
0
        internal static Rectangle ReadAttributeRectangle(XmlNode node, string attributeName)
        {
            CheckAttributeExists(node, attributeName);
            string text = node.Attributes[attributeName].Value;

            return(RectangleConverter.ConvertFromString(null, System.Globalization.CultureInfo.CurrentCulture, text));
        }
Ejemplo n.º 3
0
        void InstallPad_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Serialize form position to file, so we can restore it later.
            RectangleConverter convert      = new RectangleConverter();
            string             formPosition = convert.ConvertToString(this.Bounds);

            TextWriter writer = null;

            try
            {
                string configFolder = Path.GetDirectoryName(InstallPadApp.ConfigFilePath);
                if (!Directory.Exists(configFolder))
                {
                    Directory.CreateDirectory(configFolder);
                }
                writer = new StreamWriter(InstallPadApp.ConfigFilePath);
                writer.Write(formPosition);
            }
            // We can get here if InstallPad.form_load had a problem,
            // so just eat exceptions rather than throwing more of them.
            catch (Exception ex) { }
            finally
            {
                if (writer != null)
                {
                    writer.Close();
                }
            }
        }
Ejemplo n.º 4
0
        //</Snippet3>

        private bool WriteFormDataToFile()
        {
            // Write the form positions to the file.
            UTF8Encoding encoding = new UTF8Encoding();

            RectangleConverter rectConv = new RectangleConverter();
            string             form1pos = rectConv.ConvertToString(_form1Position);
            string             form2pos = rectConv.ConvertToString(_form2Position);

            byte[] dataToWrite = encoding.GetBytes("~" + form1pos + "~" + form2pos);

            try
            {
                // Set the write position to the start of the file and write
                _userData.Seek(0, SeekOrigin.Begin);
                _userData.Write(dataToWrite, 0, dataToWrite.Length);
                _userData.Flush();

                _userData.SetLength(dataToWrite.Length);
                return(true);
            }
            catch
            {
                // An error occurred while attempting to write, return false.
                return(false);
            }
        }
Ejemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.DefaultExt = "json";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                RectangleConverter rc       = new RectangleConverter();
                JObject            root     = JsonConvert.DeserializeObject(File.ReadAllText(ofd.FileName)) as JObject;
                JArray             patterns = root["patterns"] as JArray;
                foreach (JObject pattern in patterns)
                {
                    string identifier = pattern["identifier"].ToString();
                    JArray rectsArray = pattern["rects"] as JArray;

                    selectedRectangles[identifier] = new List <BoundRect>();
                    foreach (var rs in rectsArray)
                    {
                        JObject obj = rs as JObject;

                        Rectangle rect = (Rectangle)rc.ConvertFromString((string)rs["rect"]);
                        int       type = int.Parse((string)rs["type"]);

                        BoundRect br = new BoundRect();
                        br.Rectangle = rect;
                        br.Type      = type;

                        selectedRectangles[identifier].Add(br);
                    }

                    selectedImages[identifier] = new Bitmap(PATH + identifier + ".png");
                }
            }
        }
Ejemplo n.º 6
0
 /// <summary>Creates an instance for the default language.</summary>
 /// <returns>A repository.</returns>
 public IMapRepository ForDefaultCulture()
 {
     var vector2DConverter = new Vector2DConverter();
     var rectangleConverter = new RectangleConverter(vector2DConverter);
     var mapConverter = new MapConverter(rectangleConverter);
     var mapCollectionConverter = new MapCollectionConverter(mapConverter);
     return new MapRepository(this.serviceClient, mapCollectionConverter);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Extends ConvertTo so that methods that return a specific type object given a Type parameter can be
        /// used as generic method and casting is not required.
        /// <example>
        /// typeconverter.ConvertTo<int>(value);
        /// </example>
        /// </summary>
        public static T ConvertTo <T>(this RectangleConverter typeconverter, Object value)
        {
            if (typeconverter == null)
            {
                throw new ArgumentNullException("typeconverter");
            }

            return((T)typeconverter.ConvertTo(value, typeof(T)));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Extends ConvertTo so that methods that return a specific type object given a Type parameter can be
        /// used as generic method and casting is not required.
        /// <example>
        /// rectangleconverter.ConvertTo<int>(context, culture, value);
        /// </example>
        /// </summary>
        public static T ConvertTo <T>(this RectangleConverter rectangleconverter, System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, Object value)
        {
            if (rectangleconverter == null)
            {
                throw new ArgumentNullException("rectangleconverter");
            }

            return((T)rectangleconverter.ConvertTo(context, culture, value, typeof(T)));
        }
Ejemplo n.º 9
0
        /// <summary>Creates an instance for the default language.</summary>
        /// <returns>A repository.</returns>
        public IMapRepository ForDefaultCulture()
        {
            var vector2DConverter      = new Vector2DConverter();
            var rectangleConverter     = new RectangleConverter(vector2DConverter);
            var mapConverter           = new MapConverter(rectangleConverter);
            var mapCollectionConverter = new MapCollectionConverter(mapConverter);

            return(new MapRepository(this.serviceClient, mapCollectionConverter));
        }
Ejemplo n.º 10
0
 public coverterProgramm()
 {
     InitializeComponent();
     converter = RectangleConverter.getRectInstance();
     converter.setObserver(this);
     checkingDataCorrect.Enabled = true;
     openFileDialog.Filter = OPEN_FILE_FILTER;
     saveFileDialog.Filter = SAVE_FILE_FILTER;
     Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
 }
Ejemplo n.º 11
0
        /// <summary>Creates an instance for the default language.</summary>
        /// <returns>A repository.</returns>
        public override IMapRepository ForDefaultCulture()
        {
            var rectangleConverter           = new RectangleConverter(new Vector2DConverter());
            var mapConverter                 = new MapConverter(rectangleConverter);
            var identifiersResponseConverter = new ResponseConverter <ICollection <int>, ICollection <int> >(new ConverterAdapter <ICollection <int> >());
            var responseConverter            = new ResponseConverter <MapDTO, Map>(mapConverter);
            var bulkResponseConverter        = new DictionaryRangeResponseConverter <MapDTO, int, Map>(mapConverter, map => map.MapId);
            var pageResponseConverter        = new CollectionPageResponseConverter <MapDTO, Map>(mapConverter);

            return(new MapRepository(this.serviceClient, identifiersResponseConverter, responseConverter, bulkResponseConverter, pageResponseConverter));
        }
Ejemplo n.º 12
0
        private bool ReadFormDataFromFile()
        {
            // Read the form positions from the file.
            UTF8Encoding encoding = new UTF8Encoding();
            string       data;

            if (_userData.Length != 0)
            {
                byte[] dataToRead = new byte[_userData.Length];

                try
                {
                    // Set the read position to the start of the file and read.
                    _userData.Seek(0, SeekOrigin.Begin);
                    _userData.Read(dataToRead, 0, dataToRead.Length);
                }
                catch (IOException e)
                {
                    string errorInfo = e.ToString();
                    // An error occurred while attempt to read, return false.
                    return(false);
                }

                // Parse out the data to get the window rectangles
                data = encoding.GetString(dataToRead);

                try
                {
                    // Convert the string data to rectangles
                    RectangleConverter rectConv = new RectangleConverter();
                    string             form1pos = data.Substring(1, data.IndexOf("~", 1) - 1);

                    _form1Position = (Rectangle)rectConv.ConvertFromString(form1pos);

                    string form2pos = data.Substring(data.IndexOf("~", 1) + 1);
                    _form2Position = (Rectangle)rectConv.ConvertFromString(form2pos);

                    return(true);
                }
                catch
                {
                    // Error occurred while attempting to convert the rectangle data.
                    // Return false to use default values.
                    return(false);
                }
            }
            else
            {
                // No data in the file, return false to use default values.
                return(false);
            }
        }
Ejemplo n.º 13
0
            private static FloatWindowStruct[] LoadFloatWindows(XmlTextReader xmlIn)
            {
                EnumConverter      dockAlignmentConverter = new EnumConverter(typeof(DockAlignment));
                RectangleConverter rectConverter          = new RectangleConverter();
                int countOfFloatWindows = Convert.ToInt32(xmlIn.GetAttribute("Count"), CultureInfo.InvariantCulture);

                FloatWindowStruct[] floatWindows = new FloatWindowStruct[countOfFloatWindows];
                MoveToNextElement(xmlIn);
                for (int i = 0; i < countOfFloatWindows; i++)
                {
                    int id = Convert.ToInt32(xmlIn.GetAttribute("ID"), CultureInfo.InvariantCulture);
                    if (xmlIn.Name != "FloatWindow" || id != i)
                    {
                        throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat);
                    }

                    var convertFromInvariantString = rectConverter.ConvertFromInvariantString(xmlIn.GetAttribute("Bounds"));
                    if (convertFromInvariantString != null)
                    {
                        floatWindows[i].Bounds = (Rectangle)convertFromInvariantString;
                    }
                    floatWindows[i].ZOrderIndex = Convert.ToInt32(xmlIn.GetAttribute("ZOrderIndex"), CultureInfo.InvariantCulture);
                    MoveToNextElement(xmlIn);
                    if (xmlIn.Name != "DockList" && xmlIn.Name != "NestedPanes")
                    {
                        throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat);
                    }
                    int countOfNestedPanes = Convert.ToInt32(xmlIn.GetAttribute("Count"), CultureInfo.InvariantCulture);
                    floatWindows[i].NestedPanes = new NestedPane[countOfNestedPanes];
                    MoveToNextElement(xmlIn);
                    for (int j = 0; j < countOfNestedPanes; j++)
                    {
                        int id2 = Convert.ToInt32(xmlIn.GetAttribute("ID"), CultureInfo.InvariantCulture);
                        if (xmlIn.Name != "Pane" || id2 != j)
                        {
                            throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat);
                        }
                        floatWindows[i].NestedPanes[j].IndexPane     = Convert.ToInt32(xmlIn.GetAttribute("RefID"), CultureInfo.InvariantCulture);
                        floatWindows[i].NestedPanes[j].IndexPrevPane = Convert.ToInt32(xmlIn.GetAttribute("PrevPane"), CultureInfo.InvariantCulture);
                        var convertFrom = dockAlignmentConverter.ConvertFrom(xmlIn.GetAttribute("Alignment"));
                        if (convertFrom != null)
                        {
                            floatWindows[i].NestedPanes[j].Alignment = (DockAlignment)convertFrom;
                        }
                        floatWindows[i].NestedPanes[j].Proportion = Convert.ToDouble(xmlIn.GetAttribute("Proportion"), CultureInfo.InvariantCulture);
                        MoveToNextElement(xmlIn);
                    }
                }

                return(floatWindows);
            }
Ejemplo n.º 14
0
        public void SetUp()
        {
            rect             = new Rectangle(10, 10, 20, 30);
            rectStrInvariant = rect.X + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " +
                               rect.Y + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " +
                               rect.Width + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " +
                               rect.Height;

            rectneg             = new Rectangle(-10, -10, 20, 30);
            rectnegStrInvariant = rectneg.X + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " "
                                  + rectneg.Y + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " +
                                  rectneg.Width + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " + rectneg.Height;

            rconv = (RectangleConverter)TypeDescriptor.GetConverter(rect);
        }
Ejemplo n.º 15
0
        public override bool ParseCli(string Arg)
        {
            if (!Regex.IsMatch(Arg, @"^\d+,\d+,\d+,\d+$"))
            {
                return(false);
            }

            var rectConverter = new RectangleConverter();

            if (!(rectConverter.ConvertFromInvariantString(Arg) is Rectangle rect))
            {
                return(false);
            }

            _regionProvider.SelectedRegion = rect.Even();

            return(true);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 메모폼 정보 저장
        /// </summary>
        private void saveMemo(Item item)
        {
            XmlDocument xmlDoc   = Common.XmlControl.getInstance().xmlLoad(DEFINE.MEMO_DATA_PATH);
            XmlNode     memoNode = xmlDoc.SelectSingleNode("//MEMODATA");
            String      path     = item.PATH;

            if (path != "/")
            {
                String[] paths = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < paths.Length; i++)
                {
                    memoNode = memoNode.SelectSingleNode("./" + DEFINE.NODE_GROUPNAME + "[@name='" + paths[i] + "']");
                }
            }

            XmlNode            targetNode = memoNode.SelectSingleNode("./" + DEFINE.NODE_MEMONAME + "[@name='" + item.TITLE + "']");
            RectangleConverter rc         = new RectangleConverter();

            XmlNode      tmpNode = xmlDoc.CreateNode(XmlNodeType.Element, targetNode.Name, "");
            XmlAttribute attr1   = xmlDoc.CreateAttribute("name");

            attr1.Value = item.TITLE;
            XmlAttribute attr2 = xmlDoc.CreateAttribute("text");

            attr2.Value = item.TEXT;
            XmlAttribute attr3 = xmlDoc.CreateAttribute("rect");

            attr3.Value = rc.ConvertToString(item.RECT);
            tmpNode.Attributes.Append(attr1);
            tmpNode.Attributes.Append(attr2);
            tmpNode.Attributes.Append(attr3);

            targetNode.ParentNode.ReplaceChild(tmpNode, targetNode);

            Common.XmlControl.getInstance().xmlSave(xmlDoc, DEFINE.MEMO_DATA_PATH);

            if (mainFolder != null)
            {
                mainFolder.listViewReload();
            }
        }
Ejemplo n.º 17
0
        private void button4_Click(object sender, EventArgs e)
        {
            JArray             patterns = new JArray();
            RectangleConverter rc       = new RectangleConverter();

            foreach (var item in listBox1.Items)
            {
                string identifier = item.ToString();

                if (!selectedRectangles.ContainsKey(identifier) ||
                    !selectedImages.ContainsKey(identifier))
                {
                    continue;
                }

                JArray rectArray = new JArray();
                foreach (var r in selectedRectangles[identifier])
                {
                    JObject rectObj = new JObject();
                    rectObj["rect"] = rc.ConvertToString(r.Rectangle);
                    rectObj["type"] = r.Type;
                    rectArray.Add(rectObj);
                }


                selectedImages[identifier].Save(PATH + identifier + ".png");

                JObject pattern = new JObject();
                pattern["identifier"] = identifier;
                pattern["rects"]      = rectArray;
                patterns.Add(pattern);
            }

            JObject root = new JObject();

            root["patterns"] = patterns;
            File.WriteAllText(PATH + "config.json", JsonConvert.SerializeObject(root));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Creates XML string from instance of module
        /// </summary>
        /// <param name="module">Module</param>
        /// <returns>XML Node of module</returns>
        public HtmlNode GetNodeFromModule(AModule module)
        {
            Type moduleType = module.GetType();
            Type setupType  = module.setup.GetType();

            // Create root node
            String moduleName = (String)moduleType.GetField("name", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy).GetValue(null);


            HtmlDocument htmlDoc = new HtmlDocument();
            HtmlNode     node    = htmlDoc.CreateElement("module");

            // Save all setup_* members to attributes
            MemberInfo[] setupMembers = setupType.GetMember("setup_*", BindingFlags.Public | BindingFlags.Instance);
            foreach (MemberInfo setupMember in setupMembers)
            {
                HtmlAttribute attribute = htmlDoc.CreateAttribute(setupMember.Name);
                attribute.Value = (String)setupType.InvokeMember(setupMember.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty, null, module.setup, null);
                node.Attributes.Append(attribute);
            }

            // Save name(type) of module
            HtmlAttribute nameAttr = htmlDoc.CreateAttribute("name");

            nameAttr.Value = moduleName;
            node.Attributes.Append(nameAttr);

            // Save position as attr
            Rectangle          location     = (Rectangle)setupType.GetField("location", BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy).GetValue(module.setup);
            HtmlAttribute      locationAttr = htmlDoc.CreateAttribute("location");
            RectangleConverter converter    = new RectangleConverter();

            locationAttr.Value = converter.ConvertToString(location);
            node.Attributes.Append(locationAttr);

            return(node);
        }
Ejemplo n.º 19
0
        /// <summary>Creates an instance for the default language.</summary>
        /// <param name="continentId">The continent identifier.</param>
        /// <returns>A repository.</returns>
        public IFloorRepository ForDefaultCulture(int continentId)
        {
            var pointOfInterestConverterFactory = new PointOfInterestConverterFactory();
            var vector2DConverter                  = new Vector2DConverter();
            var rectangleConverter                 = new RectangleConverter(vector2DConverter);
            var pointOfInterestConverter           = new PointOfInterestConverter(pointOfInterestConverterFactory, vector2DConverter);
            var pointOfInterestCollectionConverter = new CollectionConverter <PointOfInterestDTO, PointOfInterest>(pointOfInterestConverter);
            var renownTaskConverter                = new RenownTaskConverter(vector2DConverter);
            var renownTaskCollectionConverter      = new CollectionConverter <RenownTaskDTO, RenownTask>(renownTaskConverter);
            var skillChallengeConverter            = new SkillChallengeConverter(vector2DConverter);
            var skillChallengeCollectionConverter  = new CollectionConverter <SkillChallengeDTO, SkillChallenge>(skillChallengeConverter);
            var outputConverter                = new SectorConverter(vector2DConverter);
            var sectorCollectionConverter      = new CollectionConverter <SectorDTO, Sector>(outputConverter);
            var subregionConverter             = new SubregionConverter(rectangleConverter, pointOfInterestCollectionConverter, renownTaskCollectionConverter, skillChallengeCollectionConverter, sectorCollectionConverter);
            var keyValuePairConverter          = new SubregionKeyValuePairConverter(subregionConverter);
            var subregionKeyValuePairConverter = new DictionaryConverter <string, SubregionDTO, int, Subregion>(keyValuePairConverter);
            var regionConverter                = new RegionConverter(vector2DConverter, subregionKeyValuePairConverter);
            var regionKeyValuePairConverter    = new RegionKeyValuePairConverter(regionConverter);
            var regionCollectionConverter      = new DictionaryConverter <string, RegionDTO, int, Region>(regionKeyValuePairConverter);
            var size2DConverter                = new Size2DConverter();
            var floorConverter = new FloorConverter(size2DConverter, rectangleConverter, regionCollectionConverter);

            return(new FloorRepository(continentId, this.serviceClient, floorConverter));
        }
Ejemplo n.º 20
0
        public static void Load()
        {
            RectangleConverter rc       = new RectangleConverter();
            JObject            root     = JsonConvert.DeserializeObject(File.ReadAllText(Runner.PATH + "configurer\\config.json")) as JObject;
            JArray             patterns = root["patterns"] as JArray;

            foreach (JObject pattern in patterns)
            {
                string identifier = pattern["identifier"].ToString();

                JArray rects = pattern["rects"] as JArray;

                Rectangle?coordRect  = null;
                Rectangle?clickRect  = null;
                Rectangle?optionRect = null;
                foreach (var jo in rects)
                {
                    Rectangle rect = (Rectangle)rc.ConvertFromString((string)jo["rect"]);
                    int       type = int.Parse((string)jo["type"]);
                    if (type == 2)
                    {
                        clickRect = rect;
                    }
                    else if (type == 3)
                    {
                        optionRect = rect;
                    }
                    else
                    {
                        coordRect = rect;
                    }
                }

                Create(identifier, new Bitmap(Runner.PATH + "configurer\\" + identifier + ".png"), (Rectangle)coordRect, clickRect, optionRect);
            }
        }
        public static void SaveAsXml(DockPanel dockPanel, Stream stream, Encoding encoding)
        {
            XmlTextWriter xmlOut = new XmlTextWriter(stream, encoding);

            // Use indenting for readability
            xmlOut.Formatting = Formatting.Indented;

            // Always begin file with identification and warning
            xmlOut.WriteStartDocument();
            xmlOut.WriteComment(" DockPanel configuration file. Author: Weifen Luo, all rights reserved. ");
            xmlOut.WriteComment(" !!! AUTOMATICALLY GENERATED FILE. DO NOT MODIFY !!! ");

            // Associate a version number with the root element so that future version of the code
            // will be able to be backwards compatible or at least recognise out of date versions
            xmlOut.WriteStartElement("DockPanel");
            xmlOut.WriteAttributeString("FormatVersion", ConfigFileVersion);
            xmlOut.WriteAttributeString("DockLeftPortion", dockPanel.DockLeftPortion.ToString(CultureInfo.InvariantCulture));
            xmlOut.WriteAttributeString("DockRightPortion", dockPanel.DockRightPortion.ToString(CultureInfo.InvariantCulture));
            xmlOut.WriteAttributeString("DockTopPortion", dockPanel.DockTopPortion.ToString(CultureInfo.InvariantCulture));
            xmlOut.WriteAttributeString("DockBottomPortion", dockPanel.DockBottomPortion.ToString(CultureInfo.InvariantCulture));
            xmlOut.WriteAttributeString("ActiveDocumentPane", dockPanel.Panes.IndexOf(dockPanel.ActiveDocumentPane).ToString());
            xmlOut.WriteAttributeString("ActivePane", dockPanel.Panes.IndexOf(dockPanel.ActivePane).ToString());

            // Contents
            xmlOut.WriteStartElement("Contents");
            xmlOut.WriteAttributeString("Count", dockPanel.Contents.Count.ToString());
            foreach (DockContent content in dockPanel.Contents)
            {
                xmlOut.WriteStartElement("Content");
                xmlOut.WriteAttributeString("ID", dockPanel.Contents.IndexOf(content).ToString());
                xmlOut.WriteAttributeString("PersistString", content.PersistString);
                xmlOut.WriteAttributeString("AutoHidePortion", content.AutoHidePortion.ToString(CultureInfo.InvariantCulture));
                xmlOut.WriteAttributeString("IsHidden", content.IsHidden.ToString());
                xmlOut.WriteAttributeString("IsFloat", content.IsFloat.ToString());
                xmlOut.WriteEndElement();
            }
            xmlOut.WriteEndElement();

            // Panes
            xmlOut.WriteStartElement("Panes");
            xmlOut.WriteAttributeString("Count", dockPanel.Panes.Count.ToString());
            foreach (DockPane pane in dockPanel.Panes)
            {
                xmlOut.WriteStartElement("Pane");
                xmlOut.WriteAttributeString("ID", dockPanel.Panes.IndexOf(pane).ToString());
                xmlOut.WriteAttributeString("DockState", pane.DockState.ToString());
                xmlOut.WriteAttributeString("ActiveContent", dockPanel.Contents.IndexOf(pane.ActiveContent).ToString());
                xmlOut.WriteStartElement("Contents");
                xmlOut.WriteAttributeString("Count", pane.Contents.Count.ToString());
                foreach (DockContent content in pane.Contents)
                {
                    xmlOut.WriteStartElement("Content");
                    xmlOut.WriteAttributeString("ID", pane.Contents.IndexOf(content).ToString());
                    xmlOut.WriteAttributeString("RefID", dockPanel.Contents.IndexOf(content).ToString());
                    xmlOut.WriteEndElement();
                }
                xmlOut.WriteEndElement();
                xmlOut.WriteEndElement();
            }
            xmlOut.WriteEndElement();

            // DockWindows
            xmlOut.WriteStartElement("DockWindows");
            int count = 0;

            foreach (DockWindow dw in dockPanel.DockWindows)
            {
                if (dw.DockList.Count > 0)
                {
                    count++;
                }
            }
            xmlOut.WriteAttributeString("Count", count.ToString());
            int i = 0;

            foreach (DockWindow dw in dockPanel.DockWindows)
            {
                if (dw.DockList.Count == 0)
                {
                    continue;
                }
                xmlOut.WriteStartElement("DockWindow");
                xmlOut.WriteAttributeString("ID", i.ToString());
                xmlOut.WriteAttributeString("DockState", dw.DockState.ToString());
                xmlOut.WriteAttributeString("ZOrderIndex", dockPanel.Controls.IndexOf(dw).ToString());
                xmlOut.WriteStartElement("DockList");
                xmlOut.WriteAttributeString("Count", dw.DockList.Count.ToString());
                foreach (DockPane pane in dw.DockList)
                {
                    xmlOut.WriteStartElement("Pane");
                    xmlOut.WriteAttributeString("ID", dw.DockList.IndexOf(pane).ToString());
                    xmlOut.WriteAttributeString("RefID", dockPanel.Panes.IndexOf(pane).ToString());
                    NestedDockingStatus status = pane.NestedDockingStatus;
                    xmlOut.WriteAttributeString("PrevPane", dockPanel.Panes.IndexOf(status.PrevPane).ToString());
                    xmlOut.WriteAttributeString("Alignment", status.Alignment.ToString());
                    xmlOut.WriteAttributeString("Proportion", status.Proportion.ToString(CultureInfo.InvariantCulture));
                    xmlOut.WriteEndElement();
                }
                xmlOut.WriteEndElement();
                xmlOut.WriteEndElement();
                i++;
            }
            xmlOut.WriteEndElement();

            // FloatWindows
            RectangleConverter rectConverter = new RectangleConverter();

            xmlOut.WriteStartElement("FloatWindows");
            xmlOut.WriteAttributeString("Count", dockPanel.FloatWindows.Count.ToString());
            foreach (FloatWindow fw in dockPanel.FloatWindows)
            {
                xmlOut.WriteStartElement("FloatWindow");
                xmlOut.WriteAttributeString("ID", dockPanel.FloatWindows.IndexOf(fw).ToString());
                xmlOut.WriteAttributeString("Bounds", rectConverter.ConvertToInvariantString(fw.Bounds));
                xmlOut.WriteAttributeString("AllowRedocking", fw.AllowRedocking.ToString());
                xmlOut.WriteAttributeString("ZOrderIndex", fw.DockPanel.FloatWindows.IndexOf(fw).ToString());
                xmlOut.WriteStartElement("DockList");
                xmlOut.WriteAttributeString("Count", fw.DockList.Count.ToString());
                foreach (DockPane pane in fw.DockList)
                {
                    xmlOut.WriteStartElement("Pane");
                    xmlOut.WriteAttributeString("ID", fw.DockList.IndexOf(pane).ToString());
                    xmlOut.WriteAttributeString("RefID", dockPanel.Panes.IndexOf(pane).ToString());
                    NestedDockingStatus status = pane.NestedDockingStatus;
                    xmlOut.WriteAttributeString("PrevPane", dockPanel.Panes.IndexOf(status.PrevPane).ToString());
                    xmlOut.WriteAttributeString("Alignment", status.Alignment.ToString());
                    xmlOut.WriteAttributeString("Proportion", status.Proportion.ToString(CultureInfo.InvariantCulture));
                    xmlOut.WriteEndElement();
                }
                xmlOut.WriteEndElement();
                xmlOut.WriteEndElement();
            }
            xmlOut.WriteEndElement();                   //	</FloatWindows>

            xmlOut.WriteEndElement();
            xmlOut.WriteEndDocument();

            // This should flush all actions and close the file
            xmlOut.Close();
        }
Ejemplo n.º 22
0
        public static void SaveApplication(DockPanel dockPanel, XmlTextWriter xmlWriter)
        {
            // Associate a version number with the root element so that future version of the code
            // will be able to be backwards compatible or at least recognise out of date versions
            xmlWriter.WriteStartElement("DockPanel");
            xmlWriter.WriteAttributeString("DockLeftPortion", dockPanel.DockLeftPortion.ToString(CultureInfo.InvariantCulture));
            xmlWriter.WriteAttributeString("DockRightPortion", dockPanel.DockRightPortion.ToString(CultureInfo.InvariantCulture));
            xmlWriter.WriteAttributeString("DockTopPortion", dockPanel.DockTopPortion.ToString(CultureInfo.InvariantCulture));
            xmlWriter.WriteAttributeString("DockBottomPortion", dockPanel.DockBottomPortion.ToString(CultureInfo.InvariantCulture));

            if (!Win32Helper.IsRunningOnMono)
            {
                xmlWriter.WriteAttributeString("ActiveDocumentPane", dockPanel.Panes.IndexOf(dockPanel.ActiveDocumentPane).ToString(CultureInfo.InvariantCulture));
                xmlWriter.WriteAttributeString("ActivePane", dockPanel.Panes.IndexOf(dockPanel.ActivePane).ToString(CultureInfo.InvariantCulture));
            }

            // Contents
            xmlWriter.WriteStartElement("Contents");
            xmlWriter.WriteAttributeString("Count", dockPanel.Contents.Count.ToString(CultureInfo.InvariantCulture));
            foreach (WorkItemDockContent content in dockPanel.Contents)
            {
                xmlWriter.WriteStartElement("Content");
                xmlWriter.WriteAttributeString("ID", dockPanel.Contents.IndexOf(content).ToString(CultureInfo.InvariantCulture));
                xmlWriter.WriteAttributeString("AutoHidePortion", content.DockHandler.AutoHidePortion.ToString(CultureInfo.InvariantCulture));
                xmlWriter.WriteAttributeString("IsHidden", content.DockHandler.IsHidden.ToString(CultureInfo.InvariantCulture));
                xmlWriter.WriteAttributeString("IsFloat", content.DockHandler.IsFloat.ToString(CultureInfo.InvariantCulture));

                content.Save(xmlWriter);

                xmlWriter.WriteEndElement();
            }
            xmlWriter.WriteEndElement();

            // Panes
            xmlWriter.WriteStartElement("Panes");
            xmlWriter.WriteAttributeString("Count", dockPanel.Panes.Count.ToString(CultureInfo.InvariantCulture));
            foreach (DockPane pane in dockPanel.Panes)
            {
                xmlWriter.WriteStartElement("Pane");
                xmlWriter.WriteAttributeString("ID", dockPanel.Panes.IndexOf(pane).ToString(CultureInfo.InvariantCulture));
                xmlWriter.WriteAttributeString("DockState", pane.DockState.ToString());
                xmlWriter.WriteAttributeString("ActiveContent", dockPanel.Contents.IndexOf(pane.ActiveContent).ToString(CultureInfo.InvariantCulture));
                xmlWriter.WriteStartElement("Contents");
                xmlWriter.WriteAttributeString("Count", pane.Contents.Count.ToString(CultureInfo.InvariantCulture));
                foreach (IDockContent content in pane.Contents)
                {
                    xmlWriter.WriteStartElement("Content");
                    xmlWriter.WriteAttributeString("ID", pane.Contents.IndexOf(content).ToString(CultureInfo.InvariantCulture));
                    xmlWriter.WriteAttributeString("RefID", dockPanel.Contents.IndexOf(content).ToString(CultureInfo.InvariantCulture));
                    xmlWriter.WriteEndElement();
                }
                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndElement();
            }
            xmlWriter.WriteEndElement();

            // DockWindows
            xmlWriter.WriteStartElement("DockWindows");
            int dockWindowId = 0;

            foreach (DockWindow dw in dockPanel.DockWindows)
            {
                xmlWriter.WriteStartElement("DockWindow");
                xmlWriter.WriteAttributeString("ID", dockWindowId.ToString(CultureInfo.InvariantCulture));
                dockWindowId++;
                xmlWriter.WriteAttributeString("DockState", dw.DockState.ToString());
                xmlWriter.WriteAttributeString("ZOrderIndex", dockPanel.Controls.IndexOf(dw).ToString(CultureInfo.InvariantCulture));
                xmlWriter.WriteStartElement("NestedPanes");
                xmlWriter.WriteAttributeString("Count", dw.NestedPanes.Count.ToString(CultureInfo.InvariantCulture));
                foreach (DockPane pane in dw.NestedPanes)
                {
                    xmlWriter.WriteStartElement("Pane");
                    xmlWriter.WriteAttributeString("ID", dw.NestedPanes.IndexOf(pane).ToString(CultureInfo.InvariantCulture));
                    xmlWriter.WriteAttributeString("RefID", dockPanel.Panes.IndexOf(pane).ToString(CultureInfo.InvariantCulture));
                    NestedDockingStatus status = pane.NestedDockingStatus;
                    xmlWriter.WriteAttributeString("PrevPane", dockPanel.Panes.IndexOf(status.PreviousPane).ToString(CultureInfo.InvariantCulture));
                    xmlWriter.WriteAttributeString("Alignment", status.Alignment.ToString());
                    xmlWriter.WriteAttributeString("Proportion", status.Proportion.ToString(CultureInfo.InvariantCulture));
                    xmlWriter.WriteEndElement();
                }
                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndElement();
            }
            xmlWriter.WriteEndElement();

            // FloatWindows
            var rectConverter = new RectangleConverter();

            xmlWriter.WriteStartElement("FloatWindows");
            xmlWriter.WriteAttributeString("Count", dockPanel.FloatWindows.Count.ToString(CultureInfo.InvariantCulture));
            foreach (FloatWindow fw in dockPanel.FloatWindows)
            {
                xmlWriter.WriteStartElement("FloatWindow");
                xmlWriter.WriteAttributeString("ID", dockPanel.FloatWindows.IndexOf(fw).ToString(CultureInfo.InvariantCulture));
                xmlWriter.WriteAttributeString("Bounds", rectConverter.ConvertToInvariantString(fw.Bounds));
                xmlWriter.WriteAttributeString("ZOrderIndex", fw.DockPanel.FloatWindows.IndexOf(fw).ToString(CultureInfo.InvariantCulture));
                xmlWriter.WriteStartElement("NestedPanes");
                xmlWriter.WriteAttributeString("Count", fw.NestedPanes.Count.ToString(CultureInfo.InvariantCulture));
                foreach (DockPane pane in fw.NestedPanes)
                {
                    xmlWriter.WriteStartElement("Pane");
                    xmlWriter.WriteAttributeString("ID", fw.NestedPanes.IndexOf(pane).ToString(CultureInfo.InvariantCulture));
                    xmlWriter.WriteAttributeString("RefID", dockPanel.Panes.IndexOf(pane).ToString(CultureInfo.InvariantCulture));
                    NestedDockingStatus status = pane.NestedDockingStatus;
                    xmlWriter.WriteAttributeString("PrevPane", dockPanel.Panes.IndexOf(status.PreviousPane).ToString(CultureInfo.InvariantCulture));
                    xmlWriter.WriteAttributeString("Alignment", status.Alignment.ToString());
                    xmlWriter.WriteAttributeString("Proportion", status.Proportion.ToString(CultureInfo.InvariantCulture));
                    xmlWriter.WriteEndElement();
                }
                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndElement();
            }
            xmlWriter.WriteEndElement();        //	</FloatWindows>

            xmlWriter.WriteEndElement();
        }
Ejemplo n.º 23
0
        private void ApplyProperties(object control, XmlNode node)
        {
            XmlNodeList props = node.SelectNodes("./property");

            foreach (XmlNode prop in props)
            {
                string propName = prop.Attributes["name"].Value;
                string propType = prop.Attributes["type"].Value;
                if (propName.ToLower() == "zorder")
                {
                    int zorder = (int)new Int32Converter().ConvertFromString(prop.Attributes["value"].Value);
                    (control as Control).Parent.Controls.SetChildIndex(control as Control, zorder);
                }
                else
                {
                    PropertyInfo propInfo = control.GetType().GetProperty(propName, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.IgnoreCase, null, null, new Type[0], null);
                    if (propInfo != null)
                    {
                        object value = null;
                        switch (propType.ToLower())
                        {
                        case "binding":
                        {
                            if (control is Control cont)
                            {
                                cont.DataBindings.Add(propName, this, prop.Attributes["value"].Value);
                            }
                            break;
                        }

                        case "colour":
                        case "color":
                        {
                            value = new ColorConverter().ConvertFromInvariantString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "font":
                        {
                            value = new FontConverter().ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "string":
                        {
                            value = new StringConverter().ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "boolean":
                        case "bool":
                        {
                            value = new BooleanConverter().ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "location":
                        case "point":
                        {
                            var p = (Point) new PointConverter().ConvertFromString(prop.Attributes["value"].Value);
                            if (p.X < 0)
                            {
                                p.X = this.DisplayRectangle.Right + p.X;
                            }
                            if (p.Y < 0)
                            {
                                p.Y = this.DisplayRectangle.Bottom + p.Y;
                            }
                            value = p;
                            break;
                        }

                        case "size":
                        {
                            var s = (Size) new SizeConverter().ConvertFromString(prop.Attributes["value"].Value);
                            if (s.Width < 0)
                            {
                                s.Width = this.DisplayRectangle.Width + s.Width;
                            }
                            if (s.Height < 0)
                            {
                                s.Height = this.DisplayRectangle.Height + s.Height;
                            }
                            value = s;
                            break;
                        }

                        case "integer":
                        case "int32":
                        case "int":
                        {
                            value = new Int32Converter().ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "rect":
                        case "rectangle":
                        {
                            value = new RectangleConverter().ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "margin":
                        case "padding":
                        {
                            value = new PaddingConverter().ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "dock":
                        {
                            value = new EnumConverter(typeof(DockStyle)).ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "anchor":
                        {
                            value = new EnumConverter(typeof(AnchorStyles)).ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "pictureboxsizemode":
                        case "sizemode":
                        {
                            value = new EnumConverter(typeof(PictureBoxSizeMode)).ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "contentalignment":
                        case "textalign":
                        case "align":
                        case "alignment":
                        {
                            value = new EnumConverter(typeof(ContentAlignment)).ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "image":
                        {
                            string filename = prop.Attributes["value"].Value;
                            filename = filename.Replace("{skindir}", System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "Skins"));
                            value    = Image.FromFile(filename);
                            break;
                        }

                        case "object":
                        {
                            // that means this property has properties of its own, so....
                            object propValue = propInfo.GetValue(control, null);
                            if (propValue != null)
                            {
                                ApplyProperties(propValue, prop);
                            }
                            break;
                        }
                        }
                        if (value != null)
                        {
                            propInfo.SetValue(control, value, null);
                        }
                    }
                }
            }
        }
Ejemplo n.º 24
0
 /// <summary>Creates an instance for the default language.</summary>
 /// <param name="continentId">The continent identifier.</param>
 /// <returns>A repository.</returns>
 public IFloorRepository ForDefaultCulture(int continentId)
 {
     var pointOfInterestConverterFactory = new PointOfInterestConverterFactory();
     var vector2DConverter = new Vector2DConverter();
     var rectangleConverter = new RectangleConverter(vector2DConverter);
     var pointOfInterestConverter = new PointOfInterestConverter(pointOfInterestConverterFactory, vector2DConverter);
     var pointOfInterestCollectionConverter = new CollectionConverter<PointOfInterestDTO, PointOfInterest>(pointOfInterestConverter);
     var renownTaskConverter = new RenownTaskConverter(vector2DConverter);
     var renownTaskCollectionConverter = new CollectionConverter<RenownTaskDTO, RenownTask>(renownTaskConverter);
     var skillChallengeConverter = new SkillChallengeConverter(vector2DConverter);
     var skillChallengeCollectionConverter = new CollectionConverter<SkillChallengeDTO, SkillChallenge>(skillChallengeConverter);
     var outputConverter = new SectorConverter(vector2DConverter);
     var sectorCollectionConverter = new CollectionConverter<SectorDTO, Sector>(outputConverter);
     var subregionConverter = new SubregionConverter(rectangleConverter, pointOfInterestCollectionConverter, renownTaskCollectionConverter, skillChallengeCollectionConverter, sectorCollectionConverter);
     var keyValuePairConverter = new SubregionKeyValuePairConverter(subregionConverter);
     var subregionKeyValuePairConverter = new DictionaryConverter<string, SubregionDTO, int, Subregion>(keyValuePairConverter);
     var regionConverter = new RegionConverter(vector2DConverter, subregionKeyValuePairConverter);
     var regionKeyValuePairConverter = new RegionKeyValuePairConverter(regionConverter);
     var regionCollectionConverter = new DictionaryConverter<string, RegionDTO, int, Region>(regionKeyValuePairConverter);
     var size2DConverter = new Size2DConverter();
     var floorConverter = new FloorConverter(size2DConverter, rectangleConverter, regionCollectionConverter);
     return new FloorRepository(continentId, this.serviceClient, floorConverter);
 }
Ejemplo n.º 25
0
        private void SetProperty(PropertyInfo p, object val)
        {
            if (p == null)
            {
                return;
            }

            if (val == null)
            {
                this.GetType().InvokeMember(p.Name,
                                            BindingFlags.DeclaredOnly | BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty,
                                            null, this, new object[] { null });
            }
            else
            {
                string str = val.ToString();

                if (p.PropertyType == typeof(string))
                {
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { str });
                    return;
                }

                if (p.PropertyType == typeof(DateTime))
                {
                    DateTime v = DateTime.Parse(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(decimal))
                {
                    decimal v = decimal.Parse(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(int))
                {
                    int v = int.Parse(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(long))
                {
                    long v = long.Parse(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(float))
                {
                    float v = float.Parse(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(double))
                {
                    double v = double.Parse(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(Color))
                {
                    ColorConverter cc = new ColorConverter();
                    Color          v  = (Color)cc.ConvertFromInvariantString(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(Font))
                {
                    FontConverter cc = new FontConverter();
                    Font          v  = (Font)cc.ConvertFromInvariantString(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(Point))
                {
                    PointConverter cc = new PointConverter();
                    Point          v  = (Point)cc.ConvertFromInvariantString(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(Size))
                {
                    SizeConverter cc = new SizeConverter();
                    Size          v  = (Size)cc.ConvertFromInvariantString(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(Rectangle))
                {
                    RectangleConverter cc = new RectangleConverter();
                    Rectangle          v  = (Rectangle)cc.ConvertFromInvariantString(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 폴더 폼 생성
        /// </summary>
        private void showFormFolder()
        {
            if (mainFolder == null)
            {
                mainFolder = new Form_Folder();

                // mainFolder 폼이 닫힐때 실행될 이벤트 할당
                mainFolder.FormClosed += delegate(Object tmp_sender, FormClosedEventArgs tmp_e)
                {
                    mainFolder.Dispose();
                    mainFolder    = null;
                    trayIcon.Text = DEFINE.TRAY_NAME;
                };

                // mainFolder 폼의 설정값이 변경될때 실행될 이벤트 할당
                mainFolder.throw_Environment_SettingChanged += mainFolder_throw_Environment_SettingChanged;


                // mainFolder TopMost 여부 지정
                mainFolder.TopMost = configDoc.SelectSingleNode("//SETTING/" + DEFINE.CONFIG_SETTING_TOPMOST).InnerText == "TRUE" ? true : false;


                // mainFolder 크기 지정(기존에 저장된 위치값 있는지)
                #region
                String str_mainFolder_rect = configDoc.SelectSingleNode("//SETTING/" + DEFINE.CONFIG_SETTING_CLOSERECT).InnerText;
                if (!String.IsNullOrEmpty(str_mainFolder_rect))
                {
                    RectangleConverter rc      = new RectangleConverter();
                    Rectangle          tmpRect = (Rectangle)rc.ConvertFromString(str_mainFolder_rect);

                    Screen[] sc = Screen.AllScreens;
                    for (int i = 0; i < sc.Length; i++)
                    {
                        if (sc[i].WorkingArea.Contains(tmpRect)) //맞는 화면 존재 시
                        {
                            mainFolder.Location = tmpRect.Location;
                            mainFolder.Size     = tmpRect.Size;
                            break;
                        }
                        else if (sc[i].WorkingArea.IntersectsWith(tmpRect)) //교차하는 화면 존재 시
                        {
                            // 넓이, 높이 체크, x,y조정
                            Rectangle scRect = sc[i].Bounds;
                            if (scRect.Width < tmpRect.Width)
                            {
                                tmpRect.Width = scRect.Width;
                            }
                            if (scRect.Height < tmpRect.Height)
                            {
                                tmpRect.Height = scRect.Height;
                            }

                            if (scRect.Left > tmpRect.Left)
                            {
                                tmpRect.X = scRect.Left;
                            }
                            if (scRect.Right < tmpRect.Right)
                            {
                                tmpRect.X = scRect.Right - tmpRect.Width;
                            }
                            if (scRect.Top > tmpRect.Top)
                            {
                                tmpRect.Y = scRect.Top;
                            }
                            if (scRect.Bottom < tmpRect.Bottom)
                            {
                                tmpRect.Y = scRect.Bottom - tmpRect.Height;
                            }

                            mainFolder.Location = tmpRect.Location;
                            mainFolder.Size     = tmpRect.Size;
                            break;
                        }
                        else
                        {
                            //mainFolder.Size = tmpRect.Size;
                            Rectangle primaryScreen_bounds = Screen.PrimaryScreen.Bounds;
                            Size      mainFolder_size      = DEFINE.DEFAULT_FOLDER_SIZE;
                            mainFolder.DesktopBounds = new Rectangle((primaryScreen_bounds.Width - mainFolder_size.Width) - 3, 3, mainFolder_size.Width, mainFolder_size.Height);
                        }
                    }
                }
                else
                {
                    Rectangle primaryScreen_bounds = Screen.PrimaryScreen.Bounds;
                    Size      mainFolder_size      = DEFINE.DEFAULT_FOLDER_SIZE;
                    mainFolder.DesktopBounds = new Rectangle((primaryScreen_bounds.Width - mainFolder_size.Width) - 3, 3, mainFolder_size.Width, mainFolder_size.Height);
                }
                mainFolder.MinimumSize = DEFINE.DEFAULT_FOLDER_SIZE;
                #endregion

                mainFolder.occurred_event += mainFolder_occurred_event;

                mainFolder.Text          = DEFINE.TRAY_NAME;
                mainFolder.ShowInTaskbar = false;
                mainFolder.Show(this);

                //trayIcon.Text = DEFINE.TRAY_NAME + " (RUNNING...)";
            }
            else
            {
                mainFolder.Activate();
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Load the application config file and restore form position
        /// </summary>
        private void LoadConfigFile()
        {
            TextReader reader     = null;
            Rectangle  formBounds = Rectangle.Empty;

            try
            {
                string configFolder = Path.GetDirectoryName(InstallPadApp.ConfigFilePath);
                if (!Directory.Exists(configFolder))
                {
                    Directory.CreateDirectory(configFolder);
                }

                reader = new StreamReader(InstallPadApp.ConfigFilePath);
                RectangleConverter converter = new RectangleConverter();
                formBounds = (Rectangle)converter.ConvertFromString(reader.ReadLine());
            }
            catch (NotSupportedException)
            {
                // Error in the configure file. Ignore
            }
            catch (IOException)
            {
                // No config file found. Ignore
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            if (formBounds != Rectangle.Empty)
            {
                // If the bounds are outside of the screen's work area, move the form so it's not outside
                // of the work area. This can happen if the user changes their resolution
                // and we then restore the applicationto its position -- it may be off screen and
                // then they can't see it or move it.

                // Get the working area of the monitor that contains this rectangle (in case it's a
                // multi-display system
                Rectangle workingArea = Screen.GetWorkingArea(formBounds);
                if (formBounds.Left < workingArea.Left)
                {
                    formBounds.Location = new Point(workingArea.Location.X, formBounds.Location.Y);
                }
                if (formBounds.Top < workingArea.Top)
                {
                    formBounds.Location = new Point(formBounds.Location.X, workingArea.Location.Y);
                }
                if (formBounds.Right > workingArea.Right)
                {
                    formBounds.Location = new Point(formBounds.X - (formBounds.Right - workingArea.Right),
                                                    formBounds.Location.Y);
                }
                if (formBounds.Bottom > workingArea.Bottom)
                {
                    formBounds.Location = new Point(formBounds.X,
                                                    formBounds.Y - (formBounds.Bottom - workingArea.Bottom));
                }

                this.Bounds = formBounds;
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 이름 정보 변경
        /// </summary>
        /// <param name="item"></param>
        private void renameItem(Item item, string newName)
        {
            XmlDocument xmlDoc   = Common.XmlControl.getInstance().xmlLoad(DEFINE.MEMO_DATA_PATH);
            XmlNode     memoNode = xmlDoc.SelectSingleNode("//MEMODATA");
            String      path     = item.PATH;

            if (path != "/")
            {
                String[] paths = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < paths.Length; i++)
                {
                    memoNode = memoNode.SelectSingleNode("./" + DEFINE.NODE_GROUPNAME + "[@name='" + paths[i] + "']");
                }
            }

            string  targetType = item.TYPE == DEFINE.FILETYPE.FILETYPE_TEXT ? DEFINE.NODE_MEMONAME : DEFINE.NODE_GROUPNAME;
            XmlNode targetNode = memoNode.SelectSingleNode("./" + targetType + "[@name='" + item.TITLE + "']");


            XmlNode      tmpNode = xmlDoc.CreateNode(XmlNodeType.Element, targetNode.Name, "");
            XmlAttribute attr1   = xmlDoc.CreateAttribute("name");

            attr1.Value = newName;
            tmpNode.Attributes.Append(attr1);

            // 이름 바뀐 항목이 Memo인 경우
            if (targetType == DEFINE.NODE_MEMONAME)
            {
                RectangleConverter rc = new RectangleConverter();

                XmlAttribute attr2 = xmlDoc.CreateAttribute("text");
                attr2.Value = item.TEXT;
                tmpNode.Attributes.Append(attr2);
                XmlAttribute attr3 = xmlDoc.CreateAttribute("rect");
                attr3.Value = rc.ConvertToString(item.RECT);
                tmpNode.Attributes.Append(attr3);



                // 현재 이름 변경하는 메모 폼이 열려있을 경우 TITLE 변경
                for (int i = memoForms.Count - 1; i >= 0; i--)
                {
                    if (memoForms[i].g_item.PATH == item.PATH && memoForms[i].g_item.TITLE == item.TITLE)
                    {
                        memoForms[i].g_item.TITLE = newName;
                        memoForms[i].refresh_memoInfo();
                    }
                }
            }
            else if (targetType == DEFINE.NODE_GROUPNAME) //이름 바뀐 항목이 그룹인 경우
            {
                tmpNode.InnerXml = targetNode.InnerXml;
                string groupPath_old = item.PATH + item.TITLE;

                string[] paths = groupPath_old.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                // 현재 이름 변경하는 그룹에 하위항목에 해당하는 메모 폼이 열려있을 경우
                for (int i = memoForms.Count - 1; i >= 0; i--)
                {
                    string[] paths2  = memoForms[i].g_item.PATH.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                    bool     isChild = true;
                    for (int j = 0; j < paths2.Length; j++)
                    {
                        if (paths.Length < paths2.Length ? true : paths[j] != paths2[j])
                        {
                            isChild = false;
                            break;
                        }
                    }
                    if (isChild)
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.Append('/');
                        for (int j = 0; j < paths2.Length; j++)
                        {
                            if (j == paths.Length - 1)
                            {
                                sb.Append(newName);
                            }
                            else
                            {
                                sb.Append(paths2[j]);
                            }
                            sb.Append('/');
                        }
                        memoForms[i].g_item.PATH = sb.ToString();
                        memoForms[i].refresh_memoInfo();
                    }
                }
            }

            targetNode.ParentNode.ReplaceChild(tmpNode, targetNode);

            Common.XmlControl.getInstance().xmlSave(xmlDoc, DEFINE.MEMO_DATA_PATH);

            if (mainFolder != null)
            {
                mainFolder.listViewReload();
            }
        }
Ejemplo n.º 29
0
        private object ProcessGetValue(Type type, MemberInfo memInfo, object result)
        {
            if (type == typeof(string))
            {
                if (memInfo == null)
                {
                    return(result);
                }
                object[] olist = memInfo.GetCustomAttributes(XObjectHelper.XCDataAttributeType, false);
                if (olist == null || olist.Length < 1 || result == null)
                {
                    return(result);
                }

                XCDataAttribute attr = olist[0] as XCDataAttribute;
                if (attr == null || attr.EnableCData == false)
                {
                    return(result);
                }
                return("<![CDATA[" + result.ToString() + "]]>");
            }

            if (type == typeof(Color))
            {
                ColorConverter cc = new ColorConverter();
                return(cc.ConvertToInvariantString(result));
            }

            if (type == typeof(Font))
            {
                FontConverter cc = new FontConverter();
                return(cc.ConvertToInvariantString(result));
            }

            if (type == typeof(Point))
            {
                PointConverter cc = new PointConverter();
                return(cc.ConvertToInvariantString(result));
            }

            if (type == typeof(Rectangle))
            {
                RectangleConverter cc = new RectangleConverter();
                return(cc.ConvertToInvariantString(result));
            }

            if (type == typeof(Size))
            {
                SizeConverter cc = new SizeConverter();
                return(cc.ConvertToInvariantString(result));
            }

            //if (type == typeof(Type))
            //{
            //    if (result == null) return "";
            //    return result.ToString();
            //}

            if (!XObjectHelper.IsXBaseType(type))
            {
                TypeConverter tc = TypeDescriptor.GetConverter(type);
                if (tc != null)
                {
                    return(tc.ConvertToInvariantString(result));
                }
            }

            return(result);
        }
Ejemplo n.º 30
0
        public static void LoadFromXml(DockContainer dockPanel, Stream stream, DeserializeDockContent deserializeContent, bool closeStream)
        {
            if (dockPanel.Contents.Count != 0)
            {
                throw new InvalidOperationException(ResourceHelper.GetString("DockPanel.LoadFromXml.AlreadyInitialized"));
            }

            EnumConverter      dockStateConverter     = new EnumConverter(typeof(DockState));
            EnumConverter      dockAlignmentConverter = new EnumConverter(typeof(DockAlignment));
            RectangleConverter rectConverter          = new RectangleConverter();

            XmlTextReader xmlIn = new XmlTextReader(stream);

            xmlIn.WhitespaceHandling = WhitespaceHandling.None;
            xmlIn.MoveToContent();

            while (!xmlIn.Name.Equals("DockPanel"))
            {
                if (!MoveToNextElement(xmlIn))
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }
            }

            string formatVersion = xmlIn.GetAttribute("FormatVersion");

            if (!IsFormatVersionValid(formatVersion))
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidFormatVersion"));
            }

            DockPanelStruct dockPanelStruct = new DockPanelStruct();

            dockPanelStruct.DockLeftPortion         = Convert.ToDouble(xmlIn.GetAttribute("DockLeftPortion"), CultureInfo.InvariantCulture);
            dockPanelStruct.DockRightPortion        = Convert.ToDouble(xmlIn.GetAttribute("DockRightPortion"), CultureInfo.InvariantCulture);
            dockPanelStruct.DockTopPortion          = Convert.ToDouble(xmlIn.GetAttribute("DockTopPortion"), CultureInfo.InvariantCulture);
            dockPanelStruct.DockBottomPortion       = Convert.ToDouble(xmlIn.GetAttribute("DockBottomPortion"), CultureInfo.InvariantCulture);
            dockPanelStruct.IndexActiveDocumentPane = Convert.ToInt32(xmlIn.GetAttribute("ActiveDocumentPane"));
            dockPanelStruct.IndexActivePane         = Convert.ToInt32(xmlIn.GetAttribute("ActivePane"));

            // Load Contents
            MoveToNextElement(xmlIn);
            if (xmlIn.Name != "Contents")
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
            }
            int countOfContents = Convert.ToInt32(xmlIn.GetAttribute("Count"));

            ContentStruct[] contents = new ContentStruct[countOfContents];
            MoveToNextElement(xmlIn);
            for (int i = 0; i < countOfContents; i++)
            {
                int id = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                if (xmlIn.Name != "Content" || id != i)
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }

                contents[i].PersistString   = xmlIn.GetAttribute("PersistString");
                contents[i].AutoHidePortion = Convert.ToDouble(xmlIn.GetAttribute("AutoHidePortion"), CultureInfo.InvariantCulture);
                contents[i].IsHidden        = Convert.ToBoolean(xmlIn.GetAttribute("IsHidden"));
                contents[i].IsFloat         = Convert.ToBoolean(xmlIn.GetAttribute("IsFloat"));
                MoveToNextElement(xmlIn);
            }

            // Load Panes
            if (xmlIn.Name != "Panes")
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
            }
            int countOfPanes = Convert.ToInt32(xmlIn.GetAttribute("Count"));

            PaneStruct[] panes = new PaneStruct[countOfPanes];
            MoveToNextElement(xmlIn);
            for (int i = 0; i < countOfPanes; i++)
            {
                int id = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                if (xmlIn.Name != "Pane" || id != i)
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }

                panes[i].DockState          = (DockState)dockStateConverter.ConvertFrom(xmlIn.GetAttribute("DockState"));
                panes[i].IndexActiveContent = Convert.ToInt32(xmlIn.GetAttribute("ActiveContent"));
                panes[i].ZOrderIndex        = -1;

                MoveToNextElement(xmlIn);
                if (xmlIn.Name != "Contents")
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }
                int countOfPaneContents = Convert.ToInt32(xmlIn.GetAttribute("Count"));
                panes[i].IndexContents = new int[countOfPaneContents];
                MoveToNextElement(xmlIn);
                for (int j = 0; j < countOfPaneContents; j++)
                {
                    int id2 = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                    if (xmlIn.Name != "Content" || id2 != j)
                    {
                        throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                    }

                    panes[i].IndexContents[j] = Convert.ToInt32(xmlIn.GetAttribute("RefID"));
                    MoveToNextElement(xmlIn);
                }
            }

            // Load DockWindows
            if (xmlIn.Name != "DockWindows")
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
            }
            int countOfDockWindows = dockPanel.DockWindows.Count;

            DockWindowStruct[] dockWindows = new DockWindowStruct[countOfDockWindows];
            MoveToNextElement(xmlIn);
            for (int i = 0; i < countOfDockWindows; i++)
            {
                int id = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                if (xmlIn.Name != "DockWindow" || id != i)
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }

                dockWindows[i].DockState   = (DockState)dockStateConverter.ConvertFrom(xmlIn.GetAttribute("DockState"));
                dockWindows[i].ZOrderIndex = Convert.ToInt32(xmlIn.GetAttribute("ZOrderIndex"));
                MoveToNextElement(xmlIn);
                if (xmlIn.Name != "DockList")
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }
                int countOfDockList = Convert.ToInt32(xmlIn.GetAttribute("Count"));
                dockWindows[i].DockList = new DockListItem[countOfDockList];
                MoveToNextElement(xmlIn);
                for (int j = 0; j < countOfDockList; j++)
                {
                    int id2 = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                    if (xmlIn.Name != "Pane" || id2 != j)
                    {
                        throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                    }
                    dockWindows[i].DockList[j].IndexPane     = Convert.ToInt32(xmlIn.GetAttribute("RefID"));
                    dockWindows[i].DockList[j].IndexPrevPane = Convert.ToInt32(xmlIn.GetAttribute("PrevPane"));
                    dockWindows[i].DockList[j].Alignment     = (DockAlignment)dockAlignmentConverter.ConvertFrom(xmlIn.GetAttribute("Alignment"));
                    dockWindows[i].DockList[j].Proportion    = Convert.ToDouble(xmlIn.GetAttribute("Proportion"), CultureInfo.InvariantCulture);
                    MoveToNextElement(xmlIn);
                }
            }

            // Load FloatWindows
            if (xmlIn.Name != "FloatWindows")
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
            }
            int countOfFloatWindows = Convert.ToInt32(xmlIn.GetAttribute("Count"));

            FloatWindowStruct[] floatWindows = new FloatWindowStruct[countOfFloatWindows];
            MoveToNextElement(xmlIn);
            for (int i = 0; i < countOfFloatWindows; i++)
            {
                int id = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                if (xmlIn.Name != "FloatWindow" || id != i)
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }

                floatWindows[i].Bounds         = (Rectangle)rectConverter.ConvertFromInvariantString(xmlIn.GetAttribute("Bounds"));
                floatWindows[i].AllowRedocking = Convert.ToBoolean(xmlIn.GetAttribute("AllowRedocking"));
                floatWindows[i].ZOrderIndex    = Convert.ToInt32(xmlIn.GetAttribute("ZOrderIndex"));
                MoveToNextElement(xmlIn);
                if (xmlIn.Name != "DockList")
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }
                int countOfDockList = Convert.ToInt32(xmlIn.GetAttribute("Count"));
                floatWindows[i].DockList = new DockListItem[countOfDockList];
                MoveToNextElement(xmlIn);
                for (int j = 0; j < countOfDockList; j++)
                {
                    int id2 = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                    if (xmlIn.Name != "Pane" || id2 != j)
                    {
                        throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                    }
                    floatWindows[i].DockList[j].IndexPane     = Convert.ToInt32(xmlIn.GetAttribute("RefID"));
                    floatWindows[i].DockList[j].IndexPrevPane = Convert.ToInt32(xmlIn.GetAttribute("PrevPane"));
                    floatWindows[i].DockList[j].Alignment     = (DockAlignment)dockAlignmentConverter.ConvertFrom(xmlIn.GetAttribute("Alignment"));
                    floatWindows[i].DockList[j].Proportion    = Convert.ToDouble(xmlIn.GetAttribute("Proportion"), CultureInfo.InvariantCulture);
                    MoveToNextElement(xmlIn);
                }
            }

            if (closeStream)
            {
                xmlIn.Close();
            }

            dockPanel.DockLeftPortion   = dockPanelStruct.DockLeftPortion;
            dockPanel.DockRightPortion  = dockPanelStruct.DockRightPortion;
            dockPanel.DockTopPortion    = dockPanelStruct.DockTopPortion;
            dockPanel.DockBottomPortion = dockPanelStruct.DockBottomPortion;

            // Set DockWindow ZOrders
            int prevMaxDockWindowZOrder = int.MaxValue;

            for (int i = 0; i < dockWindows.Length; i++)
            {
                int maxDockWindowZOrder = -1;
                int index = -1;
                for (int j = 0; j < dockWindows.Length; j++)
                {
                    if (dockWindows[j].ZOrderIndex > maxDockWindowZOrder && dockWindows[j].ZOrderIndex < prevMaxDockWindowZOrder)
                    {
                        maxDockWindowZOrder = dockWindows[j].ZOrderIndex;
                        index = j;
                    }
                }

                dockPanel.DockWindows[dockWindows[index].DockState].BringToFront();
                prevMaxDockWindowZOrder = maxDockWindowZOrder;
            }

            // Create Contents
            for (int i = 0; i < contents.Length; i++)
            {
                IDockableWindow content = deserializeContent(contents[i].PersistString);
                if (content == null)
                {
                    content = new DummyContent();
                }
                content.DockHandler.DockPanel       = dockPanel;
                content.DockHandler.AutoHidePortion = contents[i].AutoHidePortion;
                content.DockHandler.IsHidden        = true;
                content.DockHandler.IsFloat         = contents[i].IsFloat;
            }

            // Create panes
            for (int i = 0; i < panes.Length; i++)
            {
                DockPane pane = null;
                for (int j = 0; j < panes[i].IndexContents.Length; j++)
                {
                    IDockableWindow content = dockPanel.Contents[panes[i].IndexContents[j]];
                    if (j == 0)
                    {
                        pane = dockPanel.DockPaneFactory.CreateDockPane(content, panes[i].DockState, false);
                    }
                    else if (panes[i].DockState == DockState.Float)
                    {
                        content.DockHandler.FloatPane = pane;
                    }
                    else
                    {
                        content.DockHandler.PanelPane = pane;
                    }
                }
            }

            // Assign Panes to DockWindows
            for (int i = 0; i < dockWindows.Length; i++)
            {
                for (int j = 0; j < dockWindows[i].DockList.Length; j++)
                {
                    DockWindow    dw            = dockPanel.DockWindows[dockWindows[i].DockState];
                    int           indexPane     = dockWindows[i].DockList[j].IndexPane;
                    DockPane      pane          = dockPanel.Panes[indexPane];
                    int           indexPrevPane = dockWindows[i].DockList[j].IndexPrevPane;
                    DockPane      prevPane      = (indexPrevPane == -1) ? dw.DockList.GetDefaultPrevPane(pane) : dockPanel.Panes[indexPrevPane];
                    DockAlignment alignment     = dockWindows[i].DockList[j].Alignment;
                    double        proportion    = dockWindows[i].DockList[j].Proportion;
                    pane.AddToDockList(dw, prevPane, alignment, proportion);
                    if (panes[indexPane].DockState == dw.DockState)
                    {
                        panes[indexPane].ZOrderIndex = dockWindows[i].ZOrderIndex;
                    }
                }
            }

            // Create float windows
            for (int i = 0; i < floatWindows.Length; i++)
            {
                FloatWindow fw = null;
                for (int j = 0; j < floatWindows[i].DockList.Length; j++)
                {
                    int      indexPane = floatWindows[i].DockList[j].IndexPane;
                    DockPane pane      = dockPanel.Panes[indexPane];
                    if (j == 0)
                    {
                        fw = dockPanel.FloatWindowFactory.CreateFloatWindow(dockPanel, pane, floatWindows[i].Bounds);
                    }
                    else
                    {
                        int           indexPrevPane = floatWindows[i].DockList[j].IndexPrevPane;
                        DockPane      prevPane      = indexPrevPane == -1 ? null : dockPanel.Panes[indexPrevPane];
                        DockAlignment alignment     = floatWindows[i].DockList[j].Alignment;
                        double        proportion    = floatWindows[i].DockList[j].Proportion;
                        pane.AddToDockList(fw, prevPane, alignment, proportion);
                        if (panes[indexPane].DockState == fw.DockState)
                        {
                            panes[indexPane].ZOrderIndex = floatWindows[i].ZOrderIndex;
                        }
                    }
                }
            }

            // sort IDockContent by its Pane's ZOrder
            int[] sortedContents = null;
            if (contents.Length > 0)
            {
                sortedContents = new int[contents.Length];
                for (int i = 0; i < contents.Length; i++)
                {
                    sortedContents[i] = i;
                }

                int lastDocument = contents.Length;
                for (int i = 0; i < contents.Length - 1; i++)
                {
                    for (int j = i + 1; j < contents.Length; j++)
                    {
                        DockPane pane1        = dockPanel.Contents[sortedContents[i]].DockHandler.Pane;
                        int      ZOrderIndex1 = pane1 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane1)].ZOrderIndex;
                        DockPane pane2        = dockPanel.Contents[sortedContents[j]].DockHandler.Pane;
                        int      ZOrderIndex2 = pane2 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane2)].ZOrderIndex;
                        if (ZOrderIndex1 > ZOrderIndex2)
                        {
                            int temp = sortedContents[i];
                            sortedContents[i] = sortedContents[j];
                            sortedContents[j] = temp;
                        }
                    }
                }
            }

            // show non-document IDockContent first to avoid screen flickers
            for (int i = 0; i < contents.Length; i++)
            {
                IDockableWindow content = dockPanel.Contents[sortedContents[i]];
                if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState != DockState.Document)
                {
                    content.DockHandler.IsHidden = contents[sortedContents[i]].IsHidden;
                }
            }

            // after all non-document IDockContent, show document IDockContent
            for (int i = 0; i < contents.Length; i++)
            {
                IDockableWindow content = dockPanel.Contents[sortedContents[i]];
                if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState == DockState.Document)
                {
                    content.DockHandler.IsHidden = contents[sortedContents[i]].IsHidden;
                }
            }

            for (int i = 0; i < panes.Length; i++)
            {
                dockPanel.Panes[i].ActiveContent = panes[i].IndexActiveContent == -1 ? null : dockPanel.Contents[panes[i].IndexActiveContent];
            }

            if (dockPanelStruct.IndexActiveDocumentPane != -1)
            {
                dockPanel.Panes[dockPanelStruct.IndexActiveDocumentPane].Activate();
            }

            if (dockPanelStruct.IndexActivePane != -1)
            {
                dockPanel.Panes[dockPanelStruct.IndexActivePane].Activate();
            }

            for (int i = dockPanel.Contents.Count - 1; i >= 0; i--)
            {
                if (dockPanel.Contents[i] is DummyContent)
                {
                    dockPanel.Contents[i].DockHandler.Form.Close();
                }
            }
        }
Ejemplo n.º 31
0
        private bool ProcessSetValue(Type type, string name, string newvalue)
        {
            if (type == typeof(string))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { newvalue });
                return(true);
            }

            if (type == typeof(bool))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { bool.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(int))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { int.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(long))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { long.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(decimal))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { decimal.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(float))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { float.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(double))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { double.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(char))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { char.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(Enum) || type.BaseType == typeof(Enum))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { Enum.Parse(type, newvalue) });
                return(true);
            }

            if (type == typeof(Single))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { Single.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(Byte))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { Byte.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(SByte))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { SByte.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(Int16))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { Int16.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(Int32))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { Int32.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(Int64))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { Int64.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(UInt16))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { UInt16.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(UInt32))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { UInt32.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(UInt64))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { UInt64.Parse(newvalue) });
                return(true);
            }

            // 20080827 : DateTimeConvertor.ConvertToInvariantString(DateTime.MinValue) return empty string ""
            //            which cannot be parsed by following culture specific method.

            //if( type == typeof( DateTime ) )
            //{
            //    this.GetType().InvokeMember( name,
            //        /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
            //        BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField ,
            //        null, this, new object[]{ DateTime.Parse(newvalue) } );
            //    return true;
            //}

            if (type == typeof(TimeSpan))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { TimeSpan.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(Color))
            {
                ColorConverter cc = new ColorConverter();

                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { cc.ConvertFromInvariantString(newvalue) });
                return(true);
            }

            if (type == typeof(Font))
            {
                FontConverter cc = new FontConverter();

                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { cc.ConvertFromInvariantString(newvalue) });
                return(true);
            }

            if (type == typeof(Point))
            {
                PointConverter cc = new PointConverter();

                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { cc.ConvertFromInvariantString(newvalue) });
                return(true);
            }

            if (type == typeof(Rectangle))
            {
                RectangleConverter cc = new RectangleConverter();

                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { cc.ConvertFromInvariantString(newvalue) });
                return(true);
            }

            if (type == typeof(Size))
            {
                SizeConverter cc = new SizeConverter();

                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { cc.ConvertFromInvariantString(newvalue) });
                return(true);
            }

            //if (type == typeof(Type))
            //{
            //    Type newType = null;
            //    if (newvalue != null && newvalue.Length > 0)
            //    {
            //        newType = Type.GetType(newvalue, true);
            //    }

            //    this.GetType().InvokeMember(name,
            //        /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
            //        BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
            //        null, this, new object[] { newType });
            //    return true;
            //}

            if (!XObjectHelper.IsXBaseType(type))
            {
                TypeConverter tc = TypeDescriptor.GetConverter(type);
                if (tc == null)
                {
                    return(true);
                }

                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { tc.ConvertFromInvariantString(newvalue) });
                return(true);
            }

            return(true);
        }
Ejemplo n.º 32
0
            public static void SaveAsXml(DockPanel dockPanel, Stream stream, Encoding encoding, bool upstream)
            {
                XmlTextWriter xmlOut = new XmlTextWriter(stream, encoding);

                // Use indenting for readability
                xmlOut.Formatting = Formatting.Indented;

                if (!upstream)
                {
                    xmlOut.WriteStartDocument();
                }

                // Always begin file with identification and warning
                xmlOut.WriteComment(Resources.DockPanel_Persistor_XmlFileComment1);
                xmlOut.WriteComment(Resources.DockPanel_Persistor_XmlFileComment2);

                // Associate a version number with the root element so that future version of the code
                // will be able to be backwards compatible or at least recognise out of date versions
                xmlOut.WriteStartElement("DockPanel");
                xmlOut.WriteAttributeString("FormatVersion", ConfigFileVersion);
                xmlOut.WriteAttributeString("DockLeftPortion", dockPanel.DockLeftPortion.ToString(CultureInfo.InvariantCulture));
                xmlOut.WriteAttributeString("DockRightPortion", dockPanel.DockRightPortion.ToString(CultureInfo.InvariantCulture));
                xmlOut.WriteAttributeString("DockTopPortion", dockPanel.DockTopPortion.ToString(CultureInfo.InvariantCulture));
                xmlOut.WriteAttributeString("DockBottomPortion", dockPanel.DockBottomPortion.ToString(CultureInfo.InvariantCulture));
                xmlOut.WriteAttributeString("ActiveDocumentPane", dockPanel.Panes.IndexOf(dockPanel.ActiveDocumentPane).ToString(CultureInfo.InvariantCulture));
                xmlOut.WriteAttributeString("ActivePane", dockPanel.Panes.IndexOf(dockPanel.ActivePane).ToString(CultureInfo.InvariantCulture));

                // Contents
                xmlOut.WriteStartElement("Contents");
                xmlOut.WriteAttributeString("Count", dockPanel.Contents.Count.ToString(CultureInfo.InvariantCulture));
                foreach (IDockContent content in dockPanel.Contents)
                {
                    xmlOut.WriteStartElement("Content");
                    xmlOut.WriteAttributeString("ID", dockPanel.Contents.IndexOf(content).ToString(CultureInfo.InvariantCulture));
                    xmlOut.WriteAttributeString("PersistString", content.DockHandler.PersistString);
                    xmlOut.WriteAttributeString("AutoHidePortion", content.DockHandler.AutoHidePortion.ToString(CultureInfo.InvariantCulture));
                    xmlOut.WriteAttributeString("IsHidden", content.DockHandler.IsHidden.ToString(CultureInfo.InvariantCulture));
                    xmlOut.WriteAttributeString("IsFloat", content.DockHandler.IsFloat.ToString(CultureInfo.InvariantCulture));
                    xmlOut.WriteEndElement();
                }
                xmlOut.WriteEndElement();

                // Panes
                xmlOut.WriteStartElement("Panes");
                xmlOut.WriteAttributeString("Count", dockPanel.Panes.Count.ToString(CultureInfo.InvariantCulture));
                foreach (DockPane pane in dockPanel.Panes)
                {
                    xmlOut.WriteStartElement("Pane");
                    xmlOut.WriteAttributeString("ID", dockPanel.Panes.IndexOf(pane).ToString(CultureInfo.InvariantCulture));
                    xmlOut.WriteAttributeString("DockState", pane.DockState.ToString());
                    xmlOut.WriteAttributeString("ActiveContent", dockPanel.Contents.IndexOf(pane.ActiveContent).ToString(CultureInfo.InvariantCulture));
                    xmlOut.WriteStartElement("Contents");
                    xmlOut.WriteAttributeString("Count", pane.Contents.Count.ToString(CultureInfo.InvariantCulture));
                    foreach (IDockContent content in pane.Contents)
                    {
                        xmlOut.WriteStartElement("Content");
                        xmlOut.WriteAttributeString("ID", pane.Contents.IndexOf(content).ToString(CultureInfo.InvariantCulture));
                        xmlOut.WriteAttributeString("RefID", dockPanel.Contents.IndexOf(content).ToString(CultureInfo.InvariantCulture));
                        xmlOut.WriteEndElement();
                    }
                    xmlOut.WriteEndElement();
                    xmlOut.WriteEndElement();
                }
                xmlOut.WriteEndElement();

                // DockWindows
                xmlOut.WriteStartElement("DockWindows");
                int dockWindowId = 0;

                foreach (DockWindow dw in dockPanel.DockWindows)
                {
                    xmlOut.WriteStartElement("DockWindow");
                    xmlOut.WriteAttributeString("ID", dockWindowId.ToString(CultureInfo.InvariantCulture));
                    dockWindowId++;
                    xmlOut.WriteAttributeString("DockState", dw.DockState.ToString());
                    xmlOut.WriteAttributeString("ZOrderIndex", dockPanel.Controls.IndexOf(dw).ToString(CultureInfo.InvariantCulture));
                    xmlOut.WriteStartElement("NestedPanes");
                    xmlOut.WriteAttributeString("Count", dw.NestedPanes.Count.ToString(CultureInfo.InvariantCulture));
                    foreach (DockPane pane in dw.NestedPanes)
                    {
                        xmlOut.WriteStartElement("Pane");
                        xmlOut.WriteAttributeString("ID", dw.NestedPanes.IndexOf(pane).ToString(CultureInfo.InvariantCulture));
                        xmlOut.WriteAttributeString("RefID", dockPanel.Panes.IndexOf(pane).ToString(CultureInfo.InvariantCulture));
                        NestedDockingStatus status = pane.NestedDockingStatus;
                        xmlOut.WriteAttributeString("PrevPane", dockPanel.Panes.IndexOf(status.PreviousPane).ToString(CultureInfo.InvariantCulture));
                        xmlOut.WriteAttributeString("Alignment", status.Alignment.ToString());
                        xmlOut.WriteAttributeString("Proportion", status.Proportion.ToString(CultureInfo.InvariantCulture));
                        xmlOut.WriteEndElement();
                    }
                    xmlOut.WriteEndElement();
                    xmlOut.WriteEndElement();
                }
                xmlOut.WriteEndElement();

                // FloatWindows
                RectangleConverter rectConverter = new RectangleConverter();

                xmlOut.WriteStartElement("FloatWindows");
                xmlOut.WriteAttributeString("Count", dockPanel.FloatWindows.Count.ToString(CultureInfo.InvariantCulture));
                foreach (FloatWindow fw in dockPanel.FloatWindows)
                {
                    xmlOut.WriteStartElement("FloatWindow");
                    xmlOut.WriteAttributeString("ID", dockPanel.FloatWindows.IndexOf(fw).ToString(CultureInfo.InvariantCulture));
                    xmlOut.WriteAttributeString("Bounds", rectConverter.ConvertToInvariantString(fw.Bounds));
                    xmlOut.WriteAttributeString("ZOrderIndex", fw.DockPanel.FloatWindows.IndexOf(fw).ToString(CultureInfo.InvariantCulture));
                    xmlOut.WriteStartElement("NestedPanes");
                    xmlOut.WriteAttributeString("Count", fw.NestedPanes.Count.ToString(CultureInfo.InvariantCulture));
                    foreach (DockPane pane in fw.NestedPanes)
                    {
                        xmlOut.WriteStartElement("Pane");
                        xmlOut.WriteAttributeString("ID", fw.NestedPanes.IndexOf(pane).ToString(CultureInfo.InvariantCulture));
                        xmlOut.WriteAttributeString("RefID", dockPanel.Panes.IndexOf(pane).ToString(CultureInfo.InvariantCulture));
                        NestedDockingStatus status = pane.NestedDockingStatus;
                        xmlOut.WriteAttributeString("PrevPane", dockPanel.Panes.IndexOf(status.PreviousPane).ToString(CultureInfo.InvariantCulture));
                        xmlOut.WriteAttributeString("Alignment", status.Alignment.ToString());
                        xmlOut.WriteAttributeString("Proportion", status.Proportion.ToString(CultureInfo.InvariantCulture));
                        xmlOut.WriteEndElement();
                    }
                    xmlOut.WriteEndElement();
                    xmlOut.WriteEndElement();
                }
                xmlOut.WriteEndElement();       //	</FloatWindows>

                xmlOut.WriteEndElement();

                if (!upstream)
                {
                    xmlOut.WriteEndDocument();
                    xmlOut.Close();
                }
                else
                {
                    xmlOut.Flush();
                }
            }
Ejemplo n.º 33
0
        static void HandleVideoSource(MainViewModel ViewModel, CommonCmdOptions CommonOptions)
        {
            // Desktop
            if (CommonOptions.Source == null || CommonOptions.Source == "desktop")
            {
                return;
            }

            var video = ViewModel.VideoViewModel;

            // Region
            if (Regex.IsMatch(CommonOptions.Source, @"^\d+,\d+,\d+,\d+$"))
            {
                var rectConverter = new RectangleConverter();

                if (rectConverter.ConvertFromInvariantString(CommonOptions.Source) is Rectangle rect)
                {
                    FakeRegionProvider.Instance.SelectedRegion = rect.Even();
                    video.SelectedVideoSourceKind = ServiceProvider.Get <RegionSourceProvider>();
                }
            }

            // Screen
            else if (Regex.IsMatch(CommonOptions.Source, @"^screen:\d+$"))
            {
                var index = int.Parse(CommonOptions.Source.Substring(7));

                if (index < ScreenItem.Count)
                {
                    var screenSourceProvider = ServiceProvider.Get <ScreenSourceProvider>();

                    screenSourceProvider.Set(index);

                    video.RestoreSourceKind(screenSourceProvider);
                }
            }

            // Window
            else if (Regex.IsMatch(CommonOptions.Source, @"^win:\d+$"))
            {
                var handle = new IntPtr(int.Parse(CommonOptions.Source.Substring(4)));

                var winProvider = ServiceProvider.Get <WindowSourceProvider>();

                winProvider.Set(handle);

                video.RestoreSourceKind(winProvider);
            }

            // Start command only
            else if (CommonOptions is StartCmdOptions)
            {
                // Desktop Duplication
                if (Regex.IsMatch(CommonOptions.Source, @"^deskdupl:\d+$"))
                {
                    var index = int.Parse(CommonOptions.Source.Substring(9));

                    if (index < ScreenItem.Count)
                    {
                        var deskDuplSourceProvider = ServiceProvider.Get <DeskDuplSourceProvider>();

                        deskDuplSourceProvider.Set(new ScreenWrapper(Screen.AllScreens[index]));

                        video.RestoreSourceKind(deskDuplSourceProvider);
                    }
                }

                // No Video for Start
                else if (CommonOptions.Source == "none")
                {
                    video.SelectedVideoSourceKind = ServiceProvider.Get <NoVideoSourceProvider>();
                }
            }
        }