Beispiel #1
0
        public void UpdateAssets(string assetFile,
                                 UpdatePropertiesDelegate updateProps,
                                 UpdateOutputDelegate updateOutput,
                                 OpenEffectFile openEffect,
                                 MaterialsView materialsHandle)
        {
            if (!File.Exists(assetFile))
            {
                return;
            }

            m_AssetPath       = assetFile;
            m_ProjectLocation = Path.GetDirectoryName(assetFile);
            m_NodeDelegate    = updateProps;
            m_OuputDeleagate  = updateOutput;
            m_OpenEffect      = openEffect;
            m_MaterialsHandle = materialsHandle;
            m_MaterialsHandle.UpdateDelegate = m_NodeDelegate;

            m_XmlDoc.Load(assetFile);
            XmlElement rootXml = m_XmlDoc.DocumentElement;

            treeViewAssets.BeginUpdate();

            foreach (XmlNode node in rootXml.ChildNodes)
            {
                TreeNode treeNode = treeViewAssets.Nodes[node.Name];
                if (treeNode != null)
                {
                    treeNode.Tag = node;
                    treeNode.Nodes.Clear();
                    foreach (XmlNode child in node.ChildNodes)
                    {
                        if (node.Name == "Effects")
                        {
                            AddEffect(treeNode, child);
                        }
                        else if (node.Name == "Materials")
                        {
                            AddMaterial(treeNode, child);
                        }
                        else
                        {
                            XmlNode nameNode = child.Attributes["name"];
                            if (nameNode != null)
                            {
                                treeNode.Nodes.Add(new TreeNode(nameNode.Value)
                                {
                                    Tag = child
                                });
                            }
                        }
                    }
                }
            }

            treeViewAssets.EndUpdate();
        }
Beispiel #2
0
 public void UpdateOutput(string outputText)
 {
     if (!txtOutput.InvokeRequired)
     {
         txtOutput.Text = outputText;
     }
     else
     {
         UpdateOutputDelegate updateOutputDelegate = new UpdateOutputDelegate(UpdateOutput);
         this.Invoke(updateOutputDelegate, outputText + " from another thread");
     }
 }
Beispiel #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            updateoutputDelegate = new UpdateOutputDelegate(UpdateOutput);

            if (!isFormFullyVisible(Properties.Settings.Default.F1Location, Properties.Settings.Default.F1Size) || Properties.Settings.Default.F1Size.Width == 0 || Properties.Settings.Default.F1Size.Height == 0)
            {
                // first start or form not visible due to monitor setup changing since last saved
                // optional: add default values
            }
            else
            {
                this.WindowState = Properties.Settings.Default.F1State;

                // we don't want a minimized window at startup
                if (this.WindowState == FormWindowState.Minimized)
                {
                    this.WindowState = FormWindowState.Normal;
                }

                this.Location = Properties.Settings.Default.F1Location;
                if (Properties.Settings.Default.F1Size.Width < Edit.Width + Edit.Location.X + 25)
                {
                    // n.b. this calls the Form1_Resize
                    this.Size = new Size(Edit.Right + 28, Properties.Settings.Default.F1Size.Height + 5);
                }
                else
                {
                    // n.b. this calls the Form1_Resize
                    this.Size = Properties.Settings.Default.F1Size; // TODO sort out when this gets screwed
                }
                this.Update();
                MaximisedSize = this.Size;
            }
            SaveExtractedDocs.CheckState = Properties.Settings.Default.SaveDocs ? CheckState.Checked : CheckState.Unchecked;
            LibraryGen.CheckState        = Properties.Settings.Default.GenLib ? CheckState.Checked : CheckState.Unchecked;
            Verbose.CheckState           = Properties.Settings.Default.Verbose ? CheckState.Checked : CheckState.Unchecked;
            ConvertPCBDoc.Verbose        = Verbose.CheckState == CheckState.Checked;
            string Combo = Properties.Settings.Default.ComboboxItems;

            PcbnewLocation = Properties.Settings.Default.PcbnewLocation;
            TextEditorLoc  = Properties.Settings.Default.TextEditorLocation;

            string[] items = Combo.Split(';');

            // remove any duplicates
            var b = new HashSet <string>(items);

            FileHistory.ContextMenu = ComboBoxMenu;
            FileHistory.Items.Clear();
            FileHistory.Items.AddRange(b.ToArray());
            if (b.ToArray().Length != items.Length)
            {
                // some duplicate items have been removed
                // so selected index will no longer be valid
                FileHistory.SelectedIndex = 0;
            }
            else
            {
                FileHistory.SelectedIndex = Properties.Settings.Default.ComboBoxIndex;
            }

            if (FileHistory.SelectedIndex != -1)
            {
                FileHistory.Text = (string)FileHistory.Items[FileHistory.SelectedIndex];
            }

            EnableControls();
        }