示例#1
0
 /// <summary>
 /// Initialize the MM permissions
 /// </summary>
 /// <param name="xConfig">The configuration element for this permissions.</param>
 public MM_Permissions(XmlElement xConfig)
 {
     if (xConfig == null)
     {
         return;
     }
     MM_Serializable.ReadXml(xConfig, this, false);
     BoilerplateText = xConfig.InnerText;
 }
示例#2
0
        /// <summary>
        /// Initialize a new key indicator level
        /// </summary>
        /// <param name="xElem"></param>
        /// <param name="InForm"></param>
        /// <param name="Click"></param>
        public MM_Key_Indicator_Label(XmlElement xElem, Form InForm, EventHandler Click)
        {
            if (!MM_Server_Interface.ISQse)
            {
                this.Tag = InForm;
            }
            InForm.Visible = false;
            this.Click    += Click;
            this.AutoSize  = true;
            this.Font      = MM_Repository.OverallDisplay.KeyIndicatorSimpleFont;

            MM_Serializable.ReadXml(xElem, this, true);
            this.BackColor = Color.Transparent;
        }
示例#3
0
        /// <summary>
        /// Initialize a new control panel
        /// </summary>
        /// <param name="SourceElement">Our source element</param>
        /// <param name="xConfiguration">The configuration for the control panel</param>
        /// <param name="OneLineViewer">The one-line viewer</param>
        public MM_ControlPanel(MM_OneLine_Element SourceElement, XmlElement xConfiguration, MM_OneLine_Viewer OneLineViewer)
        {
            //xConfiguration.InnerXml = Clipboard.GetText();
            this.OneLineViewer = OneLineViewer;
            InitializeComponent();
            this.xConfiguration = xConfiguration;
            this.SourceElement  = SourceElement;

            Keys CurKeys = Control.ModifierKeys;

            if (CurKeys == (Keys.Control | Keys.Shift | Keys.Alt))
            {
                Editable             = true;
                this.FormBorderStyle = FormBorderStyle.SizableToolWindow;
            }
            else
            {
                Editable = false;
            }

            //Create our Communications view
            btnComm        = new Button();
            btnComm.Text   = "Comm";
            btnComm.Size   = new System.Drawing.Size(78, 17);
            btnComm.Font   = new System.Drawing.Font("Arial", 10);
            btnComm.Click += btnComm_Click;
            btnComm.Paint += btnComm_Paint;
            Controls.Add(btnComm);

            SizePanel            = new Panel();
            SizePanel.Location   = new Point(4, 4);
            SizePanel.AutoScroll = true;
            SizePanel.AutoSize   = false;
            SizePanel.HorizontalScroll.Enabled = true;
            SizePanel.VerticalScroll.Enabled   = true;
            SizePanel.HorizontalScroll.Visible = true;
            SizePanel.VerticalScroll.Visible   = true;
            Controls.Add(SizePanel);
            //Now, initialize the window, and sublements
            MM_Serializable.ReadXml(xConfiguration, this, false);
            this.Text = xConfiguration.Attributes["Title"].Value + " - " + SourceElement.BaseElement.SubLongName + " " + SourceElement.BaseElement.ElemType.Name + " " + SourceElement.BaseElement.Name;
            foreach (XmlElement xElem in xConfiguration.ChildNodes.OfType <XmlElement>())
            {
                if (xElem.Name != "DataSource")
                {
                    AddElement(SizePanel, xElem);
                }
            }
            btnComm.Location = new Point(DisplayRectangle.Width - btnComm.Width + 4, 2);//DisplayRectangle.Height - btnComm.Height);

            //If we are in editable mode, add in our propery page
            if (Editable)
            {
                PropertyGrid pG = new PropertyGrid();
                pG.Name   = "PropertyGrid";
                pG.Width  = 400;
                pG.Height = this.Height;
                pG.Left   = this.Width;
                pG.PropertyValueChanged += new PropertyValueChangedEventHandler(pG_PropertyValueChanged);
                this.Controls.Add(pG);
            }



            UpdateDisplay();
        }
示例#4
0
        /// <summary>
        /// Add an element to our display
        /// </summary>
        /// <param name="ParentControl"></param>
        /// <param name="xElem"></param>
        private void AddElement(Control ParentControl, XmlElement xElem)
        {
            Control NewCtl = null;

            if (xElem.Name == "Label")
            {
                NewCtl          = new Label();
                NewCtl.AutoSize = true;
                NewCtl.Text     = "?";
            }
            else if (xElem.Name == "TextBox")
            {
                NewCtl            = new TextBox();
                NewCtl.KeyPress  += new KeyPressEventHandler(NewCtl_KeyPress);
                NewCtl.LostFocus += new EventHandler(NewCtl_LostFocus);
                NewCtl.BackColor  = Color.Black;
                NewCtl.ForeColor  = Color.White;
                NewCtl.GotFocus  += new EventHandler(NewCtl_GotFocus);
            }
            else if (xElem.Name == "CheckBox")
            {
                NewCtl          = new CheckBox();
                NewCtl.Text     = "";
                NewCtl.AutoSize = true;
            }
            else if (xElem.Name == "Button")
            {
                NewCtl = new Button();
            }
            else if (xElem.Name == "Synchroscope")
            {
                MM_Element[] NodeElems = OneLineViewer.ElementNodes(SourceElement);
                NewCtl = new MM_OneLine_Synchroscope((MM_Breaker_Switch)SourceElement.BaseElement, (MM_Node)NodeElems[0], (MM_Node)NodeElems[1]);
            }
            else if (xElem.Name == "GeneratorControlPanel")
            {
                NewCtl       = new MM_Generator_ControlPanel(SourceElement, OneLineViewer);
                this.Closed += ((MM_Generator_ControlPanel)NewCtl).Generator_ControlPanel_Close;
                Panel TempPanel = new Panel();
                TempPanel.Size       = NewCtl.Size;
                TempPanel.AutoSize   = true;
                TempPanel.AutoScroll = true;
                TempPanel.Margin     = new System.Windows.Forms.Padding(0);
                NewCtl.Margin        = new System.Windows.Forms.Padding(0);
                TempPanel.Controls.Add(NewCtl);
                NewCtl = TempPanel;
            }
            else if (xElem.Name == "GroupBox")
            {
                if (Editable || !xElem.HasAttribute("IfTrue") || (bool)SourceElement.BaseElement.GetType().GetField(xElem.Attributes["IfTrue"].Value).GetValue(SourceElement.BaseElement))
                {
                    NewCtl           = new GroupBox();
                    NewCtl.ForeColor = Color.White;
                    foreach (XmlElement xSubElem in xElem.ChildNodes)
                    {
                        AddElement(NewCtl, xSubElem);
                    }
                    (NewCtl as GroupBox).AutoSize = true;
                }
            }
            else if (xElem.Name == "TabControl")
            {
                NewCtl = new TabControl();
                foreach (XmlElement xSubElem in xElem.ChildNodes)
                {
                    if (xSubElem.Name == "TabPage")
                    {
                        TabPage NewPage = new TabPage(xSubElem.Attributes["Title"].Value);
                        (NewCtl as TabControl).TabPages.Add(NewPage);
                        foreach (XmlElement xSubElem2 in xSubElem.ChildNodes)
                        {
                            AddElement(NewPage, xSubElem2);
                        }
                    }
                }
            }
            if (xElem.HasAttribute("OnClick") || (xElem.Name == "CheckBox" && xElem.HasAttribute("OnChange")))
            {
                NewCtl.Click += new EventHandler(NewCtl_Click);
            }


            //Go through and deserialize all attributes on our element
            if (NewCtl == null)
            {
                return;
            }

            if (Editable && NewCtl is GroupBox == false && NewCtl is TabPage == false)
            {
                NewCtl.BackColor  = Color.Purple;
                NewCtl.MouseDown += new MouseEventHandler(NewCtl_MouseDown);
                NewCtl.MouseMove += new MouseEventHandler(NewCtl_MouseMove);
                NewCtl.MouseUp   += new MouseEventHandler(NewCtl_MouseUp);
            }
            MM_Serializable.ReadXml(xElem, NewCtl, false);

            NewCtl.Top += 4;
            NewCtl.Tag  = xElem;

            if (NewCtl is GroupBox)
            {
                //Shift to the right as needed
                int RightMost = 0;
                foreach (Control ctl in SizePanel.Controls)
                {
                    if (ctl != btnComm)
                    {
                        RightMost = Math.Max(ctl.Right, RightMost);
                    }
                }
                NewCtl.Left = RightMost + 4;
            }

            DisplayedControls.Add(xElem, NewCtl);
            ParentControl.Controls.Add(NewCtl);
        }