Exemplo n.º 1
0
 private void newToolStripButton_Click(object sender, EventArgs e)
 {
     openFileDialog1.Filter = "Dll files (*.dll)|*.dll";
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         var filename   = openFileDialog1.FileName;
         var controller = new QueueStufferController(_container.Resolve <IAssemblyFetcher>());
         var view       = new QueueStufferView(controller, ConfigurationManager.AppSettings["defaultQueueName"], filename);
         AddView(view);
     }
 }
Exemplo n.º 2
0
        private void RemoveView(QueueStufferView child, bool dispose)
        {
            var childIndex = _views.IndexOf(child);

            if (childIndex == -1)
            {
                return;
            }

            //remove toolStripItem.
            var           key      = (childIndex + 1).ToString();
            ToolStripItem toolItem = FindButtonByText(key);

            if (toolItem != null)
            {
                toolStrip1.Items.Remove(toolItem);
                toolItem.Click -= activateToolStripButton_Click;
                toolItem.Dispose();
            }

            //shift tooltip keys
            for (int i = childIndex; i < _views.Count; i++)
            {
                var text   = (i + 1).ToString();
                var button = FindButtonByText(text);
                if (button != null)
                {
                    button.Text = i.ToString();
                }
            }

            //drop child view
            _views.RemoveAt(childIndex);
            if (dispose)
            {
                child.Closed    -= view_Closed;
                child.Activated -= view_Activated;

                if (child.Visible)
                {
                    child.Close();
                }
                child.Dispose();
            }


            if (ActiveMdiChild != null)
            {
                var index = _views.IndexOf(ActiveMdiChild as QueueStufferView);
                ActivateToolstripButton((index + 1).ToString());
            }

            startBatchToolStripButton.Enabled = _views.Count > 0;
        }
Exemplo n.º 3
0
        private void openToolStripButton_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter = "NQueueStuffer (*.nqs)|*.nqs";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                var filename = openFileDialog1.FileName;
                List <NqsSettingItem> settings = null;
                try
                {
                    var loader = new NqsSettingsLoader(filename);
                    settings = loader.Load();
                }
                catch
                {
                    SetMessage("Invalid file supplied!", MessageType.Error);
                    return;
                }


                while (_views.Count > 0)
                {
                    RemoveView(_views[0], true);
                }

                string error = String.Empty;
                foreach (var settingItem in settings)
                {
                    try
                    {
                        var controller = new QueueStufferController(_container.Resolve <IAssemblyFetcher>());                       //_container.Resolve<IQueueStufferController>();
                        var view       = new QueueStufferView(controller, settingItem);
                        AddView(view);
                    }
                    catch
                    {
                        error += String.Format("Error adding assembly {0}", settingItem.AssemblyPath);
                    }
                }
                if (error.Length > 0)
                {
                    SetMessage(error, MessageType.Error);
                }
                else
                {
                    SetMessage(String.Format("Successfully loaded {0} assemblies.", settings.Count), MessageType.Message);
                }
            }
        }
Exemplo n.º 4
0
        private void AddView(QueueStufferView view)
        {
            _views.Add(view);
            view.MdiParent = this;
            view.Show();
            ActivateMdiChild(view);
            view.Closed    += view_Closed;
            view.Activated += view_Activated;
            var toolStripItem = toolStrip1.Items.Add((_views.IndexOf(view) + 1).ToString());

            toolStripItem.ToolTipText = Path.GetFileNameWithoutExtension(view.SelectedSettings.AssemblyPath);
            toolStripItem.Click      += activateToolStripButton_Click;
            toolStrip1.Items.Add(toolStripItem);
            toolStripItem.PerformClick();

            startBatchToolStripButton.Enabled = _views.Count > 0;
        }
Exemplo n.º 5
0
        private void AddView(QueueStufferView view)
        {
            _views.Add(view);
            view.MdiParent = this;
            view.Show();
            ActivateMdiChild(view);
            view.Closed += view_Closed;
            view.Activated += view_Activated;
            var toolStripItem = toolStrip1.Items.Add((_views.IndexOf(view) + 1).ToString());
            toolStripItem.ToolTipText = Path.GetFileNameWithoutExtension(view.SelectedSettings.AssemblyPath);
            toolStripItem.Click += activateToolStripButton_Click;
            toolStrip1.Items.Add(toolStripItem);
            toolStripItem.PerformClick();

            startBatchToolStripButton.Enabled = _views.Count > 0;
        }
Exemplo n.º 6
0
        private void RemoveView(QueueStufferView child, bool dispose)
        {
            var childIndex = _views.IndexOf(child);
            if (childIndex == -1)
                return;

            //remove toolStripItem.
            var key = (childIndex + 1).ToString();
            ToolStripItem toolItem = FindButtonByText(key);
            if (toolItem != null)
            {
                toolStrip1.Items.Remove(toolItem);
                toolItem.Click -= activateToolStripButton_Click;
                toolItem.Dispose();
            }

            //shift tooltip keys
            for (int i = childIndex; i < _views.Count; i++)
            {
                var text = (i + 1).ToString();
                var button = FindButtonByText(text);
                if (button != null)
                {
                    button.Text = i.ToString();
                }
            }

            //drop child view
            _views.RemoveAt(childIndex);
            if (dispose)
            {
                child.Closed -= view_Closed;
                child.Activated -= view_Activated;

                if (child.Visible)
                    child.Close();
                child.Dispose();
            }

            if (ActiveMdiChild != null)
            {
                var index = _views.IndexOf(ActiveMdiChild as QueueStufferView);
                ActivateToolstripButton((index + 1).ToString());
            }

            startBatchToolStripButton.Enabled = _views.Count > 0;
        }
Exemplo n.º 7
0
        private void openToolStripButton_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter = "NQueueStuffer (*.nqs)|*.nqs";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                var filename = openFileDialog1.FileName;
                List<NqsSettingItem> settings = null;
                try
                {
                    var loader = new NqsSettingsLoader(filename);
                    settings = loader.Load();
                }
                catch
                {
                    SetMessage("Invalid file supplied!", MessageType.Error);
                    return;
                }

                while (_views.Count > 0)
                {
                    RemoveView(_views[0], true);

                }

                string error = String.Empty;
                foreach (var settingItem in settings)
                {
                    try
                    {
                        var controller = new QueueStufferController(_container.Resolve<IAssemblyFetcher>());//_container.Resolve<IQueueStufferController>();
                        var view = new QueueStufferView(controller, settingItem);
                        AddView(view);
                    }
                    catch
                    {
                        error += String.Format("Error adding assembly {0}", settingItem.AssemblyPath);
                    }
                }
                if (error.Length > 0)
                {
                    SetMessage(error, MessageType.Error);
                }
                else
                {
                    SetMessage(String.Format("Successfully loaded {0} assemblies.", settings.Count), MessageType.Message);
                }
            }
        }
Exemplo n.º 8
0
 private void newToolStripButton_Click(object sender, EventArgs e)
 {
     openFileDialog1.Filter = "Dll files (*.dll)|*.dll";
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         var filename = openFileDialog1.FileName;
         var controller = new QueueStufferController(_container.Resolve<IAssemblyFetcher>());
         var view = new QueueStufferView(controller, ConfigurationManager.AppSettings["defaultQueueName"], filename);
         AddView(view);
     }
 }