internal PaneWPFControlViewModel() { _model = Globals.ThisAddIn; lst = _model.GetSheetList(); SelectedSheets = new List <SheetInfo>(); _addSheetCommand = new RelayCommand(o => AddSheet(), o => true); _hideSheetCommand = new RelayCommand(o => HideSheet(), o => CanHideSheet()); _veryHideSheetCommand = new RelayCommand(o => VeryHideSheet(), o => CanVeryHideSheet()); _showSheetCommand = new RelayCommand(o => ShowSheet(), o => CanShowSheet()); _deleteSheetCommand = new RelayCommand(o => DeleteSheet(), o => CanDeleteSheet()); //событие возникает как следствие добавления, удаления, скрытия и отображение листов _model.Application.SheetActivate += (s) => lst = _model.GetSheetList(); ////костыль для отслеживания перетаскивания листов в Excel //_model.Application.SheetChange += (s, o) => lst = _model.GetSheetList(); //событие возникает при переключении на другую книгу _model.Application.WorkbookActivate += (s) => lst = _model.GetSheetList(); //костыль для отслеживания переименовывания листа _model.Application.SheetSelectionChange += Application_SheetSelectionChange; //событие возникает когда "галкой" меняют видимость листа _model.ChangeSheetVisibility += () => lst = _model.GetSheetList(); }
/// <summary> /// Redraws the TextBox when necessary. /// </summary> private static Hotkey ValidateHotkey(Keys key, Keys modifiers) { if (key == Keys.LWin || key == Keys.RWin) { key = Keys.None; } Hotkey validatedHotkey = new Hotkey(key, Hotkey.ConvertToWin32Modifiers(modifiers)); // No hotkey set if (key == Keys.None || (modifiers == Keys.None && !NoModifierIsNeededFor(key))) { validatedHotkey = new Hotkey(Keys.None, SCICT.Utility.Windows.Modifiers.None); } else if (modifiers.Has(Keys.Shift) && !modifiers.Has(Keys.Control) && !modifiers.Has(Keys.Alt) && needNonShiftModifier.Contains((int)key)) { validatedHotkey = new Hotkey(Keys.None, SCICT.Utility.Windows.Modifiers.None); } // I have no idea why this is needed, but it is. Without this code, pressing only Ctrl // will show up as "Control + ControlKey", etc. else if (key == Keys.Menu /* Alt */ || key == Keys.ShiftKey || key == Keys.ControlKey) { validatedHotkey = new Hotkey(Keys.None, SCICT.Utility.Windows.Modifiers.None); } ManagedWinapi.KeyboardKey kKey = new ManagedWinapi.KeyboardKey(key); ThisAddIn.DebugWriteLine(kKey.KeyName); return(validatedHotkey); }
public override bool ShowBatchModeStats() { string message = string.Format("تعداد اصلاحات انجام شده: {0}", ParsingUtils.ConvertNumber2Persian(m_bachModeStats.ToString())); PersianMessageBox.Show(ThisAddIn.GetWin32Window(), message, Constants.UIMessages.SuccessRefinementTitle); return(false); }
public User(ThisAddIn app) { App = app; items = new List <Items>(); GetUserInfo(); SetFolderEvents(); }
public override bool ShowBatchModeStats() { string message = string.Format("تعداد اصلاحات انجام شده: {0}", ParsingUtils.ConvertNumber2Persian(m_stats.ToString())); PersianMessageBox.Show(ThisAddIn.GetWin32Window(), message, Title); return(true); }
/// <summary> /// Uses the http-based method for acquiring the information of latest version /// Warning: The speed of this operation depends on the internet connection speed /// </summary> public static string GetLatestVersion() { string latestVersionUrl = Settings.Default.Updater_LatestVersionUrl; try { var request = WebRequest.Create(latestVersionUrl); #region Headers request.Headers.Add("VirastyarVersion", ThisAddIn.InstalledVersion.ToString(3)); request.Headers.Add("OfficeVersion", ThisAddIn.OfficeVersion); request.Headers.Add("WindowsVersion", Environment.OSVersion.VersionString); request.Headers.Add("Guid", ThisAddIn.InstallationGuid); #endregion using (var reader = new StreamReader(request.GetResponse().GetResponseStream())) { string version = reader.ReadToEnd(); return(ThisAddIn.CheckVersionNumbers(new Version(version)).ToString(3)); } } catch (Exception ex) { LogHelper.DebugException("Unable to get information of the lastest version from virastyar web address", ex); } return(ThisAddIn.InstalledVersion.ToString(3)); }
private void VerticalStackBtn_Click(object sender, RibbonControlEventArgs e) { float span = 0.0f; try { span = float.Parse(StackSpanBox.Text); } catch { } ThisAddIn.StackAutoShapes(StackDirection.Vertical, span); }
protected override void ExecuteAction(string ribbonId) { CustomShapePane customShape = InitCustomShapePane(); Selection selection = this.GetCurrentSelection(); ThisAddIn addIn = this.GetAddIn(); customShape.AddShapeFromSelection(selection, addIn); SetPaneVisibility(true); }
internal static void WriteToLog(ThisAddIn thisAddIn) { Log.Information($"Excel Version: {thisAddIn.Application.Version}"); Log.Information($"Excel Build: {thisAddIn.Application.Build}"); Log.Information($"Excel Operating System: {thisAddIn.Application.OperatingSystem}"); // list all addins foreach (Microsoft.Office.Core.COMAddIn addin in thisAddIn.Application.COMAddIns) { Log.Information($" Addin : {addin.Description} Loaded: {addin.Connect}"); } }
static void m_updateNotifyIcon_Click(object sender, EventArgs e) { if (s_window == null || s_window.Disposing || s_window.IsDisposed) { s_window = new AutomaticReportConfirmWindow(); s_window.FormClosed += s_window_FormClosed; } if (!s_window.Visible) { s_window.Show(ThisAddIn.GetWin32Window()); } }
public static VerifierBase CreateAndStartInteractive <T>(Microsoft.Office.Interop.Word.Application application, params object[] args) where T : VerifierBase { Document doc = null; if (!GetActiveDocument(application, ref doc)) { PersianMessageBox.Show(ThisAddIn.GetWin32Window(), "متأسفانه به نظر میرسد این متن محافظت شده است و ویراستیار قادر به تغییر آن نیست", "متنِ محافظت شده", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(null); } return(CreateAndStartInteractive <T>(doc, args)); }
public void button1_Click(object sender, EventArgs e) { ThisAddIn.DisplayInExcel(BankAccounts, (Account, cell) => // This multiline lambda expression sets custom processing rules // for the bankAccounts. { cell.Value = Account.ID; cell.Offset[0, 1].Value = Account.Balance; if (Account.Balance < 0) { cell.Interior.Color = 255; cell.Offset[0, 1].Interior.Color = 255; } }); }
public SheetModelWizViewModel(ThisAddIn thisAddIn) { _thisAddIn = thisAddIn; Steps = new ObservableCollection <bool>(); for (int i = 0; i < 5; i++) { Steps.Add(false); } Steps[0] = true; ModelClasses = new ObservableCollection <ModelClass>(); ModelAssociations = new ObservableCollection <ModelAssociation>(); TargetAssociations = new ObservableCollection <ModelAssociation>(); SheetTabs = new ObservableCollection <SheetTab>(); FilePath = _filePath; }
/// <summary> /// Fires when a key is pushed down. Here, we'll want to update the text in the box /// to notify the user what combination is currently pressed. /// </summary> void HotkeyControl_KeyDown(object sender, KeyEventArgs e) { // Clear the current hotkey ThisAddIn.DebugWriteLine("KeyCode:" + e.KeyCode); ThisAddIn.DebugWriteLine("KeyData:" + e.KeyData); ThisAddIn.DebugWriteLine("KeyValue:" + e.KeyValue); ThisAddIn.DebugWriteLine("-----------------"); if (e.KeyCode == Keys.Back || e.KeyCode == Keys.Delete) { SetHotkey(Keys.None, Keys.None); } else { SetHotkey(e.KeyCode, e.Modifiers); } }
private async void _synchronizationTimer_Tick(object sender, EventArgs e) { try { ThisAddIn.EnsureSynchronizationContext(); _synchronizationTimer.Stop(); foreach (var worker in _workersById.Values) { await worker.RunIfRequiredAndReschedule(); } _synchronizationTimer.Start(); } catch (Exception x) { ExceptionHandler.Instance.LogException(x, s_logger); } }
public static void SyncRemoveCategory(ThisAddIn addIn, int removedCategoryIndex) { if (addIn == null) { return; } foreach (PowerPoint.DocumentWindow window in Globals.ThisAddIn.Application.Windows) { if (window == addIn.Application.ActiveWindow) { continue; } CustomShapePane shapePaneControl = (addIn.GetControlFromWindow(typeof(CustomShapePane), window) as CustomShapePane); shapePaneControl?.RemoveCategory(removedCategoryIndex); } }
internal void DoPositionSelectedImages(Arrangement arrangement, int spacing, int margin) { _positionerParms.Spacing = spacing; _positionerParms.Margin = margin; var shapesCount = Globals.ThisAddIn.SelectedShapes().Length; switch (arrangement) { case Arrangement.LineVertical: _positionerParms.Rows = shapesCount; _positionerParms.Cols = 1; break; case Arrangement.RectangleVertical: { var tup = EuristicArrangeRectangle(shapesCount); _positionerParms.Rows = tup.Item2; _positionerParms.Cols = tup.Item1; } break; case Arrangement.Square: _positionerParms.Rows = _positionerParms.Cols = ThisAddIn.BestSquare(shapesCount); break; case Arrangement.RectangleHorizontal: { var tup = EuristicArrangeRectangle(shapesCount); _positionerParms.Rows = tup.Item1; _positionerParms.Cols = tup.Item2; } break; case Arrangement.LineHorizonal: _positionerParms.Rows = 1; _positionerParms.Cols = shapesCount; break; default: throw new ArgumentOutOfRangeException(nameof(arrangement), arrangement, null); } DoPositionSelectedImages(_positionerParms); }
public void CheckForUpdate(bool recheck, int startDelay) { var thread = new Thread(() => { Thread.Sleep(startDelay); Version installedVersion = ThisAddIn.InstalledVersion; Version lastCheckedVersion = LastCheckedVersion; if (string.IsNullOrEmpty(LatestVersion)) { LatestVersion = GetLatestVersion(); } else if (recheck) { LatestVersion = GetLatestVersion(); } Version latestVersion = ThisAddIn.CheckVersionNumbers(new Version(LatestVersion)); if (latestVersion.CompareTo(installedVersion) > 0) { LastCheckedVersion = latestVersion; ChangeLog = GetWhatsNew(); if (UpdateAvailable != null) { UpdateAvailable(this, EventArgs.Empty); } return; } }); try { thread.Start(); } catch (Exception ex) { LogHelper.DebugException("Could not start the update thread", ex); } }
public static void SyncShapeAdd(ThisAddIn addIn, string shapeName, string shapeFullName, string category) { if (addIn == null) { return; } foreach (PowerPoint.DocumentWindow window in Globals.ThisAddIn.Application.Windows) { if (window == addIn.Application.ActiveWindow) { continue; } CustomShapePane shapePaneControl = (addIn.GetControlFromWindow(typeof(CustomShapePane), window) as CustomShapePane); if (shapePaneControl?.CurrentCategory == category) { shapePaneControl.AddCustomShape(shapeName, shapeFullName, false); } } }
protected bool ShowWordsList(TokenInfo[] readItems, int mainItemIndex) { var sb = new StringBuilder(); for (int i = 0; i < readItems.Length; i++) { if (mainItemIndex == i) { sb.AppendFormat(" ({0}) ", readItems[i].Value); var wRange = m_curPar.GetRange(readItems[i].Index, readItems[i].EndIndex); wRange.Select(); } else { sb.AppendFormat(" {0} ", readItems[i].Value); } } Debug.WriteLine(sb.ToString()); return(DialogResult.Yes == PersianMessageBox.Show(ThisAddIn.GetWin32Window(), sb.ToString(), "df", MessageBoxButtons.YesNo)); }
public AddInWrapper(ThisAddIn thisAddIn) { this._thisAddIn = thisAddIn; this._app = thisAddIn.Application; NSOutlook.NameSpace session = _app.Session; try { this._stores = new StoresWrapper(session.Stores); } finally { ComRelease.Release(session); } // The synchronization context is needed to allow background tasks to jump back to the UI thread. // It's null in older versions of .Net, this fixes that if (SynchronizationContext.Current == null) { SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext()); } _sync = SynchronizationContext.Current; }
public CustomShapePane InitCustomShapePane() { ThisAddIn addIn = this.GetAddIn(); addIn.InitializeShapesLabConfig(); addIn.InitializeShapeGallery(); addIn.RegisterShapesLabPane(this.GetCurrentPresentation().Presentation); var customShapePane = GetShapesLabPane(); if (customShapePane == null) { return(null); } var customShape = customShapePane.Control as CustomShapePane; Logger.Log( "Before Visible: " + string.Format("Pane Width = {0}, Pane Height = {1}, Control Width = {2}, Control Height {3}", customShapePane.Width, customShapePane.Height, customShape.Width, customShape.Height)); return(customShape); }
public UserProxy(ThisAddIn app) { App = app; }
public void TestNoR() { string result = ThisAddIn.filterBody("a\r\n\n\r\nb"); Assert.AreEqual("a\r\nb", result); }
public CalculationForm(ThisAddIn thisAddIn) : this() { Controller = new ProjectController(thisAddIn); }
public MWMailControllerProxy(ThisAddIn app) { App = app; }
public static void message(String msg) { Word.Document doc = ThisAddIn.getCurrDocument(); Word.Range rng = doc.Range(0, 0); rng.Text = msg; }
/// <summary> /// Handles gesture detection results arriving from the sensor for the associated body tracking Id /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> /// //private bool SwipeOnRight = false; //private bool SwipeOnLeft = false; //void Monitor_SwipeOnRight(bool mode) //{ // if (SwipeOnRight == false && mode == true) // { // SwipeOnRight = true; // } //} //void Monitor_SwipeOnLeft(bool mode) //{ // if (SwipeOnLeft == false && mode == true) // { // SwipeOnLeft = true; // } //} private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { // get the discrete gesture results which arrived with the latest frame IReadOnlyDictionary <Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; if (discreteResults != null) { //// we only have one gesture in this source object, but you can get multiple gestures //foreach (Gesture gesture in this.vgbFrameSource.Gestures) //{ // if (gesture.Name.Equals(this.swipeRightGestureName) && gesture.GestureType == GestureType.Discrete) // { // DiscreteGestureResult result = null; // discreteResults.TryGetValue(gesture, out result); // if (result.Confidence == 1.0f) // { // Monitor_SwipeOnRight(true); // } // else if (result.Confidence == 0.0f && SwipeOnRight == true) // { // SwipeOnRight = false; // Console.WriteLine("false"); // } // //if (result != null) // //{ // // // update the GestureResultView object with new gesture result values // // this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.swipeRightGestureName); // //} // } // if (gesture.Name.Equals(this.swipeLeftGestureName) && gesture.GestureType == GestureType.Discrete) // { // DiscreteGestureResult result = null; // discreteResults.TryGetValue(gesture, out result); // if (result.Confidence == 1.0f) // { // Monitor_SwipeOnLeft(true); // } // else if (result.Confidence == 0.0f && SwipeOnLeft == true) // { // SwipeOnLeft = false; // Console.WriteLine("false"); // } // //if (result != null) // //{ // // // update the GestureResultView object with new gesture result values // // this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.swipeRightGestureName); // //} // } // we only have one gesture in this source object, but you can get multiple gestures foreach (Gesture gesture in this.vgbFrameSource.Gestures) { if (gesture.Name.Equals(this.swipeRightGestureName) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result.Confidence == 1.0f) { ThisAddIn.Monitor_SwipeOnRight(true); } else if (result.Confidence == 0.0f && ThisAddIn.SwipeOnRight == true) { ThisAddIn.SwipeOnRight = false; } //if (result != null) //{ // // update the GestureResultView object with new gesture result values // this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.swipeRightGestureName); //} } if (gesture.Name.Equals(this.swipeLeftGestureName) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result.Confidence == 1.0f) { ThisAddIn.Monitor_SwipeOnLeft(true); } else if (result.Confidence == 0.0f && ThisAddIn.SwipeOnLeft == true) { ThisAddIn.SwipeOnLeft = false; Console.WriteLine("false"); } //if (result != null) //{ // // update the GestureResultView object with new gesture result values // this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.swipeRightGestureName); //} } //if (gesture.Name.Equals(this.swipeRightGestureName) && gesture.GestureType == GestureType.Discrete) //{ // DiscreteGestureResult result = null; // discreteResults.TryGetValue(gesture, out result); // if (result != null) // { // // update the GestureResultView object with new gesture result values // this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.swipeRightGestureName); // } //} //if (gesture.Name.Equals(this.swipeLeftGestureName) && gesture.GestureType == GestureType.Discrete) //{ // DiscreteGestureResult result = null; // discreteResults.TryGetValue(gesture, out result); // if (result != null) // { // // update the GestureResultView object with new gesture result values // this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.swipeLeftGestureName); // } //} } } } } }
public override bool ShowBatchModeStats() { PersianMessageBox.Show(ThisAddIn.GetWin32Window(), StatsticsMessage(), Constants.UIMessages.SuccessRefinementTitle); return(true); }
private void SetNarrowMarginBtn_Click(object sender, RibbonControlEventArgs e) { ThisAddIn.SetMarginWidth(0.05f); }