public ClipboardService(Action<ClipboardDataItem> notificationCallback)
 {
     _form = new NotificationForm(this);
     NativeMethods.SetParent(_form.Handle, NativeMethods.HWND_MESSAGE);
     _notificationCallback = notificationCallback;
     _clipboardUpdateActionScheduler =
         new ActionScheduler<ClipboardDataItem>(TimeSpan.FromMilliseconds(SCHEDULER_RESOLUTION));
 }
示例#2
0
 private static void InitializeForm()
 {
     if (_clipboardForm != null)
     {
         throw new InvalidOperationException("Already initialized");
     }
     _clipboardForm = new NotificationForm();
     Application.Run(_clipboardForm);
 }
示例#3
0
        public void Execute(string arguments)
        {
            NotificationForm notification = new NotificationForm("Goodbye.");
            notification.FormClosed += new FormClosedEventHandler(delegate
            {
                Application.Exit();
            });

            notification.ShowDialog();
        }
示例#4
0
 public static void StartListener()
 {
     Listener = new NotificationForm();
 }
示例#5
0
        public static DialogResult Show(string text, string caption, out bool repeatNotification)
        {
            var form = new NotificationForm(text, caption, MessageBoxButtons.OK, MessageBoxIcon.None);

            return(ShowMessage(form, out repeatNotification));
        }
        private void InitializeComponent()
        {
            this.m_pTab          = new TabControl();
            this.m_pTab.Size     = new Size(515, 520);
            this.m_pTab.Location = new Point(5, 0);
            this.m_pTab.TabPages.Add(new TabPage("General"));
            this.m_pTab.TabPages.Add(new TabPage("IP Bindings"));
            this.m_pApply                                          = new Button();
            this.m_pApply.Size                                     = new Size(70, 20);
            this.m_pApply.Location                                 = new Point(450, 530);
            this.m_pApply.Text                                     = "Apply";
            this.m_pApply.Click                                   += new EventHandler(this.m_pApply_Click);
            this.m_pTabGeneral_SendSmartHost                       = new RadioButton();
            this.m_pTabGeneral_SendSmartHost.Size                  = new Size(250, 20);
            this.m_pTabGeneral_SendSmartHost.Location              = new Point(10, 15);
            this.m_pTabGeneral_SendSmartHost.Text                  = "Send mails through SmartHost";
            this.m_pTabGeneral_SendSmartHost.CheckedChanged       += new EventHandler(this.m_pTabGeneral_SendSmartHost_CheckedChanged);
            this.mt_TabGeneral_SmartHostsBalanceMode               = new Label();
            this.mt_TabGeneral_SmartHostsBalanceMode.Size          = new Size(160, 20);
            this.mt_TabGeneral_SmartHostsBalanceMode.Location      = new Point(10, 40);
            this.mt_TabGeneral_SmartHostsBalanceMode.TextAlign     = ContentAlignment.MiddleRight;
            this.mt_TabGeneral_SmartHostsBalanceMode.Text          = "Smart hosts balance mode:";
            this.m_pTabGeneral_SmartHostsBalanceMode               = new ComboBox();
            this.m_pTabGeneral_SmartHostsBalanceMode.Size          = new Size(100, 20);
            this.m_pTabGeneral_SmartHostsBalanceMode.Location      = new Point(180, 40);
            this.m_pTabGeneral_SmartHostsBalanceMode.DropDownStyle = ComboBoxStyle.DropDownList;
            this.m_pTabGeneral_SmartHostsBalanceMode.Items.Add("Load-balance");
            this.m_pTabGeneral_SmartHostsBalanceMode.Items.Add("Fail-over");
            this.m_pTabGeneral_SmartHostsBalanceMode.SelectedIndex = 0;
            this.m_pTabGeneral_SmartHosts_Toolbar              = new ToolStrip();
            this.m_pTabGeneral_SmartHosts_Toolbar.Size         = new Size(95, 25);
            this.m_pTabGeneral_SmartHosts_Toolbar.Location     = new Point(373, 40);
            this.m_pTabGeneral_SmartHosts_Toolbar.Dock         = DockStyle.None;
            this.m_pTabGeneral_SmartHosts_Toolbar.GripStyle    = ToolStripGripStyle.Hidden;
            this.m_pTabGeneral_SmartHosts_Toolbar.BackColor    = this.BackColor;
            this.m_pTabGeneral_SmartHosts_Toolbar.Renderer     = new ToolBarRendererEx();
            this.m_pTabGeneral_SmartHosts_Toolbar.ItemClicked += new ToolStripItemClickedEventHandler(this.m_pTabGeneral_SmartHosts_Toolbar_ItemClicked);
            ToolStripButton toolStripButton = new ToolStripButton();

            toolStripButton.Image       = ResManager.GetIcon("add.ico").ToBitmap();
            toolStripButton.Tag         = "add";
            toolStripButton.ToolTipText = "Add";
            this.m_pTabGeneral_SmartHosts_Toolbar.Items.Add(toolStripButton);
            ToolStripButton toolStripButton2 = new ToolStripButton();

            toolStripButton2.Enabled     = false;
            toolStripButton2.Image       = ResManager.GetIcon("edit.ico").ToBitmap();
            toolStripButton2.Tag         = "edit";
            toolStripButton2.ToolTipText = "edit";
            this.m_pTabGeneral_SmartHosts_Toolbar.Items.Add(toolStripButton2);
            ToolStripButton toolStripButton3 = new ToolStripButton();

            toolStripButton3.Enabled     = false;
            toolStripButton3.Image       = ResManager.GetIcon("delete.ico").ToBitmap();
            toolStripButton3.Tag         = "delete";
            toolStripButton3.ToolTipText = "Delete";
            this.m_pTabGeneral_SmartHosts_Toolbar.Items.Add(toolStripButton3);
            this.m_pTabGeneral_SmartHosts_Toolbar.Items.Add(new ToolStripSeparator());
            ToolStripButton toolStripButton4 = new ToolStripButton();

            toolStripButton4.Enabled = false;
            toolStripButton4.Image   = ResManager.GetIcon("up.ico").ToBitmap();
            toolStripButton4.Tag     = "up";
            this.m_pTabGeneral_SmartHosts_Toolbar.Items.Add(toolStripButton4);
            ToolStripButton toolStripButton5 = new ToolStripButton();

            toolStripButton5.Enabled = false;
            toolStripButton5.Image   = ResManager.GetIcon("down.ico").ToBitmap();
            toolStripButton5.Tag     = "down";
            this.m_pTabGeneral_SmartHosts_Toolbar.Items.Add(toolStripButton5);
            this.m_pTabGeneral_SmartHosts                       = new ListView();
            this.m_pTabGeneral_SmartHosts.Size                  = new Size(465, 100);
            this.m_pTabGeneral_SmartHosts.Location              = new Point(30, 65);
            this.m_pTabGeneral_SmartHosts.View                  = View.Details;
            this.m_pTabGeneral_SmartHosts.FullRowSelect         = true;
            this.m_pTabGeneral_SmartHosts.HideSelection         = false;
            this.m_pTabGeneral_SmartHosts.SelectedIndexChanged += new EventHandler(this.m_pTabGeneral_SmartHosts_SelectedIndexChanged);
            this.m_pTabGeneral_SmartHosts.Columns.Add("Host", 200);
            this.m_pTabGeneral_SmartHosts.Columns.Add("Port", 60);
            this.m_pTabGeneral_SmartHosts.Columns.Add("SSL Mode", 80);
            this.m_pTabGeneral_SmartHosts.Columns.Add("User Name", 100);
            this.m_pTabGeneral_SendDns                        = new RadioButton();
            this.m_pTabGeneral_SendDns.Size                   = new Size(250, 20);
            this.m_pTabGeneral_SendDns.Location               = new Point(10, 180);
            this.m_pTabGeneral_SendDns.Text                   = "Send mails directly using DNS";
            this.m_pTabGeneral_SendDns.CheckedChanged        += new EventHandler(this.m_pTabGeneral_SendSmartHost_CheckedChanged);
            this.mt_TabGeneral_SessionTimeout                 = new Label();
            this.mt_TabGeneral_SessionTimeout.Size            = new Size(200, 20);
            this.mt_TabGeneral_SessionTimeout.Location        = new Point(10, 210);
            this.mt_TabGeneral_SessionTimeout.TextAlign       = ContentAlignment.MiddleRight;
            this.mt_TabGeneral_SessionTimeout.Text            = "Session Idle Timeout:";
            this.m_pTabGeneral_SessionTimeout                 = new NumericUpDown();
            this.m_pTabGeneral_SessionTimeout.Size            = new Size(70, 20);
            this.m_pTabGeneral_SessionTimeout.Location        = new Point(215, 210);
            this.m_pTabGeneral_SessionTimeout.Minimum         = 10m;
            this.m_pTabGeneral_SessionTimeout.Maximum         = 99999m;
            this.mt_TabGeneral_SessTimeoutSec                 = new Label();
            this.mt_TabGeneral_SessTimeoutSec.Size            = new Size(70, 20);
            this.mt_TabGeneral_SessTimeoutSec.Location        = new Point(290, 210);
            this.mt_TabGeneral_SessTimeoutSec.TextAlign       = ContentAlignment.MiddleLeft;
            this.mt_TabGeneral_SessTimeoutSec.Text            = "seconds";
            this.mt_TabGeneral_MaxConnections                 = new Label();
            this.mt_TabGeneral_MaxConnections.Size            = new Size(200, 20);
            this.mt_TabGeneral_MaxConnections.Location        = new Point(10, 240);
            this.mt_TabGeneral_MaxConnections.TextAlign       = ContentAlignment.MiddleRight;
            this.mt_TabGeneral_MaxConnections.Text            = "Maximum Connections:";
            this.m_pTabGeneral_MaxConnections                 = new NumericUpDown();
            this.m_pTabGeneral_MaxConnections.Size            = new Size(70, 20);
            this.m_pTabGeneral_MaxConnections.Location        = new Point(215, 240);
            this.m_pTabGeneral_MaxConnections.Minimum         = 1m;
            this.m_pTabGeneral_MaxConnections.Maximum         = 99999m;
            this.mt_TabGeneral_MaxConnsPerIP                  = new Label();
            this.mt_TabGeneral_MaxConnsPerIP.Size             = new Size(200, 20);
            this.mt_TabGeneral_MaxConnsPerIP.Location         = new Point(1, 265);
            this.mt_TabGeneral_MaxConnsPerIP.TextAlign        = ContentAlignment.MiddleRight;
            this.mt_TabGeneral_MaxConnsPerIP.Text             = "Maximum Connections per IP:";
            this.m_pTabGeneral_MaxConnsPerIP                  = new NumericUpDown();
            this.m_pTabGeneral_MaxConnsPerIP.Size             = new Size(70, 20);
            this.m_pTabGeneral_MaxConnsPerIP.Location         = new Point(215, 265);
            this.m_pTabGeneral_MaxConnsPerIP.Minimum          = 0m;
            this.m_pTabGeneral_MaxConnsPerIP.Maximum          = 99999m;
            this.mt_TabGeneral_MaxConnsPerIP0                 = new Label();
            this.mt_TabGeneral_MaxConnsPerIP0.Size            = new Size(164, 20);
            this.mt_TabGeneral_MaxConnsPerIP0.Location        = new Point(290, 265);
            this.mt_TabGeneral_MaxConnsPerIP0.TextAlign       = ContentAlignment.MiddleLeft;
            this.mt_TabGeneral_MaxConnsPerIP0.Text            = "(0 for unlimited)";
            this.mt_TabGeneral_RelayInterval                  = new Label();
            this.mt_TabGeneral_RelayInterval.Size             = new Size(200, 20);
            this.mt_TabGeneral_RelayInterval.Location         = new Point(10, 290);
            this.mt_TabGeneral_RelayInterval.TextAlign        = ContentAlignment.MiddleRight;
            this.mt_TabGeneral_RelayInterval.Text             = "Relay Interval:";
            this.m_pTabGeneral_RelayInterval                  = new NumericUpDown();
            this.m_pTabGeneral_RelayInterval.Size             = new Size(70, 20);
            this.m_pTabGeneral_RelayInterval.Location         = new Point(215, 290);
            this.m_pTabGeneral_RelayInterval.Minimum          = 1m;
            this.m_pTabGeneral_RelayInterval.Maximum          = 9999m;
            this.mt_TabGeneral_RelayIntervalSeconds           = new Label();
            this.mt_TabGeneral_RelayIntervalSeconds.Size      = new Size(50, 20);
            this.mt_TabGeneral_RelayIntervalSeconds.Location  = new Point(290, 290);
            this.mt_TabGeneral_RelayIntervalSeconds.TextAlign = ContentAlignment.MiddleLeft;
            this.mt_TabGeneral_RelayIntervalSeconds.Text      = "seconds";
            this.mt_TabGeneral_RelayRetryInterval             = new Label();
            this.mt_TabGeneral_RelayRetryInterval.Size        = new Size(200, 20);
            this.mt_TabGeneral_RelayRetryInterval.Location    = new Point(10, 315);
            this.mt_TabGeneral_RelayRetryInterval.TextAlign   = ContentAlignment.MiddleRight;
            this.mt_TabGeneral_RelayRetryInterval.Text        = "Relay Retry Interval:";
            this.m_pTabGeneral_RelayRetryInterval             = new NumericUpDown();
            this.m_pTabGeneral_RelayRetryInterval.Size        = new Size(70, 20);
            this.m_pTabGeneral_RelayRetryInterval.Location    = new Point(215, 315);
            this.m_pTabGeneral_RelayRetryInterval.Minimum     = 1m;
            this.m_pTabGeneral_RelayRetryInterval.Maximum     = 9999m;
            this.mt_TabGeneral_RelayRetryIntervSec            = new Label();
            this.mt_TabGeneral_RelayRetryIntervSec.Size       = new Size(50, 20);
            this.mt_TabGeneral_RelayRetryIntervSec.Location   = new Point(290, 315);
            this.mt_TabGeneral_RelayRetryIntervSec.TextAlign  = ContentAlignment.MiddleLeft;
            this.mt_TabGeneral_RelayRetryIntervSec.Text       = "seconds";
            this.mt_TabGeneral_SendUndelWarning               = new Label();
            this.mt_TabGeneral_SendUndelWarning.Size          = new Size(200, 20);
            this.mt_TabGeneral_SendUndelWarning.Location      = new Point(10, 345);
            this.mt_TabGeneral_SendUndelWarning.TextAlign     = ContentAlignment.MiddleRight;
            this.mt_TabGeneral_SendUndelWarning.Text          = "Send undelivered warning after:";
            this.m_pTabGeneral_SendUndelWarning               = new NumericUpDown();
            this.m_pTabGeneral_SendUndelWarning.Size          = new Size(70, 20);
            this.m_pTabGeneral_SendUndelWarning.Location      = new Point(215, 345);
            this.m_pTabGeneral_SendUndelWarning.Minimum       = 1m;
            this.m_pTabGeneral_SendUndelWarning.Maximum       = 9999m;
            this.mt_TabGeneral_SendUndelWarnMinutes           = new Label();
            this.mt_TabGeneral_SendUndelWarnMinutes.Size      = new Size(50, 20);
            this.mt_TabGeneral_SendUndelWarnMinutes.Location  = new Point(290, 345);
            this.mt_TabGeneral_SendUndelWarnMinutes.TextAlign = ContentAlignment.MiddleLeft;
            this.mt_TabGeneral_SendUndelWarnMinutes.Text      = "minutes";
            this.mt_TabGeneral_SendUndelivered                = new Label();
            this.mt_TabGeneral_SendUndelivered.Size           = new Size(200, 20);
            this.mt_TabGeneral_SendUndelivered.Location       = new Point(10, 370);
            this.mt_TabGeneral_SendUndelivered.TextAlign      = ContentAlignment.MiddleRight;
            this.mt_TabGeneral_SendUndelivered.Text           = "Send undelivered after:";
            this.m_pTabGeneral_SendUndelivered                = new NumericUpDown();
            this.m_pTabGeneral_SendUndelivered.Size           = new Size(70, 20);
            this.m_pTabGeneral_SendUndelivered.Location       = new Point(215, 370);
            this.m_pTabGeneral_SendUndelivered.Minimum        = 1m;
            this.m_pTabGeneral_SendUndelivered.Maximum        = 999m;
            this.mt_TabGeneral_SendUndeliveredHours           = new Label();
            this.mt_TabGeneral_SendUndeliveredHours.Size      = new Size(50, 20);
            this.mt_TabGeneral_SendUndeliveredHours.Location  = new Point(290, 370);
            this.mt_TabGeneral_SendUndeliveredHours.TextAlign = ContentAlignment.MiddleLeft;
            this.mt_TabGeneral_SendUndeliveredHours.Text      = "hours";
            this.m_pTabGeneral_StoreUndeliveredMsgs           = new CheckBox();
            this.m_pTabGeneral_StoreUndeliveredMsgs.Size      = new Size(250, 20);
            this.m_pTabGeneral_StoreUndeliveredMsgs.Location  = new Point(215, 395);
            this.m_pTabGeneral_StoreUndeliveredMsgs.Text      = "Store undelivered messages";
            this.m_pTabGeneral_UseTlsIfPossible               = new CheckBox();
            this.m_pTabGeneral_UseTlsIfPossible.Size          = new Size(250, 20);
            this.m_pTabGeneral_UseTlsIfPossible.Location      = new Point(215, 415);
            this.m_pTabGeneral_UseTlsIfPossible.Text          = "Use TLS if possible";
            this.m_pTabGeneral_Notification                   = new NotificationForm();
            this.m_pTabGeneral_Notification.Size              = new Size(485, 38);
            this.m_pTabGeneral_Notification.Location          = new Point(10, 440);
            this.m_pTabGeneral_Notification.Icon              = ResManager.GetIcon("warning.ico").ToBitmap();
            this.m_pTabGeneral_Notification.Visible           = false;
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_SendSmartHost);
            this.m_pTab.TabPages[0].Controls.Add(this.mt_TabGeneral_SmartHostsBalanceMode);
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_SmartHostsBalanceMode);
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_SmartHosts_Toolbar);
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_SmartHosts);
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_SendDns);
            this.m_pTab.TabPages[0].Controls.Add(this.mt_TabGeneral_SessionTimeout);
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_SessionTimeout);
            this.m_pTab.TabPages[0].Controls.Add(this.mt_TabGeneral_SessTimeoutSec);
            this.m_pTab.TabPages[0].Controls.Add(this.mt_TabGeneral_MaxConnections);
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_MaxConnections);
            this.m_pTab.TabPages[0].Controls.Add(this.mt_TabGeneral_MaxConnsPerIP);
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_MaxConnsPerIP);
            this.m_pTab.TabPages[0].Controls.Add(this.mt_TabGeneral_MaxConnsPerIP0);
            this.m_pTab.TabPages[0].Controls.Add(this.mt_TabGeneral_RelayInterval);
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_RelayInterval);
            this.m_pTab.TabPages[0].Controls.Add(this.mt_TabGeneral_RelayIntervalSeconds);
            this.m_pTab.TabPages[0].Controls.Add(this.mt_TabGeneral_RelayRetryInterval);
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_RelayRetryInterval);
            this.m_pTab.TabPages[0].Controls.Add(this.mt_TabGeneral_RelayRetryIntervSec);
            this.m_pTab.TabPages[0].Controls.Add(this.mt_TabGeneral_SendUndelWarning);
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_SendUndelWarning);
            this.m_pTab.TabPages[0].Controls.Add(this.mt_TabGeneral_SendUndelWarnMinutes);
            this.m_pTab.TabPages[0].Controls.Add(this.mt_TabGeneral_SendUndelivered);
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_SendUndelivered);
            this.m_pTab.TabPages[0].Controls.Add(this.mt_TabGeneral_SendUndeliveredHours);
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_StoreUndeliveredMsgs);
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_UseTlsIfPossible);
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_Notification);
            this.m_pTabBindings_BindingsToolbar              = new ToolStrip();
            this.m_pTabBindings_BindingsToolbar.Size         = new Size(95, 25);
            this.m_pTabBindings_BindingsToolbar.Location     = new Point(425, 13);
            this.m_pTabBindings_BindingsToolbar.Dock         = DockStyle.None;
            this.m_pTabBindings_BindingsToolbar.GripStyle    = ToolStripGripStyle.Hidden;
            this.m_pTabBindings_BindingsToolbar.BackColor    = this.BackColor;
            this.m_pTabBindings_BindingsToolbar.Renderer     = new ToolBarRendererEx();
            this.m_pTabBindings_BindingsToolbar.ItemClicked += new ToolStripItemClickedEventHandler(this.m_pTabBindings_BindingsToolbar_ItemClicked);
            ToolStripButton toolStripButton6 = new ToolStripButton();

            toolStripButton6.Image       = ResManager.GetIcon("add.ico").ToBitmap();
            toolStripButton6.Tag         = "add";
            toolStripButton6.ToolTipText = "Add";
            this.m_pTabBindings_BindingsToolbar.Items.Add(toolStripButton6);
            ToolStripButton toolStripButton7 = new ToolStripButton();

            toolStripButton7.Enabled     = false;
            toolStripButton7.Image       = ResManager.GetIcon("edit.ico").ToBitmap();
            toolStripButton7.Tag         = "edit";
            toolStripButton7.ToolTipText = "edit";
            this.m_pTabBindings_BindingsToolbar.Items.Add(toolStripButton7);
            ToolStripButton toolStripButton8 = new ToolStripButton();

            toolStripButton8.Enabled     = false;
            toolStripButton8.Image       = ResManager.GetIcon("delete.ico").ToBitmap();
            toolStripButton8.Tag         = "delete";
            toolStripButton8.ToolTipText = "Delete";
            this.m_pTabBindings_BindingsToolbar.Items.Add(toolStripButton8);
            this.m_pTabBindings_Bindings                       = new ListView();
            this.m_pTabBindings_Bindings.Size                  = new Size(485, 375);
            this.m_pTabBindings_Bindings.Location              = new Point(10, 40);
            this.m_pTabBindings_Bindings.View                  = View.Details;
            this.m_pTabBindings_Bindings.HeaderStyle           = ColumnHeaderStyle.Nonclickable;
            this.m_pTabBindings_Bindings.HideSelection         = false;
            this.m_pTabBindings_Bindings.FullRowSelect         = true;
            this.m_pTabBindings_Bindings.MultiSelect           = false;
            this.m_pTabBindings_Bindings.SelectedIndexChanged += new EventHandler(this.m_pTabBindings_Bindings_SelectedIndexChanged);
            this.m_pTabBindings_Bindings.Columns.Add("Host Name", 250, HorizontalAlignment.Left);
            this.m_pTabBindings_Bindings.Columns.Add("IP", 190, HorizontalAlignment.Left);
            this.m_pTabBindings_Notification          = new NotificationForm();
            this.m_pTabBindings_Notification.Size     = new Size(485, 38);
            this.m_pTabBindings_Notification.Location = new Point(10, 421);
            this.m_pTabBindings_Notification.Icon     = ResManager.GetIcon("warning.ico").ToBitmap();
            this.m_pTabBindings_Notification.Visible  = false;
            this.m_pTab.TabPages[1].Controls.Add(this.m_pTabBindings_BindingsToolbar);
            this.m_pTab.TabPages[1].Controls.Add(this.m_pTabBindings_Bindings);
            this.m_pTab.TabPages[1].Controls.Add(this.m_pTabBindings_Notification);
            base.Controls.Add(this.m_pTab);
            base.Controls.Add(this.m_pApply);
        }
示例#7
0
        public void Execute(IJobExecutionContext context)
        {
            var form = new NotificationForm(context.JobDetail, context.Trigger);

            form.ShowDialog();
        }
 public ClipboardService(Action<ClipboardDataItem> notificationCallback)
 {
     _form = new NotificationForm(this);
     NativeMethods.SetParent(_form.Handle, NativeMethods.HWND_MESSAGE);
     _notificationCallback = notificationCallback;
 }
示例#9
0
        void Button1Click(object sender, EventArgs e)
        {
            float  percentofTotalSlide;
            bool   res = float.TryParse(textBox1.Text, out percentofTotalSlide);
            string pptPresPath;

            if (res == false || (percentofTotalSlide <= 0.0F) || (percentofTotalSlide > 1.1F))
            {
                MessageBox.Show("You appear to have an invalid value entered for scale. Please enter a value between 0 and 1.1.");
                return;
            }

            //Pick presentation for resizing.
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter = "PowerPoint Files|*.pptx;*.ppt;*.pptm";
            //			openFileDialog1.Filter = "Text Files|*.txt"; //Debugging filter
            openFileDialog1.Title = "Select the presentation for resizing";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                pptPresPath = openFileDialog1.FileName;
            }
            else
            {
                pptPresPath = string.Empty;
                return;
            }

            PowerPoint.Application   objApp;
            PowerPoint.Presentations objPresSet;
            PowerPoint._Presentation objPres;
            PowerPoint._Presentation objPresNew;
            PowerPoint.Slides        objSlides;
//				PowerPoint._Slide objSlide;
//				PowerPoint.TextRange objTextRng;
//				PowerPoint.Shapes objShapes;
//				PowerPoint.Shape objShape;
//				PowerPoint.SlideShowWindows objSSWs;
//				PowerPoint.SlideShowTransition objSST;
//				PowerPoint.SlideShowSettings objSSS;
//				PowerPoint.SlideRange objSldRng;
//				PowerPoint.ShapeRange objShpRng;

            string pptPresName;
            string pptCorrectedPresPath;

//				string objPresName; //don't need, is covered under string parsing

            pptPresName = Path.GetFileNameWithoutExtension(pptPresPath);

            pptCorrectedPresPath = Path.GetDirectoryName(pptPresPath) + "\\" + pptPresName + "_corrected" + Path.GetExtension(pptPresPath);

            if (pptPresName.Contains("_corrected"))
            {
                DialogResult dialogResult1 = MessageBox.Show("It looks like you selected a corrected version of this file - you selected:" +
                                                             Environment.NewLine + Environment.NewLine + pptPresName + Environment.NewLine + Environment.NewLine +
                                                             "Are you sure you want to proceed (this will create a _corrected_corrected version)?", "Correct corrected file",
                                                             MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, (MessageBoxOptions)0x40000);

                if (dialogResult1 == DialogResult.No)
                {
                    return;
                }
            }

            if (File.Exists(pptCorrectedPresPath))
            {
                DialogResult dialogResult1 = MessageBox.Show("A corrected version of this file appears to exist already in this folder." +
                                                             " Do you want to proceed (this will overwrite existing corrected version)?", "Overwrite corrected file",
                                                             MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, (MessageBoxOptions)0x40000);
                if (dialogResult1 == DialogResult.No)
                {
                    return;
                }
            }

            //Open selected presentation.
            objApp         = new PowerPoint.Application();
            objApp.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
            objPresSet     = objApp.Presentations;
            //clear the original version if one is already open
            IsOpen_Close(pptPresName, objApp, false);
            objPres   = objPresSet.Open(pptPresPath, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue);
            objSlides = objPres.Slides;

            //			objPresName = objPres.Name.ToString();



            //clear the fixed version if one is already open
            IsOpen_Close(pptPresName + "_corrected", objApp, true);

            //			try{

            //Initial notification window
            NativeWindow pptWindow = new NativeWindow();

            pptWindow.AssignHandle(new IntPtr(objApp.HWND));

            NotificationForm resizeDialog = new NotificationForm();

            resizeDialog.StartPosition   = FormStartPosition.CenterParent;
            resizeDialog.Text            = "Resizing Shapes";
            resizeDialog.label1.AutoSize = true;
            resizeDialog.label1.Location = new System.Drawing.Point(13, 13);
            resizeDialog.label1.Text     = "Resizing presentation; please do not close PowerPoint or any presentations until the 'Resizing Done' message box appears." +
                                           Environment.NewLine + Environment.NewLine + "Please close this box to continue.";
            resizeDialog.Controls.Add(resizeDialog.label1);
            resizeDialog.AutoSize = true;
            resizeDialog.ShowDialog(pptWindow);

            //Add new presentation for resize result
            objPresNew = objPresSet.Add(Microsoft.Office.Core.MsoTriState.msoTrue);
            objPresNew.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutBlank);

            //Copy and paste old small presentation slides into new size presentation
            //			var seq = Enumerable.Range(1,objPres.Slides.Count).ToArray(); //old method all slides at once
            //			objPres.Slides.Range(seq).Copy();
            int i = 1;

            while (i <= objPres.Slides.Count)
            {
                objPresNew.Slides.Add(objPresNew.Slides.Count + 1, PowerPoint.PpSlideLayout.ppLayoutBlank);
                objPres.Slides[i].Shapes.Range(Type.Missing).Copy();
                objPresNew.Slides[i].Select();
                objPresNew.Slides[i].Application.CommandBars.ExecuteMso("PasteSourceFormatting");
                //			objPresNew.Slides[1].Select();
                //			objPresNew.Slides[1].Application.CommandBars.ExecuteMso("PasteSourceFormatting");
                Application.DoEvents();
                i = i + 1;
//					PowerPoint.ShapeRange shpRng;
                bool deleteflag;
                int  tablecount = 0;
                objApp.ActiveWindow.Selection.Unselect();
                PowerPoint.Slide currentSlide = objPresNew.Slides[i - 1];
                foreach (PowerPoint.Shape f in currentSlide.Shapes)
                {
                    deleteflag = false;
                    if (f.HasTable == Microsoft.Office.Core.MsoTriState.msoTrue)
                    {
                        tablecount = tablecount + 1;
                        foreach (PowerPoint.Cell colheader in f.Table.Rows[1].Cells)
                        {
                            //							Console.WriteLine(colheader.Shape.TextFrame.TextRange.Text.ToString()); //Used for debugging tech signoff delete
                            //							Console.WriteLine(colheader.Shape.TextFrame.TextRange.Text.ToString().Contains("Technician Sign"));
                            if (colheader.Shape.TextFrame.TextRange.Text.ToString().Contains("Technician Sign"))
                            {
                                deleteflag = true;
                            }
                        }
                    }
                    else if (f.Type != MsoShapeType.msoTable)
                    {
                        f.Select(Microsoft.Office.Core.MsoTriState.msoFalse);
                    }
                    if (deleteflag)
                    {
                        f.Delete();
                        tablecount = tablecount - 1;
                    }
                }

                if ((objApp.ActiveWindow.Selection.ShapeRange.Count >= 2) && (tablecount <= 1))
                {
                    PowerPoint.Shape slideShapeGroup = objApp.ActiveWindow.Selection.ShapeRange.Group();
//						float percentofTotalSlide = 0.95F; //Now taken from textbox
                    slideShapeGroup.LockAspectRatio = MsoTriState.msoTrue;
                    if ((objPresNew.PageSetup.SlideHeight / objPresNew.PageSetup.SlideWidth) >= (slideShapeGroup.Height / slideShapeGroup.Width))
                    {
                        slideShapeGroup.ScaleWidth(objPresNew.PageSetup.SlideWidth / slideShapeGroup.Width * percentofTotalSlide, MsoTriState.msoFalse, MsoScaleFrom.msoScaleFromTopLeft);
                    }
                    else
                    {
                        slideShapeGroup.ScaleHeight(objPresNew.PageSetup.SlideHeight / slideShapeGroup.Height * percentofTotalSlide, MsoTriState.msoFalse, MsoScaleFrom.msoScaleFromTopLeft);
                    }
                    slideShapeGroup.Select(MsoTriState.msoTrue);
                    objApp.ActiveWindow.Selection.ShapeRange.Align(Microsoft.Office.Core.MsoAlignCmd.msoAlignCenters, MsoTriState.msoTrue);
                    objApp.ActiveWindow.Selection.ShapeRange.Align(Microsoft.Office.Core.MsoAlignCmd.msoAlignMiddles, MsoTriState.msoTrue);

                    objApp.ActiveWindow.Selection.Unselect();
                }
                //				else{
                //					currentSlide.Shapes.SelectAll();
                //					objApp.ActiveWindow.Selection.ShapeRange.Align(Microsoft.Office.Core.MsoAlignCmd.msoAlignCenters, MsoTriState.msoTrue);
                //					objApp.ActiveWindow.Selection.ShapeRange.Align(Microsoft.Office.Core.MsoAlignCmd.msoAlignMiddles, MsoTriState.msoTrue);
                //				}
            }

            //			objPresNew.Slides[1].Delete();
            //			objApp.ActiveWindow.Selection.Unselect();



            //Resize stuck shapes - superseded by going to old method of copy/pasting slide w/ formatting start to finish
            //			foreach (PowerPoint._Slide d in objPresNew.Slides) {
            //				foreach (PowerPoint.Shape e in d.Shapes) {
            //					Console.WriteLine(e.Name);
            //
            //					if (e.Type == Microsoft.Office.Core.MsoShapeType.msoAutoShape) {
            //						PowerPoint.Shape eOld = objPres.Slides[d.SlideNumber].Shapes[e.Name];
            //
            //						if (e.Height != eOld.Height) {
            //							e.Height = eOld.Height;
            //						}
            //
            //					}
            //				}
            //			}

            //Delete notes master if it exists
            var seq2 = Enumerable.Range(1, objPresNew.SlideMaster.Shapes.Count).ToArray();

            objPresNew.SlideMaster.Shapes.Range(seq2).Delete();

            //Delete last hanging slide
            objPresNew.Slides[objPresNew.Slides.Count].Delete();

            //Save new pres
            objPresNew.SaveAs(pptCorrectedPresPath, PowerPoint.PpSaveAsFileType.ppSaveAsDefault, Microsoft.Office.Core.MsoTriState.msoFalse);

            //Displaying "Resizing Done" on successful resizing, and closing original box if needed
            if (!resizeDialog.IsDisposed)
            {
                resizeDialog.Close();
            }

            NotificationForm resizeDialog2 = new NotificationForm();

            resizeDialog2.StartPosition   = FormStartPosition.CenterParent;
            resizeDialog2.TopMost         = false;
            resizeDialog2.Text            = "Resizing Done";
            resizeDialog2.label1.AutoSize = true;
            resizeDialog2.label1.Location = new System.Drawing.Point(13, 13);
            resizeDialog2.label1.Text     = "PowerPoint file successfully resized; you can find the new file at " +
                                            Environment.NewLine + Environment.NewLine + pptCorrectedPresPath + Environment.NewLine + Environment.NewLine + "Please close this box to continue.";
            resizeDialog2.Controls.Add(resizeDialog2.label1);
            resizeDialog2.AutoSize = true;
            resizeDialog2.ShowDialog(pptWindow);
            //			resizeDialog2.Activate();


            IsOpen_Close(pptPresName, objApp, false);



            //			if (IsOpen(pptPresName,objApp)) //old method of checking/closing open window
            //			{
            //				objPres.Close();
            //			}
            //			objPresSet.Open(pptCorrectedPresPath, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue);



            //			objApp.Quit();

            //			objApp.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;

            //			objPresNew.NewWindow();
            //			Set pptApp = GetObject(Class:="PowerPoint.Application")
            //			Set pptPres = pptApp.ActivePresentation
            //			pptPath = pptPres.Path
            //			newsaveOld = pptPath & "\" & fso.GetBaseOld(pptPres.Name) & "_corrected"
            //
            //			With Presentations.Add
            //			End With
            //
            //			Set pptnewPres = pptApp.ActivePresentation
            //
            //			i = 1
            //
            //			Do While i <= pptPres.Slides.Count
            //
            //			pptnewPres.Slides.Add Index:=pptnewPres.Slides.Count + 1, Layout:=ppLayoutBlank
            //
            //			Set myRange = pptPres.Slides(i).Shapes.Range
            //			Set newslide = pptnewPres.Slides(i)
            //			newslide.Select
            //			myRange.Copy
            //			pptnewPres.Application.CommandBars.ExecuteMso ("PasteSourceFormatting")
            //			DoEvents
            //			i = i + 1
            //
            //			Loop
            //
            //			pptnewPres.SaveAs (newsaveOld)

            //			 Console.WriteLine(pptPresPath);
            //			 Console.WriteLine(pptPresName);
            //			 Console.WriteLine(pptCorrectedPresPath);
            //			 Console.WriteLine("Press any key to continue . . . ");
            //			 Console.ReadKey(true);
            //
            //			} catch(Exception exc){
            //				objPresNew.Close();
            //				objPres.Close();
            //			}
        }
示例#10
0
 private void buttonNotification_Click(object sender, EventArgs e)
 {
     nF = new NotificationForm();
     nF.Show();
 }
示例#11
0
        static void Main()
        {
            //Initiate update process
            //deactivated for now, though it does work!
            //NinjaTranslateMain.Update(Config.GetValue("version"), Config.GetValue("updateStep"));

            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);

            //load windows
            MainWindow       mainWindow       = new MainWindow();
            NotificationForm notificationForm = new NotificationForm();

            //load config values
            LoadConfigFiles(mainWindow);

            //load tree
            PatriciaTrie translationTree = LoadTranslationTree(currentFileKey);

            //TODO normalizer is used for input and  parsing -> surely no problem when we finally add filters
            Normalizer normalizer = new Normalizer();

            //initiate translation center
            translationCenter = new TranslationCenter();
            translationCenter.SetFilter(normalizer);
            translationCenter.SetTranslationTree(translationTree);

            //initiate notification service
            CustomNotification notification = new CustomNotification();

            notification.setHeight(Int32.Parse(Config.GetValue("windowHeight")));
            notification.setWidth(Int32.Parse(Config.GetValue("windowWidth")));
            notification.SetForm(notificationForm);

            //initiate sources to be translated from
            SystemSource systemSource         = new SystemSource();
            int          clipboardAccessTimer = 500;

            int.TryParse(Config.GetValue("clipboardAccessTimer"), out clipboardAccessTimer);
            systemSource.SetClipboardAccessTimer(clipboardAccessTimer);
            systemSource.SetTranslationService(translationCenter);
            systemSource.SetNotificationService(notification);

            InputForm inputSource = new InputForm();

            inputSource.SetTranslationService(translationCenter);
            inputSource.SetNotificationService(notification);

            //register hooks
            KeyboardHook markerHook     = new KeyboardHook();
            KeyboardHook inputHook      = new KeyboardHook();
            KeyboardHook dictionaryHook = new KeyboardHook();

            try {
                // register the control + alt + N combination as hot key to translate current selection.
                markerHook.KeyPressed += new EventHandler <KeyPressedEventArgs>(delegate(object sender, KeyPressedEventArgs e) {
                    systemSource.TriggerTranslation(true);
                });
                markerHook.RegisterHotKey((ModifierKeys)2 | (ModifierKeys)1, Keys.N);
                // register the control + alt + B combination as hot key to open up input formular.
                inputHook.KeyPressed += new EventHandler <KeyPressedEventArgs>(delegate(object sender, KeyPressedEventArgs e) {
                    inputSource.TriggerTranslation(true);
                });
                inputHook.RegisterHotKey((ModifierKeys)2 | (ModifierKeys)1, Keys.B);
                //register the control + alt + V combination to trigger a switch of the chosen dictionary
                dictionaryHook.KeyPressed += new EventHandler <KeyPressedEventArgs>(delegate(object sender, KeyPressedEventArgs e) {
                    //reload in case user has added a dict
                    NinjaTranslateMain.rawFiles       = Config.GetMultiValue("path");
                    NinjaTranslateMain.quickChangeKey = Config.GetValue("quickchangeKey");
                    NinjaTranslateMain.currentFileKey = Config.GetValue("currentKey");
                    NinjaTranslateMain.ChangeDictionary(notification);
                });
                dictionaryHook.RegisterHotKey((ModifierKeys)2 | (ModifierKeys)1, Keys.V);
            }
            catch (InvalidOperationException e) {
                System.Windows.Forms.MessageBox.Show("NinjaTranslate couldn't register the necessary hotkeys. It seems like another program uses them. Try to close them :)", "NinjaTranslate found an error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            //check if construction went well or if window is marked as indisposed
            if (!mainWindow.IsDisposed)
            {
                Application.Run(mainWindow);
            }

            GC.KeepAlive(markerHook);
            GC.KeepAlive(dictionaryHook);
            GC.KeepAlive(inputHook);
        }
示例#12
0
        public static List <NotificationForm> GetNotifications(string username)
        {
            int userid = Profile.getUserID(username);

            using (boxEntities box = new boxEntities())
            {
                var noti = (from o in box.NotInfoes.Include("NotificationHeader").Include("UserProfile")
                            where o.UserID == userid
                            select o).OrderByDescending(a => a.NotificationHeader.NotDate).ToList();
                List <NotificationForm> finalResult = new List <NotificationForm>();
                foreach (var t in noti)
                {
                    NotificationForm mform = new NotificationForm();
                    switch (t.NotificationHeader.NotType)
                    {
                    case "Meeting_Parti_Insert":
                        var mID     = t.NotificationHeader.MeetingID;
                        var meeting = (from o in box.Meetings
                                       where o.MeetingID == mID
                                       select o).FirstOrDefault();
                        if (meeting != null)
                        {
                            mform.NotText = "You have been invited to a meeting by " + t.NotificationHeader.UserProfile.UserName + " On: " + meeting.StartDate.ToShortDateString();
                            mform.NotURL  = "PMeetingSetUp.aspx?id=" + meeting.MeetingID;
                            mform.seen    = t.Seen;
                            mform.Type    = "Meetings";
                            mform.ID      = t.NotInfoID;
                            finalResult.Add(mform);
                        }
                        //else
                        //{
                        //    throw new Exception("No such Meeting, Maybe Deleted?!");
                        //}

                        break;

                    case "Meeting_Info_Update":
                        var uID      = t.NotificationHeader.MeetingID;
                        var umeeting = (from o in box.Meetings
                                        where o.MeetingID == uID
                                        select o).FirstOrDefault();
                        if (umeeting != null)
                        {
                            mform.NotText = "An update has been made the meeting: " + umeeting.MeetingTitle + " On: " + t.NotificationHeader.NotDate;
                            mform.NotURL  = "PMeetingSetUp.aspx?id=" + umeeting.MeetingID;
                            mform.seen    = t.Seen;
                            mform.Type    = "Meetings";
                            mform.ID      = t.NotInfoID;
                            finalResult.Add(mform);
                        }
                        //else
                        //{
                        //    throw new Exception("No such Meeting, Maybe Deleted?!");
                        //}
                        break;

                    case "Agenda_New":
                        var GID    = t.NotificationHeader.AgendaID;
                        var agenda = (from o in box.Agenda.Include("Meeting")
                                      where o.AgendaID == GID
                                      select o).FirstOrDefault();
                        if (agenda != null)
                        {
                            mform.NotText = "A new Agenda has been added to the meeting: " + agenda.Meeting.MeetingTitle + " On: " + t.NotificationHeader.NotDate;
                            mform.NotURL  = "PMeetingSetUp.aspx?id=" + agenda.Meeting.MeetingID + "&tab=Agenda";
                            mform.seen    = t.Seen;
                            mform.Type    = "Agenda";
                            mform.ID      = t.NotInfoID;
                            finalResult.Add(mform);
                        }
                        //else
                        //{
                        //    throw new Exception("No such Agenda, Maybe deleted?!");
                        //}
                        break;

                    case "Agenda_Update":
                        var guID     = t.NotificationHeader.AgendaID;
                        var agendaup = (from o in box.Agenda.Include("Meeting")
                                        where o.AgendaID == guID
                                        select o).FirstOrDefault();
                        if (agendaup != null)
                        {
                            mform.NotText = "A update has been done to the Agendum in the meeting : " + agendaup.Meeting.MeetingTitle + " On: " + t.NotificationHeader.NotDate;
                            mform.NotURL  = "PMeetingSetUp.aspx?id=" + agendaup.Meeting.MeetingID + "&tab=Agenda";
                            mform.seen    = t.Seen;
                            mform.Type    = "Agenda";
                            mform.ID      = t.NotInfoID;
                            finalResult.Add(mform);
                        }
                        //else
                        //{
                        //    throw new Exception("No such Agenda, Maybe deleted?!");
                        //}
                        break;

                    case "Task_Assignment":
                        var tID  = t.NotificationHeader.AgendaID;
                        var task = (from o in box.Agenda.Include("Meeting")
                                    where o.AgendaID == tID
                                    select o).FirstOrDefault();
                        if (task != null)
                        {
                            mform.NotText = "You have been assigned a task for the Agendum: " + task.AgendaTitle + " On: " + t.NotificationHeader.NotDate;
                            mform.NotURL  = "PMeetingSetUp.aspx?id=" + task.Meeting.MeetingID + "&tab=Agenda";
                            mform.seen    = t.Seen;
                            mform.Type    = "Agenda";
                            mform.ID      = t.NotInfoID;
                            finalResult.Add(mform);
                        }
                        //else
                        //{
                        //    throw new Exception("No such Agenda, Maybe deleted?!");
                        //}
                        break;

                    case "Meeting_New_Discussion":
                        var dID = t.NotificationHeader.DiscussionID;
                        var dis = (from o in box.Discussions.Include("Meeting")
                                   where o.ID == dID
                                   select o).FirstOrDefault();
                        if (dis != null)
                        {
                            mform.NotText = "A new discussion has been added to the meeting: " + dis.Meeting.MeetingTitle + " On: " + t.NotificationHeader.NotDate;
                            mform.NotURL  = "PMeetingSetUp.aspx?id=" + dis.Meeting.MeetingID + "&tab=Discussion";
                            mform.seen    = t.Seen;
                            mform.Type    = "Discussions";
                            mform.ID      = t.NotInfoID;
                            finalResult.Add(mform);
                        }
                        //else
                        //{
                        //    throw new Exception("No such Discussion, Maybe deleted?!");
                        //}
                        break;

                    case "Agenda_New_Discussion":
                        var adID = t.NotificationHeader.DiscussionID;
                        var adis = (from o in box.Discussions.Include("Agendum")
                                    where o.ID == adID
                                    select o).FirstOrDefault();
                        if (adis != null)
                        {
                            mform.NotText = "A new discussion has been added to the Agenda: " + adis.Agendum.AgendaTitle + " On: " + t.NotificationHeader.NotDate;
                            mform.NotURL  = "PMeetingSetUp.aspx?id=" + adis.Agendum.MeetingID + "&tab=Agenda";
                            mform.seen    = t.Seen;
                            mform.Type    = "Discussions";
                            mform.ID      = t.NotInfoID;
                            finalResult.Add(mform);
                        }
                        //else
                        //{
                        //    throw new Exception("No such Discussion, Maybe deleted?!");
                        //}
                        break;

                    case "New_Reply":
                        var rid = t.NotificationHeader.DiscussionID;
                        var rep = (from o in box.Discussions
                                   where o.ID == rid
                                   select o).FirstOrDefault();
                        if (rep != null)
                        {
                            mform.NotText = "A new reply has been added to the discussion: " + rep.Title + " On: " + t.NotificationHeader.NotDate;
                            mform.NotURL  = "#";
                            mform.seen    = t.Seen;
                            mform.Type    = "Discussions";
                            mform.ID      = t.NotInfoID;
                            finalResult.Add(mform);
                        }
                        //else
                        //{
                        //    throw new Exception("No such rpely, Maybe deleted?!");
                        //}
                        break;
                    }
                }
                return(finalResult);
            }
        }
示例#13
0
        void Button2Click(object sender, EventArgs e)
        {
            string pptPresPath;

            //Pick presentation for resizing.
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter = "PowerPoint Files|*.pptx;*.ppt;*.pptm";
            openFileDialog1.Title  = "Select the presentation for renumbering";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                pptPresPath = openFileDialog1.FileName;
            }
            else
            {
                pptPresPath = string.Empty;
                return;
            }

            PowerPoint.Application   objApp;
            PowerPoint.Presentations objPresSet;
            PowerPoint._Presentation objPres;
            PowerPoint._Presentation objPresNew;
            PowerPoint.Slides        objSlides;

            string pptPresName;
            string pptCorrectedPresPath;

            pptPresName = Path.GetFileNameWithoutExtension(pptPresPath);

            pptCorrectedPresPath = Path.GetDirectoryName(pptPresPath) + "\\" + pptPresName + "_renumbered" + Path.GetExtension(pptPresPath);

            if (pptPresName.Contains("_corrected"))
            {
                DialogResult dialogResult1 = MessageBox.Show("It looks like you selected a renumbered version of this file - you selected:" +
                                                             Environment.NewLine + Environment.NewLine + pptPresName + Environment.NewLine + Environment.NewLine +
                                                             "Are you sure you want to proceed (this will create a _renumbered_renumbered version)?", "Correct corrected file",
                                                             MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, (MessageBoxOptions)0x40000);

                if (dialogResult1 == DialogResult.No)
                {
                    return;
                }
            }

            if (File.Exists(pptCorrectedPresPath))
            {
                DialogResult dialogResult1 = MessageBox.Show("A renumbered version of this file appears to exist already in this folder." +
                                                             " Do you want to proceed (this will overwrite existing renumbered version)?", "Overwrite corrected file",
                                                             MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, (MessageBoxOptions)0x40000);
                if (dialogResult1 == DialogResult.No)
                {
                    return;
                }
            }

            //Open selected presentation.
            objApp         = new PowerPoint.Application();
            objApp.Visible = MsoTriState.msoTrue;
            objPresSet     = objApp.Presentations;

            //clear the original version if one is already open
            IsOpen_Close(pptPresName, objApp, false);

            objPresNew = objPresSet.Open(pptPresPath, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);

            //clear the fixed version if one is already open
            IsOpen_Close(pptPresName + "_renumbered", objApp, true);

            objPresNew.SaveAs(pptCorrectedPresPath, PowerPoint.PpSaveAsFileType.ppSaveAsDefault, Microsoft.Office.Core.MsoTriState.msoFalse);

            //Initial notification window
            NativeWindow pptWindow = new NativeWindow();

            pptWindow.AssignHandle(new IntPtr(objApp.HWND));

            NotificationForm resizeDialog = new NotificationForm();

            resizeDialog.StartPosition   = FormStartPosition.CenterParent;
            resizeDialog.Text            = "Renumbering";
            resizeDialog.label1.AutoSize = true;
            resizeDialog.label1.Location = new System.Drawing.Point(13, 13);
            resizeDialog.label1.Text     = "Renumbering presentation; please do not close PowerPoint or this presentation until the 'Renumbering Done' message box appears." +
                                           Environment.NewLine + Environment.NewLine + "Please close this box to continue.";
            resizeDialog.Controls.Add(resizeDialog.label1);
            resizeDialog.AutoSize = true;
            resizeDialog.ShowDialog(pptWindow);

            //Copy and paste old small presentation slides into new size presentation
            //			var seq = Enumerable.Range(1,objPres.Slides.Count).ToArray(); //old method all slides at once
            //			objPres.Slides.Range(seq).Copy();
//				int y = 1;
//				while (y <= 8)
//				{
            int i = 1;
            int prtCounter;
            int keyrow;

            y = y + 1;
            bool tableflag = false;

            var partTbl = new List <partRef>();

            while (i <= objPresNew.Slides.Count)
            {
                PowerPoint.Slide currentSlide = objPresNew.Slides[i];
                foreach (PowerPoint.Shape f in currentSlide.Shapes)
                {
                    if (f.HasTable == MsoTriState.msoTrue)
                    {
                        keyrow = 1;
                        foreach (PowerPoint.Cell colheader in f.Table.Rows[1].Cells)
                        {
                            if ((colheader.Shape.TextFrame.TextRange.Text.Contains("Item") || colheader.Shape.TextFrame.TextRange.Text.Contains("Find")) &&
                                colheader.Shape.TextFrame.TextRange.Text.Length < 7)
                            {
                                tableflag  = true;
                                prtCounter = 1;
                                foreach (PowerPoint.Cell prt in f.Table.Rows[keyrow].Cells.Count)
                                {
                                    partTbl.Add(new partRef {
                                        SlidePartRef   = prt.Shape.TextFrame.TextRange.TrimText();
                                        partTrueNumber = f.Table.Rows[keyrow + 1].Cells[prtCounter].Shape.TextFrame.TextRange.TrimText();
                                    });
示例#14
0
        private void InitializeComponent()
        {
            this.m_pTab            = new TabControl();
            this.m_pTab.Size       = new Size(515, 490);
            this.m_pTab.Location   = new Point(5, 0);
            this.m_pApply          = new Button();
            this.m_pApply.Size     = new Size(70, 20);
            this.m_pApply.Location = new Point(450, 500);
            this.m_pApply.Text     = "Apply";
            this.m_pApply.Click   += new EventHandler(this.m_pApply_Click);
            this.m_pTab.TabPages.Add("General");
            this.mt_TabGeneral_DnsServers                    = new Label();
            this.mt_TabGeneral_DnsServers.Size               = new Size(80, 20);
            this.mt_TabGeneral_DnsServers.Location           = new Point(0, 10);
            this.mt_TabGeneral_DnsServers.TextAlign          = ContentAlignment.MiddleRight;
            this.mt_TabGeneral_DnsServers.Text               = "DNS servers:";
            this.m_pTabGeneral_DnsServer                     = new TextBox();
            this.m_pTabGeneral_DnsServer.Size                = new Size(180, 20);
            this.m_pTabGeneral_DnsServer.Location            = new Point(85, 10);
            this.m_pTabGeneral_DnsServerToolbar              = new ToolStrip();
            this.m_pTabGeneral_DnsServerToolbar.Size         = new Size(60, 25);
            this.m_pTabGeneral_DnsServerToolbar.Location     = new Point(270, 8);
            this.m_pTabGeneral_DnsServerToolbar.Dock         = DockStyle.None;
            this.m_pTabGeneral_DnsServerToolbar.GripStyle    = ToolStripGripStyle.Hidden;
            this.m_pTabGeneral_DnsServerToolbar.BackColor    = this.BackColor;
            this.m_pTabGeneral_DnsServerToolbar.Renderer     = new ToolBarRendererEx();
            this.m_pTabGeneral_DnsServerToolbar.ItemClicked += new ToolStripItemClickedEventHandler(this.m_pTabGeneral_DnsServerToolbar_ItemClicked);
            ToolStripButton toolStripButton = new ToolStripButton();

            toolStripButton.Image       = ResManager.GetIcon("add.ico").ToBitmap();
            toolStripButton.Tag         = "add";
            toolStripButton.ToolTipText = "Add";
            this.m_pTabGeneral_DnsServerToolbar.Items.Add(toolStripButton);
            ToolStripButton toolStripButton2 = new ToolStripButton();

            toolStripButton2.Enabled     = false;
            toolStripButton2.Image       = ResManager.GetIcon("delete.ico").ToBitmap();
            toolStripButton2.Tag         = "delete";
            toolStripButton2.ToolTipText = "Delete";
            this.m_pTabGeneral_DnsServerToolbar.Items.Add(toolStripButton2);
            this.m_pTabGeneral_DnsServerToolbar.Items.Add(new ToolStripSeparator());
            ToolStripButton toolStripButton3 = new ToolStripButton();

            toolStripButton3.Enabled = false;
            toolStripButton3.Image   = ResManager.GetIcon("up.ico").ToBitmap();
            toolStripButton3.Tag     = "up";
            this.m_pTabGeneral_DnsServerToolbar.Items.Add(toolStripButton3);
            ToolStripButton toolStripButton4 = new ToolStripButton();

            toolStripButton4.Enabled = false;
            toolStripButton4.Image   = ResManager.GetIcon("down.ico").ToBitmap();
            toolStripButton4.Tag     = "down";
            this.m_pTabGeneral_DnsServerToolbar.Items.Add(toolStripButton4);
            this.m_pTabGeneral_DnsServers                       = new ListView();
            this.m_pTabGeneral_DnsServers.Size                  = new Size(355, 100);
            this.m_pTabGeneral_DnsServers.Location              = new Point(10, 35);
            this.m_pTabGeneral_DnsServers.View                  = View.Details;
            this.m_pTabGeneral_DnsServers.FullRowSelect         = true;
            this.m_pTabGeneral_DnsServers.HideSelection         = false;
            this.m_pTabGeneral_DnsServers.SelectedIndexChanged += new EventHandler(this.m_pTabGeneral_DnsServers_SelectedIndexChanged);
            this.m_pTabGeneral_DnsServers.Columns.Add("IP", 325);
            this.m_pTabGeneral_Notification          = new NotificationForm();
            this.m_pTabGeneral_Notification.Size     = new Size(485, 38);
            this.m_pTabGeneral_Notification.Location = new Point(10, 421);
            this.m_pTabGeneral_Notification.Icon     = ResManager.GetIcon("warning.ico").ToBitmap();
            this.m_pTabGeneral_Notification.Visible  = false;
            this.m_pTab.TabPages[0].Controls.Add(this.mt_TabGeneral_DnsServers);
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_DnsServer);
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_DnsServerToolbar);
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_DnsServers);
            this.m_pTab.TabPages[0].Controls.Add(this.m_pTabGeneral_Notification);
            base.Controls.Add(this.m_pTab);
            base.Controls.Add(this.m_pApply);
        }
示例#15
0
 public static void Initialize(Keys hotkey)
 {
     _form = new NotificationForm(hotkey);
 }
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_form != null)
         {
             DisableNotifications();
             _form.Close();
             _form.Dispose();
             _form = null;
         }
         _notificationCallback = null;
     }
 }
示例#17
0
 public void SetForm(Form form)
 {
     this.form = (NotificationForm)form;
 }
示例#18
0
 private void NotificationFormClosed(object sender, FormClosedEventArgs e)
 {
     notificationForm.Dispose();
     notificationForm = null;
 }