Click here to Skip to main content
15,891,033 members
Articles / Desktop Programming / WPF

Integration: Kinematics + Digital Image Processing + 3D Graphics

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
9 Sep 2012CPOL12 min read 25.4K   3.4K   18  
Further promotion of integration ideas
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using CategoryTheory;
using DiagramUI.Labels;
using DiagramUI.Utils;
using DiagramUI.Interfaces;
using Diagram.UI.Interfaces;


namespace DiagramUI
{
    /// <summary>
    /// Form associated to library object
    /// </summary>
    public partial class FormLibraryObject : Form, IUpdatableForm
    {
        IObjectLabel label;
        LibraryObjectWrapper wrapper;
        string id;
        private FormLibraryObject()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="label">Associated label</param>
        /// <param name="wrapper">Library object</param>
        public FormLibraryObject(IObjectLabel label, LibraryObjectWrapper wrapper)
        {
            this.label = label;
            this.wrapper = wrapper;
            InitializeComponent();
            this.LoadControlResources(ControlUtilites.Resources);
            if (CategoryTheory.BinaryLoader.Object == null || DiagramUI.BinaryChooser.Object == null)
            {
                buttonLoad.Enabled = false;
            }
            UpdateFormUI();
        }

        #region IUpdatableForm Members

        /// <summary>
        /// Updates form UI
        /// </summary>
        public void UpdateFormUI()
        {
            Text = label.Name;
        }

        #endregion
        void fill()
        {
            if (wrapper.FileName == null)
            {
                return;
            }
            textBoxFileName.Text = wrapper.FileName;
            string[] items = LibraryObjectWrapper.GetNames(wrapper.FileName);
            int n = 0;
            int sel = 0;
            foreach (string it in items)
            {
                comboBoxName.Items.Add(it);
                if (it.Equals(wrapper.Name))
                {
                    sel = n;
                }
                ++n;
            }
            comboBoxName.SelectedIndex = sel;
        }

        private void buttonBrowse_Click(object sender, EventArgs e)
        {
            if (openFileDialogDLL.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }
            string fn = openFileDialogDLL.FileName + "";
            string[] names = LibraryObjectWrapper.GetNames(fn);
            if (names == null)
            {
                return;
            }
            textBoxFileName.Text = fn;
            comboBoxName.Items.Clear();
            foreach (string it in names)
            {
                comboBoxName.Items.Add(it);
            }
            buttonLoad.Enabled = false;
        }

        private void buttonAccept_Click(object sender, EventArgs e)
        {
            if (comboBoxName.Items.Count == 0)
            {
                return;
            }
            string it = comboBoxName.SelectedItem + "";
            if (it.Length == 0)
            {
                return;
            }
            if (id != null)
            {
                wrapper.Set(id, it);
            }
            else
            {
                wrapper.Set(textBoxFileName.Text, it);
            }

        }

        private void buttonLoad_Click(object sender, EventArgs e)
        {
            if (CategoryTheory.BinaryLoader.Object == null || DiagramUI.BinaryChooser.Object == null)
            {
                return;
            }

            DiagramUI.BinaryChooser.Object.Show(this, "dll");
            if (DiagramUI.BinaryChooser.Object.Name == null)
            {
                return;
            }
            textBoxDB.Text = DiagramUI.BinaryChooser.Object.Name + "";
            id = DiagramUI.BinaryChooser.Object.Id;
            string[] names = LibraryObjectWrapper.GetNames(id);
            if (names == null)
            {
                return;
            }
            comboBoxName.Items.Clear();
            foreach (string it in names)
            {
                comboBoxName.Items.Add(it);
            }
            buttonBrowse.Enabled = false;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Russian Federation Russian Federation
Ph. D. Petr Ivankov worked as scientific researcher at Russian Mission Control Centre since 1978 up to 2000. Now he is engaged by Aviation training simulators http://dinamika-avia.com/ . His additional interests are:

1) Noncommutative geometry

http://front.math.ucdavis.edu/author/P.Ivankov

2) Literary work (Russian only)

http://zhurnal.lib.ru/editors/3/3d_m/

3) Scientific articles
http://arxiv.org/find/all/1/au:+Ivankov_Petr/0/1/0/all/0/1

Comments and Discussions