Пример #1
0
        /// <summary>
        /// Handles the Classification changed event that comes from the Classifier aggregator
        /// </summary>
        void OnClassificationChanged(object sender, ClassificationChangedEventArgs e)
        {
            if (!_isClosed)
            {
                // When classifications change, we just invalidate the lines. That invalidation will
                // create new lines based on the new classifications.

                // Map the classification change (from the edit buffer) to the visual buffer
                Span span = Span.FromBounds(
                    TextViewModel.GetNearestPointInVisualSnapshot(e.ChangeSpan.Start, VisualSnapshot, PointTrackingMode.Negative),
                    TextViewModel.GetNearestPointInVisualSnapshot(e.ChangeSpan.End, VisualSnapshot, PointTrackingMode.Positive));

                //Classifications changes invalidate only the characters contained in the span so a zero length change
                //will have no effect.
                if (span.Length > 0)
                {
                    //IsLineInvalid will invalidate a line if it intersects the end. The result is that any call to InvalidateSpan() implicitly
                    //invalidates any line that starts at the end of the invalidated span, which we do not want here. Reduce the length of the classification
                    //change span one so -- if someone invalidated an entire line including the line break -- the next line will not be invalidated.
                    span = new Span(span.Start, span.Length - 1);

// MONO: TODO: this

                    //lock (_invalidatedSpans)
                    //{
                    //	if ((_attachedLineCache.Count > 0) || (_unattachedLineCache.Count > 0))
                    //	{
                    //		_reclassifiedSpans.Add(span);
                    //		this.QueueLayout();
                    //	}
                    //}
                }
            }
        }
Пример #2
0
        public MainWindow()
        {
            InitializeComponent();
            TextViewModel textViewModel = new TextViewModel();

            DataContext = textViewModel;
        }
Пример #3
0
        public async Task <List <SentimentAnalyzes> > SentimentAnalyzesAsync(TextViewModel textViewModel)
        {
            var payload = new
            {
                documents = new[]
                {
                    new
                    {
                        id   = "1",
                        text = textViewModel.Text
                    }
                }
            };

            var json = JsonConvert.SerializeObject(payload, _serializerSettings);

            var bytes = Encoding.UTF8.GetBytes(json);

            using (var content = new ByteArrayContent(bytes))
            {
                content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                var response = await _httpClient.PostAsync("/text/analytics/v3.0-preview.1/sentiment", content);

                if (response.IsSuccessStatusCode)
                {
                    var result = await response.Content.ReadAsJsonAsync <DynamicResponse <List <SentimentAnalyzes> > >(true);

                    return(result.Documents ?? null);
                }
                else
                {
                    return(null);
                }
            }
        }
Пример #4
0
        public ActionResult Index()
        {
            var text  = _textProvider.Get();
            var model = new TextViewModel(text);

            return(View(model));
        }
Пример #5
0
        public ActionResult Index()
        {
            var msg       = "No Db Connection";
            var tableList = string.Empty;

            ViewBag.Message = "Your application home page.";

            try
            {
                var db         = new DataContext(ConfigurationManager.ConnectionStrings["dockerdb"].ConnectionString);
                var textRepo   = new ListsRepo(db);
                var returnText = textRepo.GetCount();

                msg = "Db Connection OK";
            }
            catch (Exception e)
            {
                msg = e.Message;
            }


            var vm = new TextViewModel
            {
                Description = msg
            };



            return(View(vm));
        }
    public RbmMenuViewModel()
    {
        _doneText        = new TextObject("{=ATDone}Done").ToString();
        _cancelText      = new TextObject("{=ATCancel}Cancel").ToString();
        _tab1Text        = new TextObject("{=ATTab1Text}Main Interface").ToString();
        _tab2Text        = new TextObject("{=ATTab2Text}Sub Interface").ToString();
        _sliderText      = new TextObject("{=ATSlideText}Slider Example").ToString();
        _sliderValue     = 10f;
        _sliderValueText = _sliderValue.ToString();
        _booleanValue    = true;
        RefreshValues();
        //RbmConfigData data;
        List <string> siegeTowersOptions = new List <string> {
            "Disabled", "Enabled"
        };

        SiegeTowersEnabledText = new TextViewModel(new TextObject("Siege Towers"));
        SiegeTowersEnabled     = new SelectorVM <SelectorItemVM>(siegeTowersOptions, 0, null);

        if (XmlConfig.dict["Global.SiegeTowersEnabled"] == 0)
        {
            SiegeTowersEnabled.SelectedIndex = 0;
        }
        else if (XmlConfig.dict["Global.SiegeTowersEnabled"] == 1)
        {
            SiegeTowersEnabled.SelectedIndex = 1;
        }
    }
        public async Task Put(TextViewModel tvm)
        {
            if (tvm.MyNote == null)
            {
                return;
            }

            //UserData me = NoteDataManager.GetUserData(_userManager, User, _db);

            DateTime now = DateTime.Now.ToUniversalTime();

            tvm.NoteHeader.NoteSubject      = tvm.MySubject;
            tvm.NoteHeader.LastEdited       = now;
            tvm.NoteHeader.ThreadLastEdited = now;

            NoteContent nc = new NoteContent
            {
                NoteHeaderId    = tvm.NoteHeader.Id,
                NoteBody        = tvm.MyNote,
                DirectorMessage = tvm.DirectorMessage
            };

            await NoteDataManager.EditNote(_db, _userManager, tvm.NoteHeader, nc, tvm.TagLine);

            await ProcessLinkedNotes();

            return;
        }
Пример #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            TextViewModel tv = new TextViewModel()
            {
                NoteID           = 0,
                DirectorMessage  = textBoxDirMessage.Text,
                MySubject        = textBoxSubject.Text,
                TagLine          = textBoxTags.Text,
                MyNote           = markupConverter.ConvertRtfToHtml(rtbDoc.Rtf),
                NoteFileID       = MyFile.Id,
                BaseNoteHeaderID = MybaseId
            };

            if (MyHeader != null)
            {
                Actions.EditNote(Program.MyClient, tv, MyHeader.Id);
            }
            else
            {
                Actions.CreateNote(Program.MyClient, tv);
            }

            Thread.Sleep(400);

            MyParent.Relist();

            Close();
        }
Пример #9
0
        public int MoveToLine(object position, int offset)
        {
            this.position = (Location)position;
            int total = 0;

            if (offset >= 0)
            {
                object        subPos = this.position.InnerLocation;
                TextViewModel model  = this.Nodes[this.position.iModel].Model;
                for (int i = this.position.iModel; i < this.Nodes.Count; ++i)
                {
                    int moved = this.Nodes[i].Model.MoveToLine(subPos, offset);
                    total += moved;
                    if (moved == offset)
                    {
                        this.position = new Location(i, this.Nodes[i].Model.CurrentPosition);
                        return(total);
                    }
                    offset -= moved;
                }
                this.position = new Location(
                    this.Nodes.Count - 1,
                    this.Nodes[this.Nodes.Count - 1].Model.CurrentPosition);
            }
            return(total);
        }
Пример #10
0
#pragma warning restore CS0067

        public void Close()
        {
            if (_isClosed)
            {
                throw new InvalidOperationException();//Strings.TextViewClosed);
            }
            if (_hasAggregateFocus)
            {
                //Silently lose aggregate focus (to preserve Dev11 compatibility which did not raise a focus changed event when the view was closed).
                Debug.Assert(TextView.ViewWithAggregateFocus == this);
                TextView.ViewWithAggregateFocus = null;
                _hasAggregateFocus = false;
            }

            UnsubscribeFromEvents();

            _connectionManager.Close();

            TextViewModel.Dispose();
            TextViewModel = null;

            _isClosed = true;

            _factoryService.GuardedOperations.RaiseEvent(this, this.Closed);
        }
Пример #11
0
        public ProcessTriggerViewModel(ProcessTrigger trigger) : base(trigger)
        {
            Option = new OptionViewModel(trigger, nameof(trigger.Option));
            Text   = new TextViewModel(trigger);

            Attach(Option);
            Attach(Text);
        }
        public VariableConditionViewModel(VariableCondition condition) : base(condition)
        {
            Option = new OptionViewModel(condition, nameof(condition.Value));
            Text   = new TextViewModel(condition);

            Attach(Option);
            Attach(Text);
        }
        public SetVariableActionViewModel(SetVariableAction action) : base(action)
        {
            Option = new OptionViewModel(action, nameof(action.Value));
            Text   = new TextViewModel(action);

            Attach(Option);
            Attach(Text);
        }
Пример #14
0
        public UserControl GetRender(ViewModel parent, Response r)
        {
            string text = r.Decode <string>();

            TextViewModel vm = new TextViewModel(parent, text);

            return(new TextRender(vm));
        }
Пример #15
0
        public ProcessConditionViewModel(ProcessCondition condition) : base(condition)
        {
            Option = new OptionViewModel(condition, nameof(condition.Option));
            Text   = new TextViewModel(condition);

            Attach(Option);
            Attach(Text);
        }
Пример #16
0
 public Builder(TextViewModel model, Graphics g, StyleStack styleStack, Font defaultFont)
 {
     this.model        = model;
     this.g            = g;
     this.styleStack   = styleStack;
     this.defaultFont  = defaultFont;
     this.visibleLines = new SortedList <float, LayoutLine>();
 }
Пример #17
0
        public TextView()
        {
            InitializeComponent();

            this.Selection = new TextSelection(this);
            this.model = new EmptyEditorModel();
            this.stringFormat = StringFormat.GenericTypographic;
            this.vScroll.ValueChanged += vScroll_ValueChanged;
        }
Пример #18
0
    public TextViewModel GetOrAdd(IWpfTextView wpfTextView)
    {
      TextViewModel textViewModel;

      if (!_textViewModelsMap.TryGetValue(wpfTextView, out textViewModel))
        _textViewModelsMap.Add(wpfTextView, textViewModel = new TextViewModel(wpfTextView, this));

      return textViewModel;
    }
Пример #19
0
 public MainWinidow()
 {
     _cryptoServiceFacade = new CryptoFileServiceFacade(
         new FileService(),
         new ShaCryptoService(),
         new RijndaelCryptoService());
     InitializeComponent();
     _textViewModel = new TextViewModel();
 }
Пример #20
0
        private void GetLineSpans(TextViewModel model, int count)
        {
            var lines = model.GetLineSpans(count);

            foreach (var line in lines)
            {
                WriteLine(line, writer);
            }
        }
        public ActionResult Settings(Guid i, string t, TextViewModel data, PropertyListViewModel propertyList)
        {
            var item = i != null?this.GetItemById(i, settingsNavigationTree) : null;

            if (item == null || item.Id == Guid.Empty)
            {
                return(null);
            }

            if (t == "TextView")
            {
                if (item.Key.StartsWith("Email"))
                {
                    SettingsKey
                        subjectKey = (SettingsKey)Enum.Parse(typeof(SettingsKey), item.Key + "Subject"),
                        bodyKey    = (SettingsKey)Enum.Parse(typeof(SettingsKey), item.Key + "Body");

                    this.repository.SetSettings(subjectKey, data.Subject);
                    this.repository.SetSettings(bodyKey, data.Content);
                }
                else
                {
                    switch (item.Key)
                    {
                    case "PagesHeader":
                        this.repository.SetSettings(SettingsKey.HeaderHtml, data.Content);
                        break;

                    case "PagesFooter":
                        this.repository.SetSettings(SettingsKey.FooterHtml, data.Content);
                        break;

                    case "MainContent":
                        this.repository.SetSettings(SettingsKey.MainPageHtml, data.Content);
                        break;
                    }
                }

                return(this.RedirectToAction("Settings", new { id = i }));
            }
            else if (t == "PropertyListView" && item.Key == "GroupEmail")
            {
                foreach (var property in propertyList.Properties)
                {
                    SettingsKey settingsKey;
                    if (Enum.TryParse <SettingsKey>(property.Key, out settingsKey))
                    {
                        this.repository.SetSettings(settingsKey, property.Value);
                    }
                }

                return(this.RedirectToAction("Settings", new { id = i }));
            }

            return(null);
        }
Пример #22
0
 public ActionResult Edit(TextViewModel model)
 {
     if (ModelState.IsValid)
     {
         textService.UpdateEntity(Mapper.ToBll(model));
         UpdateTitleEditDate(model.TitleId);
         return(RedirectToAction("Index", new { textId = model.Id }));
     }
     return(View(model));
 }
Пример #23
0
        public ActionResult Text(int textID)
        {
            Text          text  = db.Text.Find(textID);
            TextViewModel model = new TextViewModel {
                Title = text.Title,
                Text  = new HtmlString(text.Script)
            };

            return(View(model));
        }
Пример #24
0
        public ActionResult Help()
        {
            var vm = new TextViewModel()
            {
                Heading  = "Help",
                RichText = new MvcHtmlString("Ipsum dolor sit amet, consectetur adipiscing elit. Fusce elementum purus er.")
            };

            return(PartialView("_Text", vm));
        }
Пример #25
0
        internal void ViewActivated(IWpfTextView wpfTextView, FileId id, IVsHierarchy hierarchy, string fullPath)
        {
            var textBuffer = wpfTextView.TextBuffer;

            TryAddServerProperty(textBuffer);

            FileModel     fileModel     = VsUtils.GetOrCreateFileModel(wpfTextView, id, this, hierarchy, fullPath);
            TextViewModel textViewModel = VsUtils.GetOrCreateTextViewModel(wpfTextView, fileModel);

            fileModel.ViewActivated(textViewModel);
        }
Пример #26
0
        public async Task <NoteHeader> Create(TextViewModel inputModel)
        {
            string authHeader = Request.Headers["authentication"];

            string[]     auths = authHeader.Split(',');
            IdentityUser me    = await _userManager.FindByIdAsync(auths[1]);

            UserAuxData appMe = await _context.UserData.SingleAsync(p => p.UserId == me.Id);

            if (String.Compare(auths[2], appMe.MyGuid, StringComparison.Ordinal) != 0)
            {
                return(null);
            }
            string     userID = auths[1];
            NoteAccess myAcc  = await AccessManager.
                                GetAccess(_context, userID, inputModel.NoteFileID, 0);

            if (!myAcc.Write)
            {
                return(null);
            }

            await _signInManager.SignInAsync(me, false);

            DateTime now = DateTime.Now.ToUniversalTime();

            NoteHeader nheader = new NoteHeader()
            {
                LastEdited       = now,
                ThreadLastEdited = now,
                CreateDate       = now,
                NoteFileId       = inputModel.NoteFileID,
                AuthorName       = appMe.DisplayName,
                AuthorID         = _userManager.GetUserId(User),
                NoteSubject      = inputModel.MySubject,
                ResponseOrdinal  = 0,
                ResponseCount    = 0
            };

            if (inputModel.BaseNoteHeaderID == 0)
            {
                return(await NoteDataManager
                       .CreateNote(_context, _userManager, nheader,
                                   inputModel.MyNote.Replace("\n", "<br />"),
                                   inputModel.TagLine,
                                   inputModel.DirectorMessage, true, false));
            }
            NoteHeader bnh = await NoteDataManager.GetNoteHeader(_context, inputModel.BaseNoteHeaderID);

            nheader.BaseNoteId = bnh.Id;
            return(await NoteDataManager.CreateResponse(_context, _userManager,
                                                        nheader, inputModel.MyNote, inputModel.TagLine,
                                                        inputModel.DirectorMessage, true, false));
        }
Пример #27
0
 public ActionResult Create(TextViewModel model)
 {
     if (ModelState.IsValid)
     {
         model.OrderInTitle =
             textService.GetTitleTextEntitiesWithoutContent(model.TitleId).Select(e => e.OrderInTitle).DefaultIfEmpty().Max() + 1;
         textService.CreateEntity(Mapper.ToBll(model));
         UpdateTitleEditDate(model.TitleId);
         return(Json(new { Success = true }));
     }
     return(PartialView(model));
 }
Пример #28
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            var textModel     = new TextModel();
            var textViewModel = new TextViewModel(textModel);

            myControl.ViewModel = textViewModel;    // TODO: Itt miert nem kellett INotifyPropertyChanged a VM modositasakor?
            var cmd = new AddCommand(textModel);

            this.myControl.SetAddCommand(cmd);
            myControl.PointerPressedCommand = new AddPositionCommand(textModel);
        }
Пример #29
0
        public async Task <TextMaterial> EditTextMaterial(Guid id, TextViewModel text)
        {
            TextMaterial textMaterial = await _text.GetTextMaterial(id);

            if (textMaterial != null)
            {
                textMaterial.Name    = text.Name;
                textMaterial.Context = text.Context;
                await _text.UpdateTextMaterial(textMaterial);
            }
            return(textMaterial);
        }
Пример #30
0
 public KeyBindingCommandFilter(
   IWpfTextView     wpfTextView,
   IServiceProvider serviceProvider,
   TextViewModel    textViewModel
   )
 {
   _serviceProvider = serviceProvider;
   _wpfTextView     = wpfTextView;
   _textViewModel   = textViewModel;
   var path = wpfTextView.TextBuffer.GetFilePath();
   AddCommandFilter(wpfTextView.ToVsTextView());
 }
        public IActionResult TextCreate(TextViewModel newText)
        {
            textContext.Add <Text>(new Text()
            {
                Title = newText.Title, Data = newText.Text
            });
            int rowCount = textContext.SaveChanges();

            Log.SeqLog.WriteNewLogMessage("Add new Text with Title {Title} - {rows} rows inserted", newText.Title, rowCount);

            return(Redirect("/Home/Add"));
        }
Пример #32
0
        public async System.Threading.Tasks.Task <IActionResult> Data(TextViewModel viewModel)
        {
            #region Login Information
            LoginInit(Constants.Rights.System, (int)ERights.Add);
            if (!(bool)ViewData[Constants.ActionViews.IsLogin])
            {
                await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);

                return(RedirectToAction(Constants.ActionViews.Login, Constants.Controllers.Account));
            }
            #endregion

            var domain = ViewData[Constants.ActionViews.Domain].ToString();
            var entity = viewModel.Text;
            entity.Alias   = Utility.AliasConvert(entity.Value);
            entity.ToolTip = entity.Value;

            if (string.IsNullOrEmpty(entity.Id))
            {
                // Check exist, if exist update lastest code ++
                var checkE = dbContext.Texts.Find(m => m.Enable.Equals(true) && m.CodeInt.Equals(entity.CodeInt)).FirstOrDefault();
                if (checkE != null)
                {
                    var texts   = dbContext.Texts.Find(m => m.Enable.Equals(true) && m.Domain.Equals(domain)).SortByDescending(m => m.CodeInt).Limit(1).ToList();
                    int codeNew = 1;
                    if (texts != null && texts.Count > 0)
                    {
                        codeNew = texts[0].CodeInt + 1;
                    }
                    entity.CodeInt = codeNew;
                }
                entity.Code = entity.CodeInt.ToString();
                dbContext.Texts.InsertOne(entity);
            }
            else
            {
                entity.Code = entity.CodeInt.ToString();
                var builder = Builders <Text> .Filter;
                var filter  = builder.Eq(m => m.Id, entity.Id);
                var update  = Builders <Text> .Update
                              .Set(m => m.Code, entity.Code)
                              .Set(m => m.CodeInt, entity.CodeInt)
                              .Set(m => m.Value, entity.Value)
                              .Set(m => m.Alias, entity.Alias)
                              .Set(m => m.ToolTip, entity.ToolTip)
                              .Set(m => m.NoDelete, entity.NoDelete);

                dbContext.Texts.UpdateOne(filter, update);
            }

            return(Redirect("/text"));
        }
        public async Task <AnalyzeResult> AnalyzeTextAsync(TextViewModel textViewModel)
        {
            var languageTask  = _textAnalyzeService.DetectLanguagesAsync(textViewModel);
            var sentimentTask = _textAnalyzeService.SentimentAnalyzesAsync(textViewModel);

            await Task.WhenAll(languageTask, sentimentTask);

            return(new AnalyzeResult()
            {
                Language = languageTask.Result,
                Sentiment = sentimentTask.Result
            });
        }
Пример #34
0
    public void Remove(IWpfTextView wpfTextView)
    {
      TextViewModel textViewModel;
      if (_textViewModelsMap.TryGetValue(wpfTextView, out textViewModel))
      {
        if (textViewModel == _activeTextViewModelOpt)
          _activeTextViewModelOpt = null;
        if (textViewModel == _mouseHoverTextViewModelOpt)
          _mouseHoverTextViewModelOpt = null;
        textViewModel.Dispose();
        _textViewModelsMap.Remove(wpfTextView);
      }

      return;
    }
Пример #35
0
 /// <summary>
 /// Generates a TextViewLayout from all the lines in the model.
 /// </summary>
 /// <param name="model"></param>
 /// <param name="g"></param>
 /// <param name="defaultFont"></param>
 /// <param name="styleStack"></param>
 /// <returns></returns>
 public static TextViewLayout AllLines(TextViewModel model, Graphics g, Font defaultFont, StyleStack styleStack)
 {
     model.MoveToLine(model.StartPosition, 0);
     var rcLine = new RectangleF();
     var builder = new Builder(model, g, styleStack, defaultFont);
     for (;;)
     {
         var lines = model.GetLineSpans(1);
         if (lines.Length == 0)
             break;
         builder.AddLayoutLine(lines[0], ref rcLine);
     }
     var layout = builder.Build();
     return layout;
 }
Пример #36
0
        public static TextViewLayout VisibleLines(TextViewModel model, Size size, Graphics g, Font defaultFont, StyleStack styleStack)
        {
            var szClient = new SizeF(size);
            var rcLine = new RectangleF(0, 0, szClient.Width, 0);

            var builder = new Builder(model, g, styleStack, defaultFont);
            while (rcLine.Top < szClient.Height)
            {
                var lines = model.GetLineSpans(1);
                if (lines.Length == 0)
                    break;
                builder.AddLayoutLine(lines[0], ref rcLine);
            }
            return builder.Build();
        }
Пример #37
0
 private string Flatten(TextViewModel model)
 {
     var sb = new StringBuilder();
     var lines = model.GetLineSpans(model.LineCount);
     foreach (var line in lines)
     {
         foreach (var span in line)
         {
             EmitSpanWrapper(span, sb);
             sb.Append(span.GetText());
             EmitSpanWrapper(span, sb);
         }
         sb.AppendLine();
     }
     return sb.ToString();
 }
        /// <summary>
        /// Called when the command is in interactive (window) mode
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        static Result RunInteractive(TextViewModel model)
        {
            using (var test = TestMonoCreateWindow(model))
            Rhino.RhinoApp.WriteLine("Test create window from nib");
              var result = Result.Cancel;

              #region Mac Specific UI
              #if ON_OS_MAC
              // Create a NSWindow from a Nib file
              using (var window = RhinoMac.Window.FromNib("NewTextWindow", model))
              {
            // Display the window
            window.ShowModal();
            // dialogResult should be null if the window was closed
            // by clicking on the "X", false if the Cancel was called
            // and true if OK was called.
            var dialogResult = window.DialogResult;
            // Success will be true if the window was closed by the
            // OK button otherwise it should be false.
            result = (true == dialogResult ? Result.Success : Result.Cancel);
              }
              #endif
              #endregion

              #if ON_OS_WINDOWS
              var window = new Win.TextWindow();
              window.Loaded += window_Loaded;
              window.DataContext = model;
              // Need to save the window so it can be used as the
              // parent for the color dialog.
              model.Window = window;
              // Need to set the Rhino main frame window as the parent
              // for the new window otherwise the window will go behind
              // the main frame when the Rhino is deactivated then
              // activated again.
              // http://blogs.msdn.com/b/mhendersblog/archive/2005/10/04/476921.aspx
              var interopHelper = new System.Windows.Interop.WindowInteropHelper(window);
              interopHelper.Owner = Rhino.RhinoApp.MainWindowHandle();
              window.ShowDialog();
              result = (true == window.DialogResult ? Result.Success : Result.Cancel);
              #endif

              return result;
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // Get a startpoint for the text
              Rhino.Geometry.Point3d startpoint;
              var rc = Rhino.Input.RhinoGet.GetPoint(Rhino.UI.LOC.STR("Start point"), false, out startpoint);
              if (rc != Rhino.Commands.Result.Success)
            return rc;

              if (m_default_entity == null)
              {
            m_default_entity = new Rhino.Geometry.TextEntity();
            double val = DefaultTextHeight;
            if( val>0 )
              m_default_entity.TextHeight = val;
            m_default_entity.FontIndex = doc.Fonts.CurrentIndex;
              }

              var plane = doc.Views.ActiveView.ActiveViewport.ConstructionPlane();
              plane.Origin = startpoint;
              m_default_entity.Plane = plane;
              var test_font = doc.Fonts[m_default_entity.FontIndex];
              if (test_font == null) //can happen when a new doc is created and the saved font index is invalid
            m_default_entity.FontIndex = 0;

              // View Model to associate with this instance of RunCommand, this
              // View Model is used by both the scripting and interactive versions
              // of the command.
              var model = new TextViewModel(doc, m_default_entity);
              // Run the scripting or GUI methods to gather data in the View Model.
              var result = (mode == RunMode.Scripted ? RunScript(model) : RunInteractive(model));
              if (result != Result.Success)
            return result;

              result = model.AddTextEntityToDocument();

              return result;
        }
Пример #40
0
 private TextViewLayout(TextViewModel model, Font defaultFont, SortedList<float, LayoutLine> visibleLines)
 {
     this.model = model;
     this.defaultFont = defaultFont;
     this.visibleLines = visibleLines;
 }
Пример #41
0
 public ActionResult Index()
 {
     var text = _textProvider.Get();
     var model = new TextViewModel(text);
     return View(model);
 }
        /// <summary>
        /// Called when the command is in scripted mode
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        static Result RunScript(TextViewModel model)
        {
            var height = new Rhino.Input.Custom.OptionDouble(model.textHeight);
              var bold = new Rhino.Input.Custom.OptionToggle(model.bold, Localization.LocalizeCommandOptionValue("No", 396), Localization.LocalizeCommandOptionValue("Yes", 397));
              var italic = new Rhino.Input.Custom.OptionToggle(model.italic, Localization.LocalizeCommandOptionValue("No", 398), Localization.LocalizeCommandOptionValue("Yes", 399));
              var mask = new Rhino.Input.Custom.OptionToggle(model.maskEnabled, Localization.LocalizeCommandOptionValue("No", 400), Localization.LocalizeCommandOptionValue("Yes", 401));
              var masksource = new Rhino.Input.Custom.OptionToggle(model.maskUsesViewportColor, Localization.LocalizeCommandOptionValue("No", 402), Localization.LocalizeCommandOptionValue("Yes", 403));
              var maskcolor = new Rhino.Input.Custom.OptionColor(model.maskColor);
              var maskborder = new Rhino.Input.Custom.OptionDouble(model.maskOffset, true, 0);
              string facename = model.Font.FaceName;

              string newtext = "";
              var go = new Rhino.Input.Custom.GetString();
              var get_rc = Rhino.Input.GetResult.Cancel;
              var rc = Rhino.Commands.Result.Cancel;
              while (get_rc != Rhino.Input.GetResult.Nothing && get_rc != Rhino.Input.GetResult.String)
              {
            go.ClearCommandOptions();
            go.AcceptNothing(true);
            go.SetCommandPrompt(LOC.STR("Text string"));
            int faceopt = go.AddOption(LOC.CON("Font"));
            go.AddOptionDouble(LOC.CON("Height"), ref height, LOC.STR("Text height"));
            go.AddOptionToggle(LOC.CON("Italic"), ref italic);
            go.AddOptionToggle(LOC.CON("Mask"), ref mask);
            go.AddOptionToggle(LOC.CON("UseBackgroundColor"), ref masksource);
            go.AddOptionColor(LOC.CON("MaskColor"), ref maskcolor);
            go.AddOptionDouble(LOC.CON("MaskMargin"), ref maskborder);
            get_rc = go.Get();

            switch (get_rc)
            {
            case Rhino.Input.GetResult.Cancel:
              return Rhino.Commands.Result.Cancel;
            case Rhino.Input.GetResult.String:
              newtext = go.StringResult();
              break;
            case Rhino.Input.GetResult.Option:
              if( go.OptionIndex() == faceopt )
              {
            string oldname = facename;
            rc = Rhino.Input.RhinoGet.GetString(LOC.STR("Font name"), true, ref facename);
            if( rc!=Rhino.Commands.Result.Success)
              return rc;
            if (string.IsNullOrWhiteSpace(facename))
              facename = oldname;
              }
              break;
            }
              }

              if (string.IsNullOrWhiteSpace(newtext))
            return Rhino.Commands.Result.Cancel;

              // update default settings
              model.text = newtext;
              int fontindex = model.Doc.Fonts.FindOrCreate(facename, bold.CurrentValue, italic.CurrentValue);
              model.fontIndex = fontindex;
              model.textHeight = height.CurrentValue;
              model.maskEnabled = mask.CurrentValue;
              model.maskUsesViewportColor = masksource.CurrentValue;
              model.maskColor = maskcolor.CurrentValue;
              model.maskOffset = maskborder.CurrentValue;

              return Result.Success;
        }
Пример #43
0
 internal void OnMouseHover(TextViewModel textViewModel)
 {
   _mouseHoverTextViewModelOpt = textViewModel;
 }
Пример #44
0
 public Builder(TextViewModel model, Graphics g, StyleStack styleStack, Font defaultFont)
 {
     this.model = model;
     this.g = g;
     this.styleStack = styleStack;
     this.defaultFont = defaultFont;
     this.visibleLines = new SortedList<float, LayoutLine>();
 }
 static MyWindowController TestMonoCreateWindow(TextViewModel model)
 {
     MyWindowController result = null;
       try
       {
     // Playing with creating Window and controller using MonoMac and not Marlin
     //result = new MonoMac.AppKit.NSWindowController("NewTextWindow");
     //result.LoadWindow();
     var location = typeof(MyWindowController).Assembly.Location;
     var index = location.IndexOf(".rhp");
     var path = location.Substring(0, index < 0 ? location.Length : index + 4);
     var bundle = MonoMac.Foundation.NSBundle.FromPath(path);
     if (null == bundle)
       return null;
     result = new MyWindowController("NewTextWindow", bundle);
     var window = result.Window; // Forces the window to get created
       }
       catch (System.Exception exception)
       {
     if (null != result)
       result.Dispose();
     result = null;
     Rhino.Runtime.HostUtils.ExceptionReport(exception);
       }
       return result;
 }
Пример #46
0
 public TextViewLayout(TextViewModel model, Font defaultFont)
 {
     this.model = model;
     this.visibleLines = new SortedList<float, LayoutLine>();
     this.defaultFont = defaultFont;
 }
Пример #47
0
 internal void ViewActivated(TextViewModel textViewModel)
 {
   _activeTextViewModelOpt = textViewModel;
 }