예제 #1
0
        /// <summary>
        /// Get a selected checkbox items
        /// </summary>
        private static Node GetNodeByName(ErdDiagramModel erd, string name)
        {
            try
            {
                for (int i = 0; i < erd.Nodes.Count; i++)
                {
                    // Get a all list items from listbox

                    Node currentNode = erd.Nodes[i] as Node;
                    // find a ContentPresenter of that list item.. [Call FindVisualChild Method]
                    ContentPresenter ContentPresenterObj = WpfUIUtilities.FindVisualChild <ContentPresenter>(currentNode);

                    // call FindName on the DataTemplate of that ContentPresenter
                    DataTemplate DataTemplateObj = ContentPresenterObj.ContentTemplate;
                    Label        Chk             = (Label)DataTemplateObj.FindName("lbl", ContentPresenterObj);
                    string       content         = Chk.Content as string;
                    if (content == name)
                    {
                        return(currentNode);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(null);
        }
예제 #2
0
        public void SynchronizeConnectors()
        {
            string node_source      = NodeSource;
            string connector_source = ConnectorSource;
            var    k    = ModelSource;
            var    type = k.GetType();
            var    connectorsproperty = type.GetProperty(connector_source);
            var    connectors         = connectorsproperty.GetValue(k) as IList;

            if (connectors.Count == Connections.Count)
            {
                for (int i = 0; i < this.Connections.Count; i++)
                {
                    ErdLineConnector lc = this.Connections[i] as ErdLineConnector;
                    lc.DataContext = connectors[i];
                    lc.Style       = ConnectorStyle as Style;
                    lc.ApplyTemplate();
                }
                foreach (Node n in this.Nodes)
                {
                    // find a ContentPresenter of that list item.. [Call FindVisualChild Method]
                    ContentPresenter ContentPresenterObj = WpfUIUtilities.FindVisualChild <ContentPresenter>(n);

                    // call FindName on the DataTemplate of that ContentPresenter
                    DataTemplate DataTemplateObj = ContentPresenterObj.ContentTemplate;

                    // Label Chk = (Label)DataTemplateObj.FindName("lbl", ContentPresenterObj);
                    Header header = (Header)WpfUIUtilities.FindVisualChild <Header>(ContentPresenterObj);
                    if (header == null)
                    {
                        continue;
                    }
                    string content = header.ItemName;


                    foreach (var ee in this.Connections)
                    {
                        if (!(ee is ErdLineConnector))
                        {
                            continue;
                        }
                        ErdLineConnector er = ee as ErdLineConnector;
                        if (er.HeadNodeName == content)
                        {
                            er.HeadNode = n;
                        }
                        if (er.TailNodeName == content)
                        {
                            er.TailNode = n;
                        }
                        er.ApplyTemplate();
                    }
                }
            }
        }
예제 #3
0
        public Header FindHeader(Node n)
        {
            ContentPresenter ContentPresenterObj = WpfUIUtilities.FindVisualChild <ContentPresenter>(n);

            // call FindName on the DataTemplate of that ContentPresenter
            DataTemplate DataTemplateObj = ContentPresenterObj.ContentTemplate;

            // Label Chk = (Label)DataTemplateObj.FindName("lbl", ContentPresenterObj);
            Header header = (Header)WpfUIUtilities.FindVisualChild <Header>(ContentPresenterObj);

            return(header);
        }
예제 #4
0
        public void Reload()
        {
            foreach (var Item in this.icFileUploadElements.Items)
            {
                FileUploadElement fileUploadElement = WpfUIUtilities.FindVisualChild <FileUploadElement>(Item as DependencyObject);
                if (fileUploadElement == null)
                {
                    fileUploadElement = WpfUIUtilities.FindLogicalChild <FileUploadElement>(Item as DependencyObject);
                }

                fileUploadElement.Reload();
            }
        }
예제 #5
0
        public string GetNodeName(Node node)
        {
            ContentPresenter ContentPresenterObj = WpfUIUtilities.FindVisualChild <ContentPresenter>(node);

            // call FindName on the DataTemplate of that ContentPresenter
            DataTemplate DataTemplateObj = ContentPresenterObj.ContentTemplate;

            // Label Chk = (Label)DataTemplateObj.FindName("lbl", ContentPresenterObj);
            Header header  = (Header)WpfUIUtilities.FindVisualChild <Header>(ContentPresenterObj);
            string content = header.ItemName;

            return(content);
        }
예제 #6
0
        //This method is called when format was changed
        //and sets the format on each of the file upload elements
        private void LstFormats_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            foreach (var Item in this.icFileUploadElements.Items)
            {
                FileUploadElement fileUploadElement = WpfUIUtilities.FindVisualChild <FileUploadElement>(Item as DependencyObject);
                if (fileUploadElement == null)
                {
                    fileUploadElement = WpfUIUtilities.FindLogicalChild <FileUploadElement>(Item as DependencyObject);
                }

                string filter = lstFormats.SelectedValue as string;
                fileUploadElement.Filter = filter;
            }
        }
예제 #7
0
        private void SetControlsToFormat()
        {
            foreach (var Item in this.icFileUploadElements.Items)
            {
                FileUploadElement fileUploadElement = WpfUIUtilities.FindVisualChild <FileUploadElement>(Item as DependencyObject);
                if (fileUploadElement == null)
                {
                    fileUploadElement = WpfUIUtilities.FindLogicalChild <FileUploadElement>(Item as DependencyObject);
                }

                string filter = Format;
                fileUploadElement.Filter = filter;
            }
        }
예제 #8
0
        public List <string> GetItems()
        {
            List <string> lstItems = new List <string>();

            foreach (var Item in this.icFileUploadElements.Items)
            {
                FileUploadElement fueUploader = WpfUIUtilities.FindVisualChild <FileUploadElement>(Item as DependencyObject);
                if (fueUploader != null && !string.IsNullOrEmpty(fueUploader.txbFileName.Text))
                {
                    lstItems.Add(fueUploader.txbFileName.Text);
                }
            }
            return(lstItems);
        }
예제 #9
0
        /// <summary>
        /// This method used to show errors that occur
        /// during validation of formats and contents of uploaded files
        /// </summary>
        /// <param name="errors">Represents dictionary of errors: the key is the type if its error/warning/etc and the value is the message to display</param>

        public void ShowErrors(SortedList <string, string> errors)
        {
            List <string> lstItems = new List <string>();

            foreach (var error in errors)
            {
                foreach (var Item in this.icFileUploadElements.Items)
                {
                    FileUploadElement fueUploader = WpfUIUtilities.FindVisualChild <FileUploadElement>(Item as DependencyObject);
                    if (fueUploader != null && fueUploader.txbFileName.Text == error.Key)
                    {
                        fueUploader.ShowError(error.Value);
                    }
                }
            }
        }
예제 #10
0
        private void ErdDiagramControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            ErdDiagramModel model = this.Model as ErdDiagramModel;

            foreach (Node n in model.Nodes)
            {
                ContentPresenter ContentPresenterObj = WpfUIUtilities.FindVisualChild <ContentPresenter>(n);

                // call FindName on the DataTemplate of that ContentPresenter
                DataTemplate DataTemplateObj = ContentPresenterObj.ContentTemplate;

                // Label Chk = (Label)DataTemplateObj.FindName("lbl", ContentPresenterObj);
                Header header = (Header)WpfUIUtilities.FindVisualChild <Header>(ContentPresenterObj);

                /* Panel pnl = n.ContentTemplate.LoadContent() as Panel;
                 * if (pnl == null) throw new Exception("The first element of template must be panel");
                 * Header header = pnl.Children[0] as Header;*/
                if (header == null)
                {
                    throw new Exception("The first element of template must be header");
                }
                string content = header.ItemName;


                foreach (var ee in model.Connections)
                {
                    if (!(ee is ErdLineConnector))
                    {
                        continue;
                    }
                    ErdLineConnector er = ee as ErdLineConnector;
                    if (er.HeadNodeName == content)
                    {
                        er.HeadNode = n;
                    }
                    if (er.TailNodeName == content)
                    {
                        er.TailNode = n;
                    }
                    er.ApplyTemplate();
                }
            }
        }