public FormEditMajorations(int compId, Profile currentProfile, ProfileLoader profileLoader)
        {
            InitializeComponent();

            _componentId = compId;
            _profileLoader = profileLoader;

            if (!DesignMode)
            {
                // plugin viewer
                _pluginViewCtrl = new PluginViewCtrl();
                _pluginViewCtrl.Size = _pb.Size;
                _pluginViewCtrl.Location = _pb.Location;
                _pluginViewCtrl.Visible = true;
                this.Controls.Add(_pluginViewCtrl);
                // hide
                _pb.Visible = false;
            }

            // fill combo box
            FillProfileComboBox(currentProfile.ToString());

            // get parameter stack
            Pic.Plugin.ParameterStack stack = null;
            using (Pic.Plugin.ComponentLoader loader = new Pic.Plugin.ComponentLoader())
            {
                PPDataContext db = new PPDataContext();
                Pic.DAL.SQLite.Component comp = Pic.DAL.SQLite.Component.GetById(db, _componentId);
                Pic.Plugin.Component component = loader.LoadComponent(comp.Document.File.Path(db));
                stack = component.BuildParameterStack(null);
                // load component in pluginviewer
                _pluginViewCtrl.Component = component;
            }

            // insert majoration label and textbox controls
            int lblX = 20, lblY = 60;
            int offsetX = 110, offsetY = 29;
            int tabIndex = bnCancel.TabIndex;
            int iCount = 0;
            foreach (Parameter param in stack.ParameterList)
            {
                // only shows majorations
                if (!param.IsMajoration) continue;
                ParameterDouble paramDouble = param as ParameterDouble;
                // create Label control
                Label lbl = new Label();
                lbl.Name = string.Format("lbl_{0}", param.Name);
                lbl.Text = param.Name;
                lbl.Location = new Point(
                    lblX + (iCount / 5) * offsetX
                    , lblY + (iCount % 5) * offsetY);
                lbl.Size = new Size(30, 13);
                lbl.TabIndex = ++tabIndex;
                this.Controls.Add(lbl);
                // create NumericUpDown control
                NumericUpDown nud = new NumericUpDown();
                nud.Name = string.Format("nud_{0}", param.Name);
                nud.Increment = 0.1M;
                nud.Minimum = paramDouble.HasValueMin ? (decimal)paramDouble.ValueMin : -10000.0M;
                nud.Maximum = paramDouble.HasValueMax ? (decimal)paramDouble.ValueMax : 10000.0M;
                nud.DecimalPlaces = 1;
                nud.Value = (decimal)paramDouble.Value;
                nud.Location = new Point(
                    lblX + (iCount / 5) * offsetX + lbl.Size.Width + 1
                    , lblY + (iCount % 5) * offsetY);
                nud.Size = new Size(60, 20);
                nud.TabIndex = ++tabIndex;
                nud.ValueChanged += new EventHandler(nudValueChanged);
                nud.GotFocus += new EventHandler(nud_GotFocus);
                nud.Click += new EventHandler(nud_GotFocus);
                this.Controls.Add(nud);

                ++iCount;
            }

            UpdateMajorationValues();
        }
Beispiel #2
0
        public FormEditMajorations(Guid compGuid, Profile currentProfile, ProfileLoader profileLoader)
        {
            InitializeComponent();

            if (compGuid == Guid.Empty)
                throw new Exception("Invalid component Guid");

            _compGuid = compGuid;
            _profileLoader = profileLoader;

            if (!DesignMode)
            {
                // plugin viewer
                _pluginViewCtrl = new PluginViewCtrl();
                _pluginViewCtrl.Size = _pb.Size;
                _pluginViewCtrl.Location = _pb.Location;
                _pluginViewCtrl.Visible = true;
                this.Controls.Add(_pluginViewCtrl);
                // hide
                _pb.Visible = false;
            }

            // fill combo box
            FillProfileComboBox(currentProfile.ToString());

            // get parameter stack
            PLMPackServiceClient client = WCFClientSingleton.Instance.Client;
            Pic.Plugin.ParameterStack stack = null;
            using (Pic.Plugin.ComponentLoader loader = new Pic.Plugin.ComponentLoader())
            {
                DCComponent comp = client.GetComponentByGuid(_compGuid);
                Pic.Plugin.Component component = loader.LoadComponent(
                    treeDiM.FileTransfer.FileTransferUtility.DownloadFile(comp.File.Guid, comp.File.Extension) );
                stack = component.BuildParameterStack(null);
                // load component in pluginviewer
                _pluginViewCtrl.Component = component;
            }

            // insert majoration label and textbox controls
            int lblX = 20, lblY = 60;
            int offsetX = 110, offsetY = 29;
            int tabIndex = bnCancel.TabIndex;
            int iCount = 0;
            foreach (Parameter param in stack.ParameterList)
            {
                // only shows majorations
                if (!param.IsMajoration) continue;
                ParameterDouble paramDouble = param as ParameterDouble;
                // create Label control
                Label lbl = new Label();
                lbl.Name = string.Format("lbl_{0}", param.Name);
                lbl.Text = param.Name;
                lbl.Location = new Point(
                    lblX + (iCount / 5) * offsetX
                    , lblY + (iCount % 5) * offsetY);
                lbl.Size = new Size(30, 13);
                lbl.TabIndex = ++tabIndex;
                this.Controls.Add(lbl);
                // create NumericUpDown control
                NumericUpDown nud = new NumericUpDown();
                nud.Name = string.Format("nud_{0}", param.Name);
                nud.Increment = 0.1M;
                nud.Minimum = paramDouble.HasValueMin ? (decimal)paramDouble.ValueMin : -10000.0M;
                nud.Maximum = paramDouble.HasValueMax ? (decimal)paramDouble.ValueMax : 10000.0M;
                nud.DecimalPlaces = 1;
                nud.Value = (decimal)paramDouble.Value;
                nud.Location = new Point(
                    lblX + (iCount / 5) * offsetX + lbl.Size.Width + 1
                    , lblY + (iCount % 5) * offsetY);
                nud.Size = new Size(60, 20);
                nud.TabIndex = ++tabIndex;
                nud.ValueChanged += new EventHandler(nudValueChanged);
                nud.GotFocus += new EventHandler(nud_GotFocus);
                nud.Click += new EventHandler(nud_GotFocus);
                this.Controls.Add(nud);

                ++iCount;
            }

            UpdateMajorationValues();
        }