Пример #1
0
        void btnSaveUpdate_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
        {
            if (_ds.HasChanges())
            {
                var c = _ds.GetChanges();
                var t = c.Tables[0];

                //var list = t.ToList<AdminProductViewProductDto>();

                for (var i = 0; i < t.Rows.Count; i++)
                {
                    var row = t.Rows[i];
                    switch (row.RowState)
                    {
                    case DataRowState.Added:
                        //_adminProductService.SaveProduct(list[i]);
                        continue;

                    case DataRowState.Deleted:
                        //_adminProductService.DeleteProduct(list[i].Id);
                        continue;

                    case DataRowState.Modified:
                        //_productModule.UpdateFromProductFlatten(t, row);
                        continue;

                    default:
                        throw new Exception("not implemented");
                    }
                }

                _ds.AcceptChanges();
            }
        }
Пример #2
0
        private void BtnClearInvitation_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
        {
            Func<string, bool> f = s => s.StartsWith("Accepted: ") || s.StartsWith("Declined: ") || s.StartsWith("Tentatively Accepted: ");

            InvitationsCounter = 0;

            Outlook.MAPIFolder inbox = Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
            for (int i = inbox.Items.Count; i > 0; i--)
            //foreach (var item in inbox.Items)
            {
                var item = inbox.Items[i];
                Outlook.MailItem mail = item as Outlook.MailItem;
                if (mail != null && mail.Subject != null)
                {
                    //todo: move it to configuration
                    if (f(mail.Subject))
                    {
                        mail.Delete();
                        InvitationsCounter++;
                    }
                }
                Outlook.MeetingItem meeting = item as Outlook.MeetingItem;
                if (meeting != null)
                {
                    if (f(meeting.ConversationTopic))
                    {
                        meeting.Delete();
                        InvitationsCounter++;
                    }
                }
            }
        }
Пример #3
0
 void btnSync_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
 {
     Globals.ThisAddIn.Application.DisplayStatusBar = true;
     Globals.ThisAddIn.Application.StatusBar        = "Loading...";
     Task.Factory.StartNew(LoadRiaProducts).ContinueWith(x =>
     {
         Globals.ThisAddIn.Application.DisplayStatusBar = false;
     });
 }
        /// <summary>
        /// Replace the contents of the existing XML part.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void buttonReplaceXML_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
        {
            CustomTaskPane ctpPaneForThisWindow = Utilities.FindTaskPaneForCurrentWindow();

            Controls.ControlMain ccm = (Controls.ControlMain)ctpPaneForThisWindow.Control;

            Office.CustomXMLPart userPart = null;
            bool cancelled = false;

            while (userPart == null && !cancelled)
            {
                using (Forms.FormAddPart fap = new Forms.FormAddPart())
                {
                    if (fap.ShowDialog() == DialogResult.OK)
                    {
                        string requiredRoot = System.Configuration.ConfigurationManager.AppSettings["RootElement"];
                        if (string.IsNullOrWhiteSpace(requiredRoot))
                        {
                            ccm.EventHandlerAndOnChildren.NodeAfterReplaceDisconnect();
                            Office.CustomXMLPart existingPart = ccm.model.getUserPart(requiredRoot);
                            CustomXmlUtilities.replaceXmlDoc(existingPart, fap.XmlString);
                            userPart = existingPart;
                        }
                        else
                        {
                            Office.CustomXMLPart existingPart = ccm.model.getUserPart(requiredRoot);
                            if (existingPart.DocumentElement.BaseName.Equals(requiredRoot))
                            {
                                ccm.EventHandlerAndOnChildren.NodeAfterReplaceDisconnect();
                                CustomXmlUtilities.replaceXmlDoc(existingPart, fap.XmlString);
                                userPart = existingPart;
                            }
                            else
                            {
                                MessageBox.Show("You need to use root element: " + requiredRoot);
                            }
                        }
                    }
                    else
                    {
                        cancelled = true;
                    }
                }
            }

            if (!cancelled)
            {
                ccm.EventHandlerAndOnChildren.NodeAfterReplaceReconnect();
            }
            ccm.RefreshTreeControl(null);
        }
Пример #5
0
 internal void ButtonStyleAsChar_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
 {
     Fire(StyleByCharQuery.MakeCommand, normalize: false);
 }
Пример #6
0
 public void ButtonAlphaD_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
 {
     Fire(AlphaDQuery.MakeCommand);
 }
Пример #7
0
 internal void ButtonStyleCitation_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
 {
     Fire(JournalReferenceQuery.MakeCommand);
 }
Пример #8
0
 internal void ButtonChemName_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
 {
     Fire(ChemNameQuery.MakeCommand);
 }
Пример #9
0
 internal void ButtonIonFormular_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
 {
     Fire(IonFormulaQuery.MakeCommand);
 }
Пример #10
0
 internal void ButtonRDigitChanger_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
 {
     Fire(RDigitQuery.MakeCommand);
 }
        void buttonClearAll_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
        {
            // First, are you sure?
            DialogResult result = MessageBox.Show("This will remove your content controls (but keep their contents), and the XML they were mapped to.", "Are you sure?", MessageBoxButtons.OKCancel);

            if (!result.Equals(DialogResult.OK))
            {
                return;
            }

            // Remove all content controls, but keep contents
            Word.Document docx = Globals.ThisAddIn.Application.ActiveDocument;
            foreach (Word.Range storyRange in docx.StoryRanges)
            {
                foreach (Word.ContentControl cc in storyRange.ContentControls)
                {
                    // Delete the content control, but keep the contents
                    cc.Delete(false);
                }
            }

            // That's not enough to get the headers/footers!
            foreach (Word.Section section in docx.Sections)
            {
                foreach (Word.HeaderFooter hf in section.Headers)
                {
                    foreach (Word.ContentControl cc in hf.Range.ContentControls)
                    {
                        cc.Delete(false);
                    }
                }
                foreach (Word.HeaderFooter hf in section.Footers)
                {
                    foreach (Word.ContentControl cc in hf.Range.ContentControls)
                    {
                        cc.Delete(false);
                    }
                }
            }



            CustomTaskPane ctpPaneForThisWindow = Utilities.FindTaskPaneForCurrentWindow();

            if (ctpPaneForThisWindow != null)
            {
                Controls.ControlMain ccm = (Controls.ControlMain)ctpPaneForThisWindow.Control;
                ccm.EventHandlerAndOnChildren.DisconnectOldDocument();

                // Remove all Custom XML Parts
                ccm.model.RemoveParts();
                //Model model = Model.ModelFactory(docx);
                //model.RemoveParts();

                // Remove task pane
                Globals.ThisAddIn.TaskPaneList.Remove(Globals.ThisAddIn.Application.ActiveWindow);
                Globals.ThisAddIn.CustomTaskPanes.Remove(ctpPaneForThisWindow);
                ctpPaneForThisWindow.Dispose();
            }

            // Grey out buttons
            this.buttonBind.Enabled      = false;
            this.buttonCondition.Enabled = false;
            this.buttonRepeat.Enabled    = false;

            this.buttonEdit.Enabled   = false;
            this.buttonDelete.Enabled = false;

            this.menuAdvanced.Enabled = false;

            this.buttonReplaceXML.Enabled = false;
            this.buttonClearAll.Enabled   = false;

            toggleButtonMapping.Checked = false;


            // Tell the user
            MessageBox.Show("Content controls and XML parts have been deleted.", "Deletion Confirmed", MessageBoxButtons.OK);
        }