private void ChangeShownTodoList(ListStates state) { switch (state) { case ListStates.AllTodo: _TodoList.Clear(); _TodoList = new ObservableCollection <Todo>(_OpenTodoList.Union(_DoneTodoList).ToList <Todo>()); this.OnPropertyChanged("TodoList"); break; case ListStates.OpenTodo: _TodoList.Clear(); _TodoList = new ObservableCollection <Todo>(_OpenTodoList); this.OnPropertyChanged("TodoList"); break; case ListStates.DoneTodo: _TodoList.Clear(); _TodoList = new ObservableCollection <Todo>(_DoneTodoList); this.OnPropertyChanged("TodoList"); break; default: break; } }
public void CreateTextFile() { ListWords = ListWords.Distinct(new WordComparer()).ToList(); string content = ""; content += $"# {Comment}" + Environment.NewLine + Environment.NewLine; content += $"alphabet: {String.Join("", ListAlphabets)}" + Environment.NewLine; content += $"stack: {String.Join("", ListStacks)}" + Environment.NewLine; content += $"states: {String.Join(",", ListStates)}" + Environment.NewLine; content += $"final: {String.Join(",", ListStates.FindAll(x => x.IsFinal))}" + Environment.NewLine + Environment.NewLine; content += $"transitions:" + Environment.NewLine; content += $"{String.Join(Environment.NewLine, ListTransitions)}" + Environment.NewLine; content += "end." + Environment.NewLine + Environment.NewLine; content += "dfa: "; if (IsDFA) { content += "y" + Environment.NewLine; } else { content += "n" + Environment.NewLine; } content += "finite: "; if (IsFinite) { content += "y" + Environment.NewLine; } else { content += "n" + Environment.NewLine; } content += Environment.NewLine; content += $"words:" + Environment.NewLine; foreach (Word word in ListWords) { if (word.IsAccepted) { content += word.Words + ",y" + Environment.NewLine; } else { content += word.Words + ",n" + Environment.NewLine; } } content += "end."; string file_name = "automaton_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt"; File.WriteAllText(file_name, content); }
public string CreateGraph() { string data = "digraph {" + Environment.NewLine + "rankdir = LR;" + Environment.NewLine + "\"\" [shape = none]"; foreach (State state in ListStates) { data += Environment.NewLine + state.CreateGraph(); } data += Environment.NewLine; data += Environment.NewLine + $"\"\" -> \"" + ListStates.Find(x => x.IsInitial).State_Name + "\""; foreach (Transition transition in ListTransitions) { data += Environment.NewLine + transition.CreateGraph(); } data += Environment.NewLine + "}"; return(data); }
private Automaton ConvertToDFAWithoutEpsilonMove(List <State> states, List <Transition> transitions, State Sink) { List <State> initial_states = ListStates.FindAll(x => x.IsInitial); foreach (var initial in initial_states) { List <State> listini = new List <State>(); listini.Add(initial); if (listini.Exists(x => x.IsFinal)) { initial.IsFinal = true; } states.Add(initial); ProcessDFA(listini, states, transitions, Sink, initial); } return(new Automaton(ListAlphabets, states, transitions, null, null)); }
private bool CheckIsFinite() { words = new List <string>(); hasLoop = false; List <State> initial_States = ListStates.FindAll(x => x.IsInitial); foreach (var initial in initial_States) { List <Transition> used_transitions = new List <Transition>(); bool hasloop = false; GetWord(initial, used_transitions, hasloop); } if (hasLoop) { return(false); } foreach (var item in words) { ListWords.Add(new Word(item)); } return(true); }
/// <summary> /// mouse up /// </summary> /// <param name="e"></param> protected override void OnMouseUp(MouseEventArgs e) { DW("MouseUp"); Cursor.Current = Cursors.Arrow; Columns.ClearStates(); int nItem = 0, nColumn = 0, nCellX = 0, nCellY = 0; ListStates eState; GLListRegion listRegion; InterpretCoords( e.X, e.Y, out listRegion, out nCellX, out nCellY, out nItem, out nColumn, out eState ); m_nState = ListStates.stateNone; base.OnMouseUp( e ); }
/// <summary> /// mouse button pressed /// </summary> /// <param name="e"></param> protected override void OnMouseDown(MouseEventArgs e) { DW("GlacialList_MouseDown"); //Debug.WriteLine( "Real " + e.X.ToString() + " " + e.Y.ToString() ); int nItem = 0, nColumn = 0, nCellX = 0, nCellY = 0; ListStates eState; GLListRegion listRegion; InterpretCoords( e.X, e.Y, out listRegion, out nCellX, out nCellY, out nItem, out nColumn, out eState ); //Debug.WriteLine( nCellX.ToString() + " - " + nCellY.ToString() ); if ( e.Button == MouseButtons.Right ) // if its the right button then we don't really care till its released { base.OnMouseDown( e ); return; } //----------------------------------------------------------------------------------------- if ( eState == ListStates.stateColumnSelect ) // Column select { m_nState = ListStates.stateNone; if ( SortType != SortTypes.None ) { Columns[ nColumn ].State = ColumnStates.csPressed; this.SortColumn( nColumn ); } if ( ColumnClickedEvent != null ) ColumnClickedEvent( this, new ClickEventArgs( nItem, nColumn ) ); // fire the column clicked event //Invalidate(); base.OnMouseDown( e ); return; } //---Resizing ----------------------------------------------------------------------------------- if ( eState == ListStates.stateColumnResizing ) // resizing { Cursor.Current = Cursors.VSplit; m_nState = ListStates.stateColumnResizing; m_pointColumnResizeAnchor = new Point( GetColumnScreenX(nColumn), e.Y ); // deal with moving column sizes m_nResizeColumnNumber = nColumn; base.OnMouseDown( e ); return; } //--Item check, if no items exist go no further-- //if ( Items.Count == 0 ) //return; //---Items -------------------------------------------------------------------------------------- if ( eState == ListStates.stateSelecting ) { // ctrl based multi select ------------------------------------------------------------ // whatever else this does, it needs to first check to see if the state of the checkbox is changing if ( ( nColumn < Columns.Count ) && ( this.Columns[ nColumn ].CheckBoxes ) ) { // there is a checkbox on this control, lets see if the click came in the region if ( ( nCellX > this.CellPaddingSize ) && ( nCellX < (this.CellPaddingSize + CHECKBOX_SIZE ) ) && ( nCellY > this.CellPaddingSize ) && ( nCellY < (this.CellPaddingSize + CHECKBOX_SIZE ) ) ) { // toggle the checkbox if ( Items[nItem].SubItems[nColumn].Checked ) Items[nItem].SubItems[nColumn].Checked = false; else Items[nItem].SubItems[nColumn].Checked = true; } } m_nState = ListStates.stateSelecting; this.FocusedItem = Items[nItem]; if ( (( ModifierKeys & Keys.Control) == Keys.Control ) && ( AllowMultiselect == true ) ) { m_nLastSelectionIndex = nItem; if ( Items[nItem].Selected == true ) Items[nItem].Selected = false; else Items[nItem].Selected = true; base.OnMouseDown( e ); return; } // shift based multi row select ------------------------------------------------------- if ( (( ModifierKeys & Keys.Shift) == Keys.Shift ) && ( AllowMultiselect == true ) ) { Items.ClearSelection(); if ( m_nLastSelectionIndex >= 0 ) // ie, non negative so that we have a starting point { int index = m_nLastSelectionIndex; do { Items[index].Selected = true; if ( index > nItem ) index--; if ( index < nItem ) index++; } while ( index != nItem ); Items[index].Selected = true; } base.OnMouseDown( e ); return; } // the normal single select ----------------------------------------------------------- Items.ClearSelection( Items[nItem] ); // following two if statements deal ONLY with non multi=select where a singel sub item is being selected if ( ( m_nLastSelectionIndex < Count ) && ( m_nLastSubSelectionIndex < Columns.Count ) ) Items[m_nLastSelectionIndex].SubItems[m_nLastSubSelectionIndex].Selected = false; if ( ( FullRowSelect == false ) && ( ( nItem < Count ) && ( nColumn < Columns.Count ) ) ) Items[nItem].SubItems[nColumn].Selected = true; m_nLastSelectionIndex = nItem; m_nLastSubSelectionIndex = nColumn; Items[nItem].Selected = true; } base.OnMouseDown( e ); return; }
/// <summary> /// interpret mouse coordinates /// /// ok, I've violated the spirit of this routine a couple times (but no more!). Do NOT put anything /// functional in this routine. It is ONLY for analyzing the mouse coordinates. Do not break this again! /// </summary> /// <param name="nScreenX"></param> /// <param name="nScreenY"></param> /// <param name="listRegion"></param> /// <param name="nCellX"></param> /// <param name="nCellY"></param> /// <param name="nItem"></param> /// <param name="nColumn"></param> /// <param name="nState"></param> public void InterpretCoords( int nScreenX, int nScreenY, out GLListRegion listRegion, out int nCellX, out int nCellY, out int nItem, out int nColumn, out ListStates nState ) { DW("Interpret Coords"); nState = ListStates.stateNone; nColumn = 0; // compiler forces me to set this since it sometimes wont get set if routine falls through early nItem = 0; nCellX = 0; nCellY = 0; listRegion = GLListRegion.nonclient; /* * Calculate horizontal subitem */ int nCurrentX = -hPanelScrollBar.Value; // offset the starting point by the current scroll point for ( nColumn=0; nColumn < Columns.Count; nColumn++ ) { GLColumn col = Columns[nColumn]; // lets find the inner X for the cell nCellX = nScreenX - nCurrentX; if ( (nScreenX > nCurrentX) && (nScreenX < (nCurrentX+col.Width-RESIZE_ARROW_PADDING)) ) { nState = ListStates.stateColumnSelect; break; } if ( (nScreenX >= (nCurrentX+col.Width-RESIZE_ARROW_PADDING)) && (nScreenX <= (nCurrentX+col.Width+RESIZE_ARROW_PADDING)) ) { // here we need to check see if this is a 0 length column (which we skip to next on) or if this is the last column (which we can't skip) if ( (nColumn+1 == Columns.Count) || ( Columns[nColumn+1].Width != 0 ) ) { if ( AllowColumnResize == true ) nState = ListStates.stateColumnResizing; //Debug.WriteLine( "Sending our column number " + nColumn.ToString() ); return; // no need for this to fall through } } nCurrentX += col.Width; } if ( ( nScreenY >= RowsInnerClientRect.Y ) && ( nScreenY < RowsInnerClientRect.Bottom ) ) { // we are in the client area listRegion = GLListRegion.client; Columns.ClearHotStates(); this.HotColumnIndex = -1; nItem = ((nScreenY - RowsInnerClientRect.Y) / ItemHeight) + vPanelScrollBar.Value; // get inner cell Y nCellY = (nScreenY - RowsInnerClientRect.Y) % ItemHeight; this.HotItemIndex = nItem; if ( ( nItem >= Items.Count ) || ( nItem > (this.vPanelScrollBar.Value + this.VisibleRowsCount) ) ) { nState = ListStates.stateNone; listRegion = GLListRegion.nonclient; } else { nState = ListStates.stateSelecting; // handle case of where FullRowSelect is OFF and we click on the second part of a spanned column for ( int nSubIndex = 0; nSubIndex < Columns.Count; nSubIndex++ ) { //if ( ( nSubIndex + (Items[nItem].SubItems[nSubIndex].Span-1) ) >= nColumn ) if ( nSubIndex >= nColumn ) { nColumn = nSubIndex; return; } } } //Debug.WriteLine( "returning client from interpretcoords" ); return; } else { if ( ( nScreenY >= this.HeaderRect.Y ) && ( nScreenY < this.HeaderRect.Bottom ) ) { //Debug.WriteLine( "Found header from interpret coords" ); listRegion = GLListRegion.header; this.HotItemIndex = -1; // we are in the header this.HotColumnIndex = nColumn; if ( ( ( nColumn > -1 ) && ( nColumn < Columns.Count ) ) && (!Columns.AnyPressed() ) ) if ( Columns[nColumn].State == ColumnStates.csNone) { Columns.ClearHotStates(); Columns[nColumn].State = ColumnStates.csHot; } } } return; }
public ReorderableCollection(SerializedProperty property, SerializedProperty collection) { bool allowDrag = true; object pathReference = SerializationReflection.GetPathReference(property); if (pathReference != null) { Type sortedType = SerializationReflection.GetPathReference(property).GetType(); while (sortedType != null) { if (sortedType.GetInterface("SortedCollection`1") != null) { allowDrag = false; break; } sortedType = sortedType.BaseType; } } string collectionPath = CollectionDisplay.GetFullPath(collection); DisplayState listState; if (ListStates.ContainsKey(collectionPath)) { ListStates.Remove(collectionPath); } listState = new DisplayState(); ListStates.Add(collectionPath, listState); listState.Collection = collection; listState.List = this; DrawerState drawerState = CollectionDisplay.GetDrawerState(property); var newList = new ReorderableList(collection.serializedObject, collection) { draggable = allowDrag, }; newList.showDefaultBackground = false; newList.onReorderCallbackWithDetails = (ReorderableList list, int oldIndex, int newIndex) => { Reorder?.Invoke(drawerState.Property, listState.Collection, oldIndex, newIndex); }; newList.drawHeaderCallback = (Rect position) => { SerializedProperty hasLostValue = drawerState.Property.FindPropertyRelative("hasLostValue"); if (hasLostValue != null && hasLostValue.boolValue == true) { EditorUtility.DisplayDialog("Collection Error", "You've attempted to change an element in a way that prevents it from being added to the collection. The element will be moved to the Add Element area of the list so you can change the element and add it back in.", "Okay"); ListStates[CollectionDisplay.GetFullPath(listState.Collection)].AddingElement = true; hasLostValue.boolValue = false; } Rect startPosition = position; DrawHeaderBackground(position, drawerState.Property, listState.Collection); DrawSettingsButton(position, drawerState.Property, listState.Collection); position.y += DrawSettings(position, drawerState.Property, listState.Collection); for (var i = 0; i < DrawHeaderAreaHandlers.Count; i++) { position.y += DrawHeaderAreaHandlers[i].Invoke(position, drawerState.Property, listState.Collection); } listState.LastHeaderHeight = position.y - startPosition.y; newList.headerHeight = listState.LastHeaderHeight; }; newList.drawElementCallback += (Rect position, int index, bool isActive, bool isFocused) => { position.y += 2; var pageRange = GetPageDisplayRange(listState.Collection); if (index >= pageRange.x && index < pageRange.y) { EditorGUI.BeginDisabledGroup(listState.AddingElement); DrawElement?.Invoke(position, index, drawerState.Property, listState.Collection); EditorGUI.EndDisabledGroup(); } }; newList.drawElementBackgroundCallback = (Rect position, int index, bool isActive, bool isFocused) => { if (Mathf.Approximately(position.height, 0)) { return; } Rect backgroundPos = position; backgroundPos.yMin -= 2; backgroundPos.yMax += 2; boxBackground.fixedHeight = backgroundPos.height; boxBackground.fixedWidth = backgroundPos.width; Color guiColor = UnityEngine.GUI.color; if (isActive) { UnityEngine.GUI.color = UnityEngine.GUI.skin.settings.selectionColor; } if (index % 2 == 0) { UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.black, .1f); } if (Event.current.type == EventType.Repaint) { boxBackground.Draw(position, false, isActive, true, false); } UnityEngine.GUI.color = guiColor; position.xMin += 2; position.xMax -= 3; }; newList.elementHeightCallback += (int index) => { int pageSize = GetItemsPerPage(listState.Collection); int pageStartIndex = (listState.CurrentPageSet * listState.PageSetSize * pageSize) + (listState.CurrentPage * pageSize); int pageEndIndex = pageStartIndex + pageSize; if (index >= pageStartIndex && index < pageEndIndex && (GetElementHeight != null)) { return(GetElementHeight(index, drawerState.Property, listState.Collection) + 2); } return(0); }; newList.drawFooterCallback = (Rect position) => { DrawFooterBackground(position, drawerState.Property, listState.Collection); DrawAddRemoveButtons(position, drawerState.Property, listState.Collection); Rect startPosition = position; for (var i = 0; i < DrawFooterAreaHandlers.Count; i++) { position.y += DrawFooterAreaHandlers[i].Invoke(position, drawerState.Property, listState.Collection); } position.y += DrawPageSelection(position, drawerState.Property, listState.Collection); if (listState.List.DrawCustomAdd) { position.y += DrawAddArea(position, property, collection); } listState.LastFooterHeight = position.y - startPosition.y; listState.LastFooterHeight += 4; List.footerHeight = listState.LastFooterHeight; }; newList.onRemoveCallback += (ReorderableList targetList) => { if (targetList.index > -1) { int pageSize = GetItemsPerPage(listState.Collection); int pageStartIndex = GetPageDisplayRange(listState.Collection).x; listState.Collection.DeleteArrayElementAtIndex(pageStartIndex + targetList.index); } }; newList.onAddCallback += (ReorderableList targetList) => { if (DrawCustomAdd) { ListStates[collectionPath].AddingElement = !ListStates[collectionPath].AddingElement; if (ListStates[collectionPath].AddingElement) { SerializationReflection.CallPrivateMethod(property, "ClearTemp"); } } else { listState.Collection.InsertArrayElementAtIndex(listState.Collection.arraySize); } }; List = newList; }